+
+
+ /* this part I suppose is read only on $room structure */
+ if ($cur_step == -1) {
+ log_rd2("PRE-NEWSTAT: ".$user->stat);
+
+ if ($user->stat == 'room') {
+ log_rd("roomma ".$user->step);
+ $curtime = time();
+
+ if ($G_with_splash &&
+ ($$CO_splashdate < $curtime - $G_splash_interval ||
+ $$CO_splashdate > $curtime)) {
+ $is_super = $user->flags & USER_FLAG_TY_SUPER;
+ $ret .= show_notify_ex(str_replace("\n", " ", $G_splash_content[$G_lang]),
+ ($is_super ? 0 : $G_splash_timeout),
+ $mlang_indrd[($is_super ? 'btn_btotabsup' : 'btn_backtotab')][$G_lang],
+ $G_splash_w, $G_splash_h, true,
+ ($is_super ? 0 : $G_splash_timeout));
+ $ret .= sprintf('|createCookie("CO_splashdate%d", %d, 24*365, cookiepath);', $G_splash_idx, $curtime);
+ }
+ $ret .= $room->show_room($user->step, $user);
+
+ // TODO uncomment and test
+ /* NOTE the sets went common */
+ $new_stat = $user->stat;
+ $new_subst = $user->subst;
+ $new_step = $user->step;
+ }
+ /***************
+ * *
+ * TABLE *
+ * *
+ ***************/
+ else if ($user->stat == 'table') {
+ log_load("RESYNC");
+ return (page_sync($user->sess, "briskin5/index.php", $user->table, $user->table_token));
+ }
+ log_rd2("NEWSTAT: ".$user->stat);
+ } /* if ($cur_step == -1) { */
+ else {
+ ignore_user_abort(TRUE);
+ $sem = Room::lock_data(FALSE);
+ $S_load_stat['rU_heavy']++;
+ if (($user = User::load_data($proxy_step['i'], $sess)) == FALSE) {
+ Room::unlock_data($sem);
+ ignore_user_abort(FALSE);
+ return (blocking_error(TRUE));
+ }
+
+ if ($cur_step < $user->step) {
+ do {
+ if ($cur_step + COMM_N < $user->step) {
+ if (($cur_stat != $user->stat)) {
+ $to_stat = $user->stat;
+ Room::unlock_data($sem);
+ ignore_user_abort(FALSE);
+ log_load("RESYNC");
+ return (page_sync($user->sess, ($to_stat == "table" ? "briskin5/index.php" : "index.php"), $user->table, $user->table_token));
+ }
+ log_rd2("lost history, refresh from scratch");
+ $new_step = -1;
+ break;
+ }
+ for ($i = $cur_step ; $i < $user->step ; $i++) {
+ $ii = $i % COMM_N;
+ log_rd2("ADDED TO THE STREAM: ".$user->comm[$ii]);
+ $ret .= $user->comm[$ii];
+ }
+ $new_stat = $user->stat;
+ $new_subst = $user->subst;
+ $new_step = $user->step;
+ } while (0);
+
+ log_rd2($user->step, 'index_rd.php: after ret set');
+
+ if ($user->the_end == TRUE) {
+ Room::unlock_data($sem);
+
+ /* Switch to exclusive locking */
+ $sem = Room::lock_data(TRUE);
+
+ unset($user);
+
+ $S_load_stat['wR_the_end']++;
+ if (($room = Room::load_data()) == FALSE) {
+ Room::unlock_data($sem);
+ ignore_user_abort(FALSE);
+ return (blocking_error(TRUE));
+ }
+
+ if (($user = $room->get_user($sess, $idx)) == FALSE) {
+ Room::unlock_data($sem);
+ ignore_user_abort(FALSE);
+ return (blocking_error(TRUE));
+ }
+
+ log_rd2("LOGOUT BYE BYE!!");
+ log_auth($user->sess, "Explicit logout.");
+
+ if ($user->the_end == TRUE) {
+ $user->reset();
+
+ if ($user->subst == 'sitdown') {
+ log_load("ROOM WAKEUP");
+ $room->room_wakeup($user);
+ }
+ else if ($user->subst == 'standup')
+ $room->room_outstandup($user);
+ else
+ log_rd2("LOGOUT FROM WHAT ???");
+
+ Room::save_data($room);
+ } /* if ($user->the_end == TRUE) { ... */
+ } /* if ($user->the_end == TRUE) { ... */
+ } /* if ($cur_step < $user->step) { */
+
+ Room::unlock_data($sem);
+ ignore_user_abort(FALSE);
+ } /* else of if ($cur_step == -1) { */
+
+
+ return ($ret);