我有一个前端控制器,用于设置页面中的各种元素。但是我突然想到,也许有些元素的顺序不正确;我的意思是,某些元素可能需要在其他元素之前使用/声明。
或者,换一种说法:我是否以最佳/正确的方式构建了文件。例如 session_start() 应该在 ini_set() 之后出现,依此类推。
ini_set('session.use_cookies', 1);
ini_set('session.use_only_cookies', 1);
ini_set('session.use_trans_sid', 0);
$mytimeout = 720 * 60; // (12hrs*60m=720) // minutes * 60
session_set_cookie_params($mytimeout);
$sessdir = "../application/data";
ini_set('session.save_path', $sessdir);
session_cache_expire($mytimeout / 60);
ini_set('session.gc_maxlifetime', $mytimeout);
session_start();
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
require_once('../application/models/front.php');
require_once('../application/models/icontroller.php');
require_once('../application/models/view.php');
require_once('../application/models/db.php');
require_once('../application/models/sconfig.php');
require_once('../application/models/acl.php');
require_once('../application/controllers/index.php');
require_once('../application/controllers/user.php');
require_once('../application/controllers/error.php');
require_once('../application/controllers/blog.php');
require_once('../application/controllers/about.php');
function exception_handler($exception) {
echo "Sorry something went wrong; And or we couldnt find what you requested.<br />We suggest you go back to our <a href=\"/\">home page</a> and try again.<br />We have logged this request in order to provide a better service.<br /> *** ". $exception->getMessage()." ***";
}
set_exception_handler('exception_handler');
$fc = FrontController::getInstance();
$c=$fc->getController();
$a=$fc->getAction();
$users=ACL::getInstance();
$sid=session_id();
if(isset($_SESSION['HTTP_USER_AGENT'])){
if($_SESSION['HTTP_USER_AGENT'] != md5($_SERVER['HTTP_USER_AGENT'])){
session_regenerate_id(TRUE);
$_SESSION=array();
$users->removeUser($sid);
if(($c!='error')&&($a!='badsession')){
$fc->redirect("error/badsession");
}
}
}
else{
$_SESSION['HTTP_USER_AGENT'] = md5($_SERVER['HTTP_USER_AGENT']);
}
$dbh=DBConnection::getInstance();
setcookie('ct', 1,0,"/");
$config = Configuration::getInstance();
$cf=array();
$cf=$config->getall();
$users=ACL::getInstance();
$users->addUser();
$users->removeOld();
$front = FrontController::getInstance();
$front->route();
echo $front->getBody();