how did that happend?

This commit is contained in:
overflowerror 2014-03-08 23:19:41 +01:00
parent 10c608e039
commit 5f5dcdea47

27
wish-sys/sys-part/lib/kernel/files.php Normal file → Executable file
View file

@ -10,4 +10,31 @@
}
echo json_encode($files);
}
if (isset($_GET['getStructure'])) {
if (strpos($_GET['dir'], "../") !== false)
die("illegal file path");
$dir = $_GET['dir'];
while (substr($dir, 0, 1) == "/")
$dir = substr($dir, 1);
$base = "../../../../" . $dir;
$structure = getStructure($base);
echo json_encode($structure);
}
function getStructure($base) {
$result = array();
$handle = opendir($base);
while ($file = readdir($handle)) {
if ($file == "." || $file == "..")
continue;
if (!is_dir($base . "/" . $file))
$result[$file] = file_get_contents($base . "/" . $file);
else
$result[$file] = getStructure($base . "/" . $file);
}
return $result;
}
?>