-
Notifications
You must be signed in to change notification settings - Fork 4
/
isuptodate.php
33 lines (28 loc) · 1.16 KB
/
isuptodate.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
<?php
date_default_timezone_set('Europe/Paris');
require __DIR__.'/app/File.php';
require __DIR__.'/app/Impact.php';
header('Content-Type: text/plain');
$today = (new DateTime())->modify('-3 minutes');
foreach(scandir(__DIR__.'/datas/json', SCANDIR_SORT_DESCENDING) as $folder) {
if(!is_dir(__DIR__.'/datas/json/'.$folder) ){
continue;
}
foreach(scandir(__DIR__.'/datas/json/'.$folder, SCANDIR_SORT_DESCENDING) as $filename) {
$file = new File(__DIR__.'/datas/json/'.$folder.'/'.$filename);
if(!$file->isValid()) {
http_response_code('500');
echo "Le dernier fichier est conforme : ERROR ($filename)\n";
exit;
}
echo "Le dernier fichier est conforme : SUCCESS ($filename)\n";
if($today > $file->getDate()) {
http_response_code('500');
echo "Le dernier fichier récupéré date d'il y a moins de 2 minutes : ERROR (".$file->getDate()->format('Y-m-d H:i:s').")\n";
exit;
}
echo "Le dernier fichier récupéré date d'il y a moins de 2 minutes : SUCCESS (".$file->getDate()->format('Y-m-d H:i:s').")\n";
break;
}
break;
}