-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path_reports.php
46 lines (38 loc) · 1.07 KB
/
_reports.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
function listFolderFiles($dir){
foreach(scandir($dir) as $file){
if ($file[0] == '.')
continue;
if (is_dir("$dir/$file"))
foreach (listFolderFiles("$dir/$file") as $infile)
yield $infile;
else
yield "${dir}/${file}";
}
}
function scanDirOrderByModifiedDate($dir) {
$ignored = array('.', '..', '.svn', '.htaccess', ".html");
$files = array();
foreach (scandir($dir) as $file) {
if (in_array($file, $ignored)) continue;
$files[$file] = filemtime($dir . '/' . $file);
}
arsort($files);
$files = array_keys($files);
return ($files) ? $files : false;
}
function getLastReport($dir){
$files = scanDirOrderByModifiedDate($dir);
if (!$files) {
die("No hay archivos de reporte");
}
$filePath = $dir . "/" . $files[0];
$f = fopen($filePath, 'r');
if ($f) {
$contents = fread($f, filesize($filePath));
fclose($f);
header("Content-Type: application/json");
echo $contents;
exit();
}
}