/**
 +----------------------------------------------------------
 * 应用程序初始化
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @return void
 +----------------------------------------------------------
 */
 public static function init()
 {
     // 设定错误和异常处理
     set_error_handler(array('App', 'appError'));
     set_exception_handler(array('App', 'appException'));
     //[RUNTIME]
     // 检查项目是否编译过
     // 在部署模式下会自动在第一次执行的时候编译项目
     if (defined('RUNTIME_MODEL')) {
         // 运行模式无需载入项目编译缓存
     } elseif (is_file(RUNTIME_PATH . '~' . APP_CACHE_NAME . '.php') && (!is_file(CONFIG_PATH . 'config.php') || filemtime(RUNTIME_PATH . '~' . APP_CACHE_NAME . '.php') > filemtime(CONFIG_PATH . 'config.php'))) {
         // 直接读取编译后的项目文件
         C(include RUNTIME_PATH . '~' . APP_CACHE_NAME . '.php');
     } else {
         // 预编译项目
         App::build();
     }
     //[/RUNTIME]
     // 设置系统时区 PHP5支持
     if (function_exists('date_default_timezone_set')) {
         date_default_timezone_set(C('DEFAULT_TIMEZONE'));
     }
     // 允许注册AUTOLOAD方法
     if (C('APP_AUTOLOAD_REG') && function_exists('spl_autoload_register')) {
         spl_autoload_register(array('Think', 'autoload'));
     }
     // Session初始化
     if (C('SESSION_AUTO_START')) {
         session_start();
     }
     // URL调度
     Dispatcher::dispatch();
     // 加载模块配置文件
     if (is_file(CONFIG_PATH . strtolower(MODULE_NAME) . '_config.php')) {
         C(include CONFIG_PATH . strtolower(MODULE_NAME) . '_config.php');
     }
     // 系统检查
     App::checkLanguage();
     //语言检查
     App::checkTemplate();
     //模板检查
     // 开启静态缓存
     if (C('HTML_CACHE_ON')) {
         HtmlCache::readHTMLCache();
     }
     // 项目初始化标签
     if (C('APP_PLUGIN_ON')) {
         tag('app_init');
     }
     return;
 }
示例#2
0
 /**
 +----------------------------------------------------------
 * 应用程序初始化
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @return void
 +----------------------------------------------------------
 */
 public static function init()
 {
     // 设定错误和异常处理
     set_error_handler(array('App', 'appError'));
     set_exception_handler(array('App', 'appException'));
     //[RUNTIME]
     App::build();
     // 预编译项目
     //[/RUNTIME]
     // 注册AUTOLOAD方法
     if (function_exists('spl_autoload_register')) {
         spl_autoload_register(array('Think', 'autoload'));
     }
     // 设置系统时区 PHP5支持
     if (function_exists('date_default_timezone_set')) {
         date_default_timezone_set(C('DEFAULT_TIMEZONE'));
     }
     // 加载动态项目公共文件
     if (is_file(COMMON_PATH . 'extend.php')) {
         include COMMON_PATH . 'extend.php';
     }
     // URL调度
     Dispatcher::dispatch();
     // 加载模块配置文件
     if (is_file(CONFIG_PATH . strtolower(MODULE_NAME) . '_config.php')) {
         C(include CONFIG_PATH . strtolower(MODULE_NAME) . '_config.php');
     }
     // 系统检查
     App::checkLanguage();
     //语言检查
     App::checkTemplate();
     //模板检查
     // 开启静态缓存
     if (C('HTML_CACHE_ON')) {
         HtmlCache::readHTMLCache();
     }
     return;
 }
