realpath file, result in error if !exist / !docroot

This commit is contained in:
Matt Pass
2014-09-17 13:35:00 +01:00
parent 9c35206e3b
commit 113e045f26

View File

@@ -12,8 +12,10 @@ $maxLines = $_GET['maxLines'];
$result = "ok";
for ($i=0; $i<count($files); $i++) {
$files[$i] = $_SERVER['DOCUMENT_ROOT'].$files[$i];
if (!file_exists($files[$i])) {
// Work out the real path for a file
$files[$i] = realpath($_SERVER['DOCUMENT_ROOT'].$files[$i]);
// If we can't find that file or it doesn't start with the doc root, it's an error
if (!file_exists($files[$i]) || strpos($files[$i],$_SERVER['DOCUMENT_ROOT']) !== 0) {
$result = "error";
} else {
$filesSizesSeen[$i] = filesize($files[$i]);