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