-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
46 lines (38 loc) · 1.2 KB
/
index.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
<?php
// Check if we are in a mission, then throw 404, cause file is missing.
$uriParts = explode('/', $_SERVER['REQUEST_URI']);
if (count($uriParts) >= 3 && $uriParts[1] === 'missions') {
die('404 - file not found');
}
$categories = [];
foreach (scandir(__DIR__ . '/missions') as $category) {
if (!is_dir(__DIR__ . '/missions/' . $category)) {
continue;
}
if (substr($category, 0, 1) === '.') {
continue;
}
$categories[] = $category;
};
echo '<ul>';
foreach ($categories as $category) {
$missions = [];
foreach (scandir(__DIR__ . '/missions/' . $category) as $mission) {
if (!is_dir(__DIR__ . '/missions/' . $category . '/' . $mission)) {
continue;
}
if (substr($mission, 0, 1) === '.') {
continue;
}
$missions[] = $mission;
};
echo '<li>';
echo $category . ' (' . count($missions) . ' missions)';
echo '<ul>';
foreach ($missions as $mission) {
echo '<li><a href="' . $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'] . '/missions/' . $category . '/' . $mission . '/">' . $category . ' ' . $mission . '</a></li>';
}
echo '</ul>';
echo '</li>';
}
echo '</ul>';