-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
66 lines (55 loc) · 1.68 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
$content = '
<!doctype html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="src/app.css">
<script src="src/app.js"></script>
</head>
<body>
<div class="container">
<img class="logo" src="src/img/logo.png" alt="Logo">
<h1>Fotobox Bilder</h1>
<div class="description">Hier finden Sie alle Bilder, die mit der Fotobox aufgenommen wurden. Durch einen Klick wird das jeweilige Bild direkt heruntergeladen.</div>
<div class="image-grid">';
$fileExtensions = [
'jpg',
'png',
'jpeg',
];
$images = [];
$directory = "images/";
foreach ($fileExtensions as $fileExtension) {
$lowerCaseExtension = '*.' . $fileExtension;
$globResult = glob($directory . $lowerCaseExtension);
array_push($images, ...($globResult ?: []));
$uppercaseExtension = '*.' . strtoupper($fileExtension);
$globResult = glob($directory . $uppercaseExtension);
array_push($images, ...($globResult ?: []));
}
usort($images, static function ($a, $b) {
return filemtime($b) - filemtime($a);
});
foreach ($images as $image) {
$urlEncodedFile = urlencode($image);
$date = new DateTime();
$date->setTimestamp(filemtime($image));
$dateTime = $date->format('d.m.Y H:i:s');
$content .= <<<EOF
<figure>
<a class="image-grid__image-wrapper" href="download.php?file=$urlEncodedFile" target="_blank">
<img loading="lazy" class="image-grid__image" src="$image">
</a>
<figcaption>$dateTime</figcaption>
</figure>
EOF;
}
$content .= '
</div>
</div>
</body>
</html>';
echo $content;