復(fù)制代碼 代碼如下:
<?php
require 'command/config.php';
require 'command/app.php';
app::run($config);
?>
復(fù)制代碼 代碼如下:
public function run($config){
header("Content-type:text/html;charset=utf-8");
self::$config = $config; //加載系統(tǒng)配置
self::copyright();
self::testsystem(); //系統(tǒng)環(huán)境
self::setsystem(); //設(shè)置系統(tǒng)參數(shù)
self::incinfo();
if(!IN_WEB){exit('網(wǎng)站正關(guān)閉維護(hù)中,請(qǐng)稍候訪問(wèn)!');}
defined('KEHENG_DEBUG') or define('KEHENG_DEBUG',true); // 是否調(diào)試模式
self::setpath(); //設(shè)置系統(tǒng)路徑
self::getdatabase(); //測(cè)試數(shù)據(jù)庫(kù)
self::loadlib(); //加載庫(kù)
self::getRouteConfig(); //運(yùn)行路由并加載控制器
}
復(fù)制代碼 代碼如下:
public function getRouteConfig(){
$route_type=self::$config[route][url_type];
switch($route_type){
case 1:
//echo $_SERVER['SCRIPT_NAME'].'<br />';
$query_string=$_SERVER['QUERY_STRING'];
//echo $_SERVER['REQUEST_URI'].'<br />';
$urlstr=$_GET['controller'];
break;
case 4:
$url = end(explode('/', $_SERVER["PHP_SELF"]));
$urlstr = strtolower(substr($url,0,-4));
break;
}
if(file_exists(Contr_DIR.'Controller.php')){
require Contr_DIR.'Controller.php';
//echo $urlstr;
$template = self::$config['Templates'];
controller::load($urlstr,$template);
}else{
exit('控制器文件不存在');
}
}
復(fù)制代碼 代碼如下:
class controller{
public $obj;
public function load($url,$template){
$config=$template;
if(file_exists(Model_DIR.$url.'.model.php')){
$views = new views;
//echo Model_DIR.$url.'.model.php';
require Model_DIR.$url.'.model.php';
$temp = $config[$url][0];
if($temp!='' && $temp!=null && isset($temp)){
if(file_exists(Templ_DIR.$temp)){
//echo Templ_DIR.$temp;
require Templ_DIR.$temp;
}else{
exit('視圖文件不存在!'.$temp);
}
}else{
exit('此頁(yè)未設(shè)置顯示模板!'.$temp);
}
unset($views);
}else{
exit('模型文件不存在:'.$url.'.model.php');
}
}
}
新聞熱點(diǎn)
疑難解答