Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
malwaredllc
GitHub Repository: malwaredllc/byob
Path: blob/master/web-gui/buildyourownbotnet/assets/js/aci-tree/php/aciTree.php
1293 views
1
<?php
2
3
error_reporting(E_ERROR);
4
5
// get the tree JSON data for the file system listing
6
7
$path = dirname(__FILE__);
8
9
require_once("$path/Tree.php");
10
require_once("$path/FsTree.php");
11
12
// we limit the access to "$path/tree"
13
$fsTree = new FsTree(new Fs("$path/tree"));
14
15
// what branch was requested?
16
$branch = isset($_GET['branch']) ? $_GET['branch'] : null;
17
18
// special case for 1k test from the demo (skip the 'sleep' thing and return faster)
19
if ((strpos($branch, 'a_new_File_ID') !== false) || (strpos($branch, 'a_new_Folder_ID') !== false)) {
20
// burn your CPU not the server with the 1k entries ... ;))
21
if (preg_match('@[0-9]+$@', $branch, $match) == 1) {
22
if ((int) $match[0] > 20) {
23
die('[]');
24
}
25
}
26
sleep(1);
27
die('[]');
28
}
29
30
if (strpos($branch, '..') !== false) {
31
// path should not have a [..] inside ;-)
32
$branch = 'undefined';
33
}
34
35
// a small delay so we can see the loading animation
36
// (comment it for faster return)
37
sleep(1);
38
39
// no cache so we can see the loading animation :)
40
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
41
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
42
header('Cache-Control: no-store, no-cache, must-revalidate');
43
header('Cache-Control: post-check=0, pre-check=0', false);
44
header('Pragma: no-cache');
45
46
// get the branch (1 level)
47
$fsTree->json($branch);
48
49
// this will get the entire tree (comment above and uncomment this)
50
//$fsTree->json($branch, true);
51
52