/*
* brisk - index.php
*
- * Copyright (C) 2006 matteo.nastasi@milug.org
+ * Copyright (C) 2006-2007 matteo.nastasi@milug.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* not, write to the Free Software Foundation, Inc, 59 Temple Place -
* Suite 330, Boston, MA 02111-1307, USA.
*
+ * $Id$
+ *
*/
require_once("brisk.phh");
exit;
}
-log_load($sess, "LOAD: index.php");
+log_load((isset($sess) ? $sess : "XXX"), "LOAD: index.php");
function main()
{
- GLOBAL $sess, $name;
+ GLOBAL $sess, $name, $BRISK_SHOWHTML, $BRISK_DEBUG, $_SERVER;
$body = "";
+ $tables = "";
$ACTION = "login";
- $is_table = false;
- $sem = lock_data();
- $bri = &load_data();
-
- /* Actions */
- if (isset($sess)) {
- $bri->garbage_manager(TRUE);
- if (($user = &get_user(&$bri, $sess, &$idx)) != FALSE) {
- if ($user->stat == "table") {
- header ("Location: table.php");
- unlock_data($sem);
- exit;
+ if (isset($BRISK_SHOWHTML) == FALSE) {
+ $is_table = FALSE;
+ $sem = lock_data();
+ $bri = &load_data();
+
+ /* Actions */
+ if (validate_sess($sess)) {
+ $bri->garbage_manager(TRUE);
+ if (($user = &$bri->get_user($sess, &$idx)) != FALSE) {
+ if ($user->stat == "table") {
+ header ("Location: table.php");
+ unlock_data($sem);
+ exit;
+ }
+ $ACTION = "room";
}
- $ACTION = "table";
- }
- else {
- setcookie ("sess", "", time() - 3600);
}
- }
- else if (isset($name)) {
- $bri->garbage_manager(TRUE);
- /* try login */
- if (($user = &add_user(&$bri, &$sess, &$idx, $name)) != FALSE) {
- $ACTION = "table";
-
- setcookie ("sess", "", time() + 180);
- standup_update(&$bri,&$user);
-
- if (save_data(&$bri) == FALSE) {
- echo "ERRORE SALVATAGGIO\n";
- exit;
+
+ if ($ACTION == "login" && isset($name)) {
+ $bri->garbage_manager(TRUE);
+ /* try login */
+ if (($user = &$bri->add_user(&$sess, &$idx, $name, $_SERVER['REMOTE_ADDR'])) != FALSE) {
+ $ACTION = "room";
+
+ // setcookie ("sess", "", time() + 180);
+ $bri->standup_update(&$user);
+
+ if (save_data(&$bri) == FALSE) {
+ echo "ERRORE SALVATAGGIO\n";
+ exit;
+ }
+ }
+ else {
+ /* Login Rendering */
+ if ($idx == -2)
+ $body .= '<div class="urgmsg"><b>Il nickname deve contenere almeno una lettera o una cifra.</b></div>';
+ else if ($idx == -1)
+ $body .= '<div class="urgmsg"><b>Spiacenti, non ci sono più posti liberi. Riprova più tardi.</b></div>';
+ else
+ $body .= '<div class="urgmsg"><b>Il tuo nickname è già in uso.</b></div>';
}
}
- else {
- /* Login Rendering */
- if ($idx == -1)
- $body .= '<div class="urgmsg"><b>Spiacenti, non ci sono più posti liberi. Riprova più tardi.</b></div>';
- else
- $body .= '<div class="urgmsg"><b>Il tuo nickname è già in uso.</b></div>';
- }
+ unlock_data($sem);
}
- unlock_data($sem);
-
/* Rendering. */
- if ($ACTION == "table") {
- $tables .= '<table align="center" valign="center" border=1 cellpadding="12" cellspacing="0">';
+ if ($BRISK_SHOWHTML == "debugtable") {
+ $ACTION = "room";
+ }
+ else if ($BRISK_SHOWHTML == "debuglogin") {
+ $ACTION = "login";
+ }
+
+ if ($ACTION == "room") {
+ $tables .= '<table class="room_tab" align="center">';
for ($i = 0 ; $i < TABLES_N ; $i++) {
if ($i % 4 == 0)
$tables .= '<tr>';
- $tables .= '<td valign="top" align="center" class="room_td"><b>Tavolo '.$i.'</b><br><br>';
+ $tables .= '<td valign="top" align="center" class="room_td"><div class="room_div"><b>Tavolo '.$i.'</b><br><br>';
$tables .= sprintf('<div class="proxhr" id="table%d"></div>', $i);
- $tables .= sprintf('<div class="proxhr" id="table_act%d"></div>', $i);
- $tables .= '</td>';
+ $tables .= sprintf('<div class="table_act" id="table_act%d"></div>', $i);
+ $tables .= '</div></td>'."\n";
if ($i % 4 == 3)
$tables .= '</tr>';
}
$tables .= '<div class="room_ex_standup">';
$tables .= '<b>Giocatori in piedi</b><br><br>';
- $tables .= sprintf('<div id="standup"></div>');
- $tables .= '</div>';
+ $tables .= sprintf('<div id="standup" class="room_standup"></div>');
+ $tables .= '<div id="esco" class="esco"></div>';
$tables .= '</td></tr>';
$tables .= '</table>';
}
+
+ $altout_propag = array( array ( 'url' => 'http://www.alternativeoutput.it',
+ 'content' => '<img class="nobo" src="img/altout80x15.png">' ),
+ array ( 'url' => 'http://virtualsky.alternativeoutput.it',
+ 'content' => '<img class="nobo" src="img/virtualsky80x15.png">' )
+ );
+
+ // seed with microseconds since last "whole" second
+ srand ((double) microtime() * 1000000);
+ $randval = rand(0,count($altout_propag)-1);
+ $altout_carousel = sprintf('<a target="_blank" href="%s">%s</a>',
+ $altout_propag[$randval]['url'],
+ $altout_propag[$randval]['content']);
+
+
+ $brisk_donate = file_get_contents(FTOK_PATH."/brisk_donate.txt");
+ if ($brisk_donate == FALSE)
+ $brisk_donate = "";
+
+$brisk_header_form = '<div class="container">
+<!-- =========== header =========== -->
+<div id="header" class="header">
+<table width="100%%" border="0" cols="3"><tr>
+<td align="left"><div style="padding-left: 8px;">
+
+
+
+<script type="text/javascript"><!--
+google_ad_client = "pub-5246925322544303";
+google_ad_width = 234;
+google_ad_height = 60;
+google_ad_format = "234x60_as";
+google_ad_type = "text_image";
+google_ad_channel = "";
+google_color_border = "808080";
+google_color_bg = "f6f6f6";
+google_color_link = "ffae00";
+google_color_text = "404040";
+google_color_url = "000000";
+//-->
+</script>
+<script type="text/javascript"
+ src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
+</script>
+
+
+
+</div></td>
+<td align="center"><div>
+ <img class="nobo" src="img/brisk_logo64.png">
+ briscola chiamata in salsa ajax<br><br>
+ </div></td>
+<td align="right"><div style="padding-right: 8px;">
+
+
+
+<script type="text/javascript"><!--
+google_ad_client = "pub-5246925322544303";
+google_ad_width = 234;
+google_ad_height = 60;
+google_ad_format = "234x60_as";
+google_ad_type = "text_image";
+google_ad_channel = "";
+google_color_border = "808080";
+google_color_bg = "f6f6f6";
+google_color_link = "ffae00";
+google_color_text = "404040";
+google_color_url = "000000";
+//-->
+</script>
+<script type="text/javascript"
+ src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
+</script>
+
+
+
+</div></td>
+</td></table>
+</div>
+<!-- =========== vertical menu =========== -->
+<div class="topmenu">
+<a target="_blank" href="/briskhome.php"><img class="nobo" src="img/brisk_homebutt.png"></a>
+<br><br><br>
+sponsored by:<br><br>'.$altout_carousel.'<br>
+<a target="_blank" href="http://www.dynamica.it"><img class="nobo" src="img/dynamica.png"></a><br><br>
+supported by:<br><br>
+<a target="_blank" href="http://www.briscolachiamata.it"><img class="nobo" src="img/brichi.png"></a><br><br>
+<div id="proflashext" class="proflashext"><div id="proflash" class="proflash">
+</div><br><br></div>
+%s
+%s
+</div>';
/* Templates. */
if ($ACTION == 'login') {
<script type="text/javascript" src="commons.js"></script>
<script type="text/javascript" src="xhr.js"></script>
<script type="text/javascript" src="preload_img.js"></script>
+<script type="text/javascript" src="AC_OETags.js"></script>
<link rel="stylesheet" type="text/css" href="brisk.css">
+<link rel="stylesheet" type="text/css" href="room.css">
</head>
<body>
<SCRIPT type="text/javascript">
+ var g_withflash = false;
+
window.onload = function() {
+ g_withflash = DetectFlashVer(6,0,0);
+ if (g_withflash == false) {
+ $("proflash").innerHTML = 'Audio con Flash.<br><a href="http://www.macromedia.com/"><img class="nobo" style="padding: 4px; width:73; height: 19;" src="img/download_now_flash.gif"></a>';
+ }
+ else
+ $("proflashext").innerHTML = "";
$("nameid").focus();
}
</SCRIPT>
-<img class="nobo" src="img/brisk_logo64.png">
-<div style="text-align: center; font-size: 12px;">briscola chiamata in salsa ajax</div>
-<br><br>
+<?php
+ printf($brisk_header_form, '', '');
+?>
+
+<!-- =========== tables =========== -->
+<div id="tables" class="tables">
<?php echo "$body"; ?>
<br>
<div style="text-align: center;">
+ <br><br><br>
Digita il tuo nickname per accedere ai tavoli della briscola.<br><br>
<form method="post" action="">
-<input id="nameid" name="name" type="text" maxlength="12" value="">
+<input id="nameid" name="name" type="text" size="24" maxlength="12" value="">
+<input id="sub" value="entra" type="submit" class="button">
</form>
</div>
-<br><br>
-<hr>
+</div></div>
+<br><br><br><br>
+
<div id="imgct"></div>
<div id="logz"></div>
<div id="sandbox"></div>
</html>
<?php
}
- else if ($ACTION == 'table') {
+ else if ($ACTION == 'room') {
?>
<html>
<head>
<script type="text/javascript" src="commons.js"></script>
<script type="text/javascript" src="xhr.js"></script>
<script type="text/javascript" src="preload_img.js"></script>
+<script type="text/javascript" src="AC_OETags.js"></script>
<link rel="stylesheet" type="text/css" href="brisk.css">
+<link rel="stylesheet" type="text/css" href="room.css">
</head>
<body>
<SCRIPT type="text/javascript">
var subst = "";
var gst = new globst();
+ var g_withflash = false;
var g_imgct= 0;
var g_imgtot = g_preload_img_arr.length;
var myfrom = "index_php";
window.onload = function() {
+<?php
+if ($BRISK_SHOWHTML == "debugtable") {
+?>
+ room_checkspace(12,8,50);
+<?php
+}
+else {
+?>
// alert("INDEX START");
xhr_rd = createXMLHttpRequest();
sess = "<?php echo "$sess"; ?>";
+ window.onunload = onunload_cb;
+ g_withflash = DetectFlashVer(6,0,0);
+ if (g_withflash == false) {
+ $("proflash").innerHTML = 'Audio con Flash.<br><a href="http://www.macromedia.com/"><img class="nobo" style="padding: 4px; width:73; height: 19;" src="img/download_now_flash.gif"></a>';
+ }
+ else
+ $("proflashext").innerHTML = "";
setTimeout(xhr_rd_poll, 0, sess);
// alert("ARR LENGTH "+g_preload_img_arr.length);
setTimeout(preload_images, 0, g_preload_img_arr, g_imgct);
+ $("txt_in").focus();
+<?php
+}
+?>
}
+
</SCRIPT>
-<img class="nobo" src="img/brisk_logo64.png">
-<div style="text-align: center; font-size: 12px;">briscola chiamata in salsa ajax</div><br>
-<!-- <div><input name="logout" value="Esco." onclick="act_logout();" type="button"></div> -->
+<?php
+ printf($brisk_header_form, '<input type="button" class="button" name="xhelp" value="Help." onclick="act_help();"><br><br><input type="button" class="button" name="xabout" value="About." onclick="act_about();"><br><br><br>',
+ $brisk_donate);
+?>
+<!-- =========== tables =========== -->
+<div id="tables" class="tables">
<input name="sess" type="hidden" value="<?php echo "$user->sess"; ?>">
<?php echo "$tables"; ?>
+</div>
+<!-- =========== bottom =========== -->
+<div id="bottom" class="bottom">
<b>Chat</b>
-<div id="txt" class="chatt"></div>
-
-<table><tr><td><div id="myname" class="txtt"></div></td><td><input id="txt_in" type="text" size="80" maxlength="256" onchange="act_chatt();" class="txtt"></td></tr></table>
-
-<hr>
+<div id="txt" class="chatt">
+</div>
+<table><tr><td><div id="myname" class="txtt"></div></td><td><input id="txt_in" type="text" size="90" maxlength="256" onkeypress="chatt_checksend(this,event);" class="txtt"></td></tr></table>
+</div>
+<div id="heartbit"></div>
+<div id="sandbox"></div>
<div id="imgct"></div>
<div id="logz"></div>
-<div id="sandbox"></div>
<div id="sandbox2"></div>
<div id="response"></div>
+<div id="remark"></div>
<div id="xhrstart"></div>
-<pre>
<div id="xhrlog"></div>
-</pre>
<div id="xhrdeltalog"></div>
+</div>
</body>
</html>
<?php