+ /* aggiorna l'array dei giocatori al tavolo. */
+ for ($i = $tabpos ; $i < $this->player_n-1 ; $i++) {
+ $this->player[$i] = $this->player[$i+1];
+ $user_cur = $brisk->user[$this->player[$i]];
+ $user_cur->table_pos = $i;
+ }
+ $this->player_n--;
+ }
+ else {
+ log_main("INCONSISTENCY ON TABLE.");
+ }
+ }
+
+ // Table->act_content - return 'id' of type of output required for table button
+ function act_content($user)
+ {
+ $ret = "";
+ $isstanding = ($user->subst == 'standup');
+ $sitted = $this->player_n;
+ $table = $this->idx;
+ $cur_table = $user->table;
+ $allowed = TRUE;
+
+ if ($isstanding) {
+ if ($sitted < PLAYERS_N) {
+ switch ($this->auth_type) {
+ case TABLE_AUTH_TY_CERT:
+ if ($user->is_cert() && !$user->is_appr())
+ $act = "sitcert";
+ else
+ $act = 'resercert';
+ break;
+ case TABLE_AUTH_TY_AUTH:
+ if ($user->is_auth() && !$user->is_appr())
+ $act = "sitreser";
+ else
+ $act = 'reserved';
+ break;
+ case TABLE_AUTH_TY_APPR:
+ if ($user->is_auth())
+ $act = "sitappr";
+ else
+ $act = 'reserved';
+ break;
+ default:
+ $act = 'sit';
+ break;
+ }
+ }
+ else {
+ $act = 'none';
+ }
+ }
+ else {
+ if ($table == $cur_table)
+ $act = 'wake';
+ else
+ $act = 'none';
+ }
+
+ if ($act != '')
+ $ret = sprintf('j_tab_act_cont(%d, \'%s\');', $table, $act);
+
+ return ($ret);
+ }
+} // end class Table
+
+
+class Delay_Manager
+{
+ var $delta;
+ var $lastckeck;
+ var $triglevel;
+
+ function Delay_Manager($triglevel)
+ {
+ $this->triglevel = $triglevel;
+ $this->delta = array();
+ $this->lastcheck = 0;
+ }
+
+ function delta_get($curtime)
+ {
+ // clean too old delta items
+ for ($i = 0 ; $i < count($this->delta) ; $i++) {
+ if ($this->delta[$i][0] < $curtime) {
+ array_splice($this->delta, $i, 1);
+ $i--;
+ }
+ }
+
+ // add new delta items if delay exceeded $this->triglevel sec
+ if ($curtime > $this->lastcheck + $this->triglevel && $curtime < $this->lastcheck + 1200.0) {
+ $delta = $curtime - $this->lastcheck - $this->triglevel;
+ array_push($this->delta, array($curtime + $delta , $delta));
+ // fprintf(STDERR, "DELTA: add new delta [%f] [%f] [%f]\n", $this->triglevel, $curtime + $delta, $delta);
+ }
+
+ // extract the maximum valid delta
+ $delta_max = 0.0;
+ for ($i = 0 ; $i < count($this->delta) ; $i++) {
+ $delta_cur = $this->delta[$i][1];
+ if ($delta_max < $delta_cur)
+ $delta_max = $delta_cur;
+ }
+
+ // fprintf(STDERR, "DELTA: status %d, delta_max: %f\n", count($this->delta), $delta_max);
+
+ return ($delta_max);
+ }
+
+ function lastcheck_set($curtime)
+ {
+ $this->lastcheck = $curtime;
+ }
+}
+
+class Client_prefs {
+ var $listen;
+ var $supp_comp;
+
+ function Client_prefs()
+ {
+ }
+
+ static function from_user($user)
+ {
+ $thiz = new Client_prefs();
+ $thiz->user_load($user);
+
+ return ($thiz);
+ }
+
+ static function from_json($json)
+ {
+ $thiz = new Client_prefs();
+ if ($thiz->json_load($json) == FALSE) {
+ unset($thiz);
+ return (FALSE);
+ }
+
+ return ($thiz);
+ }
+
+ function user_load($user)
+ {
+ // fprintf(STDERR, "QQ %s: %x\n", __FUNCTION__, $user->flags);
+ $this->listen = ($user->flags & USER_FLAG_MAP_AUTH) >> 2;
+ if ($user->rec != FALSE) {
+ $this->supp_comp = $user->rec->supp_comp_get();
+ }
+ else {
+ $this->supp_comp = "000000000000";
+ }
+
+ // fprintf(STDERR, "QQ %s: LISTEN: %d\n", __FUNCTION__, $this->listen);
+ }
+
+ function json_load($json_s)
+ {
+ $ret = FALSE;
+
+ do {
+ if (gettype($json_s) == "string") {
+ if (($json = json_decode($json_s)) == FALSE)
+ break;
+ }
+ else {
+ $json = $json_s;
+ }
+ if ($this->listen < 0 || $this->listen > 2)
+ break;
+ $this->listen = $json->listen;
+
+ if (mb_strlen($json->supp_comp, "ASCII") != 12)
+ break;
+
+ for ($i = 0, $idx = 0 ; $i < 12 ; $i++) {
+ if (($json->supp_comp[$i] >= '0' && $json->supp_comp[$i] <= '9') ||
+ ($json->supp_comp[$i] >= 'a' && $json->supp_comp[$i] <= 'f'))
+ continue;
+ break;
+ }
+ if ($i < 12)
+ break;
+ $this->supp_comp = $json->supp_comp;
+ $ret = TRUE;
+ } while (FALSE);
+
+ return ($ret);
+ }
+
+ function store($user, $is_save)
+ {
+ // save into DB
+ // fprintf(STDERR, "QQ %s::%s PRE: %x\n", __CLASS__, __FUNCTION__,
+ // $user->flags & (~USER_FLAG_S_ALL & ~USER_FLAG_AUTH));
+ $user->flags_set(($this->listen << 2), USER_FLAG_MAP_AUTH);
+ // fprintf(STDERR, "QQ %s::%s %x\n", __CLASS__, __FUNCTION__,
+ // $user->flags);
+ if ($user->is_supp_custom()) {
+ $user->rec->supp_comp_set($this->supp_comp);
+ }
+ if ($is_save)
+ $user->prefs_store();
+ }
+}
+
+define('GHOST_SESS_TOUT', 1800);
+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
+define('GHOST_SESS_REAS_ANON', 5); // anonymizer access
+define('GHOST_SESS_REAS_PROX', 6); // proxy access
+
+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
+{
+ static $delta_t;
+
+ var $crystal_filename;
+ var $user;
+ var $table;
+ var $match;
+ var $comm; // commands for many people
+ var $step; // current step of the comm array
+ var $garbage_timeout;
+ var $shm_sz;
+
+ var $ban_list; // ban list (authized allowed)
+ var $black_list; // black list (anti-dos, noone allowed)
+ var $cloud_smasher; // list of cloud ip ranges to be rejected
+ var $ghost_sess;
+ var $delay_mgr;
+
+ var $cds;
+
+ public static $sess_cur;
+
+ function Brisk()
+ {
+ $this->cds = NULL;
+ }
+
+ // constructor
+ static function create($crystal_filename, $ban_list, $black_list, $cloud_smasher) {
+ if (($brisk_ser = @file_get_contents($crystal_filename)) != FALSE) {
+ if (($brisk = unserialize($brisk_ser)) != FALSE) {
+ fprintf(STDERR, "ROOM FROM FILE\n");
+ rename($crystal_filename, $crystal_filename.".old");
+
+ $brisk->reload(TRUE, $ban_list, $black_list, $cloud_smasher);
+
+ return($brisk);
+ }
+ }
+
+ fprintf(STDERR, "NEW ROOM\n");
+ $thiz = new Brisk();
+
+ $thiz->crystal_filename = $crystal_filename;
+ $thiz->user = array();
+ $thiz->table = array();
+ $thiz->match = array();
+
+ $thiz->ban_list = IpClass::create();
+ $thiz->black_list = IpClass::create();
+ $thiz->cloud_smasher = IpClass::create();
+ $thiz->ghost_sess = new GhostSess();
+
+ for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
+ $thiz->user[$i] = User::create($thiz, $i, "", "");
+ }
+
+ for ($i = 0 ; $i < TABLES_N ; $i++) {
+ $thiz->table[$i] = Table::create($i);
+ }
+ $thiz->garbage_timeout = 0;
+ $thiz->shm_sz = SHM_DIMS_MIN;
+
+ $thiz->delay_mgr = new Delay_Manager(1.5);
+
+ static::$sess_cur = FALSE;
+
+ $thiz->reload(TRUE, $ban_list, $black_list, $cloud_smasher);
+
+ return ($thiz);
+ }
+
+ function reload($is_first, $ban_list, $black_list, $cloud_smasher)
+ {
+ fprintf(STDERR, "RELOAD STUFF (%d)(%d)(%d)\n",
+ count($ban_list), count($black_list), count($cloud_smasher));
+
+ if (defined('CURL_DE_SAC_VERS')) {
+ if (brisk_cds_reload($this) == FALSE) {
+ exit(12);
+ }
+ }
+ $this->ban_list->update($ban_list);
+ $this->black_list->update($black_list);
+ $this->cloud_smasher->update($cloud_smasher);
+
+ if (!$is_first) {
+ $this->banned_kickoff();
+ $this->garbage_manager(TRUE);
+ }
+ }
+
+ function banned_kickoff()
+ {
+ $is_ban = FALSE;
+
+ for ($table_idx = 0 ; $table_idx < TABLES_N ; $table_idx++) {
+ $table_cur = $this->table[$table_idx];
+ // if the table is complete and exists we check users IP
+
+ if ($table_cur->player_n == PLAYERS_N) {
+ if (isset($this->match[$table_idx]) &&
+ $table_cur->table_token == $bin5->table_token) {
+ log_main("PLAYERS == N TABLE ".$table_idx);
+
+ $bin5 = $this->match[$table_idx];
+
+ $is_ban |= $bin5->banned_kickoff();
+ }
+ }
+ }
+
+ for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
+ $user_cur = $this->user[$i];
+
+ if ($user_cur->is_active() == FALSE)
+ continue;
+
+ // check if the IP is blacklisted
+ if ($this->black_check($user_cur->ip) ||
+ $this->cloud_check($user_cur->ip)) {
+ $user_cur->lacc = 0;
+ $is_ban = TRUE;
+ continue;
+ }
+
+ // if authorized not check if banlisted
+ if ($user_cur->is_auth()) {
+ continue;
+ }
+
+ if ($this->ban_check($user_cur->ip)) {
+ $user_cur->lacc = 0;
+ $is_ban = TRUE;
+ }
+ }
+
+ return $is_ban;
+ }
+
+ function ban_check($ip_str)
+ {
+ return ($this->ban_list->check($ip_str));
+ }
+
+ function black_check($ip_str)
+ {
+ return ($this->black_list->check($ip_str));
+ }
+
+ function cloud_check($ip_str)
+ {
+ return ($this->cloud_smasher->check($ip_str));
+ }
+
+ function users_cleanup()
+ {
+ $curtime = time();
+ for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
+ $user_cur = $this->user[$i];
+
+ if ($user_cur->the_end
+ && (($user_cur->rd_toflush == FALSE
+ && $user_cur->rd_step == $user_cur->step)
+ || $user_cur->rd_endtime_is_expired($curtime))
+ ) {
+ $user_cur->reset(); // users_cleanup, OK
+ }
+ }
+ }
+
+ function garbage_manager($force)
+ {
+ GLOBAL $G_lang, $mlang_brisk, $G_base;
+
+ $ismod = FALSE;
+
+ log_rd2("garbage_manager START");
+
+ /* Garbage collector degli utenti in timeout */
+ $curtime = microtime(TRUE);
+
+ $delta = $this->delay_mgr->delta_get($curtime);
+
+ if (!$force && !($this->garbage_timeout < $curtime)) {
+ $this->delay_mgr->lastcheck_set($curtime);
+ return ($ismod);
+ }
+
+ // Before all align times with table timeout
+ for ($table_idx = 0 ; $table_idx < TABLES_N ; $table_idx++) {
+ $table_cur = $this->table[$table_idx];
+ // if the table is complete and exists its shared mem we get the info about users lacc
+
+ if ($table_cur->player_n == PLAYERS_N) {
+ log_main("PLAYERS == N TABLE ".$table_idx);
+
+
+ $no_recovery = FALSE;
+ if (isset($this->match[$table_idx])) {
+ $bin5 = $this->match[$table_idx];
+
+ if ($table_cur->table_token != $bin5->table_token) {
+ log_main("ERROR: not matching table_token. Brisk: ".$table_cur->table_token." Table: ".$bin5->table_token);
+ log_main("ERROR: not matching table_start. Brisk: ".$table_cur->table_start." Table: ".$bin5->table_start);
+ $no_recovery = TRUE;
+ $bin5 = FALSE;
+ }
+
+ if ($bin5 != FALSE) {
+ //
+ // SPAWN: JOIN
+ //
+ log_main("garbage_manager: bri loaded successfully.");
+ $bin5->garbage_manager(TRUE);
+
+ $bin5_table = $bin5->table[0];
+
+ // is the end of the table
+
+ if ($bin5->the_end == TRUE) {
+ /*
+ * DESTROY OF FINISHED TABLE && MOVE PLAYER TO ROOM AGAIN
+ */
+ log_main("garbage_manager: INSIDE THE END.");
+
+ $plist = "$table_cur->table_token|$table_cur->idx|$table_cur->player_n";
+ for ($i = 0 ; $i < $table_cur->player_n ; $i++) {
+ $plist .= '|'.$this->user[$table_cur->player[$i]]->sess;
+ }
+
+ for ($i = 0 ; $i < $bin5_table->player_n ; $i++) {
+ // stat must be "table" by definition
+ $user_cur = $this->user[$table_cur->player[$i]];
+ $bin5_user = $bin5->user[$i];
+
+ $user_cur->subst = $bin5_user->subst;
+ $user_cur->rd_step = $bin5_user->rd_step;
+ $user_cur->step = $bin5_user->step;
+ $user_cur->lacc = $bin5_user->lacc;
+ $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);
+
+ $this->room_join_wakeup($user_cur, FALSE, 0);
+ $table_cur->table_token = "";
+ $table_cur->wakeup_time = $curtime + WAKEUP_TIME;
+
+ $this->match_del($table_idx);
+ }
+ else {
+ log_main("gm:: save_data");
+
+ for ($i = 0 ; $i < $bin5_table->player_n ; $i++) {
+ $this->user[$table_cur->player[$i]]->lacc = $bin5->user[$i]->lacc;
+ }
+ }
+ } // if ($bin5 == FALSE
+ else if ($no_recovery == FALSE) {
+ log_crit("ERROR: table ".$table_idx." unrecoverable join");
+
+ for ($i = 0 ; $i < $table_cur->player_n ; $i++) {
+ $user_cur = $this->user[$table_cur->player[$i]];
+ $user_cur->subst = "shutdowner";
+ $user_cur->step_inc();
+
+ $ret = sprintf('stat = "%s"; subst = "%s";', $user_cur->stat, $user_cur->subst);
+ $ret .= "gst.st = ".($user_cur->step+1)."; ";
+ // MLANG <br>I dati del tavolo n° ".$user_cur->table." sono inconsistenti, verranno resettati.<br><br>Torni in piedi.<br><br>
+ $prestr = sprintf($mlang_brisk['tabincon'][$G_lang], $user_cur->table);
+ $ret .= show_notify($prestr, 2000, $mlang_brisk['btn_close'][$G_lang], 400, 110);
+ $user_cur->comm[$user_cur->step % COMM_N] = $ret;
+ $user_cur->step_inc();
+ }
+
+ $plist = "$table_cur->table_token|$user_cur->table|$table_cur->player_n";
+ for ($i = 0 ; $i < $table_cur->player_n ; $i++) {
+ $plist .= '|'.$this->user[$table_cur->player[$i]]->sess;
+ }
+ log_legal($curtime, $user_cur->ip, $user_cur, "STAT:DESTROY_GAME(RECOVERY)", $plist);
+
+ $this->room_join_wakeup($user_cur, TRUE, -2);
+ $table_cur->table_token = "";
+ }
+ }
+ } // if ($table_cur->player_n == PLAYERS_N) {
+ } // for ($table_idx = 0 ; $table_idx < TABLES_N ; $table_idx++) {
+
+ log_rd2("out new loop.");
+
+ for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
+ $user_cur = $this->user[$i];
+
+ log_rd2("User: ".$user_cur->name." stat: ".$user_cur->stat." subst: ".$user_cur->subst);
+
+ if ($user_cur->is_active() == FALSE)
+ continue;
+
+ if ($user_cur->lacc + (($user_cur->ping_req ? 1.5 : 1.0) * EXPIRE_TIME_RD) < ($curtime - $delta)) {
+ // 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.");
+ if ($user_cur->stat == 'table' || $user_cur->stat == 'room') {
+ log_auth($user_cur->sess, "Autologout session.");
+
+ if ($user_cur->subst == 'sitdown' || $user_cur->stat == 'table')
+ $this->room_wakeup($user_cur);
+ else if ($user_cur->subst == 'standup')
+ $this->room_outstandup($user_cur);
+ else
+ log_rd2("LOGOUT FROM WHAT ???");
+ }
+ }
+
+ if ($user_cur->laccwr + EXPIRE_TIME_SMAMMA < ($curtime - $delta)) { // lo rimettiamo in piedi
+ if ($user_cur->stat == 'room' && $user_cur->subst == 'sitdown') {
+ $this->room_wakeup($user_cur);
+ $user_cur->comm[$user_cur->step % COMM_N] = "gst.st = ".($user_cur->step+1)."; ";
+ /* MLANG: <br>Sei stato inattivo per ".(EXPIRE_TIME_SMAMMA/60.0)." minuti. <br><br>Quindi ritorni tra i <b>Giocatori in piedi</b>.", "torna ai tavoli" */
+ $user_cur->comm[$user_cur->step % COMM_N] .= show_notify($mlang_brisk['tabtout_a'][$G_lang].(EXPIRE_TIME_SMAMMA/60.0).$mlang_brisk['tabtout_b'][$G_lang], 0, $mlang_brisk['btn_backstand'][$G_lang], 400, 100);
+ $user_cur->step_inc();
+ }
+ }
+ }
+ log_rd2("GARBAGE UPDATED!");
+
+ $this->garbage_timeout = $curtime + GARBAGE_TIMEOUT;
+ $ismod = TRUE;
+
+ $this->ghost_sess->garbage_manager($curtime);
+
+ $this->delay_mgr->lastcheck_set($curtime);
+ return ($ismod);
+ }
+
+ function show_room($user_step, $user)
+ {
+ GLOBAL $G_lang, $mlang_brisk;
+ log_main("show_room: username: ".$user->name);
+
+ $ret = sprintf('gst.st = %d; ', $user_step);
+
+ $prefs = Client_prefs::from_user($user);
+ $ret .= sprintf('prefs_load(\'%s\', false, false);', json_encode($prefs));
+
+ if(false) {
+ if ($user->flags & USER_FLAG_ISOLAUTH) {
+ $ret .= 'list_set(\'isolation\', false, \''.$mlang_brisk['tit_onisol'][$G_lang].'\' ); ';
+ }
+ else {
+ $ret .= 'list_set(\'all\', false, \'\' ); ';
+ }
+ }
+
+ if ($user->subst == 'standup')
+ $ret .= "tra.show(); ";
+ else
+ $ret .= "tra.hide(); ";
+
+ $ret .= sprintf('stat = "%s";', $user->stat);
+
+ $ret .= root_welcome($user);
+ if ($user->flags & USER_FLAG_DBFAILED) {
+ $ret .= "gst.st = ".($user->step+1)."; ";
+ $ret .= show_notify($mlang_brisk['db_failed'][$G_lang], 0, $mlang_brisk['btn_close'][$G_lang], 400, 140);
+ }
+
+ $ret .= sprintf('subst = "%s";', $user->subst);
+ $ret .= $user->myname_innerHTML();
+
+ for ($i = 0 ; $i < TABLES_N ; $i++) {
+
+ $ret .= $this->table_content($user, $i);
+
+ $ret .= $this->table[$i]->act_content($user);
+ if ($this->table[$i]->wag_own != -1)
+ $ret .= sprintf('tra.add(%d, "%s: %s"); ', $i, $this->user[$this->table[$i]->wag_own]->name, $this->table[$i]->wag_com);
+ else
+ $ret .= sprintf('tra.rem(%d); ', $i);
+ }
+ $ret .= $this->standup_content($user);
+ $ret .= "setTimeout(preload_images, 0, g_preload_img_arr, g_imgct); ";
+
+ return ($ret);
+ }
+
+ function room_wakeup($user)
+ {
+ $table_idx = $user->table;
+ $table = $this->table[$table_idx];
+
+ log_main("WAKEUP: begin function table:".$table_idx." stat: ".$user->stat." subst: ".$user->subst);
+
+ $curtime = time();
+
+ $from_table = ($user->stat == "table");
+ if ($from_table) {
+ log_main("WAKEUP: from table [".$user->table."] nplayers_n: ".$this->table[$user->table]->player_n);
+
+ for ($i = 0 ; $i < $table->player_n ; $i++) {
+ $user_cur = $this->user[$table->player[$i]];
+ log_main("PREIMPOST: INLOOP name: ".$user_cur->name);
+
+ if ($user->idx_get() != $table->player[$i]) {
+ $user_cur->stat_set("room");
+ $user_cur->subst = "sitdown";
+ $user_cur->laccwr = $curtime;
+ }
+ else if ($user->is_active()) {
+ $user_cur->stat_set("room");
+ $user_cur->subst = "standup";
+ $user_cur->laccwr = $curtime;
+ $user_cur->table = -1;
+ }
+ }
+ }
+ else {
+ $user->stat_set("room");
+ $user->subst = "standup";
+ $user->laccwr = $curtime;
+ }
+
+ $remove_wagon = FALSE;
+ if($table->wag_own == $user->idx_get()) {
+ $table->wag_reset($curtime);
+ $remove_wagon = TRUE;
+ }
+
+ /* aggiorna l'array dei giocatori al tavolo. */
+ $table->user_rem($this, $user);
+
+ for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
+ $user_cur = $this->user[$i];
+ if ($user_cur->is_active() == FALSE || $user_cur->stat != 'room') // is not active user or the stat isn't 'room'
+ continue;
+
+ // log_main("VALORI: name: ".$user_cur->name."from_table: ".$from_table." tab: ".$user_cur->table." taix: ".$table_idx." ucur: ".$user_cur." us: ".$user);
+
+ $ret = "gst.st = ".($user_cur->step+1)."; ".($remove_wagon ? sprintf("tra.rem(%d);",$table_idx) : "");
+ if ($from_table && ($user_cur->table == $table_idx || $user->idx_get() == $i)) {
+ $ret .= 'gst.st_loc++; xstm.stop(); window.onunload = null; window.onbeforeunload = null; document.location.assign("index.php");|';
+ // $ret .= 'gst.st_loc++; document.location.assign("index.php");|';
+ log_main("DOCUMENT.index.php: from table");
+ }
+ else if ($user_cur->stat == "room") {
+ log_main("DOCUMENT.index.php: from table");
+
+ $ret .= $this->table_content($user_cur, $table_idx);
+ $ret .= $this->standup_content($user_cur);
+
+ // $ret .= table_act_content(FALSE, 0, $table_idx, $user->table, FALSE);
+ $ret .= $table->act_content($user);
+
+ if ($user->idx_get() == $i) {
+ // set the new status
+ $ret .= 'subst = "standup"; tra.show(); ';
+ // clean the action buttons in other tables
+ for ($e = 0 ; $e < TABLES_N ; $e++) {
+ if ($this->table[$e]->player_n < PLAYERS_N) {
+ $ret .= $this->table[$e]->act_content($user);
+ }
+ }
+ }
+ else {
+ $ret .= $table->act_content($user_cur);
+ }
+ }
+ log_wr("ROOM_WAKEUP: ".$ret);
+ $user_cur->comm[$user_cur->step % COMM_N] = $ret;
+ $user_cur->step_inc();