X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=web%2Fbriskin5%2FObj%2Fbriskin5.phh;h=831cffd8228d26513f74e015ac28bcd82282387c;hb=6c4c333b78bbb0bc7dcb5d39fecd00d3bb71ba31;hp=c1c0f5b8e130c70f2c2c8cac4ba1ded1a00cea78;hpb=ba124be15839e2a62fa793b70869e0209f8daf90;p=brisk.git diff --git a/web/briskin5/Obj/briskin5.phh b/web/briskin5/Obj/briskin5.phh index c1c0f5b..831cffd 100644 --- a/web/briskin5/Obj/briskin5.phh +++ b/web/briskin5/Obj/briskin5.phh @@ -257,13 +257,11 @@ class Briskin5 { // exit; // WARNING monitor this step if (($tok = @ftok(FTOK_PATH."/table".$table_idx, "B")) == -1) { - echo "FTOK FAILED"; - exit; + return (FALSE); } // WARNING monitor this step if (($res = @sem_get($tok)) == FALSE) { - echo "SEM_GET FAILED"; - exit; + return (FALSE); } if (sem_acquire($res)) { log_lock("LOCK table ".$table_idx."[res: ".$res."]"); @@ -301,7 +299,7 @@ class Briskin5 { if (($name_new = validate_name(substr($user_mesg, 6))) == FALSE) { $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; "; - $user->comm[$user->step % COMM_N] .= sprintf('chatt_sub("%s","Il nickname deve contenere almeno una lettera dell\'alfabeto o una cifra.");', $dt.NICKSERV); + $user->comm[$user->step % COMM_N] .= sprintf('chatt_sub("%s", [2, "%s"],"Il nickname deve contenere almeno una lettera dell\'alfabeto o una cifra.");', $dt, NICKSERV); $user->step_inc(); return; @@ -318,15 +316,27 @@ class Briskin5 { continue; if ($user_cur->name == $name_new) { $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; "; - $user->comm[$user->step % COMM_N] .= sprintf('chatt_sub("%s","Nickname %s già in uso.");', $dt.NICKSERV, xcape($name_new)); + $user->comm[$user->step % COMM_N] .= sprintf('chatt_sub("%s", [2, "%s"],"Nickname %s già in uso.%d");', $dt, NICKSERV, xcape($name_new), $this->table[$user->table]->auth_only == TRUE); $user->step_inc(); break; } } if ($i == BRISKIN5_MAX_PLAYERS) { + if ($user->flags & USER_FLAG_AUTH && strcasecmp($user->name,$name_new) != 0) { + if ($this->table[$user->table]->auth_only == TRUE) { + $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; "; + $user->comm[$user->step % COMM_N] .= sprintf('chatt_sub("%s", [2, "%s"],"Non puoi cambiare nick a un tavolo per soli autenticati.");', $dt, NICKSERV); + $user->step_inc(); + return; + } + else { + $user->flags &= ~USER_FLAG_AUTH; // Remove auth if name changed + } + } + $user->name = $name_new; - log_main($user->sess." chatt_send start set"); + log_main($user->sess." chatt_send start set"); for ($i = 0 ; $i < BRISKIN5_MAX_PLAYERS ; $i++) { @@ -352,15 +362,27 @@ class Briskin5 { $table = &$this->table[$user->table]; $user_cur->comm[$user_cur->step % COMM_N] = "gst.st = ".($user_cur->step+1)."; "; - $user_cur->comm[$user_cur->step % COMM_N] .= sprintf('set_names(" %s", " %s", " %s", " %s", " %s"); ', - xcape($this->user[$table->player[($user_cur->table_pos) % BRISKIN5_PLAYERS_N]]->name), - xcape($this->user[$table->player[($user_cur->table_pos+1) % BRISKIN5_PLAYERS_N]]->name), - xcape($this->user[$table->player[($user_cur->table_pos+2) % BRISKIN5_PLAYERS_N]]->name), - (BRISKIN5_PLAYERS_N == 3 ? "" : xcape($this->user[$table->player[($user_cur->table_pos+3) % BRISKIN5_PLAYERS_N]]->name)), - (BRISKIN5_PLAYERS_N == 3 ? "" : xcape($this->user[$table->player[($user_cur->table_pos+4) % BRISKIN5_PLAYERS_N]]->name))); - if ($user_cur == $user) - $user_cur->comm[$user_cur->step % COMM_N] .= sprintf('$("myname").innerHTML = "%s";', - xcape($user->name,ENT_COMPAT,"UTF-8")); + $user_cur->comm[$user_cur->step % COMM_N] .= sprintf('set_names([%d, "%s"], [%d, "%s"], [%d, "%s"], [%d, "%s"], [%d, "%s"]); ', + $this->user[$table->player[($user_cur->table_pos) % BRISKIN5_PLAYERS_N]]->flags, + xcape($this->user[$table->player[($user_cur->table_pos) % BRISKIN5_PLAYERS_N]]->name), + + $this->user[$table->player[($user_cur->table_pos+1) % BRISKIN5_PLAYERS_N]]->flags, + xcape($this->user[$table->player[($user_cur->table_pos+1) % BRISKIN5_PLAYERS_N]]->name), + + $this->user[$table->player[($user_cur->table_pos+2) % BRISKIN5_PLAYERS_N]]->flags, + xcape($this->user[$table->player[($user_cur->table_pos+2) % BRISKIN5_PLAYERS_N]]->name), + + (BRISKIN5_PLAYERS_N == 3 ? 0: $this->user[$table->player[($user_cur->table_pos+3) % BRISKIN5_PLAYERS_N]]->flags), + (BRISKIN5_PLAYERS_N == 3 ? "" : xcape($this->user[$table->player[($user_cur->table_pos+3) % BRISKIN5_PLAYERS_N]]->name)), + + (BRISKIN5_PLAYERS_N == 3 ? 0: $this->user[$table->player[($user_cur->table_pos+4) % BRISKIN5_PLAYERS_N]]->flags), + (BRISKIN5_PLAYERS_N == 3 ? "" : xcape($this->user[$table->player[($user_cur->table_pos+4) % BRISKIN5_PLAYERS_N]]->name))); + if ($user_cur == $user) { + $itin = ($user->flags & USER_FLAG_AUTH ? "" : ""); + $itou = ($user->flags & USER_FLAG_AUTH ? "" : ""); + $user_cur->comm[$user_cur->step % COMM_N] .= sprintf('$("myname").innerHTML = "%s%s%s";', + $itin, xcape($user->name,ENT_COMPAT,"UTF-8"), $itou); + } $user_cur->step_inc(); } } @@ -378,12 +400,11 @@ class Briskin5 { } $user_cur->comm[$user_cur->step % COMM_N] = "gst.st = ".($user_cur->step+1)."; "; - $user_cur->comm[$user_cur->step % COMM_N] .= sprintf('chatt_sub("%s","%s");', - $dt.xcape($user->name), xcape($user_mesg)); + $user_cur->comm[$user_cur->step % COMM_N] .= sprintf('chatt_sub("%s", [%d, "%s"],"%s");', + $dt, $user->flags, xcape($user->name), xcape($user_mesg)); $user_cur->step_inc(); } - log_legal($curtime, $user->sess, $user->name, - ($user->stat == 'room' ? 'room' : 'table '.$user->table),$user_mesg); + log_legal($curtime, $user, ($user->stat == 'room' ? 'room' : 'table '.$user->table),$user_mesg); } } @@ -408,7 +429,7 @@ class Briskin5 { $user_cur->laccwr = $curtime; $ret = "gst.st = ".($user_cur->step+1)."; "; - $ret .= 'gst.st_loc++; the_end=true; window.onunload = null; document.location.assign("../index.php");|'; + $ret .= 'gst.st_loc++; the_end=true; window.onbeforeunload = null; window.onunload = null; document.location.assign("../index.php");|'; log_wr($user_cur->sess." BRISKIN5_WAKEUP: ".$ret); $user_cur->comm[$user_cur->step % COMM_N] = $ret;