示例#3
0
 /**
 +----------------------------------------------------------
 * 应用程序初始化
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @return void
 +----------------------------------------------------------
 */
 public static function init()
 {
     // 设定错误和异常处理
     set_error_handler(array('App', 'appError'));
     set_exception_handler(array('App', 'appException'));
     //[RUNTIME]
     // 检查项目是否编译过
     // 在部署模式下会自动在第一次执行的时候编译项目
     if (defined('RUNTIME_MODEL')) {
         // 运行模式无需载入项目编译缓存
     } elseif (is_file(RUNTIME_PATH . '~app.php') && (!is_file(CONFIG_PATH . 'config.php') || filemtime(RUNTIME_PATH . '~app.php') > filemtime(CONFIG_PATH . 'config.php'))) {
         // 直接读取编译后的项目文件
         C(include RUNTIME_PATH . '~app.php');
     } else {
         // 预编译项目
         App::build();
     }
     //[/RUNTIME]
     // 项目开始标签
     if (C('APP_PLUGIN_ON')) {
         tag('app_begin');
     }
     // 设置系统时区 PHP5支持
     if (function_exists('date_default_timezone_set')) {
         date_default_timezone_set(C('DEFAULT_TIMEZONE'));
     }
     // 允许注册AUTOLOAD方法
     if (C('APP_AUTOLOAD_REG') && function_exists('spl_autoload_register')) {
         spl_autoload_register(array('Think', 'autoload'));
     }
     if (C('SESSION_AUTO_START')) {
         session_start();
     }
     // Session初始化
     // 应用调度过滤器
     // 如果没有加载任何URL调度器
     // 默认只支持 QUERY_STRING 方式
     if (C('URL_DISPATCH_ON')) {
         Dispatcher::dispatch();
     }
     if (!defined('PHP_FILE')) {
         // PHP_FILE 由内置的Dispacher定义
         // 如果不使用该插件,需要重新定义
         define('PHP_FILE', _PHP_FILE_);
     }
     // 取得模块和操作名称
     // 可以在Dispatcher中定义获取规则
     // 加载项目分组公共文件
     if (C('APP_GROUP_LIST')) {
         if (!defined('GROUP_NAME')) {
             define('GROUP_NAME', App::getGroup());
         }
         // Group名称
         // 分组配置文件
         if (is_file(CONFIG_PATH . GROUP_NAME . '/config.php')) {
             C(include CONFIG_PATH . GROUP_NAME . '/config.php');
         }
         // 分组函数文件
         if (is_file(COMMON_PATH . GROUP_NAME . '/function.php')) {
             include COMMON_PATH . GROUP_NAME . '/function.php';
         }
     }
     if (!defined('MODULE_NAME')) {
         define('MODULE_NAME', App::getModule());
     }
     // Module名称
     if (!defined('ACTION_NAME')) {
         define('ACTION_NAME', App::getAction());
     }
     // Action操作
     // 加载模块配置文件
     if (is_file(CONFIG_PATH . strtolower(MODULE_NAME) . '_config.php')) {
         C(include CONFIG_PATH . strtolower(MODULE_NAME) . '_config.php');
     }
     // 系统检查
     App::checkLanguage();
     //语言检查
     App::checkTemplate();
     //模板检查
     if (C('HTML_CACHE_ON')) {
         // 开启静态缓存
         HtmlCache::readHTMLCache();
     }
     // 项目初始化标签
     if (C('APP_PLUGIN_ON')) {
         tag('app_init');
     }
     return;
 }
示例#4
0
 public static function init()
 {
     set_error_handler(array('App', 'appError'));
     set_exception_handler(array('App', 'appException'));
     if (function_exists('date_default_timezone_set')) {
         date_default_timezone_set(C('DEFAULT_TIMEZONE'));
     }
     if (C('APP_AUTOLOAD_REG') && function_exists('spl_autoload_register')) {
         spl_autoload_register(array('Think', 'autoload'));
     }
     if (C('SESSION_AUTO_START')) {
         session_start();
     }
     Dispatcher::dispatch();
     if (is_file(CONFIG_PATH . strtolower(MODULE_NAME) . '_config.php')) {
         C(include CONFIG_PATH . strtolower(MODULE_NAME) . '_config.php');
     }
     App::checkLanguage();
     App::checkTemplate();
     if (C('HTML_CACHE_ON')) {
         HtmlCache::readHTMLCache();
     }
     if (C('APP_PLUGIN_ON')) {
         tag('app_init');
     }
     return;
 }
