修复错误
This commit is contained in:
@@ -11,14 +11,14 @@ foreach ($directory as $folderinfo) {
|
||||
}
|
||||
|
||||
foreach ($folders as $folder) {
|
||||
$subDirectory = new DirectoryIterator(dirname(__FILE__) . $folder);
|
||||
$subDirectory = new DirectoryIterator(dirname(__FILE__) . '/' . $folder);
|
||||
foreach ($subDirectory as $fileinfo) {
|
||||
if ($fileinfo->isFile() && $fileinfo->getExtension() == 'html') {
|
||||
$files[] = $folder . '/' . $fileinfo->getFilename();
|
||||
}
|
||||
}
|
||||
}
|
||||
sort($folder);
|
||||
sort($folders);
|
||||
sort($files);
|
||||
?>
|
||||
|
||||
@@ -37,12 +37,15 @@ sort($files);
|
||||
<?php
|
||||
if (isset($_GET['file'])) {
|
||||
$file = $_GET['file'];
|
||||
$filePath = dirname(__FILE__) . '/' . $file;
|
||||
if (file_exists($filePath) && is_readable($filePath)) {
|
||||
if (pathinfo($filePath, PATHINFO_EXTENSION) == 'php') {
|
||||
include $filePath;
|
||||
// Validate file path to prevent directory traversal
|
||||
$realPath = realpath(dirname(__FILE__) . '/' . $file);
|
||||
$basePath = realpath(dirname(__FILE__));
|
||||
|
||||
if ($realPath && strpos($realPath, $basePath) === 0 && file_exists($realPath) && is_readable($realPath)) {
|
||||
if (pathinfo($realPath, PATHINFO_EXTENSION) == 'php') {
|
||||
include $realPath;
|
||||
} else {
|
||||
echo file_get_contents($filePath);
|
||||
echo file_get_contents($realPath);
|
||||
}
|
||||
} else {
|
||||
echo '<p>File not found or not readable.</p>';
|
||||
|
||||
Reference in New Issue
Block a user