}
}
+define('GHOST_SESS_TOUT', 300);
+define('GHOST_SESS_REAS_ANOT', 1);
+class GhostSessEl
+{
+ var $time;
+ var $sess;
+ var $reas;
+
+ function GhostSessEl($time, $sess, $reas)
+ {
+ $this->time = $time + GHOST_SESS_TOUT;
+ $this->sess = $sess;
+ $this->reas = $reas;
+ }
+}
+
+class GhostSess
+{
+ var $gs;
+
+ function GhostSess()
+ {
+ $this->gs = array();
+ }
+
+ // push or update for this session
+ function push($time, $sess, $reas)
+ {
+ foreach($this->gs as $el) {
+ if ($el->sess == "$sess") {
+ $el->reas = $reas;
+ $el->time = $time + GHOST_SESS_TOUT;
+ return TRUE;
+ }
+ }
+
+ $this->gs[] = new GhostSessEl($time, $sess, $reas);
+ return TRUE;
+ }
+
+ function pop($sess)
+ {
+ foreach($this->gs as $key => $el) {
+ if ($el->sess == "$sess") {
+ $ret = $this->gs[$key];
+ unset($this->gs[$key]);
+ return ($ret);
+ }
+ }
+ return FALSE;
+ }
+
+ function garbage_manager($curtime)
+ {
+ foreach($this->gs as $key => $el) {
+ if ($el->time < $curtime) {
+ unset($this->gs[$key]);
+ }
+ }
+ }
+}
class Brisk
{
var $ban_list; // ban list (authized allowed)
var $black_list; // black list (anti-dos, noone allowed)
-
+ var $ghost_sess;
var $delay_mgr;
var $cds;
$thiz->ban_list = NULL;
$thiz->black_list = NULL;
+ $thiz->ghost_sess = new GhostSess();
for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
$thiz->user[$i] = User::create($thiz, $i, "", "");
$this->garbage_timeout = $curtime + GARBAGE_TIMEOUT;
$ismod = TRUE;
+ $this->ghost_sess->garbage_manager($curtime);
+
$this->delay_mgr->lastcheck_set($curtime);
return ($ismod);
}
$ghost_user = $this->user[$ghost];
$curtime = time();
+ $this->ghost_sess->push($curtime, $ghost_user->sess, GHOST_SESS_REAS_ANOT);
$ghost_user->comm[$ghost_user->step % COMM_N] = "";
$ghost_user->step_inc();
if ($sess == "") {
'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.',
$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);