0
我想確保我的頁面被包含在工作索引頁面中。我想知道什麼纔是確保我的頁面被包含而不是自己渲染的正確方法?如何正確檢查是否包含頁面?
現在我正在檢查是否至少有2個包含文件,但我不確定我是否會有這種行爲。包括('config/config.inc.php');
$cms = new cms();
if(($_SERVER['REQUEST_METHOD'] === 'GET' || $_SERVER['REQUEST_METHOD'] === 'POST') && !empty($_GET['page'])) {
include($cms->GetTheme() . "/head.php");
$cms->IncludeModule($_GET['page']); <- actual page being included
include($cms->GetTheme() . "/foot.php");
} // end (GET || POST) && GET
else { // just index.php
include($cms->GetTheme() . "/head.php");
foreach($cms->GetModuleList() as $module) {
echo " <a href=\"index.php?page=$module\"> $module </a><br />";
}
include($cms->GetTheme() . "/foot.php");
} // end ELSE
包含的頁面,我該如何檢查是它包含
<?php
$module_name = 'Log out user';
$module_directory = 'admin';
$this->SetTitle($module_name); // setting page title
if(count(get_required_files()) < 2) {
header('Location: index.php');
}
else {
if(isset($_SESSION['user'])) {
$this->DestroyUser();
echo "You have been logged out! Please navigate to the <a href=\"index.php?page=login\">Login Page</a>.";
}
else {
header('Location: index.php?page=login');
}
}
?>
如果您將要包含的文件移出網頁根目錄,您知道它們永遠不會被自己請求。 – jeroen 2014-10-30 01:15:23