X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;ds=inline;f=web%2FObj%2Fuser.phh;h=a7709643659227ec8daf35863483916549dec0eb;hb=428188cc059efade2698f32a0b40861af626cfde;hp=8beb49bfdd4fe54923ba1c2e1d14858152c4c0d9;hpb=b9ff6e8b0e1c6317d46b781ca35cfefaa2466b2d;p=brisk.git diff --git a/web/Obj/user.phh b/web/Obj/user.phh index 8beb49b..a770964 100644 --- a/web/Obj/user.phh +++ b/web/Obj/user.phh @@ -21,6 +21,9 @@ * Suite 330, Boston, MA 02111-1307, USA. */ +require_once("${G_base}Obj/transports.phh"); + + // User flags define('USER_FLAG_AUTH', 0x02); @@ -58,72 +61,6 @@ define('USER_FLAG_TY_DISABLE', 0x800000); // done define('RD_ENDTIME_DELTA', 240); define('RD_KEEPALIVE_TOUT', 4); -$G_four_rnd_string = - "GGZDGDRBXDWFXHGPYAAVDXEKFDUWSTEDTDVXBXQPMZAIFPNLRPTWMJAZRHXTIRNZ" -."HTZXAUVJDCLXENDCLIZXSSEQQGUADYEKNNANJWEGRUFHPLUNSEROZQJSLMUYNUVG" -."FPLQAGCMTTGIRRXZFBFQFTRBYPHTWFSXFKHKYBRDAOSOURCMEVGPVXJVUQAOCFPV" -."OQSUBOYWOZLDGRPQQIBNOTHFUHTCRRZOBCUONAXIYUYCJBFTVNWIITVHBYLNMPWR" -."LPMMIROZVRUNYXSJSMJINSXGACXDMJAEPNFFAERHVDJELXSPPJWKMNFGVGAPTIMR" -."VMVMVCLWKMPOAJWZGPSPFEXVNQANXGLZIQSCBIYVFSTXZOODZYCXUVUZFCLFGHUJ" -."TXZWFHSMFJQAZOQRANKZJAUJHFJIKHIIEQUSDXUBRPQBKMIAVTWYQEOIMYKKDTEV" -."EYERPXKFJXWNIMJPOFFMWJCJSLFZKPNRNVXIDLUSRVBGLUCQZCUQCZNAORDXMRSS" -."UBNMPXJDQXXLMQRCTOCCJJWHFSUWBNWXWZHPKWYYKPZIMBXTYAZXJJQ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WTTPEUUCKXGBTXAJBAXYLMUVWWGWZYTXTKYVRXSOXOBHERLZJPRDXIQZRQLU" -."TXCLIJNKIRWMVQEJTLHZIDTNGBOYSULGWUTSYTKGNMGZFWKXCCZXGOQGZNQFZJUK" -."JMBQPQPZOPYTQMPEFTZUDLIIBZAZSZAPNILMIKMPKXJIRHRQMFSTJKAPIIQWOFYQ" -."HGANJGJSUGDIENDVEQFEMUJBGMZBPHLOARCVGMUUCHLCDDNKSJSCKYSALUAGUZFN" -."YVURVLREBESGXPANIDKGLPJZGXLKFKTPEQBQEINOYYZTBMPFBLBKIKVPAPFDKKRZ" -."YMVUBYCYTRXCIICUPTXKGQOIJSVSWPYVALIROWGVXDXGNSRVZOLEJHNRSUKHNTRJ" -."LQZQKBEFXYKIPXJRZMQMJKUGCNUKBZBWABPLHMAJJZVBCWOQYCLSGDUKJSTHTVXV" -."OUGJVADGJWGVNBNXYRZDSNLOZDIQRKOQAKJJDKXRMMTXRVTLOMTETNROPDYNXAGR"; - $S_load_stat = array( 'rU_heavy' => 0, 'lL_laccgarb' => 0, 'wU_lacc_upd' => 0, @@ -163,6 +100,8 @@ class User { 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 $rd_zls; // zlibstream object handle if compressed stream, else FALSE + var $rd_transp; // class that define stream encapsulation type (iframe, xhr, ...) var $comm; // commands array // var $asta_card; // @@ -220,6 +159,8 @@ class User { $thiz->rd_scristp = -1; $thiz->rd_kalive = -1; $thiz->rd_cache = ""; + $thiz->rd_zls = FALSE; + $thiz->rd_transp = NULL; $thiz->asta_card = -2; $thiz->asta_pnt = -1; @@ -353,7 +294,7 @@ class User { return ($thiz); } - function rd_data_set($curtime, $stat, $subst, $step, $from) + function rd_data_set($curtime, $enc, $stat, $subst, $step, $from) { $this->rd_endtime = $curtime + RD_ENDTIME_DELTA; $this->rd_stat = $stat; @@ -362,6 +303,8 @@ class User { $this->rd_from = $from; $this->rd_scristp = 0; $this->rd_kalive = $curtime + RD_KEEPALIVE_TOUT; + $this->rd_zls = ZLibStream::create($enc); + $this->rd_transp = new Transport_iframe(); } function rd_socket_get() { @@ -369,6 +312,12 @@ class User { } function rd_socket_set($sock) { + if ($sock == NULL) { + if ($this->rd_zls) { + $this->rd_zls->destroy(); + $this->rd_zls = FALSE; + } + } $this->rd_socket = $sock; } @@ -409,6 +358,11 @@ class User { $this->rd_cache = $cache; } + function rd_zls_get() + { + return ($this->rd_zls); + } + function idx_get() { return ($this->idx); } @@ -523,110 +477,6 @@ class User { $this->the_end = FALSE; } - static function load_data($id, $sess) - { - log_main("load_data: id [".$id."] sess [".($sess == FALSE ? "FALSE" : $sess)."] "); - - do { - if (($tok = @ftok(FTOK_PATH."/user".$id, "B")) == -1) { - log_main("ftok failed"); - break; - } - - if (($shm_sz = sharedmem_sz($tok)) == -1) { - log_main("shmop_open failed"); - } - - if ($shm_sz == -1) - $shm_sz = SHM_DIMS_U_MIN; - - if ($shm = shm_attach($tok, $shm_sz)) { - if (($user = @shm_get_var($shm, $tok)) == FALSE) { - break; - } - if ($sess != FALSE && $user->sess != $sess) { - break; - } - log_only("user == ".($user == FALSE ? "FALSE" : "TRUE")." user === ".($user === FALSE ? "FALSE" : "TRUE")." user isset ".(isset($user) ? "TRUE" : "FALSE")); - - if ($user == FALSE) { - log_only("INIT MAIN DATA"); - - // SHSPLIT FIXME: init_data for User class ?? - $user = self::create($id, "", ""); - if (@shm_put_var($shm, $tok, $user) == FALSE) { - log_only("PUT_VAR FALLITA ".strlen(serialize($user))); - log_only(serialize($user)); - } - log_shme("User::save_data2"); - } - else { - if ($sess != FALSE) { - /* - * NOTE: this part is for check only, theoretically - * user->step anch proxy_step are set allways at the same value - */ - $old_step = $user->step; - $arr = self::load_step($sess); - $user->step = $arr['s']; - if ($old_step != $user->step) { - log_crit("steps are diffetents User->step ".$user->step." Old_step: ".$old_step); - } - } - } - $user->shm_sz = $shm_sz; - - shm_detach($shm); - } - - // - // SHSPLIT: load users from the shared memory - // - return ($user); - } while (0); - - return (FALSE); - } - - - static function save_data($user, $id) - { - GLOBAL $sess; - - $shm = FALSE; - - if (($tok = @ftok(FTOK_PATH."/user".$id, "B")) == -1) { - return (FALSE); - } - while ($user->shm_sz < SHM_DIMS_U_MAX) { - if (($shm = shm_attach($tok, $user->shm_sz)) == FALSE) - break; - - // log_only("PUT_VAR DI ".strlen(serialize($user))); - if (@shm_put_var($shm, $tok, $user) != FALSE) { - shm_detach($shm); - if ($user->sess != "") - $user->save_step(); - - log_shme("User::save_data"); - - log_main("User[".$id."] saved."); - return (TRUE); - } - if (shm_remove($shm) === FALSE) { - log_only("REMOVE FALLITA"); - break; - } - shm_detach($shm); - $user->shm_sz += SHM_DIMS_U_DLT; - } - - if ($shm) - shm_detach($shm); - - return (FALSE); - } - function myname_innerHTML() { $class_id = ($this->flags & USER_FLAG_AUTH) + 1; @@ -637,27 +487,20 @@ class User { /* INDEX_RD_IFRA PORT */ - protected function blocking_error($is_unrecoverable) + static 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");')); } // FIXME TO SUPPORT iframe protected function page_sync($sess, $page, $table_idx, $table_token) { - GLOBAL $is_page_streaming; - // log_rd2("page_sync:".var_export(debug_backtrace())); - $is_page_streaming = TRUE; - log_rd2("PAGE_SYNC"); printf("xXx USER::PAGE_SYNC [%s]\n", get_class($this)); - return (sprintf('createCookie("table_idx", %d, 24*365, cookiepath); createCookie("table_token", "%s", 24*365, cookiepath); hstm.stop(); window.onunload = null; window.onbeforeunload = null; document.location.assign("%s");', $table_idx, $table_token, $page)); + return (sprintf('createCookie("table_idx", %d, 24*365, cookiepath); createCookie("table_token", "%s", 24*365, cookiepath); xstm.stop(); window.onunload = null; window.onbeforeunload = null; document.location.assign("%s");', $table_idx, $table_token, $page)); } @@ -665,7 +508,7 @@ class User { 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 $first_loop; GLOBAL $G_with_splash, $G_splash_content, $G_splash_interval, $G_splash_idx; GLOBAL $G_splash_w, $G_splash_h, $G_splash_timeout; @@ -679,23 +522,6 @@ class 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); @@ -709,10 +535,9 @@ class 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); @@ -822,30 +647,16 @@ class User { return ($ret); } // function maincheck (... -public static function stream_fini($is_unrecoverable) + public static function stream_fini($init_string, $is_unrecoverable) { - GLOBAL $G_four_rnd_string; - - // IF IFRAME THEN: - $body = ""; - $body .= sprintf(" -
- - - - -"); - $body .= sprintf("\n", $G_four_rnd_string); - $body .= sprintf("", 0, escpush(self::blocking_error($is_unrecoverable)) ); + printf("xXx user::stream_fini\n"); + + // FIXME: dynamic "Transport_" type + $tans_class = "Transport_iframe"; + $body = $tans_class::fini($init_string, self::base_get(), static::blocking_error($is_unrecoverable)); + // ELSE IF XHR THEN: - // return (self::blocking_error($is_unrecoverable)); + // return (static::blocking_error($is_unrecoverable)); return ($body); } @@ -859,22 +670,16 @@ push(\"%s\"); stat step */ -function stream_init(&$header_out, &$body, $get, $post, $cookie) +function stream_init($init_string, $enc, &$header_out, &$body, $get, $post, $cookie) { - GLOBAL $G_four_rnd_string; - $curtime = time(); - + printf("CLASS: [%s] base: [%s]\n", get_class($this), self::base_get()); - - $is_page_streaming = FALSE; // (webservers_exceeded() || stristr($HTTP_USER_AGENT, "Mozilla/5.0 (Windows NT 6.1; rv:5.0)") || stristr($HTTP_USER_AGENT, "MSIE") || stristr($HTTP_USER_AGENT, "CHROME") ? TRUE : FALSE); - - $header_out['Cache-Control'] = 'no-cache, must-revalidate'; // HTTP/1.1 - $header_out['Expires'] = 'Mon, 26 Jul 1997 05:00:00 GMT'; // Date in the past - $header_out['Content-type'] = 'text/html; charset="utf-8"'; + + // (webservers_exceeded() || stristr($HTTP_USER_AGENT, "Mozilla/5.0 (Windows NT 6.1; rv:5.0)") || stristr($HTTP_USER_AGENT, "MSIE") || stristr($HTTP_USER_AGENT, "CHROME") ? TRUE : FALSE); log_load("index_rd_ifra_init.php"); - + if (($from = gpcs_var('from', $get, $post, $cookie)) === FALSE) $from = ""; if (($stat = gpcs_var('stat', $get, $post, $cookie)) === FALSE) @@ -884,32 +689,16 @@ function stream_init(&$header_out, &$body, $get, $post, $cookie) if (($step = gpcs_var('step', $get, $post, $cookie)) === FALSE) unset($step); - $this->rd_data_set($curtime, $stat, $subst, $step, $from); - $cc = get_called_class(); - - $body .= sprintf(" - - - - - -"); - $body .= sprintf("\n", $G_four_rnd_string); + $this->rd_data_set($curtime, $enc, $stat, $subst, $step, $from); + + $body .= $this->rd_transp->init($enc, &$header_out, $init_string, self::base_get(), $this->rd_scristp); return TRUE; -} + } function stream_main(&$body, $get, $post, $cookie) { - GLOBAL $is_page_streaming, $G_splash_idx; - // FIXME: only to test fwrite - // GLOBAL $G_four_rnd_string; + GLOBAL $G_splash_idx; $CO_splashdate = "CO_splashdate".$G_splash_idx; if (($splashdate = gpcs_var("$CO_splashdate", $get, $post, $cookie)) === FALSE) @@ -919,8 +708,7 @@ function stream_main(&$body, $get, $post, $cookie) if (($table_token = gpcs_var("table_token", $get, $post, $cookie)) === FALSE) $table_token = ""; - $is_page_streaming = FALSE; - log_rd2("FROM OUTSIDE - STAT: ".$this->rd_stat." SUBST: ".$this->rd_subst." STEP: ".$this->rd_step." FROM: ".$this->rd_from. "IS_PAGE:" . $is_page_streaming); + log_rd2("FROM OUTSIDE - STAT: ".$this->rd_stat." SUBST: ".$this->rd_subst." STEP: ".$this->rd_step." FROM: ".$this->rd_from); $pre_main = gettimeofday(TRUE); @@ -930,14 +718,8 @@ function stream_main(&$body, $get, $post, $cookie) $old_step = $this->rd_step; printf("xXx PRE : rd_step %d\n", $this->rd_step); if (($ret = $this->maincheck($old_stat, $old_subst, $old_step, $this->rd_stat, $this->rd_subst, $this->rd_step, $splashdate, $table_idx, $table_token)) != FALSE) { - $body .= sprintf("", $this->rd_scristp++, escpush($ret) ); - + $body .= $this->rd_transp->chunk( $this->rd_scristp++, $ret); log_rd2(0, 'index_rd.php: after mop_flush (begin: '.sprintf("%f", $pre_main).')'); - if ($is_page_streaming) - return TRUE; } printf("xXx POST: rd_step %d\n", $this->rd_step); @@ -946,11 +728,7 @@ push(\"%s\"); function stream_keepalive($with_ping) { - return (sprintf("", $this->rd_scristp++, ($with_ping ? "\"act_ping();\"" : "null"))); - + return ($this->rd_transp->chunk( $this->rd_scristp++, ($with_ping ? "act_ping();" : NULL))); } static function base_get() @@ -963,4 +741,4 @@ static function base_get() } // end class User -?> \ No newline at end of file +?>