-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathcontests.php
More file actions
executable file
·147 lines (132 loc) · 4.59 KB
/
contests.php
File metadata and controls
executable file
·147 lines (132 loc) · 4.59 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?php
session_start();
include('settings.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Online Judge</title>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
<link rel="stylesheet" type="text/css" media="screen" href="css/screen.css" />
</head>
<body class="contest">
<div id="wrap">
<script type="text/javascript" src="countdown.js">
</script>
<?php include('header.php');
$conn= mysql_connect('localhost',$DBUSER,$DBPASS);
mysql_select_db($DBNAME,$conn);
?>
<div id="content-outer" class="clear">
<div id="left">
<div class="entry">
<?php
if(!isset($_GET['contestID'])){
$query = "SELECT DATE_FORMAT(`startTime`,'%Y-%m-%d %T') AS startTime,DATE_FORMAT(`endTime`,'%Y-%m-%d %T') AS endTime,contestID,Name FROM contests ORDER BY endTime DESC ";
$logged = mysql_query($query);
$temp="<table width=100%><tr><th width=30%>Name</th><th width=35%>Start Time</th><th>End Time</th></tr>";
$fut="<h2>Future Contests</h2>";
$cur="<h2>Running Contests</h2>";
$past="<h2>Past Contests</h2>";
$fut=$fut.$temp;
$cur=$cur.$temp;
$past=$past.$temp;
$countf=0;$countp=0;$countc=0;
while($r= mysql_fetch_array($logged))
{
$d1 = new DateTime($r['startTime']);
$current = new DateTime(date('Y-m-d H:i:s'));//yyyy-mm-dd hh:mm:ss
if($d1>$current){
$fut=$fut."<tr><td><a href='contests.php?contestID=".$r['contestID']."'>".$r['Name']."</a></td><td>".date('jS F Y \a\t G:i', strtotime($r['startTime']))."</td><td>".date('jS F Y \a\t G:i', strtotime($r['endTime']))."</td></tr>";
$countf=1;
continue;
}
$d1 = new DateTime($r['endTime']);
if($d1>$current){
//date_diff($d1, $current)->format('%a days %H hrs %i minutes');
$cur=$cur."<tr><td><a href='contests.php?contestID=".$r['contestID']."'>".$r['Name']."</a><a href='rank.php?contestID=".$r['contestID']."' style='color: #00F000;font-size: .9em;'></br>(Rankings)</a></td><td>".date('jS F Y \a\t G:i', strtotime($r['startTime']))."</td><td>".date('jS F Y \a\t G:i', strtotime($r['endTime']))."</td></tr>";
$countc=1;
continue;
}
else{
$past=$past."<tr><td><a href='contests.php?contestID=".$r['contestID']."'>".$r['Name']."</a>
<a href='rank.php?contestID=".$r['contestID']."' style='color: #00F000;font-size: .9em;'></br>(Rankings)</a></td><td>".date('jS F Y \a\t G:i', strtotime($r['startTime']))."</td><td>".date('jS F Y \a\t G:i', strtotime($r['endTime']))."</td></tr>";
$countp=1;
break;
}
}
$temp="</table>";
$fut=$fut.$temp;
$cur=$cur.$temp;
if($countf!=1)$fut.="No future contest scheduled";
if($countc!=1)$cur.="No contest running";
echo $fut;
echo $cur;
if($countp!=1){
$past=$past.$temp."No past contests</p></code>";
echo $past;
}
else
{
echo $past;
while($r= mysql_fetch_array($logged))
{
echo "<tr><td><a href='contests.php?contestID=".$r['contestID']."'>".$r['Name']."</a><a href='rank.php?contestID=".$r['contestID']."' style='color: #00F000;font-size: .9em;'></br>(Rankings)</a></td><td>".date('jS F Y \a\t G:i', strtotime($r['startTime']))."</td><td>".date('jS F Y \a\t G:i', strtotime($r['endTime']))."</td></tr>";
}
}
echo "</table>";
}
else
{
if(is_numeric($_GET['contestID'])!=1)
{
echo "Invalid ContestID";
echo '<meta http-equiv="REFRESH" content="2;url=contests.php">';
exit(0);
}
$query = "SELECT DATE_FORMAT(`startTime`,'%Y-%m-%d %T') AS startTime,Name FROM contests WHERE contestID=".$_GET['contestID'];
$logged=mysql_query($query);
$r=mysql_fetch_array($logged);
$d1 = new DateTime($r['startTime']);
$current = new DateTime(date('Y-m-d H:i:s'));
if((mysql_num_rows($logged) == 0))
{
echo "Invalid ContestID";
echo '<meta http-equiv="REFRESH" content="2;url=contests.php">';
exit(0);
}
elseif($d1>$current)
{
echo "Contest not yet started";
}
else
{
echo "<h2>".$r['Name']."</h2>";
$query="SELECT * from problems where contestID=".$_GET['contestID'];
$logged=mysql_query($query);
echo <<<EOHTML123
<table border="1" width="100%" >
<tr>
<th>Problem</th><th>Total Submissions</th><th>Accepted Submissions</th>
</tr>
EOHTML123;
$i=0;
while($r=mysql_fetch_array($logged))
{
echo "
<tr ".($i%2==0?"class= 'altrow'":"").">
<td><a href ='problem.php?problemID=".$r['problemID']."'> ".$r['problemName']."</a></td> <td >".$r['submissions']."</td> <td >".$r['accepted']."</td>
</tr>";
$i+=1;
}
echo "</table>";
}
}
?>
</div>
</div>
<?php include("sidebar.php"); ?>
</div>
</div>
<?php include("footer.php"); ?>
</body>