-
Notifications
You must be signed in to change notification settings - Fork 18
/
archive.php
373 lines (244 loc) · 8.18 KB
/
archive.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
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
<?php
session_start();
$_SESSION['url'] = $_SERVER['REQUEST_URI'];
if(!isset($_SESSION["un"]))
{
header("Location:login.php");
}
if(isset($_SESSION['un']))
{
$username=$_SESSION['un'];
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Archive</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/font-awesome.min.css">
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="css/style.css">
<link rel="icon" type="image/png" href="img/ruet.png">
<script src="js/vendor/modernizr-2.8.3.min.js"></script>
<script src="js/vendor/modernizr-2.8.3.min.js"></script>
<script src="js/vendor/jquery-1.12.0.min.js"></script>
<script src="bootstrap-3.3.7/js/bootstrap.min.js" </script>
<script src="bootstrap-3.3.7/js/bootstrap.js" </script>
</head>
<body>
<div class="main">
<div class="row">
<div class="col-sm-12">
<nav class="shadow navbar navbar-inverse navbar-fixed-top nbar">
<div class="navbar-header">
<a class="navbar-brand lspace" href="home.php">RUET OJ</a>
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-menubuilder"><span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse navbar-menubuilder">
<ul class="nav navbar-nav">
<li class="space"><a href="compiler.php"><i class="fa fa-code ispace"></i>Compiler</a></li>
<li class="space"><a href="archive.php"><i class="fa fa-archive ispace"></i>Problem Archive</a></li>
<li class="space"><a href="contest.php"><i class="fa fa-cogs ispace"></i>Contests</a></li>
<li class="space"><a href="allsubmission.php"><i class="fa fa-check-square ispace"></i>Submission</a></li>
<li class="lgspace space"><a href="profile.php?user=<?php echo("$username"); ?>"><i class="fa fa-user ispace"></i><?php echo("$username"); ?></a></li>
<li class="space"><a href="logout.php"><i class="fa fa-power-off ispace"></i>Logout</a></li>
</ul>
</div>
</nav>
</div>
</div>
<div class="row log">
<div class=""><h3 style="text-align:center;">Problem Archive</h3></div>
</div>
<div class="row cspace">
<div class="col-sm-1">
</div>
<div class="col-sm-9">
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>ID</th>
<th>Problem Name</th>
<th>Status</th>
<th>Accepted/Submission</th>
<th>Problem Setter</th>
</tr>
</thead>
<tbody>
<?php
require_once("config.php");
error_reporting(0);
if(isset($_POST['pname']))
{
$pn=$_POST['pname'];
$pd=$_POST['description'];
$author=$_POST['c2'];
$tc=$_POST['case'];
$ac=$_POST['result'];
$ptl=$_POST['tll'];
}
error_reporting(0);
if(isset($pn))
{
$sql="INSERT INTO archieve VALUES(NULL,'$pn','$pd','$author','$tc','$ac','','$ptl')";
$sq=mysqli_query($con,$sql);
/*if($sq)
{
$last_id=mysqli_insert_id($con);
}
*/
$per_page=10;
if(isset($_GET['page']))
{
$page=$_GET['page'];
}
else
{
$page=1;
}
$start=($page-1)*$per_page;
$show="SELECT * FROM archieve limit $start,$per_page"; //start from 0 index
$send=mysqli_query($con,$show);
while($row=mysqli_fetch_array($send))
{
$problem_name=$row['pbname'];
$number="SELECT verdict from submissions WHERE pbname='$row[pbname]' and sname='$username' and verdict='Accepted'";
$snumber=mysqli_query($con,$number);
$tsol=mysqli_num_rows($snumber);
$acn="SELECT COUNT(verdict) AS verdict from submissions WHERE verdict='Accepted' AND pbname='$row[pbname]' GROUP BY pbname";
$sacn=mysqli_query($con,$acn);
$sol=mysqli_fetch_array($sacn);
$tsub="SELECT COUNT(verdict) as sub from submissions WHERE pbname='$row[pbname]' GROUP BY pbname";
$stsub=mysqli_query($con,$tsub);
$ntsub=mysqli_fetch_array($stsub);
if($tsol>0)
{
$ver="Solved";
echo "
<tr><td>$row[id]</td><td><a href=\"description.php?id=$row[id]\"><div class=\"\">$row[pbname]</div></a></td><td><div class=\"btn btn-success btn-xs\">$ver</div></td><td><progress id=\"myProgress\" value=\"$sol[verdict]\" max=\"$ntsub[sub]\"></progress> $sol[verdict]/$ntsub[sub]</td><td>$row[pbauthor]</td></tr>";
}
else
{
$ver="Unsolved";
echo "
<tr><td>$row[id]</td><td><a href=\"description.php?id=$row[id]\"><div class=\"\">$row[pbname]</div></a></td><td><div class=\"btn btn-danger btn-xs\">$ver</div></td><td><progress id=\"myProgress\" value=\"$sol[verdict]\" max=\"$ntsub[sub]\"></progress> $sol[verdict]/$ntsub[sub]</td><td>$row[pbauthor]</td></tr>";
}
}
echo "</tbody>
</table>
</div><br><br>";
$psql="SELECT * FROM archieve";
$sn=mysqli_query($con,$psql);
$total_rows=mysqli_num_rows($sn);
$total_page=ceil($total_rows/$per_page);
$c="active";
echo "<div style=\"text-align:center\"><ul class=\"pagination\"><li><a href=\"archive.php?page=1\">First Page</a></li>";
for ($i=1; $i <$total_page ; $i++) {
if($page==$i)
{
$c="active";
}
else
{
$c="";
}
echo "<li class=\"$c\"><a href=\"archive.php?page=$i\">$i</a></li>";
}
echo "<li><a href=\"archive.php?page=$total_page\">Last Page</a></li></ul></div>";
}
if(!isset($pn))
{
$per_page=10;
if(isset($_GET['page']))
{
$page=$_GET['page'];
}
else
{
$page=1;
}
$start=($page-1)*$per_page;
$show="SELECT * FROM archieve limit $start,$per_page";
$send=mysqli_query($con,$show);
while($row=mysqli_fetch_array($send))
{
$problem_name=$row['pbname'];
$number="SELECT verdict from submissions WHERE pbname='$row[pbname]' and sname='$username' and verdict='Accepted'";
$snumber=mysqli_query($con,$number);
$tsol=mysqli_num_rows($snumber);
$acn="SELECT COUNT(verdict) AS verdict from submissions WHERE verdict='Accepted' AND pbname='$row[pbname]' GROUP BY pbname";
$sacn=mysqli_query($con,$acn);
$sol=mysqli_fetch_array($sacn);
$tsub="SELECT COUNT(verdict) as sub from submissions WHERE pbname='$row[pbname]' GROUP BY pbname";
$stsub=mysqli_query($con,$tsub);
$ntsub=mysqli_fetch_array($stsub);
if($tsol>0)
{
$ver="Solved";
echo "
<tr><td>$row[id]</td><td><a href=\"description.php?id=$row[id]\"><div class=\"\">$row[pbname]</div></a></td><td><div class=\"btn btn-success btn-xs\">$ver</div></td><td><progress id=\"myProgress\" value=\"$sol[verdict]\" max=\"$ntsub[sub]\"></progress> $sol[verdict]/$ntsub[sub]</td><td>$row[pbauthor]</td></tr>";
}
else
{
$ver="Unsolved";
echo "
<tr><td>$row[id]</td><td><a href=\"description.php?id=$row[id]\"><div class=\"\">$row[pbname]</div></a></td><td><div class=\"btn btn-danger btn-xs\">$ver</div></td><td><progress id=\"myProgress\" value=\"$sol[verdict]\" max=\"$ntsub[sub]\"></progress> $sol[verdict]/$ntsub[sub]</td><td>$row[pbauthor]</td></tr>";
}
}
echo "</tbody>
</table>
</div><br><br>";
$psql="SELECT * FROM archieve";
$sn=mysqli_query($con,$psql);
$total_rows=mysqli_num_rows($sn);
$total_page=ceil($total_rows/$per_page);
$c="active";
echo "<div style=\"text-align:center\"><ul class=\"pagination\"><li><a href=\"archive.php?page=1\">First Page</a></li>";
for ($i=1; $i <$total_page ; $i++) {
if($page==$i)
{
$c="active";
}
else
{
$c="";
}
echo "<li class=\"$c\"><a href=\"archive.php?page=$i\">$i</a></li>";
}
echo "<li><a href=\"archive.php?page=$total_page\">Last Page</a></li></ul></div>";
}
?>
</div>
<div class="col-sm-2">
<!--<a href="allsubmission.php"><div class="btn btn-primary">Submissions</div></a><br><br>-->
</div>
</div>
</div><br><br><br><br>
<div class="area">
<div class="well foot">
<div class="row area">
<div class="col-sm-3">
</div>
<div class="col-sm-5">
<div class="">
<b>Beta Version-2016</b><br>
<b>Developed By Ashadullah Shawon</b>
</div>
</div>
<div class="col-sm-4">
<?php
require_once("time.php");
?>
</div>
</div>
</div>
</div>
</body>
</html>