prevents debug users from exploring system's directory structure * ex: $root = $_SERVER['DOCUMENT_ROOT']; */ function path($dir) { return mb_substr($dir,-1) == '/' ? $dir : $dir.'/'; } function is_top($dir) { global $root; return mb_strlen($dir) > mb_strlen($root); } function no_dots($name) { return !in_array($name, ['.','..']); } function my_dir($name) { global $rootdir, $userdir, $topdir, $UDincluded; return ($rootdir === $userdir && in_array($name, $UDincluded)) ? $topdir : $rootdir; } $root = path(realpath($_POST['root'])); if (!$root) exit("ERROR: Root filesystem directory not set in jqueryFileTree.php"); $docroot = '/usr/local/emhttp'; require_once "$docroot/webGui/include/Secure.php"; $mntdir = '/mnt/'; $userdir = '/mnt/user/'; $rootdir = path(realpath($_POST['dir'])); $topdir = str_replace($userdir, $mntdir, $rootdir); $filters = (array)$_POST['filter']; $match = $_POST['match']; $checkbox = $_POST['multiSelect'] == 'true' ? "" : ""; // Excluded UD shares to hide under '/mnt' $UDexcluded = ['RecycleBin', 'addons', 'rootshare']; // Included UD shares to show under '/mnt/user' $UDincluded = ['disks','remotes']; echo ""; ?>