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 if(isset($SESSIONS)) {
27 foreach ($SESSIONS as $session) {
28 if($session['id'] < $SESSIONS_next || (! isset($SESSIONS_next)) ) { $SESSIONS_totex += $session['nexamples']; }
32 $SESSIONS_totex_nextinc = 0;
33 if( isset($SESSIONS) && isset($SESSIONS_next) ) {
34 foreach ($SESSIONS as $session) {
35 if($session['id'] <= $SESSIONS_next) { $SESSIONS_totex_nextinc += $session['nexamples']; }