作者:LAMP小白 点击:5374 发布日期:2013-03-22 23:57:00 返回列表
这个文件类似于主要是设置一些基础的常量和声明类pc_base()实现对资源的管理
定义的常量有
//安全设置 防止直接针对某个文件进行访问
define('IN_PHPCMS', true);
//PHPCMS框架路径
define('PC_PATH', dirname(__FILE__).DIRECTORY_SEPARATOR);
//如果没有PHPCMS_PATH则在这里补充声明根目录路径 这种情况只有在没有通过index.php访问的情况下发生 难道有时会直接包含这个文件?
if(!defined('PHPCMS_PATH')) define('PHPCMS_PATH', PC_PATH.'..'.DIRECTORY_SEPARATOR);
//缓存文件夹地址
define('CACHE_PATH', PHPCMS_PATH.'caches'.DIRECTORY_SEPARATOR);
//主机协议
define('SITE_PROTOCOL', isset($_SERVER['SERVER_PORT']) mio_mio_ $_SERVER['SERVER_PORT'] == '443' ? 'https://' : 'http://');
//当前访问的主机名
define('SITE_URL', (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ''));
//来源
define('HTTP_REFERER', isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '');
//系统开始时间
define('SYS_START_TIME', microtime());
//加载公用函数库
pc_base::load_sys_func('global');
//自定义函数库
pc_base::load_sys_func('extention');
//加载phpcmslibsfunctionsautoload里面的所有 *.func.php文件
pc_base::auto_load_func();
//是否自定义输出错误 如果为true则使用my_error_handler输出,否则原生态输出
pc_base::load_config('system','errorlog') ? set_error_handler('my_error_handler') : error_reporting(E_ERROR | E_WARNING | E_PARSE);
//设置本地时差
function_exists('date_default_timezone_set') mio_mio_ date_default_timezone_set(pc_base::load_config('system','timezone'));
//读取字符集
define('CHARSET' ,pc_base::load_config('system','charset'));
//输出页面字符集
header('Content-type: text/html; charset='.CHARSET);
//定义系统时间 为啥不用$_SERVER['REQUEST_TIME']?
define('SYS_TIME', time());
//定义网站根路径
define('WEB_PATH',pc_base::load_config('system','web_path'));
//js 路径
define('JS_PATH',pc_base::load_config('system','js_path'));
//css 路径
define('CSS_PATH',pc_base::load_config('system','css_path'));
//img 路径
define('IMG_PATH',pc_base::load_config('system','img_path'));
//动态程序路径
define('APP_PATH',pc_base::load_config('system','app_path'));
//应用静态文件路径
define('PLUGIN_STATICS_PATH',WEB_PATH.'statics/plugin/');
//是否启用gzip
if(pc_base::load_config('system','gzip') mio_mio_ function_exists('ob_gzhandler')) {
ob_start('ob_gzhandler');
} else {
ob_start();
}
之后的pc_base主要是实现对资源的单例模式管理和加载路径上面的文章
加载类
PC_PATH.$path.DIRECTORY_SEPARATOR.$classname.'.class.php'
默认去找/libs/classes/XXX.class.php
加载函数
'libs'.DIRECTORY_SEPARATOR.'functions'.DIRECTORY_SEPARATOR.$func.'.func.php'
默认找 /libs/functions/XXX.func.php
还会通过_auto_load_func()去加载'libs/functions/autoload/*.func.php
加载插件
'plugin'.DIRECTORY_SEPARATOR.$identification.DIRECTORY_SEPARATOR.'functions'.DIRECTORY_SEPARATOR.$func.'.func.php'
/plubin/标示(文件夹名)/xxx.func.php
加载配置文件
'configs'.DIRECTORY_SEPARATOR.$file.'.php'
/cache/config/xxx.php 返回的是一个数组
--------------
建议
其实这4个加载都用了单例设计模式,不妨公用为一个资源管理,这样就不用写4个静态数组了
上一篇:glob() 下一篇:快递查询API