*/
-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, 36);
-define(TABLES_AUTH_N, 4);
-define(PLAYERS_N, 3);
-define(MAX_POINTS, 5);
-define(MAX_PLAYERS, (20 + (PLAYERS_N * TABLES_N)));
-define(SHM_DIMS_MIN, (50000 + 10000 * TABLES_N + 15000 * MAX_PLAYERS));
-define(SHM_DIMS_MAX, SHM_DIMS_MIN + 1048576);
-define(SHM_DIMS_DLT, 65536);
-
-define(SHM_DIMS_U_MIN, 4096);
-define(SHM_DIMS_U_MAX, 65536);
-define(SHM_DIMS_U_DLT, 4096);
-
-define(COMM_N, 18);
-define(COMM_GEN_N, 50);
-
-define(CHAT_N, 3);
-define(CHAT_ILL_TIME, 6);
-
-define(SESS_LEN, 13);
-define(STREAM_TIMEOUT, 20);
-define(EXPIRE_TIME_RD, 180);
-define(EXPIRE_TIME_SMAMMA, 360);
-define(EXPIRE_TIME_WAG, 10);
-define(WAKEUP_TIME, 12);
+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', 36);
+define('TABLES_AUTH_N', 4);
+define('PLAYERS_N', 3);
+define('MAX_POINTS', 5);
+define('MAX_PLAYERS', (20 + (PLAYERS_N * TABLES_N)));
+define('SHM_DIMS_MIN', (50000 + 10000 * TABLES_N + 15000 * MAX_PLAYERS));
+define('SHM_DIMS_MAX', SHM_DIMS_MIN + 1048576);
+define('SHM_DIMS_DLT', 65536);
+
+define('SHM_DIMS_U_MIN', 4096);
+define('SHM_DIMS_U_MAX', 65536);
+define('SHM_DIMS_U_DLT', 4096);
+
+define('COMM_N', 18);
+define('COMM_GEN_N', 50);
+
+define('CHAT_N', 3);
+define('CHAT_ILL_TIME', 6);
+
+define('SESS_LEN', 13);
+define('STREAM_TIMEOUT', 60);
+define('EXPIRE_TIME_RD', 180);
+define('EXPIRE_TIME_SMAMMA', 360);
+define('EXPIRE_TIME_WAG', 10);
+define('WAKEUP_TIME', 12);
// BAN_TIME da allineare anche in commons.js
-define(BAN_TIME, 3600);
-define(GARBAGE_TIMEOUT, 10);
-define(NICKSERV, "<i>BriskServ</i>");
-
-define(LOCK_SHARE_MAX, 10000);
-
-define(DBG_ONL2, 0x0001);
-define(DBG_ONLY, 0x0002);
-define(DBG_MAIN, 0x0004);
-define(DBG_READ, 0x0008);
-define(DBG_REA2, 0x0010);
-define(DBG_SEND, 0x0020);
-define(DBG_LOCK, 0x0040);
-define(DBG_WRIT, 0x0080);
-define(DBG_LOAD, 0x0100);
-define(DBG_AUTH, 0x0200);
-define(DBG_CRIT, 0x0400);
-define(DBG_LMOP, 0x0800);
-define(DBG_TRAC, 0x1000);
-define(DBG_SHME, 0x2000);
+define('BAN_TIME', 3600);
+define('GARBAGE_TIMEOUT', 10);
+define('NICKSERV', "<i>BriskServ</i>");
+
+define('LOCK_SHARE_MAX', 10000);
+
+define('DBG_ONL2', 0x0001);
+define('DBG_ONLY', 0x0002);
+define('DBG_MAIN', 0x0004);
+define('DBG_READ', 0x0008);
+define('DBG_REA2', 0x0010);
+define('DBG_SEND', 0x0020);
+define('DBG_LOCK', 0x0040);
+define('DBG_WRIT', 0x0080);
+define('DBG_LOAD', 0x0100);
+define('DBG_AUTH', 0x0200);
+define('DBG_CRIT', 0x0400);
+define('DBG_LMOP', 0x0800);
+define('DBG_TRAC', 0x1000);
+define('DBG_SHME', 0x2000);
// NOTE: BRISK DEBUG must be a numerical constant, not the result of operations on symbols
-define(BRISK_DEBUG, 0xffffffbf);
+define('BRISK_DEBUG', 0x0800);
-define(BRISK_SINGLE_DEBUG,0);
-define(BRISK_SINGLE_SESS, "");
-// define(DEBUGGING, "local");
+define('BRISK_SINGLE_DEBUG',0);
+define('BRISK_SINGLE_SESS', "");
+define('DEBUGGING', "no-debugging");
require_once("$DOCUMENT_ROOT/Etc/".BRISK_CONF);
$G_lng = langtolng($G_lang);
$G_all_points = array( 11,10,4,3,2, 0,0,0,0,0 );
-$G_brisk_version = "3.5.6";
+$G_brisk_version = "3.6.3";
/* MLANG: ALL THE INFO STRINGS IN brisk.phh */
-$root_wellarr = array( 'it' => array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NOVITA\'</b>: (tecnica) utilizzo di locking tipo lettori/scrittori al posto del locking esclusivo generico.',
+$root_wellarr = array( 'it' => array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NOVITA\'</b>: nuovo sistema di evidenziazione degli utenti registrati.',
'Se vuoi iscriverti alla <a target="_blank" href="mailto:ml-briscola+subscribe@milug.org">Mailing List</a>, cliccala!' ),
'en' => array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NEWS</b>: usage of reader/writer locking instead of generic exclusive locking.',
'If you want to subscribe our <a target="_blank" href="ml-briscola+subscribe@milug.org">Mailing List</a>, click it!' ) );
briscola chiamata in salsa ajax
</div>
<br><b>version '.$G_brisk_version.'</b><br><br>
-Copyright 2006-2009 <a href=\\"mailto:brisk@alternativeoutput.it\\">Matteo Nastasi</a> (aka mop)<br><br>',
+Copyright 2006-2012 <a href=\\"mailto:brisk@alternativeoutput.it\\">Matteo Nastasi</a> (aka mop)<br><br>',
'en' => '<br>
<div id=\\"header\\" class=\\"header\\">
<img class=\\"nobo\\" src=\\"img/brisk_logo64.png\\">
function file_lock($fname, $is_exclusive)
{
- if (($res = fopen($fname, "r+")) == FALSE) {
+ if (($res = @fopen($fname, "r+")) == FALSE) {
return (FALSE);
}
return ($ct);
}
+$escpush_from = array("\\", "\"");
+$escpush_to = array("\\\\", "\\\"");
+function escpush($s)
+{
+ GLOBAL $escpush_from, $escpush_to;
+
+ return str_replace($escpush_from, $escpush_to, $s);
+}
+
$escinp_from = array( "\"" );
$escinp_to = array( """ );
// User flags
-define(USER_FLAG_AUTH, 0x02);
+define('USER_FLAG_AUTH', 0x02);
-define(USER_FLAG_MAP_AUTH, 0x0c);
-define(USER_FLAG_LISTAUTH, 0x04);
-define(USER_FLAG_ISOLAUTH, 0x08);
+define('USER_FLAG_MAP_AUTH', 0x0c);
+define('USER_FLAG_LISTAUTH', 0x04);
+define('USER_FLAG_ISOLAUTH', 0x08);
-define(USER_FLAG_DBFAILED, 0x10);
+define('USER_FLAG_DBFAILED', 0x10);
// user status
-define(USER_FLAG_S_NORM, 0x000); // done
-define(USER_FLAG_S_PAU, 0x100); // done
-define(USER_FLAG_S_OUT, 0x200); // done
-define(USER_FLAG_S_DOG, 0x300); // done
-define(USER_FLAG_S_EAT, 0x400); // done
-define(USER_FLAG_S_WRK, 0x500); // done
-define(USER_FLAG_S_SMK, 0x600); // done
-define(USER_FLAG_S_EYE, 0x700); // done
-define(USER_FLAG_S_RABB, 0x800); // done
-define(USER_FLAG_S_SOCC, 0x900); // done
-define(USER_FLAG_S_BABY, 0xa00); // done
-define(USER_FLAG_S_MOP, 0xb00); // done
-
-define(USER_FLAG_S_ALL, 0xf00); // done
+define('USER_FLAG_S_NORM', 0x000); // done
+define('USER_FLAG_S_PAU', 0x100); // done
+define('USER_FLAG_S_OUT', 0x200); // done
+define('USER_FLAG_S_DOG', 0x300); // done
+define('USER_FLAG_S_EAT', 0x400); // done
+define('USER_FLAG_S_WRK', 0x500); // done
+define('USER_FLAG_S_SMK', 0x600); // done
+define('USER_FLAG_S_EYE', 0x700); // done
+define('USER_FLAG_S_RABB', 0x800); // done
+define('USER_FLAG_S_SOCC', 0x900); // done
+define('USER_FLAG_S_BABY', 0xa00); // done
+define('USER_FLAG_S_MOP', 0xb00); // done
+
+define('USER_FLAG_S_ALL', 0xf00); // done
/* type of user normal, supporter etc ... */
-define(USER_FLAG_TY_ALL, 0xff0000); // done
-define(USER_FLAG_TY_NORM, 0x010000); // done
-define(USER_FLAG_TY_SUPER, 0x020000); // done
+define('USER_FLAG_TY_ALL', 0xff0000); // done
+define('USER_FLAG_TY_NORM', 0x010000); // done
+define('USER_FLAG_TY_SUPER', 0x020000); // done
// ... other usefull status ...
-define(USER_FLAG_TY_SUSPEND, 0x400000); // done
-define(USER_FLAG_TY_DISABLE, 0x800000); // done
+define('USER_FLAG_TY_SUSPEND', 0x400000); // done
+define('USER_FLAG_TY_DISABLE', 0x800000); // done
+
+// 240 is the right value, 600 is for fwrite error test
+define('RD_ENDTIME_DELTA', 240);
+define('RD_KEEPALIVE_TOUT', 4);
class User {
var $idx; // index in the users array when you are in game
var $subst; // substatus for each status
var $step; // step of the current status
var $trans_step; // step to enable transition between pages (disable == -1)
+
+ var $rd_socket; // socket handle of push stream
+ var $rd_endtime; // end time for push stream
+ var $rd_stat; // actual status of push stream
+ var $rd_subst; // actual substatus of push stream
+ var $rd_step; // actual step of push stream
+ var $rd_from; // referer
+ var $rd_scristp; // current script step (for each session)
+ var $rd_kalive; // if no message are sent after RD_KEEPALIVE_TOUT secs we send a keepalive from server
+ var $rd_cache; // store place where failed fwrite data
+
var $comm; // commands array
// var $asta_card; //
// var $asta_pnt; //
$thiz->step = 1;
$thiz->trans_step = -1;
$thiz->comm = array();
+
+ $thiz->rd_socket = NULL;
+ $thiz->rd_endtime = -1;
+ $thiz->rd_stat = -1;
+ $thiz->rd_subst = "";
+ $thiz->rd_step = -1;
+ $thiz->rd_from = "";
+ $thiz->rd_scristp = -1;
+ $thiz->rd_kalive = -1;
+ $thiz->rd_cache = "";
+
$thiz->asta_card = -2;
$thiz->asta_pnt = -1;
$thiz->handpt = -1;
return ($thiz);
}
+ function rd_data_set($curtime, $stat, $subst, $step, $from)
+ {
+ $this->rd_endtime = $curtime + RD_ENDTIME_DELTA;
+ $this->rd_stat = $stat;
+ $this->rd_subst = $subst;
+ $this->rd_step = $step;
+ $this->rd_from = $from;
+ $this->rd_scristp = 0;
+ $this->rd_kalive = $curtime + RD_KEEPALIVE_TOUT;
+ }
+
+ function rd_socket_get() {
+ return ($this->rd_socket);
+ }
+
+ function rd_socket_set($sock) {
+ $this->rd_socket = $sock;
+ }
+
+ function rd_kalive_get()
+ {
+ return ($this->rd_kalive);
+ }
+
+ function rd_kalive_set($tm)
+ {
+ $this->rd_kalive = $tm;
+ }
+
+ function rd_kalive_is_expired($tm)
+ {
+ // printf("rd_kalive %d tm %d\n", $this->rd_kalive, $tm);
+ return ($this->rd_kalive < $tm);
+ }
+
+ function rd_endtime_is_expired($tm)
+ {
+ // printf("rd_endtime %d tm %d\n", $this->rd_kalive, $tm);
+ return ($this->rd_endtime < $tm);
+ }
+
+ function rd_kalive_reset($tm)
+ {
+ $this->rd_kalive = $tm + RD_KEEPALIVE_TOUT;
+ }
+
+ function rd_cache_get()
+ {
+ return ($this->rd_cache);
+ }
+
+ function rd_cache_set($cache)
+ {
+ $this->rd_cache = $cache;
+ }
+
function idx_get() {
return ($this->idx);
}
if (validate_sess($this->sess)) {
if (file_exists(PROXY_PATH) == FALSE)
mkdir(PROXY_PATH, 0775, TRUE);
- $fp = fopen(PROXY_PATH."/".$this->sess.".stat", 'w');
+ $fp = @fopen(PROXY_PATH."/".$this->sess.".stat", 'w');
fwrite($fp, sprintf("%s\n",$this->stat));
fclose($fp);
}
return TRUE;
}
+
function save_step()
{
do {
return (FALSE);
}
+ function myname_innerHTML()
+ {
+ $class_id = ($this->flags & USER_FLAG_AUTH) + 1;
+
+ return (sprintf('$("myname").innerHTML = "<span class=\"au%d\">%s</span>";', $class_id,
+ xcape($this->name,ENT_COMPAT,"UTF-8")));
+ }
} // end class User
}
$ret .= sprintf('subst = "%s";', $user->subst);
- $itin = ($user->flags & USER_FLAG_AUTH ? "<i>" : "");
- $itou = ($user->flags & USER_FLAG_AUTH ? "</i>" : "");
- $ret .= sprintf('$("myname").innerHTML = "<b>%s%s%s</b>";', $itin, xcape($user->name), $itou);
+ $ret .= $user->myname_innerHTML();
+
for ($i = 0 ; $i < TABLES_N ; $i++) {
$ret .= $this->table_content($user, $i);
$ret = "gst.st = ".($user_cur->step+1)."; ".($remove_wagon ? sprintf("tra.rem(%d);",$table_idx) : "");
if ($from_table && ($user_cur->table == $table_idx || $user->idx_get() == $i)) {
- $ret .= 'gst.st_loc++; the_end=true; window.onunload = null; window.onbeforeunload = null; document.location.assign("index.php");|';
+ $ret .= 'gst.st_loc++; hstm.stop(); window.onunload = null; window.onbeforeunload = null; document.location.assign("index.php");|';
// $ret .= 'gst.st_loc++; document.location.assign("index.php");|';
log_main("DOCUMENT.index.php: from table");
}
$ret .= $this->table_content($user_cur, $table_idx);
if ($user->idx_get() == $i) {
- $itin = ($user->flags & USER_FLAG_AUTH ? "<i>" : "");
- $itou = ($user->flags & USER_FLAG_AUTH ? "</i>" : "");
- $ret .= sprintf('$("myname").innerHTML = "<b>%s%s%s</b>: ";', $itin, xcape($user->name), $itou);
+ $ret .= $user->myname_innerHTML();
}
$user_cur->comm[$user_cur->step % COMM_N] = $ret;
$user_cur->step_inc();
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) {
- $itin = ($user->flags & USER_FLAG_AUTH ? "<i>" : "");
- $itou = ($user->flags & USER_FLAG_AUTH ? "</i>" : "");
-
- $user_cur->comm[$user_cur->step % COMM_N] .= sprintf('$("myname").innerHTML = "<b>%s%s%s</b>: ";',
- $itin, xcape($user->name), $itou);
+ $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]);
if (( (BRISK_DEBUG | ($sess == BRISK_SINGLE_SESS ? BRISK_SINGLE_DEBUG : 0) ) & DBG_AUTH) == 0)
return;
- if ((BRISK_DEBUG | ($ssess == BRISK_SINGLE_SESS ? BRISK_SINGLE_DEBUG : 0) ) & DBG_TRAC)
+ if ((BRISK_DEBUG | ($sess == BRISK_SINGLE_SESS ? BRISK_SINGLE_DEBUG : 0) ) & DBG_TRAC)
$btrace = btrace_line(debug_backtrace());
else
$btrace = "";
$shm_sz = shmop_size($shm_id);
shmop_close($shm_id);
- log_main("shm_sz: ".$shm_sz." SHM_DIMS: ".SHM_DIMS);
+ // log_main("shm_sz: ".$shm_sz." SHM_DIMS: ".SHM_DIMS);
return ($shm_sz);
}