X-Git-Url: http://git.treefish.org/banana.git/blobdiff_plain/17d5ad30f747658451fae84fe65cb1f5b66d377c..74ec84ba871e86491a79a21b85cf37126b41cc7a:/include/session.inc?ds=sidebyside diff --git a/include/session.inc b/include/session.inc index 554ac1f..787d644 100644 --- a/include/session.inc +++ b/include/session.inc @@ -5,6 +5,7 @@ $result=$db->query("SELECT id,examples,nexamples FROM sessions ORDER BY id"); $SESSIONS_next = -1; $SESSIONS_actual = -1; + $SESSIONS_n = 0; while ($session = $result->fetch(PDO::FETCH_ASSOC)) { $SESSIONS[$session['id']] = array("id" => $session['id'], "timestr" => date("d.m.Y H:i", $session['id']), @@ -16,18 +17,23 @@ if ( strtotime("now") < $session['id'] + 3600 && ( $SESSIONS_actual==-1 || $SESSIONS_actual > $session['id'] ) ) { $SESSIONS_actual = $session['id']; } + $SESSIONS_n++; } if($SESSIONS_next == -1) unset($SESSIONS_next); if($SESSIONS_actual == -1) unset($SESSIONS_actual); $SESSIONS_totex = 0; - foreach ($SESSIONS as $session) { - if($session['id'] < $SESSIONS_next) { $SESSIONS_totex += $session['nexamples']; } + if(isset($SESSIONS)) { + foreach ($SESSIONS as $session) { + if($session['id'] < $SESSIONS_next) { $SESSIONS_totex += $session['nexamples']; } + } } $SESSIONS_totex_nextinc = 0; - foreach ($SESSIONS as $session) { - if($session['id'] <= $SESSIONS_next) { $SESSIONS_totex_nextinc += $session['nexamples']; } + if( isset($SESSIONS) && isset($SESSIONS_next) ) { + foreach ($SESSIONS as $session) { + if($session['id'] <= $SESSIONS_next) { $SESSIONS_totex_nextinc += $session['nexamples']; } + } } } ?>