-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrank.php
More file actions
70 lines (57 loc) · 2.19 KB
/
rank.php
File metadata and controls
70 lines (57 loc) · 2.19 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
<?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 - Rank</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">Rank</h2>
<?php
$conn = get_sql_conn();
$sql = "select * from (select a.nickname as nickname, a.comment as comment, count(b.sid) as solved, a.uid as uid from user as a left join solved as b on a.uid=b.uid group by a.nickname) as c order by solved desc, uid limit 100";
$result = $conn->query($sql);
?>
<table class="table table-hover table-bordered">
<thead>
<tr>
<th>#</th>
<th>Nickname</th>
<th>solved</th>
<th>Comment</th>
</tr>
</thead>
<tbody>
<?php
$length = $result->num_rows;
for($i = 0; $i < $length; $i++){
$row = $result->fetch_assoc();
echo "<tr>";
echo "<td>".(string)($i + 1)."</td>";
echo "<td>".htmlspecialchars($row['nickname'])."</td>";
echo "<td>".htmlspecialchars($row['solved'])."</td>";
echo "<td>".($row['comment'] ? htmlspecialchars($row['comment']) : "NULL")."</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>