<?php
- require 'nav.inc';
+ require 'include/head.inc';
+ require 'include/session.inc';
+ require 'include/common.inc';
- $lines = file('var/sessions.txt');
-
- foreach ($lines as $line_num => $line) {
- $sessions[$line_num] = explode("\t",$line);
- }
-
- if ( strtotime("now") > strtotime(end($sessions)[0]) ) {
- print '<table bgcolor="red">';
- print '<tr><th><b><font color="white">submission closed</font></b></th><tr>';
- print '</table>';
- break;
+ if ( ! isset($SESSIONS_next) ) {
+ block("red", "submission closed");
+ exit;
}
if(isset($_POST['submit']) && $_POST['mnumber']!="") {
- require 'usercheck.inc';
-
+ require 'include/usercheck.inc';
+
$exchecked = $_POST['exchecked'];
$mnumber = $_POST['mnumber'];
- $sessionid = strtotime(end($sessions)[0]);
+ $sessionid = $SESSIONS[$SESSIONS_next]['id'];
if($db->query("SELECT COUNT(*) FROM workdone WHERE mnumber = $mnumber AND session = $sessionid")->fetch(PDO::FETCH_NUM)[0] == 1) {
- print '<table bgcolor="red">';
- print '<tr><th><b><font color="white">You already submitted results for this session</font></b></th><tr>';
+ $db->query("DELETE FROM workdone WHERE mnumber = $mnumber AND session = $sessionid");
+ print '<table bgcolor="lightgreen">';
+ print '<tr><th><b><font color="white">deleted old submission</font></b></th><tr>';
print '</table>';
- print "You can only submit your calculated examples once!";
- break;
}
$excount = count($exchecked);
- $donestring = implode(', ', $exchecked);
+ $donestring = implode(',', $exchecked);
$db->query("INSERT INTO workdone (mnumber,session,manydone,thisdone)
VALUES (\"$mnumber\", \"$sessionid\", \"$excount\", \"$donestring\")");
print '<table bgcolor="lightgreen">';
print '<tr><th><b><font color="white">submitted</font></b></th><tr>';
print '</table>';
- break;
+ exit;
}
+
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<table bgcolor="black">
- <tr><th><b><font color="white">submit examples for <?php echo end($sessions)[0]; ?></font></b></th><tr>
+ <tr><th><b><font color="white">submit examples for <?php echo $SESSIONS[$SESSIONS_next]['timestr']; ?></font></b></th><tr>
</table>
<table>
<th align="left">Mat.nummer:</th> <th align="left"><input type="text" name="mnumber"></th>
</tr>
<tr>
- <th align="left">Password:</th> <th align="left"><input type="text" name="password"></th>
+ <th align="left">Password:</th> <th align="left"><input type="password" name="password"></th>
</tr>
<tr><th colspan=2></th></tr>
<?php
$exnum=0;
- foreach (explode(",",end($sessions)[1]) as $exid) {
+ foreach (explode(",",$SESSIONS[$SESSIONS_next]['examples']) as $exid) {
print " <input type='checkbox' name='exchecked[]' value=$exid>$exid ";
$exnum++;
if ($exnum%3 == 0) { print ""; }