define(“PATH_REGULATION”,”~[(\\\\)|(/)]+~”);
define(“DOC_ROOT”,preg_replace(PATH_REGULATION,’/’,$_SERVER[‘DOCUMENT_ROOT’]));
define(“SITE_ABS_DIR”,preg_replace(PATH_REGULATION,’/’,dirname(__FILE__)));
define(“SITE_DIR”,preg_replace(PATH_REGULATION,’/’,str_replace(DOC_ROOT,””,SITE_ABS_DIR)));
define(“MULTIBYTE_LEN”,strlen(“一”));
$includePath = array(
SITE_ABS_DIR.”/lib”,
SITE_ABS_DIR.”/lib/api”,
SITE_ABS_DIR.”/lib/exception”,
SITE_ABS_DIR.”/lib/model/mo”,
SITE_ABS_DIR.”/lib/model/vo”
);
set_include_path(join(DIRECTORY_SEPARATOR == “/” ? “:” : “;”,$includePath));
/**
* 自动载入所需要的类
*
* @param string $class 类名
* @return void
*/
function __autoload($class){
include_once(“$class.inc.php”);
}
/**
* 最外层自定义异常捕获接口
*
* @param unknown_type $e
*/
function __exception_handler($e){
GLog::reportToPage($e);
}
function getLastPage($default = “”){
if (!empty($_SERVER[“HTTP_REFERER”]))
return $_SERVER[“HTTP_REFERER”];
else
return $default == “” ? GDir::getRelativePath(“/index.php”) : $default;
}
session_start();
date_default_timezone_set(GConfig::DEFAULT_TIMEZONE );
set_exception_handler(array(GLog,”reportToPage”));
//set_exception_handler(“GLog::reportToPage”); //PHP Version 5.2.1 中,不能这样写
//set_exception_handler(“__exception_handler”);