+
+ /******************
+ * *
+ * STAT: room *
+ * *
+ ******************/
+ else if ($user->stat == 'room') {
+ $user->laccwr = time();
+
+ if ($argz[0] == 'help') {
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+ $user->comm[$user->step % COMM_N] .= show_notify(str_replace("\n", " ", $G_room_help[$G_lang]), 0, $mlang_indwr['btn_backtotab'][$G_lang], 600, 500);
+
+ log_wr($user->comm[$user->step % COMM_N]);
+ $user->step_inc();
+
+ }
+ else if ($argz[0] == 'passwdhowto') {
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+ $user->comm[$user->step % COMM_N] .= show_notify(str_replace("\n", " ", $G_room_passwdhowto[$G_lang]), 0, $mlang_indwr['btn_backtotab'][$G_lang], 600, 500);
+
+ log_wr($user->comm[$user->step % COMM_N]);
+ $user->step_inc();
+
+ }
+ else if ($argz[0] == 'splash') {
+ GLOBAL $G_with_splash, $G_splash_content, $G_splash_interval, $G_splash_idx;
+ GLOBAL $G_splash_w, $G_splash_h, $G_splash_timeout;
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+
+ $user->comm[$user->step % COMM_N] .= show_notify_ex(str_replace("\n", " ", $G_splash_content[$G_lang]), 0, $mlang_indwr['btn_backtotab'][$G_lang], $G_splash_w, $G_splash_h, true, 0);
+
+ log_wr($user->comm[$user->step % COMM_N]);
+ $user->step_inc();
+ }
+ else if ($argz[0] == 'about') {
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+ $user->comm[$user->step % COMM_N] .= show_notify(str_replace("\n", " ", $G_room_about[$G_lang]), 0, $mlang_indwr['btn_backtotab'][$G_lang], 400, 200);
+
+ log_wr($user->comm[$user->step % COMM_N]);
+ $user->step_inc();
+
+ }
+ else if ($argz[0] == 'placing') {
+ require_once("briskin5/Obj/briskin5.phh");
+ require_once("briskin5/Obj/placing.phh");
+
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+ $user->comm[$user->step % COMM_N] .= show_notify_ex(str_replace("\n", " ", placings_show($user)), 0, $mlang_indwr['btn_backtotab'][$G_lang], 800, 600, TRUE, 0);
+
+ log_wr($user->comm[$user->step % COMM_N]);
+ $user->step_inc();
+ }
+ else if ($argz[0] == 'roadmap') {
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+ $user->comm[$user->step % COMM_N] .= show_notify(str_replace("\n", " ", $G_room_roadmap[$G_lang]), 0, $mlang_indwr['btn_backtotab'][$G_lang], 400, 200);
+
+ log_wr($user->comm[$user->step % COMM_N]);
+ $user->step_inc();
+
+ }
+ else if ($argz[0] == 'whysupport') {
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+ $user->comm[$user->step % COMM_N] .= show_notify(str_replace("\n", " ", $G_room_whysupport[$G_lang]), 0, $mlang_indwr['btn_backtotab'][$G_lang], 400, 200);
+
+ log_wr($user->comm[$user->step % COMM_N]);
+ $user->step_inc();
+
+ }
+ else if ($argz[0] == 'chatt') {
+ $brisk->chatt_send(&$user, xcapemesg($mesg));
+ }
+ else if ($argz[0] == 'tosmgr') {
+ // check IF is authnticated user, both terms of service versions matches
+ if ($user->is_auth() && count($argz) == 5) {
+ $f_type = $argz[1]; $f_code = $argz[2];
+ $f_tos_curr = $argz[3]; $f_tos_vers = $argz[4];
+
+ if ("$f_tos_curr" == $user->rec->tos_vers_get() &&
+ "$f_tos_vers" == "$G_tos_vers") {
+ if ("$f_type" == "soft" || "$f_type" == "hard") {
+ $res = 100;
+ switch ($f_code) {
+ case LICMGR_CHO_ACCEPT:
+ $user->rec->tos_vers_set($G_tos_vers);
+ $res = $user->tos_store();
+ break;
+ case LICMGR_CHO_REFUSE:
+ $user->flags_set(USER_FLAG_TY_DISABLE, USER_FLAG_TY_ALL);
+ $user->rec->disa_reas_set(USER_DIS_REA_LICENCE);
+ $res = $user->state_store();
+
+ $user->comm[$user->step % COMM_N] = $user->blocking_error(TRUE);
+ $user->the_end = TRUE;
+ $user->step_inc();
+ break;
+ }
+ }
+ }
+ }
+ }
+ /**********************
+ * *
+ * SUBST: standup *
+ * *
+ **********************/
+ else if ($user->subst == 'standup') {
+ if ($argz[0] == 'sitdown') {
+ log_wr("SITDOWN command");
+
+ if ($user->the_end == TRUE) {
+ log_wr("INFO:SKIP:argz == sitdown && ->the_end == TRUE => ignore request.");
+ return FALSE;
+ }
+
+ // Take parameters
+ $table_idx = (int)$argz[1];
+ $table = &$brisk->table[$table_idx];
+
+ $not_allowed_msg = "";
+ if ($G_shutdown) {
+ $not_allowed_msg = nickserv_msg($dt, $mlang_indwr['shutmsg'][$G_lang]);
+ }
+ else if ($table->wakeup_time > $curtime) {
+ $not_allowed_msg = nickserv_msg($dt, sprintf($mlang_indwr['tabwait'][$G_lang],
+ $table->wakeup_time - $curtime));
+ }
+ else if ( $table->auth_type == TABLE_AUTH_TY_CERT &&
+ (!$user->is_cert() || $user->is_appr()) ) {
+ $not_allowed_msg = nickserv_msg($dt, $mlang_indwr['mustcert'][$G_lang]);
+ }
+ else if ( $table->auth_type == TABLE_AUTH_TY_AUTH &&
+ (!$user->is_auth() || $user->is_appr()) ) {
+ $not_allowed_msg = nickserv_msg($dt, $mlang_indwr['mustauth'][$G_lang]);
+ }
+ else if ( $table->auth_type == TABLE_AUTH_TY_APPR &&
+ (!$user->is_auth()) ) {
+ $not_allowed_msg = nickserv_msg($dt, $mlang_indwr['mustappr'][$G_lang]);
+ }
+ else if ($user->flags & USER_FLAG_TY_FIRONLY && $table->player_n > 0) {
+ $not_allowed_msg = nickserv_msg($dt, $mlang_indwr['mustfirst'][$G_lang]);
+ }
+ if ($not_allowed_msg != "") {
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ".$not_allowed_msg;
+ $user->step_inc();
+ return TRUE;
+ }
+
+ /* TODO: refact to a function */
+ // if ($user->bantime > $user->laccwr) {
+ require_once("Obj/hardban.phh");
+
+ if (($bantime = Hardbans::check(($user->is_auth() ? $user->name : FALSE),
+ $user->ip, $user->sess)) != -1) {
+ $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($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);
+ }
+ $user->step_inc();
+ return TRUE;
+ }
+
+ if ($table->player_n == PLAYERS_N) {
+ log_wr("WARN:FSM: Sitdown unreachable, table full.");
+ return FALSE;
+ }
+
+ // set new status
+ $user->subst = "sitdown";
+ $user->table = $table_idx;
+ $user->table_pos = $table->user_add($idx);
+
+ log_wr("MOP before");
+
+ if ($table->player_n == PLAYERS_N) {
+ require_once("briskin5/Obj/briskin5.phh");
+ log_wr("MOP inall");
+
+ // Start game for this table.
+ log_wr("Start game!");
+
+ //
+ // START THE SPAWN HERE!!!!
+ //
+
+ // Create new spawned table
+ // $bin5_sem = Bin5::lock_data(TRUE, $table_idx);
+ $table_token = uniqid("");
+ $brisk->table[$table_idx]->table_token = $table_token;
+ $brisk->table[$table_idx]->table_start = $curtime;
+
+ $plist = "$table_token|$user->table|$table->player_n";
+ for ($i = 0 ; $i < $table->player_n ; $i++) {
+ $plist .= '|'.$brisk->user[$table->player[$i]]->sess;
+ }
+ log_legal($curtime, $user->ip, $user, "STAT:CREATE_GAME", $plist);
+
+ log_wr("pre new Bin5");
+ if (($bin5 = new Bin5($brisk, $table_idx, $table_token, $get, $post, $cookie)) == FALSE)
+ log_wr("bri create: FALSE");
+ else
+ log_wr("bri create: ".serialize($bin5));
+
+ log_wr("pre init table");
+ // init table
+ $bin5_table = $bin5->table[0];
+ $bin5_table->init($bin5->user);
+ $bin5_table->game_init($bin5->user);
+ //
+ // Init spawned users.
+ //
+ // MULTIGAME: here init of selected game instead of hardcabled briskin5 init (look subst status)
+ //
+ log_wr("game_init after");
+ for ($i = 0 ; $i < $table->player_n ; $i++) {
+ $bin5_user_cur = $bin5->user[$i];
+ $user_cur = $brisk->user[$table->player[$i]];
+
+ $bin5_user_cur->laccwr = $curtime;
+ $bin5_user_cur->trans_step = $user_cur->step + 1;
+ $bin5_user_cur->comm[$bin5_user_cur->step % COMM_N] = "";
+ $bin5_user_cur->step_inc();
+ $bin5_user_cur->comm[$bin5_user_cur->step % COMM_N] = show_table(&$bin5,&$bin5_user_cur,$bin5_user_cur->step+1,TRUE,FALSE);
+ $bin5_user_cur->step_inc();
+
+ log_wr("TRY PRESAVE: ".$bin5_user_cur->step." TRANS STEP: ".$bin5_user_cur->trans_step);
+
+ log_wr("Pre if!");
+
+ // ARRAY_POP DISABLED
+ // // CHECK
+ while (array_pop($user_cur->comm) != NULL);
+
+ $user_cur->trans_step = $user_cur->step + 1;
+ $user_cur->comm[$user_cur->step % COMM_N] = sprintf('gst.st_loc++; gst.st=%d; createCookie("table_idx", %d, 24*365, cookiepath); createCookie("table_token", "%s", 24*365, cookiepath); createCookie("lang", "%s", 24*365, cookiepath); xstm.stop(); window.onunload = null ; window.onbeforeunload = null ; document.location.assign("briskin5/index.php");|', $user_cur->step+1, $table_idx, $table_token, $G_lang);
+ log_wr("TRANS ATTIVATO");
+
+ $user_cur->stat_set('table');
+ $user_cur->subst = 'asta';
+ $user_cur->laccwr = $curtime;
+ $user_cur->step_inc();
+ }
+ log_wr("presave bri");
+ $brisk->match_add($table_idx, $bin5);
+ log_wr("postsave bri");
+ }
+ // change room
+ $brisk->room_sitdown($user, $table_idx);
+
+ log_wr("MOP finish");
+ }
+ else if ($argz[0] == 'logout') {
+ $brisk->ghost_sess->push($curtime, $user->sess, GHOST_SESS_REAS_LOUT);
+ $user->the_end = TRUE;
+
+ if ($user->subst == 'sitdown') {
+ log_load("ROOM WAKEUP");
+ $brisk->room_wakeup($user);
+ }
+ else if ($user->subst == 'standup')
+ $brisk->room_outstandup($user);
+ else
+ log_rd2("LOGOUT FROM WHAT ???");
+ }
+ }
+ /**********************
+ * *
+ * SUBST: sitdown *
+ * *
+ **********************/
+ else if ($user->subst == 'sitdown') {
+ if ($user->the_end == TRUE) {
+ log_wr("INFO:SKIP:argz == sitdown && ->the_end == TRUE => ignore request.");
+ return FALSE;
+ }
+
+ if ($argz[0] == 'wakeup') {
+ $brisk->room_wakeup($user);
+ }
+ else if ($argz[0] == 'logout') {
+ $brisk->ghost_sess->push($curtime, $user->sess, GHOST_SESS_REAS_LOUT);
+ $user->the_end = TRUE;
+
+ $brisk->room_wakeup($user);
+ }
+ }