标签:style blog os io ar 文件 数据 art div
index.php:
<?php
require_once ‘config.php‘;
require_once DB_DIR . ‘db.php‘;
//数据库对象
$DB = new MySQL();
/**
* 单入口Dispatcher处理
*/
//是否登陆
//if ($_GET[‘action‘] != ‘login‘) {
// if (empty($_SESSION[‘user‘])) {
// return 0;
// }
//}
$controller = !empty($_GET[‘controller‘]) ? $_GET[‘controller‘] : ‘index.php‘;
$dir = CLASSES_DIR . ‘/‘ . $controller . ‘/‘ . $controller . ‘.php‘;
if (is_file($dir) && !empty($_GET[‘controller‘])) {
include_once $dir;
$obj = new $_GET[‘controller‘]();
$action = $_GET[‘action‘];
if (!empty($action)) {
echo $obj->$action();
}
//清除对象
unset($obj);
} else {
//未登陆或请求错误
echo 0;
}
$DB->CloseConnection();
config.php:
<?php
error_reporting(E_ERROR);
session_start(); //开启session
date_default_timezone_set(‘Asia/Shanghai‘); //时区设置
/**
* 文件地址常量定义
*/
define(‘BASE_DIR‘, dirname(__FILE__)); //根目录
define(‘CLASSES_DIR‘, BASE_DIR . ‘/Classes/‘); //Classes目录
define(‘DB_DIR‘, CLASSES_DIR . ‘db/‘); //数据库对象目录
define(‘TEST_DIR‘, CLASSES_DIR . ‘test/‘); //php测试类
标签:style blog os io ar 文件 数据 art div
原文地址:http://www.cnblogs.com/MrLenon/p/3949513.html