X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=web%2FObj%2Fbrisk.phh;h=1ff1f9f21eace19d1b93f4e12c436d95908d85b9;hb=e620dd90d1922e518c6e685c6b56d72ebced708f;hp=58f1e85c05232e380c4b25140e34e66f35151e8e;hpb=c3ccbbd5bc7c8534127fa10b4f88b81cffc6029a;p=brisk.git diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index 58f1e85..1ff1f9f 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -275,7 +275,7 @@ $G_room_about = array( 'it' => '
briscola chiamata in salsa ajax
version '.$G_brisk_version.'

-Copyright 2006-2009 Matteo Nastasi (aka mop)

', +Copyright 2006-2012 Matteo Nastasi (aka mop)

', 'en' => '
@@ -286,7 +286,9 @@ Copyright 2006-2009 Matteo Nasta function mop_flush() { - ob_flush(); + for ($i = 0; $i < ob_get_level(); $i++) + ob_end_flush(); + ob_implicit_flush(1); flush(); } @@ -690,6 +692,10 @@ define('USER_FLAG_TY_SUPER', 0x020000); // 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 $idx_orig; // index in the users array when you aren't in game @@ -712,6 +718,9 @@ class User { 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; // place where store failed fwrite data + var $comm; // commands array // var $asta_card; // // var $asta_pnt; // @@ -763,6 +772,8 @@ class User { $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; @@ -896,6 +907,17 @@ class User { 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); } @@ -904,6 +926,43 @@ class User { $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); } @@ -942,16 +1001,6 @@ class User { return TRUE; } - function rd_data_set($endtime, $stat, $subst, $step, $from) - { - $this->rd_endtime = $endtime; - $this->rd_stat = $stat; - $this->rd_subst = $subst; - $this->rd_step = $step; - $this->rd_from = $from; - $this->rd_scristp = 0; - } - function save_step() { @@ -1012,7 +1061,7 @@ class User { function reset() { $curtime = time(); - log_legal($curtime, $this, "STAT:LOGOUT", ''); + log_legal($curtime, 'xxx', $this, "STAT:LOGOUT", ''); $tmp_sess = $this->sess; $this->sess = ""; @@ -1258,7 +1307,7 @@ class Room { $user_cur->bantime = $bri_user->bantime; } - log_legal($curtime, $user_cur, "STAT:DESTROY_GAME", $plist); + log_legal($curtime, 'xxx', $user_cur, "STAT:DESTROY_GAME", $plist); $this->room_join_wakeup($user_cur, FALSE, 0); $table_cur->table_token = ""; @@ -1297,7 +1346,7 @@ class Room { for ($i = 0 ; $i < $table_cur->player_n ; $i++) { $plist .= '|'.$this->user[$table_cur->player[$i]]->sess; } - log_legal($curtime, $user_cur, "STAT:DESTROY_GAME(RECOVERY)", $plist); + log_legal($curtime, 'xxx', $user_cur, "STAT:DESTROY_GAME(RECOVERY)", $plist); $this->room_join_wakeup($user_cur, TRUE, -2); $table_cur->table_token = ""; @@ -1984,7 +2033,7 @@ class Room { $to_room = $to_user; } - log_legal($curtime, $user, + log_legal($curtime, 'xxx', $user, ($user->stat == 'room' ? 'room' : 'table '.$user->table),$msg); $user->chat_lst = "$msg"; @@ -2975,7 +3024,7 @@ function log_auth($sess, $log) 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 = ""; @@ -3013,15 +3062,14 @@ function log_shme($log) // function log_legal($curtime, $sess, $name, $where, $mesg) -function log_legal($curtime, $user, $where, $mesg) +function log_legal($curtime, $addr, $user, $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|%s|\n", $curtime, $user->sess, ($user->flags & USER_FLAG_AUTH ? 'A' : 'N'), - $user->name, $_SERVER['REMOTE_ADDR'], $where , $mesg)); + $user->name, $addr, $where , $mesg)); fclose($fp); } } @@ -3140,7 +3188,7 @@ function sharedmem_sz($tok) $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); }