-
- // Take parameters
- $table_idx = $argz[1];
- $table = &$bri->table[$table_idx];
-
- if ($table->player_n == PLAYERS_N) {
- log_wr($sess, "Warning ! unreachable, table full.");
- unlock_data($sem);
- exit;
- }
-
- // set new status
- $user->subst = "sitdown";
- $user->table = $table_idx;
- $user->table_pos = $table->player_n;
- $table->player[$table->player_n] = $idx;
- $table->player_n++;
-
- if ($table->player_n == PLAYERS_N) {
- // Start game for this table.
- log_wr($sess, "Start game!");
-
- $table->init();
- $table->game_init(&$bri);
-
- for ($i = 0 ; $i < $table->player_n ; $i++) {
- $user_cur = &$bri->user[$table->player[$i]];
- log_wr($sess, "Pre if!");
-
- $ret = "";
- $ret .= sprintf('gst.st_loc++; gst.st=%d; the_end=true; window.onunload = null ; document.location.assign("table.php");|', $user_cur->step+1);
-
- $user_cur->comm[$user_cur->step % COMM_N] = $ret;
- $user_cur->trans_step = $user_cur->step + 1;
- log_wr($sess, "TRANS ATTIVATO");
-
- $user_cur->stat = 'table';
- $user_cur->subst = 'asta';
- $user_cur->step++;
-
- $user_cur->comm[$user_cur->step % COMM_N] = show_table(&$bri,&$user_cur,$user_cur->step+1,TRUE, FALSE);
- $user_cur->step++;
- }
+
+ /*
+ * MAIN
+ */
+ $is_spawn = FALSE;
+
+ log_wr(0, 'index_wr.php: COMM: '.xcapemesg($mesg));
+ log_wr('COMM: '.xcapemesg($mesg));
+
+ $curtime = time();
+ $dt = date("H:i ", $curtime);
+
+ if (($user = $brisk->get_user($sess, &$idx)) == FALSE) {
+ $argz = explode('|', xcapemesg($mesg));
+
+ if ($argz[0] == 'getchallenge') {
+ if (isset($get['cli_name']))
+ $cli_name = $get['cli_name'];
+ if (($a_sem = Challenges::lock_data(TRUE)) != FALSE) {
+ log_main("chal lock data success");
+
+ if (($chals = &Challenges::load_data()) != FALSE) {
+
+ $token = uniqid("");
+ // echo '2|'.$argz[1].'|'.$token.'|'.$remote_addr.'|'.$curtime.'|';
+ // exit;
+
+ if (($login_new = validate_name(urldecode($cli_name))) != FALSE) {
+ if ($chals->add($login_new, $token, $remote_addr, $curtime) != FALSE) {
+ log_send("SUCCESS: token:".$token);
+ echo '0|'.$token;
+ }
+ else {
+ log_send("getchallenge FAILED");
+ echo '1|';
+ }
+ }
+ else {
+ log_send("getchallenge FAILED");
+ echo '1|';
+ }
+ if ($chals->ismod()) {
+ Challenges::save_data(&$chals);
+ }
+ }
+
+
+ Challenges::unlock_data($a_sem);
+ }
+ else {
+ echo "CHALLENGE LOCK FAILED\n";
+ return FALSE;
+ }
+ }
+ else if ($argz[0] == 'auth') {
+ printf("challenge|ok");
+ }
+ else if ($argz[0] == 'help') {
+ /* MLANG: "torna ai tavoli" */
+ echo show_notify(str_replace("\n", " ", $G_room_help[$G_lang]), 0, $mlang_indwr['btn_close'][$G_lang], 600, 500);
+ }
+ else if ($argz[0] == 'about') {
+ echo show_notify(str_replace("\n", " ", $G_room_about[$G_lang]), 0, $mlang_indwr['btn_close'][$G_lang], 400, 230);
+ }
+ else if ($argz[0] == 'passwdhowto') {
+ echo show_notify(str_replace("\n", " ", $G_room_passwdhowto[$G_lang]), 0, $mlang_indwr['btn_close'][$G_lang], 400, 200);
+ }
+ else if ($argz[0] == 'roadmap') {
+ echo show_notify(str_replace("\n", " ", $G_room_roadmap[$G_lang]), 0, $mlang_indwr['btn_close'][$G_lang], 400, 200);
+ }
+ else if ($argz[0] == 'placing') {
+ require_once("briskin5/Obj/briskin5.phh");
+ require_once("briskin5/Obj/placing.phh");
+
+ echo show_notify(str_replace("\n", " ", placings_show(FALSE)), 0, $mlang_indwr['btn_close'][$G_lang], 800, 600);
+ }
+ else if ($argz[0] == 'apprentice') {
+ if (($cli_name = gpcs_var('cli_name', $get, $post, $cookie)) === FALSE)
+ $cli_name = "";
+
+ if (($cli_email = gpcs_var('cli_email', $get, $post, $cookie)) === FALSE)
+ $cli_email = "";
+
+ $mesg_to_user = "";
+
+ // check existence of username or email
+ $is_trans = FALSE;
+ do {
+ error_log($cli_name);
+ if (login_consistency($cli_name) == FALSE) {
+ $mesg_to_user = "Il nickname non è conforme alle regole per la sua costruzione.";
+ break;
+ }
+
+ if (($bdb = BriskDB::create()) == FALSE) {
+ $mesg_to_user = "Connessione al database fallita";
+ break;
+ }
+
+ // check IP address as previous requirer
+ if ($bdb->selfreg_check($remote_ip) == FALSE) {
+ $mesg_to_user = $mlang_indwr['nu_netguard'][$G_lang];
+ break;
+ }
+
+ $cli_name = urldecode($cli_name);
+ $cli_email = urldecode($cli_email);
+
+ // check for already used fields
+ if (($idret = $bdb->check_record_by_login_or_email($cli_name, $cli_email)) != 0) {
+ $mesg_to_user = ($idret == 1 ? $mlang_indwr['nu_loginau'][$G_lang] :
+ ($idret == 2 ? $mlang_indwr['nu_emailau'][$G_lang] :
+ $mlang_indwr['unknownerr'][$G_lang]));
+ break;
+ }
+
+ $bdb->transaction('BEGIN');
+ $is_trans = TRUE;
+ // insert the new user disabled with reason NU_MAILED
+ // FIXME: move 'no-guaran' user into configuration file
+ if (($usr_obj = $bdb->user_add($cli_name, 'THE_PASS', $cli_email,
+ USER_FLAG_TY_DISABLE | USER_FLAG_TY_APPR,
+ USER_DIS_REA_NU_MAILED, $G_notguar_code)) == FALSE) {
+ fprintf(STDERR, "ERROR: user_add FAILED\n");
+ $mesg_to_user = "Fallito inserimento nel database.";
+ break;
+ }
+
+ if (($mail_code = $bdb->mail_reserve_code()) == FALSE) {
+ fprintf(STDERR, "ERROR: mail reserve code FAILED\n");
+ $mesg_to_user = "Fallita creazione codice email.";
+ break;
+ }
+ $hash = md5($curtime . $G_alarm_passwd . $cli_name . $cli_email);
+
+ $confirm_page = sprintf("http://%s/%s/mailmgr.php?f_act=checkmail&f_code=%d&f_hash=%s",
+ $G_domain, $G_webbase, $mail_code, $hash);
+ $subj = $mlang_indwr['nu_msubj'][$G_lang];
+ $body_txt = sprintf($mlang_indwr['ap_mtext'][$G_lang],
+ $cli_name, $confirm_page);
+ $body_htm = sprintf($mlang_indwr['ap_mhtml'][$G_lang],
+ $cli_name, $confirm_page);
+
+ $mail_item = new MailDBItem($mail_code, $usr_obj->code, MAIL_TYP_CHECK,
+ $curtime, $subj, $body_txt, $body_htm, $hash);
+
+ // save the mail
+ if ($mail_item->store($bdb) == FALSE) {
+ // store mail error
+ fprintf(STDERR, "ERROR: store mail FAILED\n");
+ $mesg_to_user = "Fallita procedura di store.";
+ break;
+ }
+
+ // check IP address as previous requirer
+ if ($bdb->selfreg_set($remote_ip) == FALSE) {
+ $mesg_to_user = $mlang_indwr['nu_unkerr'][$G_lang];
+ break;
+ }
+
+ if (brisk_mail($cli_email, $subj, $body_txt, $body_htm) == FALSE) {
+ // mail error
+ fprintf(STDERR, "ERROR: mail send FAILED\n");
+ $mesg_to_user = "Fallito invio email.";
+ break;
+ }
+
+ $bdb->transaction('COMMIT');
+ fprintf(STDERR, "REMOTE: %d\n", $remote_ip);
+ echo "1";
+ return TRUE;
+ } while(FALSE);
+ if ($is_trans)
+ $bdb->transaction('ROLLBACK');
+ echo "$mesg_to_user";
+ return FALSE;
+ }
+ else {
+ log_wr("Get User Error");
+ echo "Get User Error:" + $argz[0];
+ return FALSE;
+ }
+ return TRUE;
+ } // end if (($user = $brisk->get_user($sess, ... == FALSE) {
+
+ $brisk->sess_cur_set($user->sess);
+ $argz = explode('|', xcapemesg($mesg));
+
+ log_wr('POSTSPLIT: '.$argz[0]);
+
+ // LACC UPDATED
+ $user->lacc = $curtime;
+ if ($user->cl_step < $cl_step) {
+ log_step(sprintf("%s|%s|%d|%d|%d|%d", $user->sess, $user->name, $user->step, $user->cl_step, $cl_step, $user->step - $user->cl_step));
+ $user->cl_step = $cl_step;