+ // Compute actions
+ //
+
+ $to_user = FALSE;
+ $to_all = FALSE;
+ $to_room = FALSE;
+ $to_tabl = FALSE;
+ $is_normchat = FALSE;
+ /* for old isolation management $is_ticker = FALSE; */
+ $update_room = FALSE;
+
+ if (strcmp($msg, "/tav") == 0 ||
+ strncmp($msg, "/tav ", 5) == 0) {
+ do {
+ if ($user->stat != 'room' || $user->subst != 'sitdown') {
+ /* MLANG: "<br>Per attivare il messaggio di segnalazione del tavolo occorre essere seduti.<br><br>", "<br>Il messaggio di segnalazione del tavolo è già attivato.<br><br>", "<br>Il messaggio di segnalazione del tavolo<br>è disattivato ancora per %d second%s.<br><br>" */
+ $msg = $mlang_brisk['tickmust'][$G_lang];
+ $to_user = show_notify($msg, 0, "chiudi", 400, 100);
+
+ break;
+ }
+
+ $table = $this->table[$user->table];
+
+ if ($table->wag_own != -1) {
+ // MLANG <br>Il messaggio di segnalazione del tavolo è già attivato.<br><br>
+ $msg = $mlang_brisk['tickjust'][$G_lang];
+ $to_user = show_notify($msg, 0, "chiudi", 400, 100);
+
+ break;
+ }
+
+ $dtime = $curtime - $table->wag_tout;
+ if ($dtime < EXPIRE_TIME_WAG) {
+ // MLANG - <br>Il messaggio di segnalazione del tavolo<br>è disattivato ancora per %d second%s.<br><br>
+ $msg = sprintf($mlang_brisk['tickwait'][$G_lang],
+ EXPIRE_TIME_WAG - $dtime, (EXPIRE_TIME_WAG - $dtime == 1 ? ($G_lang == 'en' ? "" : "o") : ($G_lang == 'en' ? "s" : "i")));
+ $to_user = show_notify($msg, 0, $mlang_brisk['btn_close'][$G_lang] , 400, 100);
+
+ break;
+ }
+
+ $msg = substr($msg, 5);
+
+ $table->wag_set($user->idx_get(), $msg);
+ $to_user = sprintf('tra.add(%d, "%s");', $user->table, xcape(sprintf("%s: %s", $user->name, $msg)));
+ $to_room = $to_user;
+ /* for old isolation management $is_ticker = TRUE; */
+ } while (0);
+ } // /tav chat command
+ // just for development use currently
+ else if (FALSE && strncmp($msg, "/out ", 5) == 0) {
+ fprintf(STDERR, "MOP OUT\n");
+ $target = substr($msg, 5);
+ $this->kickuser_by_name($target, GHOST_SESS_REAS_ANON);
+ }
+ else if (strncmp($msg, "/alarm ", 7) == 0) {
+ if (strncmp($msg, "/alarm to ", 10) == 0) {
+ $sp_pos = strpos($msg, " ", 10);
+ $target = substr($msg, 10, $sp_pos - 10);
+ $alarm_check = "/alarm to ".$target." ".$G_alarm_passwd." ";
+ }
+ else {
+ $target = "";
+ $alarm_check = "/alarm ".$G_alarm_passwd." ";
+ }
+ do {
+ if (strncmp($msg, $alarm_check, strlen($alarm_check)) != 0) {
+ /* MLANG: "<br>La password digitata non è corretta.<br><br>" */
+ $msg = $mlang_brisk['alarpass'][$G_lang];
+ $to_user = show_notify($msg, 0, $mlang_brisk['btn_close'][$G_lang], 400, 100);
+
+ break;
+ }
+
+ /* MLANG: "Alarm <b>%s</b> inviato a <b>%s</b>." */
+ $prestr = sprintf($mlang_brisk['alarret'][$G_lang], xcape(substr($msg, strlen($alarm_check))),
+ ($target == "" ? $mlang_brisk['tit_all'][$G_lang] : xcape($target)) );
+ $to_user = nickserv_msg($dt, $prestr);
+
+ $msg = sprintf("<br><b>%s<br><br>%s</b><br><br>",
+ $dt.NICKSERV, xcape(substr($msg, strlen($alarm_check))));
+ /* MLANG: "chiudi" */
+ $to_all = show_notify($msg, 0, $mlang_brisk['btn_close'][$G_lang], 400, 120);
+ } while (0);
+ } // /alarm chat command
+ else if (FALSE && strncmp($msg, "/listen ", 8) == 0) {
+ $arg = substr($msg, 8);
+
+ if (strcasecmp($arg, "isolation") == 0) {
+ $flags_old = 0;
+ if ($user->stat == 'room' && $user->subst == 'sitdown' &&
+ $user->table >= TABLES_AUTH_N) {
+ $to_user = nickserv_msg($dt, $mlang_brisk['listmust'][$G_lang]);
+
+ }
+ else {
+ $user->flags &= ~USER_FLAG_MAP_AUTH;
+ $user->flags |= USER_FLAG_ISOLAUTH;
+ $to_user = 'list_set(\'isolation\', true, \''.$mlang_brisk['tit_onisol'][$G_lang].'\'); ';
+ }
+ }
+ else {
+ $flags_old = $user->flags;
+ $user->flags &= ~USER_FLAG_MAP_AUTH;
+ $to_user = 'list_set(\'all\', true, \'\'); ';
+
+ }
+ // if from isolation redraw standup area
+ if (($flags_old ^ $user->flags) & USER_FLAG_ISOLAUTH) {
+ $to_user .= 'standup_data_old = null; '.$this->standup_content($user);
+
+ }
+ }
+ else if (strcmp($msg, "/authreq") == 0) {
+ if ($user->is_cert()) {
+ $to_user = sprintf('authbox(300,200);');
+ }
+ else {
+ /* MLANG: "<b>Per autenticare qualcuno devi a tua volta essere autenticato.</b>", "Il nickname deve contenere almeno una lettera dell\'alfabeto o una cifra.", "Nickname <b>%s</b> già in uso." */
+ $to_user = nickserv_msg($dt, $mlang_brisk['authmust'][$G_lang]);
+ }
+ }
+ else if (strncmp($msg, "/mesgtoadm", 8) == 0) {
+ if ($user->is_auth()) {
+ $to_user = sprintf('mesgtoadmbox(500,300);');
+ }
+ else {
+ /* MLANG: "<b>Per inviare un messaggio devi essere autenticato.</b>" */
+ $to_user = nickserv_msg($dt, $mlang_brisk['mesgmust'][$G_lang]);
+ }
+ }
+ else if (FALSE && strncmp($msg, "/nick ", 6) == 0) {
+ log_main("chatt_send BEGIN");
+
+ do {
+ if (($name_new = validate_name(substr($msg, 6))) == FALSE) {
+ $to_user = nickserv_msg($dt, $mlang_brisk['nickmust'][$G_lang]);
+ break;
+ }
+
+ $msg = "COMMAND ".$msg;
+ for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
+ $user_cur = $this->user[$i];
+
+ if ($user_cur->is_active() == FALSE)
+ continue;
+ if (strcasecmp($user_cur->name,$name_new) == 0)
+ break;
+ }
+ if ($i < MAX_PLAYERS) {
+ $prestr = sprintf($mlang_brisk['nickdupl'][$G_lang], xcape($name_new));
+ $to_user = nickserv_msg($dt, $prestr);
+ break;
+ }
+
+ /* MLANG: "<b>Non puoi cambiare nick a un tavolo per soli autenticati.</b>", "Il nickname <b>\'%s\'</b> è già registrato, <b>se il suo proprietario si autentificherà verrai rinominato d\'ufficio come ghost<i>N</i>.</b>" */
+ if ($user->is_auth()) {
+ if (strcasecmp($user->name,$name_new) != 0) {
+ if (( ($user->flags & USER_FLAG_MAP_AUTH) != USER_FLAG_ISOLAUTH) &&
+ ($user->subst == 'standup' ||
+ ($user->subst != 'standup' && $this->table[$user->table]->auth_type == TABLE_AUTH_TY_PUBL)
+ )
+ ) {
+ $user->flags &= ~(USER_FLAG_AUTH | USER_FLAG_TY_ALL); // Remove auth if name changed
+ for ($i = 0 ; $i < TABLES_N ; $i++) {
+ $to_user .= $this->table[$i]->act_content($user);
+ }
+ }
+ else {
+ $to_user = nickserv_msg($dt, $mlang_brisk['authchan'][$G_lang]);
+ break;
+ }
+ }
+ }
+ $user->name = $name_new; // OK - nick changed
+ /* se nome gia' in uso, segnala cosa potrebbe capitare */
+ if ( ! $user->is_auth() ) {
+ if (($bdb = BriskDB::create()) != FALSE) {
+ $bdb->users_load();
+ /* MLANG: "Il nickname <b>\'%s\'</b> è già registrato, <b>se il suo proprietario si autentificherà verrai rinominato d\'ufficio come ghost<i>N</i>.</b>" */
+ if ($bdb->login_exists(strtolower($name_new))) {
+ $prestr = sprintf($mlang_brisk['nickjust'][$G_lang], xcape($name_new));
+ $to_user .= nickserv_msg($dt, $prestr);
+ }
+ }
+ }
+
+ log_main("chatt_send start set");
+
+ $update_room = TRUE;
+ } while (0);
+ } // nick chat command
+ else if (strncmp($msg, "/info ", 6) == 0) {
+ do {
+ if (! $user->is_auth()) {
+ if ($mlang_indwr) {
+ $to_user = nickserv_msg($dt, $mlang_indwr['info_auth'][$G_lang]);
+ }
+ else {
+ $to_user = nickserv_msg($dt, "error");
+ }
+ break;
+ }
+ $info_user = substr($msg, 6);
+
+ echo $this->info_show($user, urldecode($info_user), $dt);
+ } while(0);
+ }
+ else if (strncmp($msg, "/st ", 4) == 0) {
+ log_main("chatt_send BEGIN");
+
+ do {
+ $st_str = substr($msg, 4);
+
+ if (strcasecmp($st_str, "normale") == 0) {
+ $st = USER_FLAG_S_NORM;
+ }
+ else if (strcasecmp($st_str, "pausa") == 0) {
+ $st = USER_FLAG_S_PAU;
+ }
+ else if (strcasecmp($st_str, "fuori") == 0) {
+ $st = USER_FLAG_S_OUT;
+ }
+ else if (strcasecmp($st_str, "cane") == 0) {
+ $st = USER_FLAG_S_DOG;
+ }
+ else if (strcasecmp($st_str, "cibo") == 0) {
+ $st = USER_FLAG_S_EAT;
+ }
+ else if (strcasecmp($st_str, "lavoro") == 0) {
+ $st = USER_FLAG_S_WRK;
+ }
+ else if (strcasecmp($st_str, "sigaretta") == 0) {
+ $st = USER_FLAG_S_SMK;
+ }
+ else if (strcasecmp($st_str, "presente") == 0) {
+ $st = USER_FLAG_S_EYE;
+ }
+ else if (strcasecmp($st_str, "coniglio") == 0) {
+ $st = USER_FLAG_S_RABB;
+ }
+ else if (strcasecmp($st_str, "calcio") == 0) {
+ $st = USER_FLAG_S_SOCC;
+ }
+ else if (strcasecmp($st_str, "pupo") == 0) {
+ $st = USER_FLAG_S_BABY;
+ }
+ else if (strcasecmp($st_str, "pulizie") == 0) {
+ $st = USER_FLAG_S_MOP;
+ }
+ else if (strcasecmp($st_str, "babbo") == 0) {
+ $st = USER_FLAG_S_BABBO;
+ }
+ else if (strcasecmp($st_str, "renna") == 0) {
+ $st = USER_FLAG_S_RENNA;
+ }
+ else if (strcasecmp($st_str, "pupazzo") == 0) {
+ $st = USER_FLAG_S_PUPAZ;
+ }
+ else if (strcasecmp($st_str, "vischio") == 0) {
+ $st = USER_FLAG_S_VISCH;
+ }
+ else {
+ /* MLANG: "Questo stato non esiste." */
+ $to_user = nickserv_msg($dt, $mlang_brisk['statunkn'][$G_lang]);
+ break;
+ }
+
+ log_main("chatt_send start set");
+ if (($user->flags & USER_FLAG_S_ALL) != $st) {
+ $update_room = TRUE;
+ $user->flags = ($user->flags & ~USER_FLAG_S_ALL) | $st;
+ }
+ } while (0);
+ } // nick chat command
+
+ else { // normal chat line
+ $is_normchat = TRUE;
+ if (CHAT_ENABLED && $curtime < ($user->chat_ban + $user->chat_dlt)) {
+ $only_you = TRUE;
+ $user->chat_dlt = $user->chat_dlt * 2;
+ if ($user->chat_dlt > 120)
+ $user->chat_dlt = 120;
+ }
+ else if ($user->chat_lst == $msg)
+ $only_you = TRUE;
+ else if (CHAT_ENABLED && $curtime - $user->chattime[($user->chat_cur + 1) % CHAT_N] < CHAT_ILL_TIME) {
+ $user->chat_ban = $curtime;
+ $user->chat_dlt = 5;
+ $only_you = TRUE;
+ }
+ else {
+ $user->chat_ban = 0;
+ $user->chat_dlt = 0;
+ }
+
+ if ($only_you) {
+ $to_user = sprintf('chatt_sub("%s",[%d,"%s"],"%s");', $dt, $user->flags, xcape($user->name), xcape("== chat ban =="));
+ }
+ else {
+ // TEMPORARY DISABLED UNTIL test user option will be available
+ // if ( TRUE && (!$user->is_auth() || $user->is_appr()) ) {
+ if (!$user->is_auth()) {
+ $to_user = nickserv_msg($dt, xcape("Visto l'elevato numero di molestatori che ultimamente hanno preso dimora su Brisk abbiamo deciso"));
+ $to_user .= nickserv_msg($dt, xcape("di disattivare temporaneamente la chat in room per i non registrati, non ce ne vogliate e buone feste."));
+ if (FALSE) {
+ $aug_head = array("Tanti", "Tantissimi", "Un enormità", "Un milione", "Un' esagerazione");
+ $aug_body = array("a tutti gli utenti", "a tutti gli uomini", "a tutte le donne", "a tutti gli utenti");
+ $aug_tail = array("di Brisk", "del sito", "della ciurma", "della comitiva", "del gruppo");
+
+ $auguri = sprintf("%s auguri %s %s.",
+ $aug_head[mt_rand(0, count($aug_head)-1)],
+ $aug_body[mt_rand(0, count($aug_body)-1)],
+ $aug_tail[mt_rand(0, count($aug_tail)-1)]);
+
+ $to_room = sprintf('chatt_sub("%s",[%d,"%s"],"%s");', $dt, $user->flags, xcape($user->name),
+ xcape($auguri));
+ }
+ }
+ else {
+ $to_user = sprintf('chatt_sub("%s",[%d,"%s"],"%s");', $dt, $user->flags, xcape($user->name), xcape($msg));
+ // temporary silentiation for troll (will became array check)
+ // if (strcasecmp($user->name,'JackRokka') != 0 && $user->sess != '47ea653f602e8')
+ $to_room = $to_user;
+ }
+ }
+
+ log_legal($curtime, $user->ip, $user,
+ ($user->stat == 'room' ? 'room' : 'table '.$user->table),$msg);
+
+ $user->chat_lst = "$msg";
+ $user->chattime[$user->chat_cur % CHAT_N] = $curtime;
+ $user->chat_cur++;
+ }
+
+ if ($to_all) {
+ $to_room = $to_all;
+ $to_tabl = $to_all;
+ }
+
+ //
+ // Output to clients
+ //
+
+ if ($to_user != FALSE) {
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+ $user->comm[$user->step % COMM_N] .= $to_user;
+ $user->step_inc();
+ }
+
+ if ($to_room != FALSE) {
+ for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
+ $user_cur = $this->user[$i];
+ if ($target != "" && $user_cur->name != $target)
+ continue;
+ if ($user_cur->is_active() == FALSE // is not active user
+ || $user_cur->stat == 'table' // or stat is 'table'
+ || $user->idx_get() == $i) // or the $user idx is equal to current var
+ continue;
+
+ if ($is_normchat == TRUE) {
+ // use MAP_AUTH to check if auth or isolation
+ if ($user_cur->flags & USER_FLAG_MAP_AUTH) {
+ if ( ! $user->is_auth() ) {
+ continue;
+ }
+ }
+ }
+ /*
+ else if ($is_ticker) {
+ if (($user_cur->flags & USER_FLAG_MAP_AUTH) == USER_FLAG_ISOLAUTH) {
+ if ($user->table >= TABLES_AUTH_N)
+ continue;
+ }
+ }
+ */
+ $user_cur->comm[$user_cur->step % COMM_N] = "gst.st = ".($user_cur->step+1)."; ";
+ $user_cur->comm[$user_cur->step % COMM_N] .= $to_room;
+ $user_cur->step_inc();
+ }
+ }
+
+ if ($to_tabl) {
+ // FIXME BRISK4: include for each kind of table
+ require_once("${G_base}briskin5/Obj/briskin5.phh");
+ // Before all align times with table timeout
+ for ($table_idx = 0 ; $table_idx < TABLES_N ; $table_idx++) {
+ if (isset($this->match[$table_idx])) {
+ $bin5 = $this->match[$table_idx];
+
+ $bin5_table = $bin5->table[0];
+ for ($i = 0 ; $i < $bin5_table->player_n ; $i++) {
+ // stat must be "table" by definition
+ $bin5_user = $bin5->user[$i];
+
+ if ($target != "" && $bin5_user->name != $target)
+ continue;
+ log_main("writa: ".$user_mesg);
+ $bin5_user->comm[$bin5_user->step % COMM_N] = "gst.st = ".($bin5_user->step+1)."; ";
+ $bin5_user->comm[$bin5_user->step % COMM_N] .= $to_tabl;
+ $bin5_user->step_inc();
+ }
+ } // if (isset($this->match
+ } // for ($table_idx = 0 ; $table_idx < TABLES_N ; $table_idx++) {
+ } // if ($to_tabl == true ...
+
+ if ($update_room) {
+ if ($user->stat == 'room' && $user->subst == 'standup') {
+ $this->standup_update($user);
+ }
+ else if ($user->stat == 'room' && $user->subst == 'sitdown') {
+ log_main("chatt_send pre table update");
+ $this->table_update($user);
+ log_main("chatt_send post table update");
+ }
+ } // if ($update_room ...
+
+ return;
+ } // function chatt_send( ...
+
+ function get_user($sess, &$idx)
+ {
+ GLOBAL $PHP_SELF;
+
+ if (validate_sess($sess)) {
+ for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
+ if ($this->user[$i]->is_empty())
+ continue;
+ if (strcmp($sess, $this->user[$i]->sess) == 0) {
+ // find it
+ $idx = $i;
+ $ret = $this->user[$i];
+ return ($ret);
+ }
+ }
+ log_main(sprintf("get_user: Wrong sess from page [%s]",$PHP_SELF));
+ // for ($i = 0 ; $i < MAX_PLAYERS ; $i++)
+ // log_main(sprintf("get_user: Wrong sess compared with [%s]",$this->user[$i]->sess));
+ }
+ else {
+ log_main(sprintf("get_user: Wrong strlen [%s]",$sess));
+ }
+
+ return (FALSE);
+ }
+
+ /*
+ * function add_user(&$brisk, &$sess, &$idx, $name, $pass, $ip, $header, $cookie)
+ *
+ * RETURN VALUE:
+ * if ($idx > -1 && ret == FALSE) => duplicated nick
+ * if ($idx == -2 && ret == FALSE) => invalid name
+ * if ($idx == -3 && ret == FALSE) => wrong password
+ * if ($idx == -1 && ret == FALSE) => no space left
+ * if ($idx == 0 && ret == user) => SUCCESS
+ * if ($idx == -($idx + 1) && ret == user) => SUCCESS (but the login exists in the auth db)
+ */
+
+ function add_user(&$sess, &$idx, $name, $pass, $ip, $header, $cookie)
+ {
+ GLOBAL $G_base;
+
+ $idx = 0;
+
+ $authenticate = FALSE;
+ $user_type = 0;
+ $login_exists = FALSE;
+ $ghost = -1;
+ $ghost_auth = FALSE;
+ $idx = -1;
+ $idfree = -1;
+ $code = FALSE;
+
+ if (($name_new = validate_name($name)) == FALSE) {
+ $idx = -2;
+ return (FALSE);
+ }
+
+ log_auth("XXX", sprintf("ARRIVA: [%s] pass:[%s]", $sess, ($pass == FALSE ? "FALSE" : $pass)));
+ if (validate_sess($sess) == FALSE)
+ $sess = "";
+
+ /* if pass != FALSE verify the login with pass */
+ log_auth("XXX", "auth1");
+
+ if (($bdb = BriskDB::create()) != FALSE) {
+ $bdb->users_load();
+ if ($pass != FALSE) { // TODO: here add a method to $bdb to check if the db is available.
+ log_auth("XXX", "auth2");
+ $authenticate = $bdb->login_verify($name_new, $pass, $code);
+ log_auth("XXX", "authenticate: ".($authenticate != FALSE ? "TRUE" : "FALSE"));
+
+ if ($authenticate != FALSE) {
+ $user_type = $authenticate->type_get();
+ }
+ else {
+ $idx = -3;
+ return (FALSE);
+ }
+ }
+ else {
+ $login_exists = $bdb->login_exists(strtolower($name_new));
+/*
+ TO ENABLE USER-LOGIN ONLY
+ - $login_exists = $bdb->login_exists(strtolower($name_new));
+ + // $login_exists = $bdb->login_exists(strtolower($name_new));
+ + // Force access with login and password
+ + $idx = -3;
+ + return (FALSE);
+*/
+ }
+ }
+ else {
+ // if db is down, send a warning and verify only current users
+ // no actions at this moment
+ }
+ for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
+ /* free user ? */
+ if ($this->user[$i]->is_empty()) {
+ if ($idfree == -1) {
+ $idfree = $i;
+ }
+ continue;
+ }
+ if (strcmp($sess, $this->user[$i]->sess) == 0) {
+ if ($idx == -1) {
+ $idx = $i;
+ }
+ }
+ if (strcasecmp($this->user[$i]->name, $name_new) == 0) {
+ if ($authenticate != FALSE) {
+ $ghost = $i;
+ $ghost_auth = $this->user[$i]->is_auth();
+ }
+ else {
+ $idx = $i;
+ break;
+ }
+ }
+ }
+ if ($idx == -1)
+ $idx = $idfree;
+
+ log_auth("XXX", sprintf("TROVATO A QUESTO PUNTO [%d] sess [%s] name [%s]", $idx, $sess, $name_new));
+
+ /* there is another user logged with your account and you and him have authenticated => new user
+ get the session of the old user */
+ if ($ghost > -1 && $ghost_auth && ($authenticate != FALSE)) {
+ /* swap session */
+
+ $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 == "") {
+ $sess = uniqid("");
+ $ghost_user->sess = $sess;
+ }
+ else {
+ $ghost_user->sess = $sess;
+ }
+
+ // If user at the table we need to update the table data too
+ $table_idx = $ghost_user->table;
+ if ($ghost_user->stat == "table" && $this->table[$table_idx]->player_n == PLAYERS_N) {
+ require_once("${G_base}briskin5/Obj/briskin5.phh");
+ if (isset($this->match[$table_idx])) {
+ $bin5 = $this->match[$table_idx];
+
+ if ($bin5->the_end != TRUE) {
+ $bin5->user[$ghost_user->table_pos]->comm[$bin5->user[$ghost_user->table_pos]->step % COMM_N] = "";
+ $bin5->user[$ghost_user->table_pos]->step_inc();
+ $bin5->user[$ghost_user->table_pos]->sess = $sess;
+ }
+ }
+ }
+
+ $idx = $ghost;
+ if (defined('CURL_DE_SAC_VERS')) {
+ brisk_cds_execute($this, $ghost, $idx, $sess, $ip, $authenticate, $header);
+ }
+ return ($this->user[$ghost]);
+ }
+ else if ($idx != -1 && $i == MAX_PLAYERS) {
+ /* SUCCESS */
+ $curtime = time();
+ if ($sess == "") {
+ $sess = uniqid("");
+ $this->user[$idx]->sess = $sess;
+ }
+ else {
+ $this->user[$idx]->sess = $sess;
+ }
+ $this->user[$idx]->name = $name_new; // OK - add new user
+ $this->user[$idx]->stat_set("room");
+ $this->user[$idx]->step_set(0);
+ while (array_pop($this->user[$idx]->comm) != NULL);
+ $this->user[$idx]->subst = "standup";
+ $this->user[$idx]->lacc = $curtime;
+ $this->user[$idx]->laccwr = $curtime;
+ $this->user[$idx]->bantime = 0;
+ $this->user[$idx]->ip = $ip;
+
+ $this->user[$idx]->rec = $authenticate;
+ $this->user[$idx]->flags = $user_type;
+ $this->user[$idx]->flags |= ($authenticate != FALSE ? USER_FLAG_AUTH : 0x00);
+ $this->user[$idx]->flags |= ( ($pass != FALSE && $bdb == FALSE) ? USER_FLAG_DBFAILED : 0x00);
+ log_auth("XXX", sprintf("FLAGS: [%x]", $this->user[$idx]->flags));
+
+ if ($authenticate != FALSE) {
+ $this->user[$idx]->code = $authenticate->code_get();
+ if (0 == 1) {
+ // all this part is included in the db server
+ $this->user[$idx]->flags |= USER_FLAG_LISTAUTH;
+
+ if (isset($cookie['CO_list'])) {
+ // fprintf(STDERR, "QQ: %s CO_list: [%s]\n", __FUNCTION__, $cookie['CO_list']);
+ if (strcmp($cookie['CO_list'], "auth") == 0) {
+ $this->user[$idx]->flags &= ~USER_FLAG_MAP_AUTH;
+ $this->user[$idx]->flags |= USER_FLAG_LISTAUTH;
+ }
+ if (strcmp($cookie['CO_list'], "isolation") == 0) {
+ $this->user[$idx]->flags &= ~USER_FLAG_MAP_AUTH;
+ $this->user[$idx]->flags |= USER_FLAG_ISOLAUTH;
+ }
+ else {
+ $this->user[$idx]->flags &= ~USER_FLAG_MAP_AUTH;
+ }
+ }
+ }
+ // else {
+ // fprintf(STDERR, "QQ: CO_list not set flags: %x\n", __FUNCTION__, $this->user[$idx]->flags);
+ // }
+ }
+ // fprintf(STDERR, "QQ %s: flag %x\n", __FUNCTION__, $this->user[$idx]->flags);
+ if ($ghost > -1) {
+ log_main("ghost: rename!");
+ $ghost_user = $this->user[$ghost];
+
+ if ($ghost_auth == FALSE) {
+ for ($sfx = 1 ; $sfx <= MAX_PLAYERS ; $sfx++) {
+ $ghostname = 'ghost'.$sfx;
+ for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
+ if (strcmp("", $this->user[$i]->sess) == 0)
+ continue;
+
+ if (strcasecmp($this->user[$i]->name, $ghostname) == 0) {
+ $ghostname = '';
+ break;
+ }
+ }
+ if ($ghostname != '')
+ break;
+ }
+
+ $ghost_user->name = $ghostname;
+
+ if ($ghost_user->stat == 'room' && $ghost_user->subst == 'standup') {
+ $this->standup_update($ghost_user);
+ }
+ else {
+ log_main("chatt_send pre table update");
+ $this->table_update($ghost_user);
+ log_main("chatt_send post table update");
+ }
+ } // if ($ghost_auth == FALSE
+ else {
+ // FIXME: cacciare il vecchio utente room && table (if needed)
+ $ghost_user->the_end = TRUE;
+ $ghost_user->lacc = 0;
+ $this->garbage_manager(TRUE);
+ }
+ } // if ($ghost > -1) {
+
+ $real_idx = $idx;
+ if ($login_exists)
+ $idx = -($idx + 1);
+ log_main(sprintf("TROVATO LIBERO A [%d] sess [%s] name [%s] count [%d] name [%s] code [%s]", $idx, $sess, $name_new, count($this->user),$this->user[$real_idx]->name, $this->user[$real_idx]->code));
+
+ $ret = $this->user[$real_idx];
+ if (defined('CURL_DE_SAC_VERS')) {
+ brisk_cds_execute($this, $ghost, $real_idx, $sess, $ip, $authenticate, $header);
+ }
+ return ($ret);
+ }
+
+ return (FALSE);
+ }
+
+ function standup_update($user)
+ {
+ for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
+ $user_cur = $this->user[$i];
+ if ($user_cur->is_active() == FALSE)
+ continue;
+
+ log_main("STANDUP START: ".$user_cur->stat);
+
+ if ($user_cur->stat == 'room') {
+ $user_cur->comm[$user_cur->step % COMM_N] = "gst.st = ".($user_cur->step+1)."; ".$this->standup_content($user_cur);
+ if ($user->idx_get() == $i) {
+ $user_cur->comm[$user_cur->step % COMM_N] .= $user->myname_innerHTML();
+ }
+ log_main("FROM STANDUP: NAME: ".$user_cur->name." SENDED: ".$user_cur->comm[$user_cur->step % COMM_N]);
+
+ $user_cur->step_inc();
+ }
+ }