-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathproblem.php
More file actions
executable file
·133 lines (114 loc) · 3.73 KB
/
problem.php
File metadata and controls
executable file
·133 lines (114 loc) · 3.73 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
<?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="problem">
<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['problemID']))
{
if(!isset($_GET['page']))$page=1;
else $page=intval($_GET['page']);
echo'<table border="1" width="100%" >
<tr><th>Contest</th>
<th>Problem</th><th>Total Submissions</th><th>Accepted Submissions</th>
</tr>';
$page=($page-1)*10;
$query = "SELECT * FROM problems WHERE problemID > ".$page.";";
$logged = mysql_query($query);
if(mysql_num_rows($logged)==0)echo '<meta http-equiv="REFRESH" content="0;url=problem.php">';
$i=0;
while($r= mysql_fetch_array($logged))
{
$query = "SELECT * FROM contests WHERE contestID = ".$r['contestID'].";";
$res = mysql_query($query);
$res= mysql_fetch_array($res);
$ctime = new DateTime(date('Y-m-d H:i:s'));
if($res['startTime'] > date('Y-m-d H:i:s')) continue;
echo "
<tr ".($i%2==0?"class= 'altrow'":"")."><td><a href='contests.php?contestID=".$res['contestID']."'>".$res['Name']."</td>
<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>";
}
else
{
if(is_numeric($_GET['problemID'])!=1)
{
echo "Invalid problemID";
echo '<meta http-equiv="REFRESH" content="1;url=problem.php">';
exit(0);
}
$query = "SELECT * from problems where problemID=".$_GET['problemID'];
$logged=mysql_query($query);
if((mysql_num_rows($logged) == 0))
{
echo "Invalid ProblemID";
echo '<meta http-equiv="REFRESH" content="2;url=problem.php">';
exit(0);
}
$r=mysql_fetch_array($logged);
$query = "SELECT * FROM contests WHERE contestID = ".$r['contestID'].";";
$res = mysql_query($query);
$res= mysql_fetch_array($res);
$res= mysql_fetch_array($res);
$d1 = new DateTime($res['startTime']);
$current = new DateTime(date('Y-m-d H:i:s'));
if($d1>$current){
echo "<meta http-equiv='Refresh' content='4; URL=problem.php' /> ";
exit(0);
}
echo"<h2>".$r['problemName']."</h2><p id='statementpanel'><code class='statement'>";
echo $r['statement'];
echo "</p></code>
<p id='statementpanel'><code class='statement'>
<b>Time Limit:".$r['timeLimit']." seconds </b></br>
<b>Memory Limit:".$r['memoryLimit']." MB </b></br>
</p></code>
";
if($_SESSION['isloggedin']==1){
echo '<form action="insert.php" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" />
<select name="language">
<option value="c">C</option>
<option value="cpp">C++</option>
<option value="py">Python</option>
</select>
<input type="hidden" value='.$_GET['problemID'].' name="problemID">
<input class="button" type="submit" name="submit" value="Submit" />
</form>';
echo'<div class="entry"><h4>Comments</h4><p>';
include('comments/problem/'.$_GET['problemID'].".php");
include('comment.php');
echo'</p></div>';
}
else{
echo "<b>Please login to submit</b>";
}
}
?>
</div>
</div>
<?php include("sidebar.php"); ?>
</div>
</div>
<?php include("footer.php"); ?>
</body>