-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathgetsubmissions.php
70 lines (53 loc) · 1.34 KB
/
getsubmissions.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
<?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');
print '<tr><th>Id</th><th>Time</th><th>User</th><th>Problem</th><th>Status</th></tr>';
$cn = mysql_connect('localhost', $DBUSER , $DBPASS);
mysql_select_db($DBNAME, $cn);
$result = mysql_query("select submissions.id, time, username, problemid, status from users, submissions where users.id = submissions.userid order by time desc LIMIT 0,30");
if($result)
{
while($row = mysql_fetch_array($result))
{
switch($row[4])
{
case 0:
$row[4] = "Accepted";
break;
case 1:
$row[4] = "Compile Error";
break;
case 2:
$row[4] = "Wrong Answer";
break;
case 3:
$row[4] = "Time Limit";
break;
case 4:
$row[4] = "Invalid File";
break;
}
$t = strftime('%H:%M:%S',$row[1]);
if($row[4] == "Accepted")
$class = "correct";
else
$class = "row-a";
print "<tr class='$class'><td>$row[0]</td><td>$t</td><td>$row[2]</td><td>$row[3]</td><td>$row[4]</td></tr>";
}
}
mysql_close($cn);
?>