X-Git-Url: https://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;ds=inline;f=web%2FObj%2Fbrisk.phh;h=5f87709ae91aae2953562e5489f80eb092840f59;hb=bd4ee6dd7696eeb5b0f8d7c7dc0cd9c840843146;hp=b53cefb75d5a7459344b8eac234e1f2024621b46;hpb=440015e75749093a64016809118e64572a2ba99e;p=brisk.git
diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh
index b53cefb..5f87709 100644
--- a/web/Obj/brisk.phh
+++ b/web/Obj/brisk.phh
@@ -140,10 +140,10 @@ $mlang_brisk = array( 'btn_backstand'=> array( 'it' => 'torna in piedi',
$G_lng = langtolng($G_lang);
$G_all_points = array( 11,10,4,3,2, 0,0,0,0,0 );
-$G_brisk_version = "4.1.0";
+$G_brisk_version = "4.5.3";
/* MLANG: ALL THE INFO STRINGS IN brisk.phh */
-$root_wellarr = array( 'it' => array ( 'Brisk (Ver. '.$G_brisk_version.'), NOVITA\': adottato sac-a-push come motore per l\'invio dei dati in tempo reale, nuovo trasporto httpfile per explorer.',
+$root_wellarr = array( 'it' => array ( 'Brisk (Ver. '.$G_brisk_version.'), NOVITA\': nuova visualizzazione dello stato della connessione dati, indirizzo IP sorgente memorizzato correttamente nei log, risolte alcune inconsistenze.',
'Se vuoi iscriverti alla Mailing List, cliccala!' ),
'en' => array ( 'Brisk (Ver. '.$G_brisk_version.'), NEWS: usage of reader/writer locking instead of generic exclusive locking.',
'If you want to subscribe our Mailing List, click it!' ) );
@@ -288,6 +288,18 @@ Copyright 2006-2012 Matteo Nasta
version '.$G_brisk_version.'
Copyright 2006-2012 Matteo Nastasi (aka mop)
');
+function addrtoipv4($addr)
+{
+ $ipv4addr_arr = explode(':' , $addr);
+ if (isset($ipv4addr_arr[3])) {
+ $ipv4addr = $ipv4addr_arr[3];
+ }
+ else {
+ $ipv4addr = $addr;
+ }
+ return $ipv4addr;
+}
+
function mop_flush()
{
for ($i = 0; $i < ob_get_level(); $i++)
@@ -325,42 +337,6 @@ function file_unlock($res)
}
}
-function webservers_exceeded()
-{
- return(file_exists(PROXY_PATH."/webservers_exceded.flag"));
-}
-
-function webservers_check()
-{
- GLOBAL $G_webserver_max;
-
- /* FIXME: check all procs expirations */
- return (10);
-
- $ct = 0;
-
- $dh = opendir('/proc');
- while (($file = readdir($dh)) !== false) {
- if (preg_match('/[0-9]+/', $file)) {
- $cmdline = explode("\0", file_get_contents('/proc/'.$file.'/cmdline'));
- // echo "xxx".$cmdline[0].$n;
- if (strstr('/usr/sbin/apache2', $cmdline[0]) != FALSE) {
- // echo "yyy".$cmdline[0].$n;
- $ct++;
- }
- }
- }
- closedir($dh);
-
- if ($ct >= $G_webserver_max) {
- touch(PROXY_PATH."/webservers_exceded.flag");
- }
- else {
- unlink(PROXY_PATH."/webservers_exceded.flag");
- }
- return ($ct);
-}
-
$escpush_from = array("\\", "\"");
$escpush_to = array("\\\\", "\\\"");
function escpush($s)
@@ -672,46 +648,49 @@ class Table {
-class Room {
+class Room
+{
static $delta_t;
-
- var $user;
- var $table;
- var $match;
- var $comm; // commands for many people
- var $step; // current step of the comm array
- var $garbage_timeout;
- var $shm_sz;
-
- function Room () {
- $this->user = array();
- $this->table = array();
- $this->match = array();
-
- for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
- $this->user[$i] = User::create($this, $i, "", "");
- }
-
- for ($i = 0 ; $i < TABLES_N ; $i++) {
- $this->table[$i] = Table::create($i);
- /* OLD METHOD
- if ($i < 12) {
- $row = ( (((int)($i / 4)) % 2) == 0 );
- $col = ($i % 2 == 0);
- $this->table[$i]->auth_only = (($row && $col) || (!$row && !$col));
- }
- else {
- $this->table[$i]->auth_only = FALSE;
- }
- */
- if ($i < TABLES_AUTH_N)
- $this->table[$i]->auth_only = TRUE;
- else
- $this->table[$i]->auth_only = FALSE;
+
+ var $crystal_filename;
+ var $user;
+ var $table;
+ var $match;
+ var $comm; // commands for many people
+ var $step; // current step of the comm array
+ var $garbage_timeout;
+ var $shm_sz;
+
+ function Room ($crystal_filename) {
+ $this->crystal_filename = $crystal_filename;
+ $this->user = array();
+ $this->table = array();
+ $this->match = array();
+
+ for ($i = 0 ; $i < MAX_PLAYERS ; $i++) {
+ $this->user[$i] = User::create($this, $i, "", "");
+ }
+
+ for ($i = 0 ; $i < TABLES_N ; $i++) {
+ $this->table[$i] = Table::create($i);
+ /* OLD METHOD
+ if ($i < 12) {
+ $row = ( (((int)($i / 4)) % 2) == 0 );
+ $col = ($i % 2 == 0);
+ $this->table[$i]->auth_only = (($row && $col) || (!$row && !$col));
+ }
+ else {
+ $this->table[$i]->auth_only = FALSE;
+ }
+ */
+ if ($i < TABLES_AUTH_N)
+ $this->table[$i]->auth_only = TRUE;
+ else
+ $this->table[$i]->auth_only = FALSE;
+ }
+ $this->garbage_timeout = 0;
+ $this->shm_sz = SHM_DIMS_MIN;
}
- $this->garbage_timeout = 0;
- $this->shm_sz = SHM_DIMS_MIN;
- }
function garbage_manager($force)
{
@@ -728,8 +707,6 @@ class Room {
return ($ismod);
}
- webservers_check();
-
// Before all align times with table timeout
for ($table_idx = 0 ; $table_idx < TABLES_N ; $table_idx++) {
$table_cur = $this->table[$table_idx];
@@ -785,7 +762,7 @@ class Room {
$user_cur->bantime = $bri_user->bantime;
}
- log_legal($curtime, 'xxx', $user_cur, "STAT:DESTROY_GAME", $plist);
+ log_legal($curtime, $user_cur->ip, $user_cur, "STAT:DESTROY_GAME", $plist);
$this->room_join_wakeup($user_cur, FALSE, 0);
$table_cur->table_token = "";
@@ -822,7 +799,7 @@ class Room {
for ($i = 0 ; $i < $table_cur->player_n ; $i++) {
$plist .= '|'.$this->user[$table_cur->player[$i]]->sess;
}
- log_legal($curtime, 'xxx', $user_cur, "STAT:DESTROY_GAME(RECOVERY)", $plist);
+ log_legal($curtime, $user_cur->ip, $user_cur, "STAT:DESTROY_GAME(RECOVERY)", $plist);
$this->room_join_wakeup($user_cur, TRUE, -2);
$table_cur->table_token = "";
@@ -902,7 +879,7 @@ class Room {
$ret .= sprintf('stat = "%s";', $user->stat);
- $ret .= root_wellcome($user);
+ $ret .= root_welcome($user);
if ($user->flags & USER_FLAG_DBFAILED) {
$ret .= "gst.st = ".($user->step+1)."; ";
$ret .= show_notify($mlang_brisk['db_failed'][$G_lang], 0, $mlang_brisk['btn_close'][$G_lang], 400, 140);
@@ -1463,6 +1440,18 @@ class Room {
else if (strcasecmp($st_str, "pulizie") == 0) {
$st = USER_FLAG_S_MOP;
}
+ else if (strcasecmp($st_str, "babbo") == 0) {
+ $st = USER_FLAG_S_BABBO;
+ }
+ else if (strcasecmp($st_str, "renna") == 0) {
+ $st = USER_FLAG_S_RENNA;
+ }
+ else if (strcasecmp($st_str, "pupazzo") == 0) {
+ $st = USER_FLAG_S_PUPAZ;
+ }
+ else if (strcasecmp($st_str, "vischio") == 0) {
+ $st = USER_FLAG_S_VISCH;
+ }
else {
/* MLANG: "Questo stato non esiste." */
$to_user = sprintf('chatt_sub("%s", [2,"%s"],"%s");', $dt, NICKSERV, $mlang_brisk['statunkn'][$G_lang]);
@@ -1507,7 +1496,7 @@ class Room {
$to_room = $to_user;
}
- log_legal($curtime, 'xxx', $user,
+ log_legal($curtime, $user->ip, $user,
($user->stat == 'room' ? 'room' : 'table '.$user->table),$msg);
$user->chat_lst = "$msg";
@@ -1717,6 +1706,7 @@ class Room {
$ghost_user = $this->user[$ghost];
$curtime = time();
+ $ghost_user->comm[$ghost_user->step % COMM_N] = "";
$ghost_user->step_inc();
if ($sess == "") {
$sess = uniqid("");
@@ -1734,6 +1724,7 @@ class Room {
$bri = $this->match[$table_idx];
if ($bri->the_end != TRUE) {
+ $bri->user[$ghost_user->table_pos]->comm[$bri->user[$ghost_user->table_pos]->step % COMM_N] = "";
$bri->user[$ghost_user->table_pos]->step_inc();
$bri->user[$ghost_user->table_pos]->sess = $sess;
}
@@ -1861,10 +1852,17 @@ class Room {
}
// Static functions
- static function create()
+ static function create($crystal_filename)
{
- $room = new Room();
-
+ if (($room_ser = @file_get_contents($crystal_filename)) == FALSE ||
+ ($room = unserialize($room_ser)) == FALSE) {
+ fprintf(STDERR, "NEW ROOM\n");
+ $room = new Room($crystal_filename);
+ }
+ else {
+ fprintf(STDERR, "ROOM FROM FILE\n");
+ }
+
return $room;
}
@@ -1964,7 +1962,16 @@ class Room {
return (FALSE);
}
-
+ function dump_data()
+ {
+ $room_ser = serialize($this);
+ $room_ser_len = mb_strlen($room_ser, "ASCII");
+ if (file_put_contents($this->crystal_filename, $room_ser) == $room_ser_len) {
+ return (TRUE);
+ }
+
+ return (FALSE);
+ }
function save_data($room)
{
@@ -2116,8 +2123,13 @@ class Room {
printf("NEW_SOCKET (root): %d\n", intval($new_socket));
$enc = get_encoding($header);
- if (isset($header['User-Agent']) && strstr($header['User-Agent'], "MSIE")) {
- $transp_type = "htmlfile";
+ if (isset($header['User-Agent'])) {
+ if (strstr($header['User-Agent'], "MSIE")) {
+ $transp_type = "htmlfile";
+ }
+ else {
+ $transp_type = "xhr";
+ }
}
else {
$transp_type = "iframe";
@@ -2150,8 +2162,11 @@ class Room {
do {
if (!isset($cookie['sess'])
|| (($user = $this->get_user($cookie['sess'], $idx)) == FALSE)) {
- $content = User::stream_fini($s_a_p->rndstr, TRUE);
+ if (($transp = gpcs_var('transp', $get, $post, $cookie)) === FALSE)
+ $transp = "iframe";
+ $content = User::stream_fini($transp, $s_a_p->rndstr, TRUE);
+
$s_a_p->pgflush_try_add($enc, $new_socket, 20, $header_out, $content);
return TRUE;
@@ -2585,8 +2600,8 @@ function log_shme($log)
-// function log_legal($curtime, $sess, $name, $where, $mesg)
-function log_legal($curtime, $addr, $user, $where, $mesg)
+// function log_legal($curtime, $sess, $name, $where, $mesg)
+function log_legal($curtime, $addr, $user, $where, $mesg)
{
if (($fp = @fopen(LEGAL_PATH."/legal.log", 'a')) != FALSE) {
@@ -2636,7 +2651,7 @@ function show_notify_ex($text, $tout, $butt, $w, $h, $is_opaque, $block_time)
}
-function root_wellcome($user)
+function root_welcome($user)
{
GLOBAL $root_wellarr, $G_lang;
$ret = "";