4 if ( ! isset($SESSIONS) ) {
5 $result=$db->query("SELECT id,examples,nexamples FROM sessions ORDER BY id");
10 while ($session = $result->fetch(PDO::FETCH_ASSOC)) {
11 $SESSIONS[$session['id']] = array("id" => $session['id'], "timestr" => date("d.m.Y H:i", $session['id']),
12 "workdone" => $db->query("SELECT COUNT(*) FROM workdone WHERE session=" . $session['id'])->fetch(PDO::FETCH_NUM)[0],
13 "examples" => $session['examples'], "nexamples" => $session['nexamples']);
14 if ( strtotime("now") < $session['id'] && ( $SESSIONS_next==-1 || $SESSIONS_next > $session['id'] ) ) {
15 $SESSIONS_next = $session['id'];
17 if ( strtotime("now") < $session['id'] + 3600 && ( $SESSIONS_actual==-1 || $SESSIONS_actual > $session['id'] ) ) {
18 $SESSIONS_actual = $session['id'];
22 if($SESSIONS_next == -1) unset($SESSIONS_next);
23 if($SESSIONS_actual == -1) unset($SESSIONS_actual);
26 $SESSIONS_totex_nextinc = 0;
27 if(isset($SESSIONS)) {
28 foreach ($SESSIONS as $session) {
29 if( (! isset($SESSIONS_next)) || $session['id'] < $SESSIONS_next ) { $SESSIONS_totex += $session['nexamples']; }
30 if( (! isset($SESSIONS_actual)) || $session['id'] != $SESSIONS_actual ) { $SESSIONS_last = $session['id']; }
31 if( (! isset($SESSIONS_next)) || $session['id'] <= $SESSIONS_next ) { $SESSIONS_totex_nextinc += $session['nexamples']; }