/
hints.php
63 lines (51 loc) · 1.43 KB
/
hints.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
<?php
require('../include/mellivora.inc.php');
enforce_authentication();
head('Hints');
if (cache_start('hints', CONFIG_CACHE_TIME_HINTS)) {
$hints = db_query_fetch_all('
SELECT
h.id,
h.added,
h.body,
c.title,
ca.title AS category_title
FROM hints AS h
LEFT JOIN challenges AS c ON c.id = h.challenge
LEFT JOIN categories AS ca ON ca.id = c.category
WHERE c.available_from < UNIX_TIMESTAMP() AND c.available_until > UNIX_TIMESTAMP() AND h.visible = 1
ORDER BY h.id DESC
');
if (!count($hints)) {
message_generic("Hints", "No hints have been made available yet.", false);
}
section_head('Hints');
echo '
<table id="files" class="table table-striped table-hover">
<thead>
<tr>
<th>Category</th>
<th>Challenge</th>
<th>Added</th>
<th>Hint</th>
</tr>
</thead>
<tbody>
';
foreach ($hints as $hint) {
echo '
<tr>
<td>',htmlspecialchars($hint['category_title']),'</td>
<td>',htmlspecialchars($hint['title']),'</td>
<td>',time_elapsed($hint['added']),' ago</td>
<td>',htmlspecialchars($hint['body']),'</td>
</tr>
';
}
echo '
</tbody>
</table>
';
cache_end('hints');
}
foot();