X-Git-Url: https://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=web%2FObj%2Fbrisk.phh;h=4f304e45c8bdfaaa86bcc35e5088af848af35067;hb=15d64a141d65abceb973f6df4a5065f441b01965;hp=d2b7173ec646309e80075e4cae3c1b12cb2e76f2;hpb=7f71718f94358b4196988e4596619cfd87205acc;p=brisk.git diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index d2b7173..4f304e4 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 = "3.6.3"; +$G_brisk_version = "4.1.1"; /* MLANG: ALL THE INFO STRINGS IN brisk.phh */ -$root_wellarr = array( 'it' => array ( 'Brisk (Ver. '.$G_brisk_version.'), NOVITA\': nuovo sistema di evidenziazione degli utenti registrati.', +$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, tanti bug fixati.', '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!' ) ); @@ -984,7 +984,7 @@ class Room { $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++; hstm.stop(); window.onunload = null; window.onbeforeunload = null; document.location.assign("index.php");|'; + $ret .= 'gst.st_loc++; xstm.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"); } @@ -1219,7 +1219,7 @@ class Room { $only_you = FALSE; // common settings - $msg = substr($mesg, 6, 128); + $msg = mb_substr($mesg, 6, 128, "UTF-8"); $curtime = time(); $dt = date("H:i ", $curtime); $target = ""; @@ -1561,46 +1561,27 @@ class Room { } if ($to_tabl) { - // FIXME BRISK4: include for each kind of table - require_once("${G_base}briskin5/Obj/briskin5.phh"); - // Before all align times with table timeout - for ($table_idx = 0 ; $table_idx < TABLES_N ; $table_idx++) { - $table_cur = $this->table[$table_idx]; - // if the table is complete and exists its shared mem we get the info about users lacc - - if ($table_cur->player_n == PLAYERS_N) { - log_main("PLAYERS == N TABLE ".$table_idx); - - if (($sem = Bin5::lock_data(TRUE, $table_idx)) != FALSE) { - log_main("bin5 lock data success"); - - $no_recovery = FALSE; - if (($bri = Bin5::load_data($table_idx)) != FALSE) { - if ($table_cur->table_token != $bri->table_token) { - log_main("ERROR: not matching table_token. Room: ".$table_cur->table_token." Table: ".$bri->table_token); - $bri = FALSE; - } - } - - if ($bri != FALSE) { - $bri_table = $bri->table[0]; - for ($i = 0 ; $i < $bri_table->player_n ; $i++) { - // stat must be "table" by definition - $bri_user = $bri->user[$i]; + // FIXME BRISK4: include for each kind of table + require_once("${G_base}briskin5/Obj/briskin5.phh"); + // Before all align times with table timeout + for ($table_idx = 0 ; $table_idx < TABLES_N ; $table_idx++) { + if (isset($this->match[$table_idx])) { + $bri = $this->match[$table_idx]; + + $bri_table = $bri->table[0]; + for ($i = 0 ; $i < $bri_table->player_n ; $i++) { + // stat must be "table" by definition + $bri_user = $bri->user[$i]; - if ($target != "" && $bri_user->name != $target) - continue; - log_main("writa: ".$user_mesg); - $bri_user->comm[$bri_user->step % COMM_N] = "gst.st = ".($bri_user->step+1)."; "; - $bri_user->comm[$bri_user->step % COMM_N] .= $to_tabl; - $bri_user->step_inc(); - } - Bin5::save_data($bri); - } - Bin5::unlock_data($sem); - } // bri::lock_data - } // if ($table_cur->player_n == PLAYERS_N) { - } // for ($table_idx = 0 ; $table_idx < TABLES_N ; $table_idx++) { + if ($target != "" && $bri_user->name != $target) + continue; + log_main("writa: ".$user_mesg); + $bri_user->comm[$bri_user->step % COMM_N] = "gst.st = ".($bri_user->step+1)."; "; + $bri_user->comm[$bri_user->step % COMM_N] .= $to_tabl; + $bri_user->step_inc(); + } + } // if (isset($this->match + } // for ($table_idx = 0 ; $table_idx < TABLES_N ; $table_idx++) { } // if ($to_tabl == true ... if ($update_room) { @@ -1736,6 +1717,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(""); @@ -1748,18 +1730,16 @@ class Room { // If user at the table we need to update the table data too $table_idx = $ghost_user->table; if ($ghost_user->stat == "table" && $this->table[$table_idx]->player_n == PLAYERS_N) { - // FIXME BRISK4: include for each kind of table - require_once("${G_base}briskin5/Obj/briskin5.phh"); - if (($brisem = Bin5::lock_data(TRUE, $table_idx)) != FALSE) { - if (($bri = Bin5::load_data($table_idx)) != FALSE) { - if ($bri->the_end != TRUE) { - $bri->user[$ghost_user->table_pos]->step_inc(); - $bri->user[$ghost_user->table_pos]->sess = $sess; - Bin5::save_data($bri); - } + require_once("${G_base}briskin5/Obj/briskin5.phh"); + if (isset($this->match[$table_idx])) { + $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; + } } - Bin5::unlock_data($brisem); - } } $idx = $ghost; @@ -1896,7 +1876,7 @@ class Room { GLOBAL $sess; do { - if (($tok = @ftok(FTOK_PATH."/main", "B")) == -1) { + if (($tok = @ftok(FTOK_PATH."/main", "C")) == -1) { log_main("ftok failed"); break; } @@ -1961,7 +1941,7 @@ class Room { // var_dump($room); - if (($tok = @ftok(FTOK_PATH."/main", "B")) == -1) + if (($tok = @ftok(FTOK_PATH."/main", "C")) == -1) return (FALSE); while ($room->shm_sz < SHM_DIMS_MAX) { @@ -1995,7 +1975,7 @@ class Room { $ret = FALSE; $shm = FALSE; - if (($tok = @ftok(FTOK_PATH."/main", "B")) == -1) + if (($tok = @ftok(FTOK_PATH."/main", "C")) == -1) return (FALSE); // SHSPLIT: before save the $room you must save users, @@ -2133,31 +2113,38 @@ class Room { return ($ret); } - function request_mgr(&$s_a_p, &$header_out, &$new_socket, $path, $addr, $get, $post, $cookie) + function request_mgr(&$s_a_p, $header, &$header_out, &$new_socket, $path, $addr, $get, $post, $cookie) { 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"; + } + else { + $transp_type = "iframe"; + } force_no_cache($header_out); switch ($path) { case "": case "index.php": ob_start(); - index_main($this, $header_out, $addr, $get, $post, $cookie); - $content = ob_get_contents(); - ob_end_clean(); + index_main($this, $transp_type, $header_out, $addr, $get, $post, $cookie); + $content = ob_get_contents(); + ob_end_clean(); - $s_a_p->pgflush_try_add($new_socket, 20, $header_out, $content); - return TRUE; + $s_a_p->pgflush_try_add($enc, $new_socket, 20, $header_out, $content); + return TRUE; - break; + break; case "index_wr.php": ob_start(); index_wr_main($this, $addr, $get, $post, $cookie); $content = ob_get_contents(); ob_end_clean(); - - $s_a_p->pgflush_try_add($new_socket, 20, $header_out, $content); + + $s_a_p->pgflush_try_add($enc, $new_socket, 20, $header_out, $content); return TRUE; break; @@ -2165,9 +2152,9 @@ class Room { do { if (!isset($cookie['sess']) || (($user = $this->get_user($cookie['sess'], $idx)) == FALSE)) { - $content = User::stream_fini(TRUE); + $content = User::stream_fini($s_a_p->rndstr, TRUE); - $s_a_p->pgflush_try_add($new_socket, 20, $header_out, $content); + $s_a_p->pgflush_try_add($enc, $new_socket, 20, $header_out, $content); return TRUE; break; @@ -2179,11 +2166,11 @@ class Room { printf("CLOSE AND OPEN AGAIN ON IFRA2\n"); $user->rd_socket_set(NULL); } - + $content = ""; - $user->stream_init($header_out, $content, $get, $post, $cookie); + $user->stream_init($s_a_p->rndstr, $enc, $header_out, $content, $get, $post, $cookie); - $response = headers_render($header_out, -1).chunked_content($content); + $response = headers_render($header_out, -1).chunked_content($user->rd_zls_get(), $content); $response_l = mb_strlen($response, "ASCII"); $wret = @fwrite($new_socket, $response, $response_l); @@ -2211,7 +2198,7 @@ class Room { $subs = "briskin5/"; $subs_l = strlen($subs); if (!strncmp($path, $subs, $subs_l)) { - $ret = Bin5::request_mgr(&$s_a_p, &$header_out, &$new_socket, substr($path, $subs_l) , $addr, $get, $post, $cookie); + $ret = Bin5::request_mgr(&$s_a_p, $header, &$header_out, &$new_socket, substr($path, $subs_l) , $addr, $get, $post, $cookie); return ($ret); } break; @@ -2677,7 +2664,7 @@ function validate_sess($sess) function validate_name($name) { - $name_new = str_replace(' ', '_', substr(trim($name),0,12)); + $name_new = str_replace(' ', '_', mb_substr(trim($name),0,12, "UTF-8")); for ($i = 0 ; $i < strlen($name_new) ; $i++) { $c = $name_new[$i];