X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=web%2FObj%2Fbrisk.phh;h=799ea68bf2263bd0b3a8a9ef2d16f4f869c94fa2;hb=45fd3084c52ef5c560300fa32a2fef75edc47ca7;hp=09b1da8481e77cefe9dc96301132c4c4d82ba2d1;hpb=1ccc2ec3beebfc0939ce8558a15f23e99b29dcaa;p=brisk.git diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index 09b1da8..799ea68 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -134,12 +134,12 @@ $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.4.3"; +$G_brisk_version = "3.5.0"; /* MLANG: ALL THE INFO STRINGS IN brisk.phh */ -$root_wellarr = array( 'it' => array ( 'Brisk (Ver. '.$G_brisk_version.'), NOVITA\': versione di test per la nuova gestione dei dati volatili, rivista gestione del ticker.', +$root_wellarr = array( 'it' => array ( 'Brisk (Ver. '.$G_brisk_version.'), NOVITA\': seconda versione di test per la nuova gestione dei dati volatili, rivista gestione del ticker.', 'Se vuoi iscriverti alla Mailing List, cliccala!' ), - 'en' => array ( 'Brisk (Ver. '.$G_brisk_version.'), NEWS: test version for the new volatile data management, ticker management refactored.', + 'en' => array ( 'Brisk (Ver. '.$G_brisk_version.'), NEWS: second test version for the new volatile data management, ticker management refactored.', 'If you want to subscribe our Mailing List, click it!' ) ); $G_room_help = array( 'it' => ' @@ -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,22 +845,32 @@ 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)) { + static function load_step($sess) + { + $fp = FALSE; + do { + if (validate_sess($sess) == FALSE) + break; + 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)); + 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_main("step_inc [".$this->sess. "] [".$this->step."]"); - return (TRUE); - } + // 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); } @@ -872,137 +893,112 @@ class User { $this->the_end = FALSE; } - - - // SHSPLIT save and load function for the User class. 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; - do { - if (($tok = @ftok(FTOK_PATH."/user".$id, "B")) == -1) { - log_main("ftok failed"); - $doexit = TRUE; - 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)) { - $user = @shm_get_var($shm, $tok); - - 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)); - - if ($user == FALSE) { - log_only("INIT MAIN DATA"); - - // SHSPLIT FIXME: init_data for User class ?? - $user = User::create($id, "", ""); - if (@shm_put_var($shm, $tok, $user) == FALSE) { - log_only("PUT_VAR FALLITA ".strlen(serialize($user))); - log_only(serialize($user)); - } - } - - $user->shm_sz = $shm_sz; - - shm_detach($shm); - } + log_main("load_data: id [".$id."] sess [".($sess == FALSE ? "FALSE" : $sess)."] "); - // - // SHSPLIT: load users from the shared memory - // - return ($user); - } while (0); - - if ($doexit) - exit(); - - return (FALSE); + $doexit = FALSE; + do { + if (($tok = @ftok(FTOK_PATH."/user".$id, "B")) == -1) { + log_main("ftok failed"); + $doexit = TRUE; + 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)) { + $user = @shm_get_var($shm, $tok); + + 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 ($user == FALSE) { + log_only("INIT MAIN DATA"); + + // SHSPLIT FIXME: init_data for User class ?? + $user = User::create($id, "", ""); + if (@shm_put_var($shm, $tok, $user) == FALSE) { + log_only("PUT_VAR FALLITA ".strlen(serialize($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); + } + + // + // SHSPLIT: load users from the shared memory + // + return ($user); + } while (0); + + if ($doexit) + exit(); + + return (FALSE); } - function save_data($user, $id) + static function save_data($user, $id) { - GLOBAL $sess; - - $shm = FALSE; - - // var_dump($user); - // error_log("User::save_data BEGIN", 0); - - 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; + GLOBAL $sess; - // log_only("PUT_VAR DI ".strlen(serialize($user))); - if (shm_put_var($shm, $tok, $user) != FALSE) { - shm_detach($shm); - log_main("User[".$id."] saved."); - return (TRUE); - } - if (shm_remove($shm) === FALSE) { - log_only("REMOVE FALLITA"); - break; + $shm = FALSE; + + if (($tok = @ftok(FTOK_PATH."/user".$id, "B")) == -1) { + return (FALSE); } - shm_detach($shm); - $user->shm_sz += SHM_DIMS_U_DLT; - } - - if ($shm) - shm_detach($shm); - - return (FALSE); - } - - - static function step_get($sess) - { - $fp = FALSE; - do { - if (validate_sess($sess) == FALSE) + while ($user->shm_sz < SHM_DIMS_U_MAX) { + if (($shm = shm_attach($tok, $user->shm_sz)) == 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) + // 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); + } + if (shm_remove($shm) === FALSE) { + log_only("REMOVE FALLITA"); 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); + } + shm_detach($shm); + $user->shm_sz += SHM_DIMS_U_DLT; + } - log_rd2("STEP_GET [".$sess."]: return false "); + if ($shm) + shm_detach($shm); return (FALSE); } + } // end class User @@ -2033,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 { @@ -2246,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"); @@ -2273,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) @@ -2346,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); @@ -2502,7 +2490,7 @@ class Room { do { if (file_exists(PROXY_PATH) == FALSE) mkdir(PROXY_PATH); - if (($fp = @fopen(PROXY_PATH."/room_garbage_time.expired", 'rb')) == FALSE) + if (($fp = @fopen(PROXY_PATH."/garbage_time.expired", 'rb')) == FALSE) break; if (($s = fread($fp, 4)) == FALSE) break; @@ -2526,7 +2514,7 @@ class Room { do { if (file_exists(PROXY_PATH) == FALSE) mkdir(PROXY_PATH); - if (($fp = @fopen(PROXY_PATH."/room_garbage_time.expired", 'wb')) == FALSE) + if (($fp = @fopen(PROXY_PATH."/garbage_time.expired", 'wb')) == FALSE) break; fwrite($fp, pack("L",$tm)); fclose($fp); @@ -2945,6 +2933,8 @@ function secstoword($secs) { GLOBAL $G_lang; + $ret = ""; + $mins = floor($secs / 60); $secs = $secs % 60; if ($G_lang == 'en') {