-
Notifications
You must be signed in to change notification settings - Fork 0
/
scan.php
36 lines (28 loc) · 1.02 KB
/
scan.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
<?php
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Credentials: true");
header('Content-type: application/json');
//$files = array_map('basename', glob("./data/*.{txt}", GLOB_BRACE));
//echo json_encode($files);
$path = 'projects';
$directory = new RecursiveDirectoryIterator($path,RecursiveDirectoryIterator::SKIP_DOTS);
$iterator = new RecursiveIteratorIterator($directory,RecursiveIteratorIterator::LEAVES_ONLY);
$extensions = array("project.json");
foreach ($iterator as $fileinfo) {
if (in_array($fileinfo->getFilename(), $extensions)) {
$activedirs[] = $fileinfo->getPath();
}
}
//echo '<pre>';
//print_r($activedirs);
//echo '</pre>';
foreach ($activedirs as $dir) {
$string = file_get_contents($dir."/project.json");
$json_a = json_decode($string, true);
$json_a['dir'] = $dir;
$json_a["files"] = array_map('basename', glob($dir."/*.{pdf,jpg,png}", GLOB_BRACE));;
// echo $json_a['id']." ".$json_a['title'];
$jsons[] = $json_a;
}
echo json_encode($jsons);
?>