]> git.treefish.org Git - banana.git/blob - submit.php
...
[banana.git] / submit.php
1 <?php
2   require 'include/head.inc';
3   require 'include/session.inc';
4   require 'include/common.inc';
5
6   if ( ! isset($SESSIONS_next) ) {
7     block("red", "submission closed");
8     break;
9   }
10
11   if(isset($_POST['submit']) && $_POST['mnumber']!="") {
12     require 'include/usercheck.inc';
13
14     $exchecked = $_POST['exchecked'];
15
16     $mnumber = $_POST['mnumber'];
17     $sessionid = $SESSIONS[$SESSIONS_next]['id'];
18
19     if($db->query("SELECT COUNT(*) FROM workdone WHERE mnumber = $mnumber AND session = $sessionid")->fetch(PDO::FETCH_NUM)[0] == 1) {
20       print '<table bgcolor="red">';
21         print '<tr><th><b><font color="white">You already submitted results for this session</font></b></th><tr>';
22       print '</table>';
23       print "You can only submit your calculated examples once!";
24       break;
25     }
26
27     $excount = count($exchecked);
28     $donestring = implode(', ', $exchecked);
29
30     $db->query("INSERT INTO workdone (mnumber,session,manydone,thisdone) 
31         VALUES (\"$mnumber\", \"$sessionid\", \"$excount\", \"$donestring\")");
32
33     print '<table bgcolor="lightgreen">';
34       print '<tr><th><b><font color="white">submitted</font></b></th><tr>';
35     print '</table>';
36     break;
37   }
38
39 ?>
40
41   <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
42   <table bgcolor="black">
43     <tr><th><b><font color="white">submit examples for <?php echo $SESSIONS[$SESSIONS_next]['timestr']; ?></font></b></th><tr>
44   </table>
45
46   <table>
47     <tr>  
48       <th align="left">Mat.nummer:</th> <th align="left"><input type="text" name="mnumber"></th>
49     </tr>
50     <tr>  
51       <th align="left">Password:</th> <th align="left"><input type="text" name="password"></th>
52     </tr>
53  
54     <tr><th colspan=2></th></tr>
55
56     <tr>
57       <th align="left">Examples:</th>
58       <th>
59
60         <?php
61           $exnum=0;
62           foreach (explode(",",$SESSIONS[$SESSIONS_next]['examples']) as $exid) {
63             print " <input type='checkbox' name='exchecked[]' value=$exid>$exid ";
64             $exnum++;
65             if ($exnum%3 == 0) { print ""; }
66           }
67         ?>
68       </th>     
69     </tr>
70
71     <tr><th colspan=2></th></tr>
72
73     <tr>
74       <th align="left"><input type="submit" name="submit" value="Submit"></th> <th></th>
75     </tr>
76   </table>
77 </form>