add more logout reasons to be pushed in the ghost_session management
authorMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Thu, 27 Nov 2014 07:41:09 +0000 (08:41 +0100)
committerMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Thu, 27 Nov 2014 07:41:09 +0000 (08:41 +0100)
web/Obj/brisk.phh
web/index.php
web/index_wr.php

index bc65746..4cd3b18 100644 (file)
@@ -984,7 +984,11 @@ class Client_prefs {
 }
 
 define('GHOST_SESS_TOUT', 300);
-define('GHOST_SESS_REAS_ANOT', 1);
+define('GHOST_SESS_REAS_LOUT', 1); // logout
+define('GHOST_SESS_REAS_ANOT', 2); // another user get session
+define('GHOST_SESS_REAS_TOUT', 3); // room timeout
+define('GHOST_SESS_REAS_TTOT', 4); // table timeout
+
 class GhostSessEl
 {
     var $time;
@@ -1315,6 +1319,9 @@ class Brisk
                             $user_cur->laccwr     = $bin5_user->lacc;
                             $user_cur->bantime    = $bin5_user->bantime;
                             $user_cur->the_end    = $bin5_user->the_end;
+                            if ($user_cur->the_end) {
+                                $this->ghost_sess->push($curtime, $user_cur->sess, GHOST_SESS_REAS_TTOT);
+                            }
                         }
 
                         log_legal($curtime, $user_cur->ip, $user_cur, "STAT:DESTROY_GAME", $plist);
@@ -1377,6 +1384,7 @@ class Brisk
             // Auto logout dell'utente
             log_rd2("AUTO LOGOUT.".($user_cur->lacc + EXPIRE_TIME_RD)." curtime - delta ".($curtime - $delta));
 
+            $this->ghost_sess->push($curtime, $user_cur->sess, GHOST_SESS_REAS_TOUT);
             $user_cur->the_end = TRUE;
 
             log_rd2("AUTO LOGOUT.");
index 0f1434f..defcdf0 100644 (file)
@@ -41,6 +41,14 @@ $mlang_room = array( 'userpasserr'  => array('it' => 'Utente e/o password errati
                                              '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.'),
+                     'reas_unkn'    => array('it' => 'Logout per motivi sconosciuti.',
+                                             'en' => 'Logout with unknown reason.'),
+                     'reas_lout'    => array('it' => 'Orevoire.',
+                                             'en' => 'EN Orevoire.'),
+                     'reas_tout'    => array('it' => 'Abbiamo perso le tue tracce, quindi ti abbiamo disconnesso.',
+                                             'en' => 'EN Abbiamo perso le tue tracce, quindi ti abbiamo disconnesso.'),
+                     'reas_ttot'    => array('it' => 'Abbiamo perso le tue tracce mentre stavi giocando, quindi ti abbiamo disconnesso.',
+                                             'en' => 'EN Abbiamo perso le tue tracce mentre stavi giocando, quindi ti abbiamo disconnesso.'),
                      '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',
@@ -341,8 +349,22 @@ function index_main(&$brisk, $transp_type, $header, &$header_out, $remote_addr_f
 
       /* Actions */
       if (($ghost_sess = $brisk->ghost_sess->pop($sess)) != FALSE) {
-          if ($ghost_sess->reas == GHOST_SESS_REAS_ANOT) {
+          switch ($ghost_sess->reas) {
+          case GHOST_SESS_REAS_LOUT:
+              $last_msg = $mlang_room['reas_lout'][$G_lang];
+              break;
+          case GHOST_SESS_REAS_ANOT:
               $last_msg = $mlang_room['reas_anot'][$G_lang];
+              break;
+          case GHOST_SESS_REAS_TOUT:
+              $last_msg = $mlang_room['reas_tout'][$G_lang];
+              break;
+          case GHOST_SESS_REAS_TTOT:
+              $last_msg = $mlang_room['reas_ttot'][$G_lang];
+              break;
+          default:
+              $last_msg = $mlang_room['reas_unkn'][$G_lang];
+              break;
           }
       }
       if (validate_sess($sess)) {
index 5a7c265..8cde2fa 100644 (file)
@@ -730,7 +730,7 @@ function index_wr_main(&$brisk, $remote_addr_full, $get, $post, $cookie)
                     $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
                     /* MLANG: "<br>Ti sei alzato da un tavolo senza il consenso degli altri giocatori. <br><br>Dovrai aspettare ancora ".secstoword($user->bantime - $user->laccwr)." prima di poterti sedere nuovamente.", "resta in piedi.", "<br>Tu o qualcuno col tuo stesso indirizzo IP si è alzato da un tavolo senza il consenso degli altri giocatori.<br><br>Dovrai aspettare ancora ".secstoword($bantime - $user->laccwr)." prima di poterti sedere nuovamente.<br><br>Se non sei stato tu ad alzarti e possiedi un login con password, autenticandoti con quello, potrai accedere." */
                     if ($user->is_auth()) {
-                        $user->comm[$user->step % COMM_N] .= show_notify($mlang_indwr['badwake_a'][$G_lang].secstoword($user->bantime - $user->laccwr).$mlang_indwr['badwake_b'][$G_lang], 2000, $mlang_indwr['btn_stays'][$G_lang], 400, 100);
+                        $user->comm[$user->step % COMM_N] .= show_notify($mlang_indwr['badwake_a'][$G_lang].secstoword($bantime - $user->laccwr).$mlang_indwr['badwake_b'][$G_lang], 2000, $mlang_indwr['btn_stays'][$G_lang], 400, 140);
                     }
                     else {
                         $user->comm[$user->step % COMM_N] .= show_notify($mlang_indwr['badsit_a'][$G_lang].secstoword($bantime - $user->laccwr).$mlang_indwr['badsit_a'][$G_lang], 2000, $mlang_indwr['btn_stays'][$G_lang], 400, 180);