X-Git-Url: https://mop.ddnsfree.com/gitweb/?a=blobdiff_plain;f=web%2Findex_rd.php;h=20a7c149255727c0180177ebd2913cac0e7add2a;hb=a838a4cb3f09dec55f9edb3d882d30320faa3eef;hp=9f3870cc08240c206cb210d3c34ca9220359082e;hpb=f406d58f75cd486eaab74be94faf70d516684e5a;p=brisk.git diff --git a/web/index_rd.php b/web/index_rd.php index 9f3870c..20a7c14 100644 --- a/web/index_rd.php +++ b/web/index_rd.php @@ -23,7 +23,7 @@ require_once("brisk.phh"); -log_load($sess, "LOAD: index_rd.php"); +log_load($sess, "LOAD: index_rd.php ".$QUERY_STRING); $first_loop = TRUE; $the_end = FALSE; @@ -46,9 +46,16 @@ function unrecerror() GLOBAL $is_page_streaming; $is_page_streaming = TRUE; - return (sprintf('the_end=true; document.location.assign("index.php");')); + return (sprintf('the_end=true; window.onunload = null; document.location.assign("index.php");')); } +function page_sync($page) +{ + GLOBAL $is_page_streaming; + + $is_page_streaming = TRUE; + return (sprintf('the_end=true; window.onunload = null; document.location.assign("%s");', $page)); +} @@ -58,49 +65,67 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su GLOBAL $is_page_streaming, $first_loop; $ret = FALSE; - - + $bri = FALSE; + + log_rd2($sess, "M"); /* Sync check (read only without modifications */ + ignore_user_abort(TRUE); if (($sem = lock_data()) != FALSE) { - $bri = &load_data(); // Aggiorna l'expire time lato server if ($first_loop == TRUE) { - if (($user = &get_user($bri, $sess, $idx)) == FALSE) { + log_rd2($sess, "F"); + $bri = &load_data(); + if (($user = &$bri->get_user($sess, $idx)) == FALSE) { unlock_data($sem); + ignore_user_abort(FALSE); return (unrecerror()); } log_auth($sess, "update lacc"); - $user->lacc = time() + EXPIRE_TIME; - save_data($bri); - $first_loop = FALSE; - - + $user->lacc = time(); + $bri->garbage_manager(FALSE); save_data($bri); + $first_loop = FALSE; } unlock_data($sem); + ignore_user_abort(FALSE); } else { return (FALSE); } - if (($user = &get_user(&$bri, $sess, $idx)) == FALSE) { + if (validate_sess($sess)) { + $proxy_step = step_get($sess); + // log_rd2($sess, "Postget".$proxy_step."zizi"); + + if ($cur_step == $proxy_step) { + log_rd2($sess, "P"); + return; + } + } + + if ($bri == FALSE) + $bri = &load_data(); + + if (($user = &$bri->get_user($sess, $idx)) == FALSE) { return (unrecerror()); } /* Nothing changed, return. */ - if ($cur_stat == $user->stat && $cur_step == $user->step) + if ($cur_step == $user->step) return; log_rd2($sess, "do other ++".$cur_stat."++".$user->stat."++".$cur_step."++".$user->step); if ($cur_step == -1) { // FUNZIONE from_scratch DA QUI + ignore_user_abort(TRUE); $sem = lock_data(); $bri = &load_data(); - if (($user = &get_user($bri, $sess, $idx)) == FALSE) { + if (($user = &$bri->get_user($sess, $idx)) == FALSE) { unlock_data($sem); + ignore_user_abort(FALSE); return (unrecerror()); } if ($user->the_end) @@ -115,10 +140,12 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su save_data($bri); unlock_data($sem); + ignore_user_abort(FALSE); } else { log_rd2($sess, "TRANS NON ATTIVATO"); unlock_data($sem); + ignore_user_abort(FALSE); } } @@ -146,15 +173,23 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su $new_step = $user->step; } else { + ignore_user_abort(TRUE); $sem = lock_data(); $bri = &load_data(); - if (($user = &get_user($bri, $sess, $idx)) == FALSE) { + if (($user = &$bri->get_user($sess, $idx)) == FALSE) { unlock_data($sem); + ignore_user_abort(FALSE); return (unrecerror()); } if ($cur_step < $user->step) { do { if ($cur_step + COMM_N < $user->step) { + if (($cur_stat != $user->stat)) { + $to_stat = $user->stat; + unlock_data($sem); + ignore_user_abort(FALSE); + return (page_sync($to_stat == "table" ? "table.php" : "index.php")); + } log_rd2($sess, "lost history, refresh from scratch"); $new_step = -1; break; @@ -171,7 +206,10 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su if ($user->the_end == TRUE) { log_rd2($sess, "LOGOUT BYE BYE!!"); log_auth($user->sess, "Explicit logout."); + $tmp_sess = $user->sess; $user->sess = ""; + step_unproxy($tmp_sess); + $user->name = ""; $user->the_end = FALSE; @@ -187,6 +225,7 @@ function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_su } unlock_data($sem); + ignore_user_abort(FALSE); } @@ -236,7 +275,7 @@ for ($i = 0 ; time() < $endtime ; $i++) { $old_step = $step; // log_rd($sess, "POST MAIN ".$step);; usleep(200000); - if (($i % 5) == 0) { + if (($i % 10) == 0) { // log_rd2($sess, "TIME: ".time()); echo '_'; flush();