\n\n
\n$query
\nthe following error occurred:
\n
" . mysql_error($db) . "
"; } else { return ""; } } function dbstring($str) { if (!isset($str)) return "NULL"; return "'" . addcslashes($str, "'\"\\\0") . "'"; } function dbdate($y, $m, $d) { if (!isset($y) || !isset($m) || !isset($d)) return "NULL"; return sprintf("'%04d-%02d-%02d'", $y, $m, $d); } function dbint($int) { if (!isset($int)) return "NULL"; if (!is_numeric($int)) return "NULL"; return $int; } function dbbool($val) { if (!isset($val)) return "NULL"; // return $val? 'true' : 'false'; // MySQL doesn't support true booleans.... sic. return $val? '1' : '0'; } function dbselect($query, $mode = DB_ASSOC_INT) { $db = initdb(); $key = obj_genkey($query . $mode); if (obj_fresh($key)) { closedb(); return obj_fetch($key); } obj_start_update($key); $result = @mysql_query($query, $db); if (!$result) { print dberror($db, $query); closedb(); exit; } $ret = array(); $num = mysql_num_rows($result); for ($i = 0; $i < $num; $i++) { $temp = mysql_fetch_array($result, $mode); $ret[] = $temp; } obj_store($key, $ret); closedb(); return $ret; } function dbinsert($query) { $db = initdb(); $result = mysql_query($query, $db); if ($result == FALSE) { print dberror($db, $query); closedb(); return false; } $id = mysql_insert_id($db); closedb(); return $id? $id: true; } function dbdelete($query) { $db = initdb(); $result = @mysql_query($query, $db); if ($result == FALSE) { print dberror($db, $query); closedb(); return false; } closedb(); return true; } function closedb() { global $db_is_open, $db; if ($db_is_open) { mysql_close($db); $db_is_open = 0; } } ?> 0) { $s = ''; if ($timeused > 0) { $data = dbselect('SELECT lasttimeused,timeused FROM users WHERE `id`=' . dbint($user), DB_ASSOC_ONLY); if (count($data) > 0) { // timeused should be higher than database-value (no cheating ;) if ($timeused < $data[0]['timeused']) $timeused = -1; // get lastvisit from db, difference with current time should be same as difference between timeused en database-value of timeused // unfortunately, timer differences (and reloading the website) cause too much difference. /* if ($data[0]['lasttimeused'] != '') { $now = time(); $last = strtotime($data[0]['lasttimeused']); $diffl = $now - $last; $diffu = $timeused - $data[0]['timeused']; $f = fopen('storeresults.wri','a'); fputs($f, "last=$last now=$now diff:$diffl diff timeused: $diffu\n"); fclose($f); } */ } } if ($timeused > 0) $s .= ',`timeused`=' . $timeused . ',`lasttimeused`= NOW()'; $q = 'UPDATE users SET `lastaction`=' . dbstring($lastaction) . $s . ' WHERE `id`=' . dbint($user); dbinsert($q); if ($timeused != NULL) $timeused = dbint($timeused); else $timeused = 'NULL'; dbinsert('INSERT INTO `actions` (`datum`,`userid`,`action`,`timeused`) VALUES (NOW(),' . dbint($user) . ',' . dbstring($lastaction) . ',' . $timeused . ');'); } } function GetUserTimes($userid,$moduleseq=1) { if ($userid == 1) { $data = Array( Array('timeused'=>55, 'title'=>'Algemene introductie'), Array('timeused'=>28*60+4, 'title'=>'Hoofdstuk 1 Kiezen voor een veilig rijgedrag'), Array('timeused'=>36*60+45, 'title'=>'Hoofdstuk 2 Gedrag andere weggebruikers'), Array('timeused'=>29*60+12, 'title'=>'Hoofdstuk 3 Snelheid en bochten liggen elkaar niet'), Array('timeused'=>38*60, 'title'=>'Hoofdstuk 4 Technische veiligheidssystemen'), Array('timeused'=>22*60+57, 'title'=>'Hoofdstuk 5 Denken en doen bij ongevallen'), Array('timeused'=>0, 'title'=>'Hoofdstuk 6 Uw eerste hulp bij een ongeval'), Array('timeused'=>0, 'title'=>'Extra oefenvragen') ); } else { $data = Array( Array('timeused'=>55, 'title'=>'Algemene introductie'), Array('timeused'=>42*60+15, 'title'=>'Hoofdstuk 1 Kiezen voor een veilig rijgedrag'), Array('timeused'=>40*60+9, 'title'=>'Hoofdstuk 2 Gedrag andere weggebruikers'), Array('timeused'=>35*60+28, 'title'=>'Hoofdstuk 3 Snelheid en bochten liggen elkaar niet'), Array('timeused'=>0, 'title'=>'Hoofdstuk 4 Technische veiligheidssystemen'), Array('timeused'=>0, 'title'=>'Hoofdstuk 5 Denken en doen bij ongevallen'), Array('timeused'=>0, 'title'=>'Hoofdstuk 6 Uw eerste hulp bij een ongeval'), Array('timeused'=>0, 'title'=>'Extra oefenvragen') ); } $q = 'SELECT menunivo2.title,chapter_usage.timeused FROM menunivo2 INNER JOIN menunivo1 ON menunivo1.id=menunivo2.nivo1_id LEFT JOIN chapter_usage ON (chapter_usage.chapter=menunivo2.seq AND chapter_usage.user_id=' . dbint($userid) . ') WHERE menunivo1.seq=' . dbint($moduleseq) . ' ORDER BY menunivo2.seq'; //print $q; $data = dbselect($q, DB_ASSOC_ONLY); return $data; } function GetTotalTime($userid,$module=1) { $data = GetUserTimes($userid, $module=1); $nTimeUsed = 0; foreach($data as $result) { $nTimeUsed += $result['timeused']; } return $nTimeUsed; } ?> Cursisten

Cursisten

zoek losse logincode: (geeft status van ingevoerde code, ongeacht de cursusdatum)
zoek reeks: (geeft status van alle toekomstige codes)
zoek historische reeks:     (geeft status van alle codes in een bepaalde periode)