X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=web%2FObj%2Fbrisk.phh;h=799ea68bf2263bd0b3a8a9ef2d16f4f869c94fa2;hb=45fd3084c52ef5c560300fa32a2fef75edc47ca7;hp=13a21a3f54bdd44ababe595ed8d628405d4f7510;hpb=15e64d578a2e1901dd829403af8b0eba1a45dbb8;p=brisk.git diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index 13a21a3..799ea68 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -638,8 +638,6 @@ class User { } function create($idx, $name, $sess, $stat = "", $subst = "", $table = -1, $ip="0.0.0.0") { - // error_log("User::create BEGIN", 0); - if (($thiz = new User()) == FALSE) return (FALSE); @@ -816,6 +814,19 @@ class User { { $this->step = $step & 0x7fffffff; + return (TRUE); + } + + function step_inc($delta = 1) { + $this->step += $delta; + /* modularization because unpack() not manage unsigned 32bit int correctly */ + $this->step &= 0x7fffffff; + + return TRUE; + } + + function save_step() + { do { if (validate_sess($this->sess) == FALSE) break; @@ -825,7 +836,7 @@ class User { break; fwrite($fp, pack("LL",$this->step, $this->idx)); fclose($fp); - + log_main("step_set [".$this->sess. "] [".$this->step."]"); return (TRUE); @@ -834,27 +845,7 @@ class User { return (FALSE); } - function step_inc($delta = 1) { - $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); - } - - static function step_get($sess) + static function load_step($sess) { $fp = FALSE; do { @@ -904,8 +895,6 @@ class User { static function load_data($id, $sess) { - // error_log("User::load_data BEGIN", 0); - log_main("load_data: id [".$id."] sess [".($sess == FALSE ? "FALSE" : $sess)."] "); $doexit = FALSE; @@ -931,8 +920,6 @@ class User { 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)); if ($user == FALSE) { log_only("INIT MAIN DATA"); @@ -944,7 +931,20 @@ class User { log_only(serialize($user)); } } - + 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 = User::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); @@ -969,9 +969,6 @@ class User { $shm = FALSE; - // var_dump($user); - // error_log("User::save_data BEGIN", 0); - if (($tok = @ftok(FTOK_PATH."/user".$id, "B")) == -1) { return (FALSE); } @@ -982,6 +979,8 @@ class User { // 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_main("User[".$id."] saved."); return (TRUE); } @@ -2030,7 +2029,6 @@ class Room { log_auth("XXX", "authenticate: ".($authenticate != FALSE ? "TRUE" : "FALSE")); if ($authenticate != FALSE) { - // error_log(print_r(&$authenticate, TRUE),0); $user_type = $authenticate->type_get(); } else { @@ -2243,8 +2241,6 @@ class Room { GLOBAL $sess; $doexit = FALSE; - // error_log("Room::load_data BEGIN", 0); - do { if (($tok = @ftok(FTOK_PATH."/main", "B")) == -1) { log_main("ftok failed"); @@ -2270,8 +2266,6 @@ class Room { log_only("INIT MAIN DATA"); shm_detach($shm); - // error_log("DE CHE", 0); - $room = Room::create(); if (Room::save_data($room) == FALSE) @@ -2343,9 +2337,6 @@ class Room { $ret = FALSE; $shm = FALSE; - // var_dump($room); - // error_log("Room::save_data BEGIN", 0); - if (($tok = @ftok(FTOK_PATH."/main", "B")) == -1) return (FALSE); @@ -2942,6 +2933,8 @@ function secstoword($secs) { GLOBAL $G_lang; + $ret = ""; + $mins = floor($secs / 60); $secs = $secs % 60; if ($G_lang == 'en') {