forked from dom-astro/skywatch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_date_image.php
More file actions
32 lines (25 loc) · 873 Bytes
/
get_date_image.php
File metadata and controls
32 lines (25 loc) · 873 Bytes
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
<?php
$directories = scandir("./",SCANDIR_SORT_DESCENDING);
foreach($directories as $directory){
// Si le répertoire contient est de la forme yyyy-mm-dd (4digits-2digits-2digits)
if (preg_match("/((\d{4})\-(\d{2})\-(\d{2}))/", $directory)) {
// Alors on l'ajoute dans la liste
$lastDirectory = $directory;
break;
}
}
// On récupère la liste des fichiers du répertoire
$files = scandir($lastDirectory, SCANDIR_SORT_DESCENDING);
// Pour chaque fichier
foreach($files as $file) {
// Si le fichier ne contient pas le mot "unfold" et son format est ".jpg"
if (!preg_match("/unfold/", $file) && preg_match("/\.(jpg)$/", $file)) {
// Alors on l'ajoute dans la liste
$lastFile = $file;
break;
}
}
echo $lastDirectory.'/'.$lastFile;
#echo "</br>";
#echo json_encode('data: png;base64,'.base64_encode(file_get_contents($lastDirectory.'/'.$lastFile)));
?>