-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.phtml
40 lines (40 loc) · 1.24 KB
/
index.phtml
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
<!DOCTYPE html>
<html>
<head>
<title>Список турниров</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="index.css">
</head>
<body>
<?php
date_default_timezone_set('Europe/Ulyanovsk');
$date = date('ymd');
echo '<span class="tournament">';
echo '<a href="table.html?name=' . $date . '">Создать новый турнир</a>';
echo '<input type="text" name="filename" value="' . $date . '" maxlength="26">';
echo '</span>';
$tournaments = [];
$directory = opendir('saves');
while ($filename = readdir($directory)) {
if (substr($filename, -4) === 'json') {
$tournaments[] = $filename;
}
}
closedir($directory);
$tournaments = array_map(function ($filename) {
return [substr($filename, 0, -5), filemtime('saves' . DIRECTORY_SEPARATOR . $filename)];
}, $tournaments);
usort($tournaments, function ($s1, $s2) {
return $s1[1] > $s2[1] ? -1 : 1;
});
array_walk($tournaments, function ($filedata) {
list($name, $time) = $filedata;
echo '<span class="tournament">';
echo '<a href="table.html?name=', $name, '">', $name, '</a>';
echo '<span>', date('H:i d.m.Y', $time), '</span>';
echo '</span>';
});
?>
<script type="text/javascript" src="index.js"></script>
</body>
</html>