aggiunto bottone di help
[brisk.git] / web / index.php
index 2cfa99e..96f79e2 100644 (file)
@@ -42,29 +42,28 @@ function main()
     $bri = &load_data();
     
     /* Actions */
-    if (isset($sess)) {
+    if (validate_sess($sess)) {
       $bri->garbage_manager(TRUE);
-      if (($user = &get_user(&$bri, $sess, &$idx)) != FALSE) {
+      if (($user = &$bri->get_user($sess, &$idx)) != FALSE) {
        if ($user->stat == "table") {
          header ("Location: table.php");
          unlock_data($sem);
          exit;
        }
-       $ACTION = "table";
-      }
-      else {
-       setcookie ("sess", "", time() - 3600);
+       $ACTION = "room";
       }
     }
-    else if (isset($name)) {
+    
+    if ($ACTION == "login" && isset($name)) {
       $bri->garbage_manager(TRUE);
       /* try login */
       $name = substr($name, 0, 12);
-      if (($user = &add_user(&$bri, &$sess, &$idx, $name)) != FALSE) {
-       $ACTION = "table";
+      $name = str_replace(" ", "_", $name);
+      if (($user = &$bri->add_user(&$sess, &$idx, $name)) != FALSE) {
+       $ACTION = "room";
        
-       setcookie ("sess", "", time() + 180);      
-       standup_update(&$bri,&$user);
+       // setcookie ("sess", "", time() + 180);      
+       $bri->standup_update(&$user);
        
        if (save_data(&$bri) == FALSE) {
          echo "ERRORE SALVATAGGIO\n";
@@ -84,13 +83,13 @@ function main()
   /* Rendering. */
 
   if ($BRISK_DEBUG == "debugtable") {
-    $ACTION = "table";
+    $ACTION = "room";
   }
   else if ($BRISK_DEBUG == "debuglogin") {
     $ACTION = "login";
   }
 
-  if ($ACTION == "table") {
+  if ($ACTION == "room") {
     $tables .= '<table class="room_tab" align="center">';
     for ($i = 0 ; $i < TABLES_N ; $i++) {
       if ($i % 4 == 0)
@@ -113,7 +112,7 @@ function main()
     $tables .= '</table>';
   }
 
-$brisk_header = '<div class="container">
+$brisk_header_form = '<div class="container">
 <!-- =========== header ===========  -->
 <div class="header">
 <img class="nobo" src="img/brisk_logo64.png">
@@ -128,7 +127,8 @@ sponsored by:<br><br>
 <a target="_blank" href="http://www.alternativeoutput.it"><img class="nobo" src="img/altout80x15.png"></a><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>
+<a target="_blank" href="http://www.briscolachiamata.it"><img class="nobo" src="img/brichi.png"></a><br><br><br>
+%s
 </div>';
     
   /* Templates. */
@@ -152,11 +152,11 @@ supported by:<br><br>
    }
 </SCRIPT>
 <?php
-    echo "$brisk_header";
+    printf($brisk_header_form, '');
 ?> 
 
 <!--  =========== tables ===========  -->
-<div class="tables">
+<div id="tables" class="tables">
 <?php echo "$body"; ?>
 
 <br>
@@ -165,6 +165,7 @@ supported by:<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" size="24" maxlength="12" value="">
+<input id="sub"    value="entra" type="submit" class="button">
 </form>
 </div>
 </div></div>
@@ -184,7 +185,7 @@ Digita il tuo nickname per accedere ai tavoli della briscola.<br><br>
 </html>
 <?php
   }
-  else if ($ACTION == 'table') {
+  else if ($ACTION == 'room') {
   ?>
 <html>
 <head>
@@ -224,7 +225,7 @@ else {
 
      setTimeout(xhr_rd_poll, 0, sess); 
      // alert("ARR LENGTH "+g_preload_img_arr.length);
-     setTimeout(preload_images, 0, g_preload_img_arr, g_imgct); 
+     // setTimeout(preload_images, 0, g_preload_img_arr, g_imgct); 
      $("txt_in").focus();
 <?php
 }
@@ -233,16 +234,16 @@ else {
 
 </SCRIPT>
 <?php
-    echo "$brisk_header";
+    printf($brisk_header_form, '<input type="button" class="button" name="xhelp"  value="Help." onclick="act_help();">');
 ?> 
 <!--  =========== tables ===========  -->
-<div class="tables">
+<div id="tables" class="tables">
 <input name="sess" type="hidden" value="<?php echo "$user->sess"; ?>">
 <?php echo "$tables"; ?>
 </div>
 
 <!--  =========== bottom ===========  -->
-<div class="bottom">
+<div id="bottom" class="bottom">
 <b>Chat</b>
 <div id="txt" class="chatt">
 </div>