示例#5
0
 public static function init()
 {
     set_error_handler(array('App', 'appError'));
     set_exception_handler(array('App', 'appException'));
     if (defined('RUNTIME_MODEL')) {
     } elseif (is_file(RUNTIME_PATH . '~app.php') && (!is_file(CONFIG_PATH . 'config.php') || filemtime(RUNTIME_PATH . '~app.php') > filemtime(CONFIG_PATH . 'config.php'))) {
         C(include RUNTIME_PATH . '~app.php');
     } else {
         App::build();
     }
     if (C('APP_PLUGIN_ON')) {
         tag('app_begin');
     }
     if (function_exists('date_default_timezone_set')) {
         date_default_timezone_set(C('DEFAULT_TIMEZONE'));
     }
     if (C('APP_AUTOLOAD_REG') && function_exists('spl_autoload_register')) {
         spl_autoload_register(array('Think', 'autoload'));
     }
     if (C('SESSION_AUTO_START')) {
         session_start();
     }
     if (C('URL_DISPATCH_ON')) {
         Dispatcher::dispatch();
     }
     if (!defined('PHP_FILE')) {
         define('PHP_FILE', _PHP_FILE_);
     }
     if (C('APP_GROUP_LIST')) {
         if (!defined('GROUP_NAME')) {
             define('GROUP_NAME', App::getGroup());
         }
         if (is_file(CONFIG_PATH . GROUP_NAME . '/config.php')) {
             C(include CONFIG_PATH . GROUP_NAME . '/config.php');
         }
         if (is_file(COMMON_PATH . GROUP_NAME . '/function.php')) {
             include COMMON_PATH . GROUP_NAME . '/function.php';
         }
     }
     if (!defined('MODULE_NAME')) {
         define('MODULE_NAME', App::getModule());
     }
     if (!defined('ACTION_NAME')) {
         define('ACTION_NAME', App::getAction());
     }
     if (is_file(CONFIG_PATH . strtolower(MODULE_NAME) . '_config.php')) {
         C(include CONFIG_PATH . strtolower(MODULE_NAME) . '_config.php');
     }
     App::checkLanguage();
     App::checkTemplate();
     if (C('HTML_CACHE_ON')) {
         HtmlCache::readHTMLCache();
     }
     if (C('APP_PLUGIN_ON')) {
         tag('app_init');
     }
     return;
 }
示例#6
0
 /**
 +----------------------------------------------------------
 * 应用程序初始化
 +----------------------------------------------------------
 * @access public 
 +----------------------------------------------------------
 * @return void
 +----------------------------------------------------------
 */
 public function init()
 {
     // 设定错误和异常处理
     set_error_handler(array(&$this, "appError"));
     set_exception_handler(array(&$this, "appException"));
     // 检查项目是否编译过
     // 在部署模式下会自动在第一次执行的时候编译项目
     if (file_exists(RUNTIME_PATH . '~app.php')) {
         // 直接读取编译后的项目文件
         C(array_change_key_case(include RUNTIME_PATH . '~app.php'));
     } else {
         // 预编译项目
         $this->build();
     }
     // 设置系统时区 PHP5支持
     if (function_exists('date_default_timezone_set')) {
         date_default_timezone_set(C('TIME_ZONE'));
     }
     if ('FILE' != strtoupper(C('SESSION_TYPE'))) {
         // 其它方式Session支持 目前支持Db 通过过滤器方式扩展
         import("Think.Util.Filter");
         Filter::load(ucwords(C('SESSION_TYPE')) . 'Session');
     }
     // Session初始化
     session_start();
     // 加载插件 必须在Session开启之后加载插件
     if (C('THINK_PLUGIN_ON')) {
         $this->loadPlugIn();
     }
     // 应用调度过滤器
     // 如果没有加载任何URL调度器
     // 默认只支持 QUERY_STRING 方式
     // 例如 ?m=user&a=add
     if (C('DISPATCH_ON')) {
         if ('Think' == C('DISPATCH_NAME')) {
             // 使用内置的ThinkDispatcher调度器
             import('Think.Core.Dispatcher');
             Dispatcher::dispatch();
         } else {
             // 加载第三方调度器
             apply_filter('app_dispatch');
         }
     }
     if (!defined('PHP_FILE')) {
         // PHP_FILE 由内置的Dispacher定义
         // 如果不使用该插件,需要重新定义
         define('PHP_FILE', _PHP_FILE_);
     }
     // 取得模块和操作名称 如果有伪装 则返回真实的名称
     // 可以在Dispatcher中定义获取规则
     if (!defined('MODULE_NAME')) {
         define('MODULE_NAME', $this->getModule());
     }
     // Module名称
     if (!defined('ACTION_NAME')) {
         define('ACTION_NAME', $this->getAction());
     }
     // Action操作
     // 加载模块配置文件 并自动生成配置缓存文件
     if (file_exists(CONFIG_PATH . 'm_' . MODULE_NAME . 'Config.php')) {
         C(array_change_key_case(include CONFIG_PATH . 'm_' . MODULE_NAME . 'Config.php'));
     }
     //	启用页面防刷新机制
     if (C('LIMIT_RESFLESH_ON')) {
         //	启用页面防刷新机制
         $guid = md5($_SERVER['PHP_SELF']);
         // 检查页面刷新间隔
         if (Cookie::is_set('_last_visit_time_' . $guid) && Cookie::get('_last_visit_time_' . $guid) > time() - C('LIMIT_REFLESH_TIMES')) {
             // 页面刷新读取浏览器缓存
             header('HTTP/1.1 304 Not Modified');
             exit;
         } else {
             // 缓存当前地址访问时间
             Cookie::set('_last_visit_time_' . $guid, $_SERVER['REQUEST_TIME'], $_SERVER['REQUEST_TIME'] + 3600);
             header('Last-Modified:' . date('D,d M Y H:i:s', $_SERVER['REQUEST_TIME'] - C('LIMIT_REFLESH_TIMES')) . ' GMT');
         }
     }
     // 系统检查
     $this->checkLanguage();
     //语言检查
     $this->checkTemplate();
     //模板检查
     if (C('USER_AUTH_ON')) {
         // 启用权限认证 调用RBAC组件
         import('ORG.RBAC.RBAC');
         RBAC::AccessDecision();
     }
     if (C('HTML_CACHE_ON')) {
         import('Think.Util.HtmlCache');
         HtmlCache::readHTMLCache();
     }
     // 应用初始化过滤插件
     apply_filter('app_init');
     // 记录应用初始化时间
     $GLOBALS['_initTime'] = microtime(TRUE);
     return;
 }
