-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwriteups.php
89 lines (72 loc) · 2.59 KB
/
writeups.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
<?php
include_once('./config.php');
define('SELF_FILE', __FILE__);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>pwn challenge - writeups</title>
<!-- source_header -->
<?php include_once(ROOT_DIR.'template/source_header.php'); ?>
</head>
<body>
<div class="body-wrap boxed-container">
<!-- header -->
<?php include_once(ROOT_DIR.'template/header.php'); ?>
<div class="container">
<h2 class="text-center">Writeups</h2>
<p>You can share write-up or exploit code in your profile, only players who also solved the same challenge are able to see them.</p>
<?php
$conn = get_sql_conn();
$sql = "
select * from
(select b.name as name, count(c.wid) writeup, b.cid as cid
from solved as a
right join challenge as b
on a.cid=b.cid
left join writeups as c
on a.sid=c.sid
group by b.name, b.cid
order by b.cid) e
order by writeup desc
";
$result = $conn->query($sql);
$conn->close();
?>
<table class="table table-hover table-bordered">
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>Submit times</th>
<th> </th>
</tr>
</thead>
<tbody>
<?php
if(isset($result)){
$length = $result->num_rows;
for($i = 0; $i < $length; $i++){
$row = $result->fetch_assoc();
echo "<tr>";
echo "<td>".(string)($i + 1)."</td>";
echo '<td><a href="'.(relative(SELF_FILE)).'user/writeups_challenge.php?cid='.$row['cid'].'">'.htmlspecialchars($row['name'])."</a></td>";
echo "<td>".htmlspecialchars($row['writeup'])."</td>";
echo '<td><a href="'.(relative(SELF_FILE)).'user/writeups_challenge.php?cid='.$row['cid'].'">'."View</a></td>";
echo "</tr>";
}
}
?>
</tbody>
</table>
</div>
<!-- footer -->
<?php include_once(ROOT_DIR.'template/footer.php'); ?>
<!-- source_footer -->
<?php include_once(ROOT_DIR.'template/source_footer.php'); ?>
</div>
</body>
</html>