日期:2014-05-17  浏览次数:20420 次

自制一个小小的网站,其中一个功能总是有问题,求各位解答?
one.php:(开始运行的入口)

<?php
/**
 * index.php MyLocalShop 入口
 * 
 * @copyright (C)2013-2014 MyLocalShop
 * @license http://www.baidu.com/
 * @lastmodify 2013-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中判断是否有该目录或文件)

<?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:(用于检查目录及文件名是否存在,存在则转向所指页面)

<?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) || st