示例#7
0
 public function init()
 {
     set_error_handler(array(&$this, "appError"));
     set_exception_handler(array(&$this, "appException"));
     if (is_file(RUNTIME_PATH . '~app.php') && (!is_file(CONFIG_PATH . 'config.php') || filemtime(RUNTIME_PATH . '~app.php') > filemtime(CONFIG_PATH . 'config.php'))) {
         C(include RUNTIME_PATH . '~app.php');
     } else {
         $this->build();
     }
     if (IS_CLI) {
         define('MODULE_NAME', $this->getModule());
         define('ACTION_NAME', $this->getAction());
         L(include CORE_PATH . 'Lang/' . C('DEFAULT_LANGUAGE') . '.php');
     } else {
         if (function_exists('date_default_timezone_set')) {
             date_default_timezone_set(C('TIME_ZONE'));
         }
         if ('FILE' != strtoupper(C('SESSION_TYPE'))) {
             import("Think.Util.Filter");
             Filter::load(ucwords(strtolower(C('SESSION_TYPE'))) . 'Session');
         }
         session_start();
         if ($plugInOn = C('THINK_PLUGIN_ON')) {
             $this->loadPlugIn();
         }
         if (C('DISPATCH_ON')) {
             if ('Think' == C('DISPATCH_NAME')) {
                 import('Think.Util.Dispatcher');
                 Dispatcher::dispatch();
             } elseif ($plugInOn) {
                 apply_filter('app_dispatch');
             }
         }
         if (!defined('PHP_FILE')) {
             define('PHP_FILE', _PHP_FILE_);
         }
         if (!defined('MODULE_NAME')) {
             define('MODULE_NAME', $this->getModule());
         }
         if (!defined('ACTION_NAME')) {
             define('ACTION_NAME', $this->getAction());
         }
         if (is_file(CONFIG_PATH . MODULE_NAME . '_config.php')) {
             C(include CONFIG_PATH . MODULE_NAME . '_config.php');
         }
         if (C('LIMIT_RESFLESH_ON') && (!isset($_REQUEST[C('VAR_RESFLESH')]) || $_REQUEST[C('VAR_RESFLESH')] != "1")) {
             $guid = md5($_SERVER['PHP_SELF']);
             if (Cookie::is_set('last_visit_time_' . $guid) && Cookie::get('last_visit_time_' . $guid) > time() - C('LIMIT_REFLESH_TIMES')) {
                 header('HTTP/1.1 304 Not Modified');
                 exit;
             } else {
                 Cookie::set('last_visit_time_' . $guid, $_SERVER['REQUEST_TIME'], C('COOKIE_EXPIRE'));
                 header('Last-Modified:' . date('D,d M Y H:i:s', $_SERVER['REQUEST_TIME'] - C('LIMIT_REFLESH_TIMES')) . ' GMT');
             }
         }
         $this->checkLanguage();
         $this->checkTemplate();
         if (C('HTML_CACHE_ON')) {
             import('Think.Util.HtmlCache');
             HtmlCache::readHTMLCache();
         }
         if ($plugInOn) {
             apply_filter('app_init');
         }
     }
     if (C('SHOW_RUN_TIME')) {
         $GLOBALS['_initTime'] = microtime(TRUE);
     }
     return;
 }
