X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=web%2FObj%2Fbrisk.phh;h=87185da28b58a1a463528a6034913faacc9c6300;hb=182eff6ad1aafbdcb765a4190a24a1c8f2f93f6b;hp=cc7ff2cb060e51b93c4e859ed591808fe07aeecf;hpb=b931144918e0a60462c3db827552669f7cd1d0d3;p=brisk.git diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index cc7ff2c..87185da 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -808,39 +808,46 @@ class User { */ } - function step_set($step) { - $this->step = $step; - - do { - if (validate_sess($this->sess) == FALSE) - break; - if (file_exists(PROXY_PATH) == FALSE) - mkdir(PROXY_PATH); - if (($fp = @fopen(PROXY_PATH."/".$this->sess.".step", 'w')) == FALSE) - break; - fwrite($fp, pack("LL",$this->step, $this->idx)); - fclose($fp); - - return (TRUE); - } while (0); + function step_set($step) + { + $this->step = $step & 0x7fffffff; + + do { + if (validate_sess($this->sess) == FALSE) + break; + if (file_exists(PROXY_PATH) == FALSE) + mkdir(PROXY_PATH); + if (($fp = @fopen(PROXY_PATH."/".$this->sess.".step", 'w')) == FALSE) + break; + fwrite($fp, pack("LL",$this->step, $this->idx)); + fclose($fp); - return (FALSE); + log_main("step_set [".$this->sess. "] [".$this->step."]"); + + return (TRUE); + } while (0); + + return (FALSE); } - + function step_inc($delta = 1) { - $this->step += $delta; - - if (validate_sess($this->sess)) { - if (file_exists(PROXY_PATH) == FALSE) - mkdir(PROXY_PATH); - $fp = fopen(PROXY_PATH."/".$this->sess.".step", 'w'); - fwrite($fp, pack("LL", $this->step, $this->idx)); - fclose($fp); - - return (TRUE); - } - - return (FALSE); + $this->step += $delta; + /* modularization because unpack() not manage unsigned 32bit int correctly */ + $this->step &= 0x7fffffff; + + if (validate_sess($this->sess)) { + if (file_exists(PROXY_PATH) == FALSE) + mkdir(PROXY_PATH); + $fp = fopen(PROXY_PATH."/".$this->sess.".step", 'w'); + fwrite($fp, pack("LL", $this->step, $this->idx)); + fclose($fp); + + log_main("step_inc [".$this->sess. "] [".$this->step."]"); + + return (TRUE); + } + + return (FALSE); } function reset() { @@ -864,12 +871,12 @@ class User { // SHSPLIT save and load function for the User class. - function load_data($id) + static function load_data($id, $sess) { - GLOBAL $sess; - // error_log("User::load_data BEGIN", 0); + log_main("load_data: id [".$id."] sess [".($sess == FALSE ? "FALSE" : $sess)."] "); + $doexit = FALSE; do { if (($tok = @ftok(FTOK_PATH."/user".$id, "B")) == -1) { @@ -888,7 +895,11 @@ class User { if ($shm = shm_attach($tok, $shm_sz)) { $user = @shm_get_var($shm, $tok); - log_only("bri == ".($user == FALSE ? "FALSE" : "TRUE")." bri === ".($user === FALSE ? "FALSE" : "TRUE")." bri isset ".(isset($user) ? "TRUE" : "FALSE")); + if ($sess != FALSE && $user->sess != $sess) { + $doexit = TRUE; + break; + } + log_only("user == ".($user == FALSE ? "FALSE" : "TRUE")." user === ".($user === FALSE ? "FALSE" : "TRUE")." user isset ".(isset($user) ? "TRUE" : "FALSE")); if (isset($user)) log_only("bri count ".count($user)); @@ -896,7 +907,7 @@ class User { log_only("INIT MAIN DATA"); // SHSPLIT FIXME: init_data for User class ?? - $user =& User::create($id, "", ""); + $user = User::create($id, "", ""); if (@shm_put_var($shm, $tok, $user) == FALSE) { log_only("PUT_VAR FALLITA ".strlen(serialize($user))); log_only(serialize($user)); @@ -921,7 +932,7 @@ class User { } - function save_data(&$user, $id) + function save_data($user, $id) { GLOBAL $sess; @@ -957,39 +968,39 @@ class User { } + static function step_get($sess) + { + $fp = FALSE; + do { + if (validate_sess($sess) == FALSE) + break; + + if (file_exists(PROXY_PATH) == FALSE) + mkdir(PROXY_PATH); + if (($fp = @fopen(PROXY_PATH."/".$sess.".step", 'rb')) == FALSE) + break; + if (($s = fread($fp, 8)) == FALSE) + break; + if (strlen($s) != 8) + break; + $arr = unpack('Ls/Li', $s); + fclose($fp); + + // log_rd2("A0: ".$arr[0]." A1: ".$arr[1]); + return ($arr); + } while (0); + + if ($fp != FALSE) + fclose($fp); + + log_rd2("STEP_GET [".$sess."]: return false "); + + return (FALSE); + } } // end class User -function step_get($sess) { - $fp = FALSE; - do { - if (validate_sess($sess) == FALSE) - break; - - if (file_exists(PROXY_PATH) == FALSE) - mkdir(PROXY_PATH); - if (($fp = @fopen(PROXY_PATH."/".$sess.".step", 'rb')) == FALSE) - break; - if (($s = fread($fp, 8)) == FALSE) - break; - if (strlen($s) != 8) - break; - $arr = unpack('Ls/Li', $s); - fclose($fp); - - // log_rd2("A0: ".$arr[0]." A1: ".$arr[1]); - return ($arr); - } while (0); - - if ($fp != FALSE) - fclose($fp); - - log_rd2("STEP_GET: return false "); - - return (FALSE); -} - function step_unproxy($sess) { log_rd2("UNPROXY: ".PROXY_PATH."/".$sess.".step"); if (file_exists(PROXY_PATH) == FALSE)