-
Notifications
You must be signed in to change notification settings - Fork 0
/
aciTree.php
executable file
·48 lines (37 loc) · 1.44 KB
/
aciTree.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
<?php
// get the tree JSON data for the file system listing
$path = dirname(__FILE__);
require_once("$path/Tree.php");
require_once("$path/FsTree.php");
// we limit the access to "$path/tree"
$fsTree = new FsTree(new Fs("$path/tree"));
// what branch was requested?
$branch = isset($_GET['branch']) ? $_GET['branch'] : null;
// special case for 1k test from the demo (skip the 'sleep' thing and return faster)
if ((strpos($branch, 'a_new_File_ID') !== false) || (strpos($branch, 'a_new_Folder_ID') !== false)) {
// burn your CPU not the server with the 1k entries ... ;))
if (preg_match('@[0-9]+$@', $branch, $match) == 1) {
if ((int) $match[0] > 20) {
die('[]');
}
}
sleep(1);
die('[]');
}
if (strpos($branch, '..') !== false) {
// path should not have a [..] inside ;-)
$branch = 'undefined';
}
// a small delay so we can see the loading animation
// (comment it for faster return)
sleep(1);
// no cache so we can see the loading animation :)
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
// get the branch (1 level)
$fsTree->json($branch);
// this will get the entire tree (comment above and uncomment this)
//$fsTree->json($branch, true);