示例#8
0
 /**
 +----------------------------------------------------------
 * 应用程序初始化
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @return void
 +----------------------------------------------------------
 */
 public function init()
 {
     // 设定错误和异常处理
     set_error_handler(array(&$this, "appError"));
     set_exception_handler(array(&$this, "appException"));
     // 检查项目是否编译过
     // 在部署模式下会自动在第一次执行的时候编译项目
     if (is_file(RUNTIME_PATH . '~app.php') && (!is_file(CONFIG_PATH . 'config.php') || filemtime(RUNTIME_PATH . '~app.php') > filemtime(CONFIG_PATH . 'config.php'))) {
         // 直接读取编译后的项目文件
         C(include RUNTIME_PATH . '~app.php');
     } else {
         // 预编译项目
         $this->build();
     }
     // 项目开始标签
     if (C('TAG_PLUGIN_ON')) {
         tag('app_begin');
     }
     // 设置系统时区 PHP5支持
     if (function_exists('date_default_timezone_set')) {
         date_default_timezone_set(C('TIME_ZONE'));
     }
     if (C('SESSION_AUTO_START')) {
         // Session初始化
         session_start();
     }
     // 应用调度过滤器
     // 如果没有加载任何URL调度器
     // 默认只支持 QUERY_STRING 方式
     // 例如 ?m=user&a=add
     if (C('DISPATCH_ON')) {
         import('Dispatcher');
         Dispatcher::dispatch();
     }
     if (!defined('PHP_FILE')) {
         // PHP_FILE 由内置的Dispacher定义
         // 如果不使用该插件,需要重新定义
         define('PHP_FILE', _PHP_FILE_);
     }
     // 取得模块和操作名称
     // 可以在Dispatcher中定义获取规则
     if (!defined('MODULE_NAME')) {
         define('MODULE_NAME', $this->getModule());
     }
     // Module名称
     if (!defined('ACTION_NAME')) {
         define('ACTION_NAME', $this->getAction());
     }
     // Action操作
     // 加载模块配置文件
     if (is_file(CONFIG_PATH . strtolower(MODULE_NAME) . '_config.php')) {
         C(include CONFIG_PATH . strtolower(MODULE_NAME) . '_config.php');
     }
     // 系统检查
     $this->checkLanguage();
     //语言检查
     $this->checkTemplate();
     //模板检查
     if (C('HTML_CACHE_ON')) {
         // 开启静态缓存
         import('HtmlCache');
         HtmlCache::readHTMLCache();
     }
     // 项目初始化标签
     if (C('TAG_PLUGIN_ON')) {
         tag('app_init');
     }
     return;
 }
