X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2FObj%2Fbrisk.phh;h=c0dadf907919b9f38ddbccd588716e743efc8b8a;hb=640c4f0d3c284d00919556d20970cc5b61ef5e88;hp=93b9983e0dc7a5b9176e5d243b8d2e888bfccfc9;hpb=87e71c389b8da4cbd18ecbe372ad6e75a15cb965;p=brisk.git
diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh
index 93b9983..c0dadf9 100644
--- a/web/Obj/brisk.phh
+++ b/web/Obj/brisk.phh
@@ -27,7 +27,7 @@ define(BRISK_CONF, "brisk.conf.pho");
define(FTOK_PATH, "/var/lib/brisk");
define(LEGAL_PATH, "/tmp/legal_brisk");
define(PROXY_PATH, "/var/lib/brisk_proxy");
-define(TABLES_N, 24);
+define(TABLES_N, 32);
define(PLAYERS_N, 3);
define(MAX_POINTS, 5);
define(MAX_PLAYERS, (20 + (PLAYERS_N * TABLES_N)));
@@ -72,13 +72,12 @@ define(BRISK_SINGLE_SESS, "");
require_once("$DOCUMENT_ROOT/Etc/".BRISK_CONF);
-
$G_false = FALSE;
$G_all_points = array( 11,10,4,3,2, 0,0,0,0,0 );
-$G_brisk_version = "spawn-0.12.0";
+$G_brisk_version = "spawn-0.14.0";
-$root_wellarr = Array ( 'Benvenuto in brisk (Ver. '.$G_brisk_version.'), NOVITA\': aggiunta messaggistica a tutti i tavoli - versione beta2.',
+$root_wellarr = Array ( 'Benvenuto in brisk (Ver. '.$G_brisk_version.'), NOVITA\': input bug risolto, aggiunte le foto e le statistiche d\`uso - Beta7.',
'Se vuoi iscriverti alla Mailing List, cliccala!' );
$table_wellarr = Array ( 'Benvenuto al tavolo. Se almeno tre giocatori non sbloccano l\'uscita cliccando il lucchetto, chi esce non può risedersi a un qualunque tavolo per '.floor(BAN_TIME/60).' minuti.');
@@ -86,7 +85,7 @@ $table_wellarr = Array ( 'Benvenuto al tavolo. Se almeno tre giocatori non sbloc
$G_room_help= '
Descrizione
-Questa è un\'implementazione della briscola in cinque, così come è spiegata su
+Questa è un\'implementazione della briscola in cinque, così come è spiegata su
Wikipedia; in breve è la variante con l\'asta prima sulla carta e poi sui punti.
Configurazione del browser.
Occorre abilitare i cookies.
@@ -105,7 +104,7 @@ Dopo che è iniziata una partita per uscirne dovete chiedere agli altri gi
- Comandi della chat
- /nick <nuovo_nickname> - cambio di nickname
-
- /tav <frase di invitogt; - invito per gli altri giocatori al tavolo dove si è seduti
+
- /tav <frase di invito> - invito per gli altri giocatori al tavolo dove si è seduti
';
@@ -116,7 +115,7 @@ $G_room_about= '
briscola chiamata in salsa ajax
version '.$G_brisk_version.'
-Copyright 2006-2007 Matteo Nastasi (aka mop)
';
+Copyright 2006-2008 Matteo Nastasi (aka mop)
';
function xcape($s)
@@ -690,6 +689,8 @@ class User {
/*
if (validate_sess($this->sess)) {
+ if (file_exists(PROXY_PATH) == FALSE)
+ mkdir(PROXY_PATH);
$fp = fopen(PROXY_PATH."/".$this->sess.".stat", 'w');
fwrite($fp, sprintf("%s\n",$this->stat));
fclose($fp);
@@ -703,6 +704,8 @@ class User {
do {
if (validate_sess($this->sess) == FALSE)
break;
+ if (file_exists(PROXY_PATH) == FALSE)
+ mkdir(PROXY_PATH);
if (($fp = @fopen(PROXY_PATH."/".$this->sess.".step", 'w')) == FALSE)
break;
fwrite($fp, pack("l",$this->step), 4);
@@ -718,6 +721,8 @@ class User {
$this->step += $delta;
if (validate_sess($this->sess)) {
+ if (file_exists(PROXY_PATH) == FALSE)
+ mkdir(PROXY_PATH);
$fp = fopen(PROXY_PATH."/".$this->sess.".step", 'w');
fwrite($fp, pack("l",$this->step), 4);
fclose($fp);
@@ -729,12 +734,20 @@ class User {
}
function reset() {
+ $curtime = time();
+ log_legal($curtime, $this->sess, $this->name, "STAT:LOGOUT", '');
+
$tmp_sess = $this->sess;
$this->sess = "";
step_unproxy($tmp_sess);
- $this->name = "";
+ $this->name = ""; // OK here
while (array_pop($this->comm) != NULL);
$this->step = 0;
+ $this->chattime = array_fill(0, CHAT_N, 0);
+ $this->chat_cur = 0;
+ $this->chat_lst = "";
+ $this->chat_ban = 0;
+ $this->chat_dlt = 0;
$this->the_end = FALSE;
}
} // end class User
@@ -742,20 +755,18 @@ class User {
function step_get($sess) {
$fp = FALSE;
- $ct = 0;
do {
if (validate_sess($sess) == FALSE)
break;
- $ct = 1;
+
+ if (file_exists(PROXY_PATH) == FALSE)
+ mkdir(PROXY_PATH);
if (($fp = @fopen(PROXY_PATH."/".$sess.".step", 'rb')) == FALSE)
break;
- $ct = 2;
if (($s = fread($fp, 4)) == FALSE)
break;
- $ct = 3;
if (strlen($s) != 4)
break;
- $ct = 4;
$arr = unpack('l', $s);
fclose($fp);
@@ -766,12 +777,15 @@ function step_get($sess) {
if ($fp != FALSE)
fclose($fp);
- log_rd2("STEP_GET: return false ".$ct);
+ log_rd2("STEP_GET: return false ");
+
return (FALSE);
}
function step_unproxy($sess) {
log_rd2("UNPROXY: ".PROXY_PATH."/".$sess.".step");
+ if (file_exists(PROXY_PATH) == FALSE)
+ mkdir(PROXY_PATH);
@unlink(PROXY_PATH."/".$sess.".step");
}
@@ -844,6 +858,11 @@ class Room {
*/
log_main("garbage_manager: INSIDE THE END.");
+ $plist = "$table_cur->table_token|$user_cur->table|$table_cur->player_n";
+ for ($i = 0 ; $i < $table_cur->player_n ; $i++) {
+ $plist .= '|'.$this->user[$table_cur->player[$i]]->sess;
+ }
+
for ($i = 0 ; $i < $bri_table->player_n ; $i++) {
// stat must be "table" by definition
$user_cur =& $this->user[$table_cur->player[$i]];
@@ -855,7 +874,9 @@ class Room {
$user_cur->laccwr = $bri_user->lacc;
$user_cur->bantime = $bri_user->bantime;
}
-
+
+ log_legal($curtime, $user_cur->sess, $user_cur->name, "STAT:DESTROY_GAME", $plist);
+
$this->room_join_wakeup(&$user_cur, FALSE, 0);
$table_cur->table_token = "";
$table_cur->wakeup_time = $curtime + WAKEUP_TIME;
@@ -886,6 +907,12 @@ class Room {
$user_cur->step_inc();
}
+ $plist = "$table_cur->table_token|$user_cur->table|$table_cur->player_n";
+ for ($i = 0 ; $i < $table_cur->player_n ; $i++) {
+ $plist .= '|'.$this->user[$table_cur->player[$i]]->sess;
+ }
+ log_legal($curtime, $user_cur->sess, $user_cur->name, "STAT:DESTROY_GAME(RECOVERY)", $plist);
+
$this->room_join_wakeup(&$user_cur, TRUE, -2);
$table_cur->table_token = "";
}
@@ -913,15 +940,6 @@ class Room {
log_auth($user_cur->sess, "Autologout session.");
$user_cur->reset();
- /* factorized with ->reset()
- $tmp_sess = $user_cur->sess;
- $user_cur->sess = "";
- step_unproxy($tmp_sess);
- $user_cur->name = "";
- while (array_pop($user_cur->comm) != NULL);
- $user_cur->step = 0;
- $user_cur->the_end = FALSE;
- */
log_rd2("AUTO LOGOUT.");
if ($user_cur->subst == 'sitdown' || $user_cur->stat == 'table')
@@ -1213,11 +1231,12 @@ class Room {
{
log_main("room_sitdown ".($user == FALSE ? "USER: FALSE" : "USER: ".$user->name));
+ $train_app = "";
+
if ($table_idx > -1 && $table_idx < TABLES_N) {
$table = &$this->table[$table_idx];
// wagon shutdown
- $train_app = "";
if ($table->wag_own != NULL && $table->player_n == PLAYERS_N) {
for ($i = 0 ; $i < TABLES_N ; $i++) {
$user_cur =& $this->user[$table->player[$i]];
@@ -1266,9 +1285,9 @@ class Room {
$only_you = FALSE;
// common settings
- $msg = substr($mesg,6);
- $timecur = time();
- $dt = date("H:i ", $timecur);
+ $msg = substr($mesg, 6, 128);
+ $curtime = time();
+ $dt = date("H:i ", $curtime);
//
// Compute actions
@@ -1299,7 +1318,7 @@ class Room {
break;
}
- $dtime = $timecur - $table->wag_tout;
+ $dtime = $curtime - $table->wag_tout;
if ($dtime < EXPIRE_TIME_WAG) {
$msg = sprintf("
Il messaggio di segnalazione del tavolo
è disattivato ancora per %d second%s.
",
EXPIRE_TIME_WAG - $dtime, (EXPIRE_TIME_WAG - $dtime == 1 ? "o" : "i"));
@@ -1311,7 +1330,8 @@ class Room {
$msg = substr($msg, 5);
$table->wag_set($user, $msg);
- $to_room = sprintf('tra.add(%d, "%s");', $user->table, xcape(sprintf("%s: %s", $user->name, $msg)));
+ $to_user = sprintf('tra.add(%d, "%s");', $user->table, xcape(sprintf("%s: %s", $user->name, $msg)));
+ $to_room = $to_user;
} while (0);
} // /tav chat command
@@ -1329,9 +1349,8 @@ class Room {
$to_user = sprintf('chatt_sub("%s","Alarm %s inviato a tutti.");',
$dt.NICKSERV, xcape(substr($msg, strlen($alarm_check))));
- // $msg = "
".$dt.NICKSERV."
".xcape(substr($msg, strlen($alarm_check)))."
";
- $msg = sprintf("
%s%s
%s
",
- $dt, NICKSERV, xcape(substr($msg, strlen($alarm_check))));
+ $msg = sprintf("
%s
%s
",
+ $dt.NICKSERV, xcape(substr($msg, strlen($alarm_check))));
$to_all = show_notify($msg, 0, "chiudi", 400, 120);
} while (0);
} // /alarm chat command
@@ -1341,7 +1360,7 @@ class Room {
do {
if (($name_new = validate_name(substr($msg, 6))) == FALSE) {
- $to_user = sprintf('chatt_sub("%s","Il nickname deve contenere almeno una lettera o una cifra.");', $dt.NICKSERV, xcape($name_new));
+ $to_user = sprintf('chatt_sub("%s","Il nickname deve contenere almeno una lettera dell\'alfabeto o una cifra.");', $dt.NICKSERV);
break;
}
@@ -1359,7 +1378,7 @@ class Room {
break;
}
- $user->name = $name_new;
+ $user->name = $name_new; // OK - nick changed
log_main("chatt_send start set");
@@ -1368,7 +1387,7 @@ class Room {
} // nick chat command
else { // normal chat line
- if ($timecur < ($user->chat_ban + $user->chat_dlt)) {
+ if ($curtime < ($user->chat_ban + $user->chat_dlt)) {
$only_you = TRUE;
$user->chat_dlt = $user->chat_dlt * 2;
if ($user->chat_dlt > 120)
@@ -1376,8 +1395,8 @@ class Room {
}
else if ($user->chat_lst == $msg)
$only_you = TRUE;
- else if ($timecur - $user->chattime[($user->chat_cur + 1) % CHAT_N] < CHAT_ILL_TIME) {
- $user->chat_ban = $timecur;
+ else if ($curtime - $user->chattime[($user->chat_cur + 1) % CHAT_N] < CHAT_ILL_TIME) {
+ $user->chat_ban = $curtime;
$user->chat_dlt = 5;
$only_you = TRUE;
}
@@ -1391,14 +1410,16 @@ class Room {
}
else {
$to_user = sprintf('chatt_sub("%s","%s");', $dt.xcape($user->name), xcape($msg));
- $to_room = $to_user;
+ // temporary silentiation for troll (will became array check)
+ if (strcasecmp($user->name,'JackRokka') != 0 && $user->sess != '47ea653f602e8')
+ $to_room = $to_user;
}
- log_legal($timecur, $user->sess, $user->name,
+ log_legal($curtime, $user->sess, $user->name,
($user->stat == 'room' ? 'room' : 'table '.$user->table),$msg);
$user->chat_lst = "$msg";
- $user->chattime[$user->chat_cur % CHAT_N] = $timecur;
+ $user->chattime[$user->chat_cur % CHAT_N] = $curtime;
$user->chat_cur++;
}
@@ -1562,7 +1583,7 @@ class Room {
else {
$this->user[$idx]->sess = $sess;
}
- $this->user[$idx]->name = $name_new;
+ $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);
@@ -2032,13 +2053,13 @@ function log_auth($sess, $log) {
}
-function log_legal($timecur, $sess, $name, $where, $mesg)
+function log_legal($curtime, $sess, $name, $where, $mesg)
{
GLOBAL $_SERVER;
if (($fp = @fopen(LEGAL_PATH."/legal.log", 'a')) != FALSE) {
/* Unix time | session | nickname | IP | where was | mesg */
- fwrite($fp, sprintf("%ld|%s|%s|%s|%s|%s|\n", $timecur, $sess, $name, $_SERVER['REMOTE_ADDR'], $where , $mesg));
+ fwrite($fp, sprintf("%ld|%s|%s|%s|%s|%s|\n", $curtime, $sess, $name, $_SERVER['REMOTE_ADDR'], $where , $mesg));
fclose($fp);
}
}
@@ -2240,13 +2261,18 @@ function show_table_info(&$room, &$table, $table_pos)
$unam = xcape($room->user[$table->player[$curplayer]]->name);
$noty .= " tocca a $unam giocare.";
}
-
+
if ($table->mult > 1) {
$noty .= sprintf(" La partita vale %s.", multoval($table->mult));
}
$noty .= "
";
-
$ret .= show_notify($noty, 3000, "torna alla partita", 500, 400);
+ /* NOTE: show_notify($noty, 3000, "torna alla partita", 500,
+ * 130 + ($table->points_n > 0 ? 50 : 0) +
+ * (120 * ($table->points_n / MAX_POINTS)));
+ * will be used when we refact notify js function following
+ * photoo class logic
+ */
return ($ret);
}
@@ -2256,8 +2282,8 @@ function root_wellcome($user)
GLOBAL $root_wellarr;
$ret = "";
- $timecur = time();
- $dt = date("H:i ", $timecur);
+ $curtime = time();
+ $dt = date("H:i ", $curtime);
for ($i = 0 ; $i < count($root_wellarr) ; $i++)
$ret .= sprintf('chatt_sub("%s","%s");', $dt.NICKSERV, str_replace('"', '\"', $root_wellarr[$i]));