自製一個小小的網站,其中一個功能總是有問題,求各位解答?
one.php:(開始啟動並執行入口)
/**
* index.php MyLocalShop 入口
*
* @copyright(C)2013-2014 MyLocalShop
* @licensehttp://www.baidu.com/
* @lastmodify2013-01-07
*/
/**
* 網站根目錄路徑
* @var string
*/
define('LOCALSHOP_PATH', dirname(__FILE__).DIRECTORY_SEPARATOR);
//echo LOCALSHOP_PATH;
require_once LOCALSHOP_PATH.'/base.php';
$mls = new MLS();
$mls->Load('front/includes/', 'dindex.phdp'); // 這是錯誤的,但為什麼這裡同樣正確顯示?
$mls->Load('front/includes/', 'index.php'); // 這個才是真本文件名
?>
dir_list.php:(顯示分類樹結構用於在base.php中判斷是否有該目錄或檔案)
/**
* 顯示整個網站的分類樹結構
* @author Administrator
*
*/
function dir_list() {
return array(
'admin' => array(
'css',
'images',
'includes' => array(
'libs'
),
'js'
),
'common' => array(
'config' => array(
'admin' => array(
'config.php'
),
'front' => array(
'config.php'
),
'config.php',
'dir_list.php'
),
'includes' => array(
'libs'
),
'js',
'languages' => array(
'en_US' => array(
'admin' => array(
'common.php'
),
'front' => array(
'common.php'
)
),
'zh_CN' => array(
'admin' => array(
'common.php'
),
'front' => array(
'common.php'
)
)
),
'templates' => array(
'Templates.php'
)
),
'front' => array(
'css',
'images',
'includes' => array(
'libs'
),
'js'
),
//'base.php',
//'index.php'
);
}
?>
base.php:(用於檢查目錄及檔案名稱是否存在,存在則轉向所指頁面)
/**
* MyLocalShop 架構入口
* @author Administrator
*
*/
require_once LOCALSHOP_PATH.'/common/config/dir_list.php';
class MLS {
/**
* 私人函數。判斷是否存在該目錄或檔案,有則返回true,無則返回false
* @param string $target目錄或檔案
* @return 若判斷為檔案類型則返回"beFile",若判斷為目錄類型則返回"beDir";若既不是檔案也不是目錄則返回 false。
*/
private function hasDirectoryOrFile($target) {
$dirs = MLS::load_all_directory();
foreach ($dirs as $key => $value) {
if (in_array($target, $value)) {
$suffix = substr($target, -1, 4);
if ($suffix === '.php')
/*if (strrchr('.php', $target) || strrchr('.html', $target) || strrchr('.htm', $target) || strrchr('.xhtm', $target) ||
strrchr('.xhtml', $target) || strrchr('.tpl', $target) || strrchr('.xml', $target) || strrchr('.xls', $target) ||