示例#9
0
 /**
 +----------------------------------------------------------
 * 应用程序初始化
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @return void
 +----------------------------------------------------------
 */
 public static function init()
 {
     // 设定错误和异常处理
     set_error_handler(array('App', 'appError'));
     set_exception_handler(array('App', 'appException'));
     //[RUNTIME]
     // 检查项目是否编译过
     // 在部署模式下会自动在第一次执行的时候编译项目
     if (defined('RUNTIME_MODEL')) {
         // 运行模式无需载入项目编译缓存
     } else {
         if (is_file(RUNTIME_PATH . '/~app.php') && (!is_file(CONFIG_PATH . 'config.php') || filemtime(RUNTIME_PATH . '/~app.php') > filemtime(CONFIG_PATH . 'config.php'))) {
             // 直接读取编译后的项目文件
             C(include RUNTIME_PATH . '/~app.php');
         } else {
             // 预编译项目
             App::build();
         }
     }
     //[/RUNTIME]
     //加载所有插件
     Addons::loadAllValidAddons();
     if (!defined('MODULE_NAME')) {
         define('MODULE_NAME', App::getModule());
     }
     // Module名称
     if (!defined('ACTION_NAME')) {
         define('ACTION_NAME', App::getAction());
     }
     // Action操作
     // If already slashed, strip.
     if (get_magic_quotes_gpc()) {
         $_GET = stripslashes_deep($_GET);
         $_POST = stripslashes_deep($_POST);
         $_COOKIE = stripslashes_deep($_COOKIE);
     }
     // 初始化运行时缓存
     object_cache_init();
     // 修正IIS下的$_SERVER['REQUEST_URI']
     if ($_SERVER['REQUEST_URI']) {
         $_SERVER['REQUEST_URI'] = $_SERVER['PHP_SELF'] . ($_SERVER['QUERY_STRING'] ? '?' . $_SERVER['QUERY_STRING'] : '');
     }
     // 站点设置
     App::checkSiteOption();
     // 项目开始标签
     if (C('APP_PLUGIN_ON')) {
         tag('app_begin');
     }
     // 设置系统时区 PHP5支持
     if (function_exists('date_default_timezone_set')) {
         date_default_timezone_set(C('DEFAULT_TIMEZONE'));
     }
     // 允许注册AUTOLOAD方法
     if (C('APP_AUTOLOAD_REG') && function_exists('spl_autoload_register')) {
         spl_autoload_register(array('Think', 'autoload'));
     }
     // 重塑Session (必须位于session_start()之前)
     if (isset($_POST['PHPSESSID'])) {
         Session::destroy();
         session_id($_POST['PHPSESSID']);
     }
     // 初始化Session
     if (C('SESSION_AUTO_START')) {
         Session::start();
     }
     /*
      * 应用调度过滤器
      * 如果没有加载任何URL调度器, 默认只支持 QUERY_STRING 方式
      */
     if (C('URL_DISPATCH_ON')) {
         Dispatcher::dispatch();
     }
     /*
      * PHP_FILE 由内置的Dispacher定义
      * 如果不使用该插件,需要重新定义
      */
     if (!defined('PHP_FILE')) {
         define('PHP_FILE', _PHP_FILE_);
     }
     // 取得模块和操作名称
     // 可以在Dispatcher中定义获取规则
     // 使用手持设备时, 对home的访问默认跳转至移动版, 除非用户指定访问普通版。
     if (APP_NAME == 'home' && $_SESSION['wap_to_normal'] != '1' && cookie('wap_to_normal') != '1' && $_REQUEST['wap_to_normal'] != '1') {
         if (MODULE_NAME == 'Public' && ACTION_NAME == 'tryOtherLogin') {
         } else {
             if (MODULE_NAME == 'Widget' && ACTION_NAME == 'addonsRequest') {
             } else {
                 if (isiOS() || isAndroid()) {
                     // iOS和Android跳转至3G版
                     U('w3g/Index/index', '', true);
                 } else {
                     if (isMobile()) {
                         // 其他手机跳转至WAP版
                         U('wap/Index/index', '', true);
                     }
                 }
             }
         }
     }
     // 检查应用是否安装 (Admin和默认应用不需要安装)
     if (MODULE_NAME != 'Admin' && !in_array(APP_NAME, C('DEFAULT_APPS')) && !model('App')->isAppNameActive(APP_NAME)) {
         throw_exception(L('_APP_INACTIVE_') . APP_NAME);
     }
     $GLOBALS['ts']['_app'] = APP_NAME;
     $GLOBALS['ts']['_mod'] = MODULE_NAME;
     $GLOBALS['ts']['_act'] = ACTION_NAME;
     // 加载模块配置文件
     if (is_file(CONFIG_PATH . strtolower(MODULE_NAME) . '_config.php')) {
         C(include CONFIG_PATH . strtolower(MODULE_NAME) . '_config.php');
     }
     //Ucenter初始化
     App::initUcenter();
     // 用户认证
     App::checkUser();
     // 语言检查
     App::checkLanguage();
     // 模板检查
     App::checkTemplate();
     // 开启静态缓存
     if (C('HTML_CACHE_ON')) {
         HtmlCache::readHTMLCache();
     }
     // 项目初始化标签
     if (C('APP_PLUGIN_ON')) {
         tag('app_init');
     }
     return;
 }
