refactored exit management and add ghost_session class to manage welcome messages
[brisk.git] / web / index.php
index 70e1ddd..0f1434f 100644 (file)
@@ -22,6 +22,7 @@
  *
  */
 
+require_once("Obj/user.phh");
 require_once("Obj/brisk.phh");
 require_once("Obj/auth.phh");
 require_once("Obj/proxyscan.phh");
@@ -38,8 +39,10 @@ $mlang_room = array( 'userpasserr'  => array('it' => 'Utente e/o password errati
                                              'en' => 'Standing players'),
                      'headline'     => array('it' => 'briscola chiamata in salsa ajax',
                                              'en' => 'declaration briscola in ajax sauce <b>(Beta)</b>'),
-                     'welcome'      => array('it' => 'Digita il tuo nickname per accedere ai tavoli della briscola',
-                                             'en' => 'Enter your nickname to access to the tables of briscola'),
+                     'welcome'      => array('it' => 'Digita il tuo nickname per accedere ai tavoli della briscola.',
+                                             'en' => 'Enter your nickname to access to the tables of briscola.'),
+                     'reas_anot'    => array('it' => 'La tua sessione è stata assegnata ad un altro browser.',
+                                             'en' => 'EN La tua sessione è stata assegnata ad un altro browser.'),
                      'btn_enter'    => array('it' => 'entra',
                                              'en' => 'enter'),
                      'passwarn'     => array('it' => 'Se non hai ancora una password, lascia il campo in bianco ed entra.',
@@ -297,7 +300,7 @@ function sidebanners_render($sidebanner, $sidebanner_idx)
     }
 }
 
-function index_main(&$brisk, $transp_type, &$header_out, $remote_addr_full, $get, $post, $cookie)
+function index_main(&$brisk, $transp_type, $header, &$header_out, $remote_addr_full, $get, $post, $cookie)
 {
     GLOBAL $G_with_donors, $G_donors_cur, $G_donors_all;
     GLOBAL $G_with_topbanner, $G_topbanner, $G_is_local;
@@ -329,6 +332,7 @@ function index_main(&$brisk, $transp_type, &$header_out, $remote_addr_full, $get
   $tables = "";
   $standup = "";
   $ACTION = "login";
+  $last_msg = "";
 
   if (isset($BRISK_SHOWHTML) == FALSE) {
       $is_table = FALSE;
@@ -336,23 +340,29 @@ function index_main(&$brisk, $transp_type, &$header_out, $remote_addr_full, $get
       $curtime = time();
 
       /* Actions */
-
+      if (($ghost_sess = $brisk->ghost_sess->pop($sess)) != FALSE) {
+          if ($ghost_sess->reas == GHOST_SESS_REAS_ANOT) {
+              $last_msg = $mlang_room['reas_anot'][$G_lang];
+          }
+      }
       if (validate_sess($sess)) {
           log_main("pre garbage_manager UNO");
           $brisk->garbage_manager(TRUE);
           log_main("post garbage_manager");
           if (($user = &$brisk->get_user($sess, &$idx)) != FALSE) {
-              $brisk->sess_cur_set($user->sess);
-              log_main("user stat: ".$user->stat);
-              if ($user->stat == "table") {
-                  $cookies = new Cookies();
-                  $cookies->add("table_token", $user->table_token, $curtime + 31536000);
-                  $cookies->add("table_idx", $user->table, $curtime + 31536000);
-                  $header_out['cookies'] = $cookies;
-                  $header_out['Location'] = "briskin5/index.php";
-                  return TRUE;
+              if ($user->the_end == FALSE) {
+                  $brisk->sess_cur_set($user->sess);
+                  log_main("user stat: ".$user->stat);
+                  if ($user->stat == "table") {
+                      $cookies = new Cookies();
+                      $cookies->add("table_token", $user->table_token, $curtime + 31536000);
+                      $cookies->add("table_idx", $user->table, $curtime + 31536000);
+                      $header_out['cookies'] = $cookies;
+                      $header_out['Location'] = "briskin5/index.php";
+                      return TRUE;
+                  }
+                  $ACTION = "room";
               }
-              $ACTION = "room";
           }
       }
 
@@ -374,7 +384,7 @@ function index_main(&$brisk, $transp_type, &$header_out, $remote_addr_full, $get
           /* try login */
 
           if ($banned == FALSE &&
-              ($user = $brisk->add_user(&$sess, &$idx, $name, $pass_private, $remote_addr, $cookie)) != FALSE) {
+              ($user = $brisk->add_user(&$sess, &$idx, $name, $pass_private, $remote_addr, $header, $cookie)) != FALSE) {
               $brisk->sess_cur_set($user->sess);
               $ACTION = "room";
               if ($idx < 0) {
@@ -1034,7 +1044,9 @@ supported by:<br>
 echo "$body"; ?>
 <br>
 <div style="text-align: center;">
-   <br><br><br>
+   <br>
+     <div class="bye_msg" id="bye_msg"><?php echo "$last_msg"; ?></div>
+<br>
 <?php echo $mlang_room['welcome'][$G_lang];?>
 <br><br>
 <form accept-charset="utf-8" method="post" action="" onsubmit="return j_login_manager(this);">