-
Notifications
You must be signed in to change notification settings - Fork 11
/
uploadform.php
82 lines (63 loc) · 1.96 KB
/
uploadform.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/*
* @copyright (c) 2008 Nicolo John Davis
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/
session_start();
if(!isset($_SESSION['isloggedin']))
{
echo "<meta http-equiv='Refresh' content='0; URL=login.php' />";
exit(0);
}
else
{
$username = $_SESSION['username'];
$userid = $_SESSION['userid'];
}
include('settings.php');
?>
<?php
//Make sure that a variable $problemid is defined before this in the calling file
$problemid = htmlentities($problemid);
$good = false;
for($i=1 ; $i<=count($points) ; $i++)
if($problemid == $i)
$good = true;
if($good == false)
$problemid = 1;
$cn = mysql_connect('localhost', $DBUSER, $DBPASS);
mysql_select_db($DBNAME, $cn);
$status = 0;
$query = "select problemid, status from submissions where userid=$userid and problemid=$problemid order by time desc";
$result = mysql_query($query);
$result = mysql_fetch_array($result);
if(isset($result['status']))
$status = $result['status'];
else
$status = -1;
$status++;
$statString = array('-', 'Accepted', 'Compile Error', 'Wrong Answer', 'Time Limit', 'Invalid File');
mysql_close($cn);
print "<table style='margin-top: 20px; border: 0;'><tr>";
if($statString[$status] != 'Accepted')
{
print "<td id='upload$problemid' class='submitform'>";
print "<form id='upload$problemid' class='uploadform' action='processfile.php' method='post' enctype='multipart/form-data'>
<input type='file' name='$problemid'/><input type='submit' value='Submit Solution'/>
<input type='hidden' name='redirectFile' value='$redirectFile'/></form>";
print "</td>";
}
print "<td id='status$problemid' class=";
switch($status)
{
case 0: print '"none"'; break;
case 1: print '"accepted"'; break;
case 2: print '"compile"'; break;
case 3: print '"wrong"'; break;
case 4: print '"time"'; break;
case 5: print '"invalid"'; break;
}
print '>';
print "<strong>$statString[$status]</strong></td>";
print "</tr></table>";
?>