X-Git-Url: https://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=web%2Fbriskin5%2FObj%2Fbriskin5.phh;h=94a8940b6043d36e741b99ed8ec8cdeb010e8a56;hb=879ef1677b59eb159d0b9982a8fb5b056f13bff7;hp=c5ad7cec580b09549e5045031bc2490d948f317b;hpb=22d0d66d55607bc8941922fc1bf4d818664abbc2;p=brisk.git diff --git a/web/briskin5/Obj/briskin5.phh b/web/briskin5/Obj/briskin5.phh index c5ad7ce..94a8940 100644 --- a/web/briskin5/Obj/briskin5.phh +++ b/web/briskin5/Obj/briskin5.phh @@ -2,7 +2,7 @@ /* * brisk - briskin5.phh * - * Copyright (C) 2006-2011 Matteo Nastasi + * Copyright (C) 2006-2012 Matteo Nastasi * mailto: nastasi@alternativeoutput.it * matteo.nastasi@milug.org * web: http://www.alternativeoutput.it @@ -477,13 +477,15 @@ class Bin5_user extends User { } */ - function spawn($from, &$bri, $table, $table_pos) + function spawn($from, &$bri, $table, $table_pos, $get, $post, $cookie) { - GLOBAL $CO_bin5_pref_ring_endauct; - if (($thiz = new Bin5_user()) == FALSE) return (FALSE); - + + if (($CO_bin5_pref_ring_endauct = gpcs_var("CO_bin5_pref_ring_endauct", $get, $post, $cookie)) === FALSE) { + $CO_bin5_pref_ring_endauct = ""; + } + $thiz->parentcopy($from); /* NOTE: at this moment idx and table_pos fields have the same value @@ -498,7 +500,7 @@ class Bin5_user extends User { log_wr("Bin5 constructor"); $this->privflags = ($CO_bin5_pref_ring_endauct == "true" ? BIN5_USER_FLAG_RING_ENDAUCT : 0) | 0; - + $thiz->table_orig = $table; $thiz->table = 0; $thiz->table_pos = $table_pos; @@ -718,28 +720,22 @@ class Bin5_user extends User { return ($ret); } - static function blocking_error($is_unrecoverable) + protected function blocking_error($is_unrecoverable) { - GLOBAL $is_page_streaming; - - $is_page_streaming = TRUE; log_crit("BLOCKING_ERROR UNREC: ".($is_unrecoverable ? "TRUE" : "FALSE")); - return (sprintf(($is_unrecoverable ? 'hstm.stop(); ' : '').'window.onbeforeunload = null; window.onunload = null; document.location.assign("../index.php");')); + return (sprintf(($is_unrecoverable ? 'xstm.stop(); ' : '').'window.onbeforeunload = null; window.onunload = null; document.location.assign("../index.php");')); } protected function page_sync($sess, $page) { - GLOBAL $is_page_streaming; - - $is_page_streaming = TRUE; log_rd2("PAGE_SYNC"); printf("xXx BIN5_USER::PAGE_SYNC\n"); - return (sprintf('hstm.stop(); window.onbeforeunload = null; window.onunload = null; document.location.assign("%s");', $page)); + return (sprintf('xstm.stop(); window.onbeforeunload = null; window.onunload = null; document.location.assign("%s");', $page)); } protected function maincheck($cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_subst, &$new_step, $splashdate, $table_idx, $table_token) { - GLOBAL $G_lang, $mlang_indrd, $is_page_streaming; + GLOBAL $G_lang, $mlang_indrd; GLOBAL $G_with_splash, $G_splash_content, $G_splash_interval, $G_splash_idx; GLOBAL $G_splash_w, $G_splash_h, $G_splash_timeout; $CO_splashdate = "CO_splashdate".$G_splash_idx; @@ -752,23 +748,6 @@ class Bin5_user extends User { $ret = FALSE; $curtime = time(); - /* if ((($curtime - $this->lacc) > STREAM_TIMEOUT) || Room::garbage_time_is_expired($curtime)) { */ - /* $S_load_stat['lL_laccgarb']++; */ - - /* if (($curtime - $this->lacc) >= STREAM_TIMEOUT) { */ - /* $S_load_stat['wU_lacc_upd']++; */ - /* $this->lacc = $curtime; */ - /* } */ - - /* if (Room::garbage_time_is_expired($curtime)) { */ - /* log_only("F"); */ - - /* $S_load_stat['wR_garbage']++; */ - /* log_main("pre garbage_manager TRE"); */ - /* $this->room->garbage_manager(FALSE); */ - /* } */ - /* } */ - /* Nothing changed, return. */ if ($cur_step == $this->step) return (FALSE); @@ -782,10 +761,9 @@ class Bin5_user extends User { $S_load_stat['wR_minusone']++; - if ($this->the_end == TRUE) { - log_rd2("main_check: the end".var_export(debug_backtrace())); - $is_page_streaming = TRUE; - } + // if ($this->the_end == TRUE) { + // log_rd2("main_check: the end".var_export(debug_backtrace())); + // } if ($this->trans_step != -1) { log_rd2("TRANS USATO ".$this->trans_step); @@ -894,7 +872,7 @@ class Bin5 { var $table; var $comm; // commands for many people var $step; // current step of the comm array - // externalized var $garbage_timeout; + var $garbage_timeout; var $shm_sz; var $table_idx; @@ -926,7 +904,7 @@ class Bin5 { return TRUE; } - function Bin5 ($room, $table_idx, $table_token) { + function Bin5 ($room, $table_idx, $table_token, $get, $post, $cookie) { $this->user = array(); $this->table = array(); @@ -944,7 +922,7 @@ class Bin5 { for ($i = 0 ; $i < $table->player_n ; $i++) { $user[$table->player[$i]]->table_token = $table_token; - $this->user[$i] = Bin5_user::spawn($user[$table->player[$i]], $this, $table_idx, $i); + $this->user[$i] = Bin5_user::spawn($user[$table->player[$i]], $this, $table_idx, $i, $get, $post, $cookie); } $this->table[0] = Bin5_table::spawn(&$table); @@ -952,7 +930,7 @@ class Bin5 { $this->table_idx = $table_idx; $this->table_token = $table_token; - Bin5::garbage_time_expire_set($table_idx, 0); + $this->garbage_timeout = 0; log_wr("Bin5 constructor end"); } @@ -990,8 +968,7 @@ class Bin5 { /* Garbage collector degli utenti in timeout */ $ismod = FALSE; $curtime = time(); - // externalized if ($force || $this->garbage_timeout < $curtime) { - if ($force || Bin5::garbage_time_is_expired($this->table_idx, $curtime)) { + if ($force || $this->garbage_timeout < $curtime) { for ($i = 0 ; $i < BIN5_MAX_PLAYERS ; $i++) { $user_cur = $this->user[$i]; if ($user_cur->sess == "" || @@ -1029,8 +1006,7 @@ class Bin5 { } log_rd2($user_cur->sess." GARBAGE UPDATED!"); - // externalized $this->garbage_timeout = $curtime + GARBAGE_TIMEOUT; - Bin5::garbage_time_expire_set($this->table_idx, $curtime + GARBAGE_TIMEOUT); + $this->garbage_timeout = $curtime + GARBAGE_TIMEOUT; $ismod = TRUE; } @@ -1344,7 +1320,7 @@ class Bin5 { $user_cur->laccwr = $curtime; $ret = "gst.st = ".($user_cur->step+1)."; "; - $ret .= 'gst.st_loc++; hstm.stop(); window.onbeforeunload = null; window.onunload = null; document.location.assign("../index.php");|'; + $ret .= 'gst.st_loc++; xstm.stop(); window.onbeforeunload = null; window.onunload = null; document.location.assign("../index.php");|'; log_wr($user_cur->sess." BIN5_WAKEUP: ".$ret); $user_cur->comm[$user_cur->step % COMM_N] = $ret; @@ -1376,96 +1352,64 @@ class Bin5 { return ($is_ab); } - - static function garbage_time_is_expired($tab_id, $tm) - { - $ret = TRUE; - $fp = FALSE; - do { - if (file_exists(BIN5_PROXY_PATH."/table".$tab_id) == FALSE) - mkdir(BIN5_PROXY_PATH."/table".$tab_id, 0775, TRUE); - if (($fp = @fopen(BIN5_PROXY_PATH."/table".$tab_id."/garbage_time.expired", 'rb')) == FALSE) - break; - if (($s = fread($fp, 4)) == FALSE) - break; - if (mb_strlen($s, "ASCII") != 4) - break; - $arr = unpack('Le', $s); - if ($arr['e'] > $tm) - $ret = FALSE; - } while (0); - - if ($fp != FALSE) - fclose($fp); - - log_rd2("END: return ".($ret ? "TRUE" : "FALSE")); - - return ($ret); - } - - static function garbage_time_expire_set($tab_id, $tm) - { - do { - if (file_exists(BIN5_PROXY_PATH."/table".$tab_id) == FALSE) - mkdir(BIN5_PROXY_PATH."/table".$tab_id, 0775, TRUE); - if (($fp = @fopen(BIN5_PROXY_PATH."/table".$tab_id."/garbage_time.expired", 'wb')) == FALSE) - break; - fwrite($fp, pack("L",$tm)); - fclose($fp); - - return (TRUE); - } while (0); - - return (FALSE); - } - - static function request_mgr(&$s_a_p, &$header_out, &$new_socket, $path, $addr, $get, $post, $cookie) + static 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); + if (($table_idx = gpcs_var('table_idx', $get, $post, $cookie)) === FALSE) unset($table_idx); if (($table_token = gpcs_var('table_token', $get, $post, $cookie)) === FALSE) unset($table_token); + switch ($path) { case "": case "index.php": ob_start(); - bin5_index_main($header_out, $addr, $get, $post, $cookie); + bin5_index_main($transp_type, $header_out, $addr, $get, $post, $cookie); $content = ob_get_contents(); ob_end_clean(); - force_no_cache($header_out); - - $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; case "index_wr.php": - $bri = $s_a_p->app->match_get($table_idx, $table_token); - ob_start(); - bin5_index_wr_main($bri, $addr, $get, $post, $cookie); - $content = ob_get_contents(); - ob_end_clean(); - - force_no_cache($header_out); - - $s_a_p->pgflush_try_add($new_socket, 20, $header_out, $content); + // FIXME $content can be unset + if (isset($table_idx) && isset($table_token)) { + if (($bri = $s_a_p->app->match_get($table_idx, $table_token)) != FALSE) { + ob_start(); + bin5_index_wr_main($bri, $addr, $get, $post, $cookie); + $content = ob_get_contents(); + ob_end_clean(); + } + } + $s_a_p->pgflush_try_add($enc, $new_socket, 20, $header_out, $content); return TRUE; break; case "index_rd_ifra.php": do { - if (($bri = $s_a_p->app->match_get($table_idx, $table_token)) == NULL + if (!isset($table_idx) + || !isset($table_token) || !isset($cookie['sess']) + || ($bri = $s_a_p->app->match_get($table_idx, $table_token)) == NULL || (($user = $bri->get_user($cookie['sess'], $idx)) == FALSE)) { - $content = Bin5_user::stream_fini(TRUE); - $s_a_p->pgflush_try_add($new_socket, 20, $header_out, $content); + $content = Bin5_user::stream_fini($s_a_p->rndstr, TRUE); + $s_a_p->pgflush_try_add($enc, $new_socket, 20, $header_out, $content); - return TRUE; + return TRUE; break; } // close a previous opened index_read_ifra socket, if exists @@ -1477,8 +1421,8 @@ class Bin5 { } $content = ""; - $user->stream_init($header_out, $content, $get, $post, $cookie); - $response = headers_render($header_out, -1).chunked_content($content); + $user->stream_init($s_a_p->rndstr, $enc, $header_out, $content, $get, $post, $cookie); + $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); @@ -1672,6 +1616,7 @@ function show_table(&$bri, &$user, $sendstep, $is_transition, $is_again) /* NOTIFY FOR THE CARD MAKER */ if ($is_transition) { // && $user->subst == "asta" superfluo $ret .= show_table_info(&$bri, &$table, $table_pos); + $ret .= "setTimeout(preload_images, 500, g_preload_img_arr, g_imgct);"; } if (!$is_again) $ret .= table_wellcome($user);