- 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;
+ 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);