示例#10
0
 /**
 +----------------------------------------------------------
 * 应用程序初始化
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @return void
 +----------------------------------------------------------
 */
 public static function init()
 {
     // 设定错误和异常处理
     set_error_handler(array('App', 'appError'));
     set_exception_handler(array('App', 'appException'));
     //[RUNTIME]
     // 检查项目是否编译过
     // 在部署模式下会自动在第一次执行的时候编译项目
     if (defined('RUNTIME_MODEL')) {
         // 运行模式无需载入项目编译缓存
     } elseif (is_file(RUNTIME_PATH . '/~app.php') && (!is_file(CONFIG_PATH . 'config.php') || filemtime(RUNTIME_PATH . '/~app.php') > filemtime(CONFIG_PATH . 'config.php'))) {
         // 直接读取编译后的项目文件
         C(include RUNTIME_PATH . '/~app.php');
     } else {
         // 预编译项目
         App::build();
     }
     //[/RUNTIME]
     if (!defined('MODULE_NAME')) {
         define('MODULE_NAME', App::getModule());
     }
     // Module名称
     if (!defined('ACTION_NAME')) {
         define('ACTION_NAME', App::getAction());
     }
     // Action操作
     // If already slashed, strip.
     if (get_magic_quotes_gpc()) {
         $_GET = stripslashes_deep($_GET);
         $_POST = stripslashes_deep($_POST);
         $_COOKIE = stripslashes_deep($_COOKIE);
     }
     // 站点设置
     App::checkSiteOption();
     // 项目开始标签
     if (C('APP_PLUGIN_ON')) {
         tag('app_begin');
     }
     // 设置系统时区 PHP5支持
     if (function_exists('date_default_timezone_set')) {
         date_default_timezone_set(C('DEFAULT_TIMEZONE'));
     }
     // 允许注册AUTOLOAD方法
     if (C('APP_AUTOLOAD_REG') && function_exists('spl_autoload_register')) {
         spl_autoload_register(array('Think', 'autoload'));
     }
     if (C('SESSION_AUTO_START')) {
         session_start();
     }
     // Session初始化
     // 应用调度过滤器
     // 如果没有加载任何URL调度器
     // 默认只支持 QUERY_STRING 方式
     if (C('URL_DISPATCH_ON')) {
         Dispatcher::dispatch();
     }
     if (!defined('PHP_FILE')) {
         // PHP_FILE 由内置的Dispacher定义
         // 如果不使用该插件,需要重新定义
         define('PHP_FILE', _PHP_FILE_);
     }
     // 取得模块和操作名称
     // 可以在Dispatcher中定义获取规则
     // 404
     C('ERROR_PAGE', U('home/Public/error404'));
     // 检查应用是否安装
     if (!in_array(APP_NAME, C('DEFAULT_APPS')) && !model('App')->isAppNameActive(APP_NAME)) {
         throw_exception(L('_APP_INACTIVE_') . APP_NAME);
     }
     global $ts;
     $ts['_app'] = APP_NAME;
     $ts['_mod'] = MODULE_NAME;
     $ts['_act'] = ACTION_NAME;
     // 加载模块配置文件
     if (is_file(CONFIG_PATH . strtolower(MODULE_NAME) . '_config.php')) {
         C(include CONFIG_PATH . strtolower(MODULE_NAME) . '_config.php');
     }
     // 用户认证
     App::checkUser();
     // 系统检查
     App::checkLanguage();
     //语言检查
     App::checkTemplate();
     //模板检查
     if (C('HTML_CACHE_ON')) {
         // 开启静态缓存
         HtmlCache::readHTMLCache();
     }
     // 项目初始化标签
     if (C('APP_PLUGIN_ON')) {
         tag('app_init');
     }
     return;
 }
示例#11
0
 /**
 +----------------------------------------------------------
 * 应用程序初始化
 +----------------------------------------------------------
 * @access public 
 +----------------------------------------------------------
 * @return void
 +----------------------------------------------------------
 */
 public function init()
 {
     // 设定错误和异常处理
     set_error_handler(array(&$this, "appError"));
     set_exception_handler(array(&$this, "appException"));
     // 加载惯例配置文件
     C(array_change_key_case(include THINK_PATH . '/Common/convention.php'));
     // 加载项目配置文件
     // 支持App.* 作为配置文件
     // 自动生成_appConfig.php 配置缓存
     $this->loadConfig('App', CONFIG_PATH, '_config.php');
     // 如果是调试模式加载调试模式配置文件
     if (C('DEBUG_MODE')) {
         // 加载系统默认的开发模式配置文件
         C(array_change_key_case(include THINK_PATH . '/Common/debug.php'));
         if (file_exists(CONFIG_PATH . '_debug.php')) {
             // 允许项目增加开发模式配置定义
             C(array_change_key_case(include CONFIG_PATH . '_debug.php'));
         }
     }
     // 设置系统时区 PHP5支持
     if (function_exists('date_default_timezone_set')) {
         date_default_timezone_set(C('TIME_ZONE'));
     }
     if ('FILE' != strtoupper(C('SESSION_TYPE'))) {
         // 其它方式Session支持 目前支持Db 通过过滤器方式扩展
         import("Think.Util.Filter");
         Filter::load(ucwords(C('SESSION_TYPE')) . 'Session');
     }
     // Session初始化
     Session::start();
     // 加载插件 必须在Session开启之后加载插件
     if (C('THINK_PLUGIN_ON')) {
         $this->loadPlugIn();
     }
     // 应用调度过滤器
     // 如果没有加载任何URL调度器
     // 默认只支持 QUERY_STRING 方式
     // 例如 ?m=user&a=add
     if (C('DISPATCH_ON')) {
         if ('Think' == C('DISPATCH_NAME')) {
             // 使用内置的ThinkDispatcher调度器
             import('Think.Core.Dispatcher');
             Dispatcher::dispatch();
         } else {
             // 加载第三方调度器
             apply_filter('app_dispatch');
         }
     }
     if (!defined('PHP_FILE')) {
         // PHP_FILE 由内置的Dispacher定义
         // 如果不使用该插件,需要重新定义
         define('PHP_FILE', _PHP_FILE_);
     }
     // 取得模块和操作名称 如果有伪装 则返回真实的名称
     // 可以在Dispatcher中定义获取规则
     if (!defined('MODULE_NAME')) {
         define('MODULE_NAME', $this->getModule());
     }
     // Module名称
     if (!defined('ACTION_NAME')) {
         define('ACTION_NAME', $this->getAction());
     }
     // Action操作
     // 加载模块配置文件 并自动生成配置缓存文件
     $this->loadConfig('m_' . MODULE_NAME, CONFIG_PATH, 'm_' . MODULE_NAME . 'Config.php', false);
     //	启用页面防刷新机制
     if (C('LIMIT_RESFLESH_ON')) {
         $guid = md5($_SERVER['PHP_SELF']);
         // 检查页面刷新间隔
         if (Session::is_set('_last_visit_time_' . $guid) && Session::get('_last_visit_time_' . $guid) > time() - C('LIMIT_REFLESH_TIMES')) {
             // 页面刷新读取浏览器缓存
             header('HTTP/1.1 304 Not Modified');
             exit;
         } else {
             // 缓存当前地址访问时间
             Session::set('_last_visit_time_' . $guid, time());
             header('Last-Modified:' . date('D,d M Y H:i:s', time() - C('LIMIT_REFLESH_TIMES')) . ' GMT');
         }
     }
     // 加载项目公共文件
     if (file_exists(APP_PATH . '/Common/common.php')) {
         include APP_PATH . '/Common/common.php';
     }
     // 系统检查
     $this->checkLanguage();
     //语言检查
     $this->checkTemplate();
     //模板检查
     if (C('USER_AUTH_ON')) {
         // 启用权限认证 调用RBAC组件
         import('ORG.RBAC.RBAC');
         RBAC::AccessDecision();
     }
     if (C('HTML_CACHE_ON')) {
         import('Think.Util.HtmlCache');
         HtmlCache::readHTMLCache();
     }
     // 应用初始化过滤插件
     apply_filter('app_init');
     // 记录应用初始化时间
     $GLOBALS['_initTime'] = array_sum(explode(' ', microtime()));
     return;
 }