Example #1
0
 /**
  * 系统启动
  *
  * @param boolean $auto_execute 是否直接运行
  */
 public static function setup($auto_execute = true)
 {
     static $run = null;
     if (null === $run) {
         $run = true;
         Core::$charset = Core::$config['charset'];
         if (!IS_CLI) {
             # 输出powered by信息
             $x_powered_by = isset(Core::$config['hide_x_powered_by_header']) && Core::$config['hide_x_powered_by_header'] ? Core::$config['hide_x_powered_by_header'] : false;
             if (is_string($x_powered_by)) {
                 $str = 'X-Powered-By: ' . trim(str_replace(array("\r", "\n"), '', $x_powered_by));
             } else {
                 if (!$x_powered_by) {
                     $str = 'X-Powered-By: PHP/' . PHP_VERSION . ' MyQEE/' . Core::VERSION . '(' . Core::RELEASE . ')';
                 } else {
                     $str = null;
                 }
             }
             if ($str) {
                 header($str);
             }
         }
         if ((IS_CLI || IS_DEBUG) && class_exists('DevException', true)) {
             # 注册脚本
             register_shutdown_function(array('DevException', 'shutdown_handler'));
             # 捕获错误
             set_exception_handler(array('DevException', 'exception_handler'));
             set_error_handler(array('DevException', 'error_handler'), error_reporting());
         } else {
             # 注册脚本
             register_shutdown_function(array('Core', 'shutdown_handler'));
             //                # 捕获错误
             set_exception_handler(array('Core', 'exception_handler'));
             set_error_handler(array('Core', 'error_handler'), error_reporting());
         }
         if (!IS_CLI) {
             # 初始化 HttpIO 对象
             HttpIO::setup();
         }
         # 注册输出函数
         register_shutdown_function(array('Core', '_output_body'));
         if (true === IS_SYSTEM_MODE) {
             if (false === Core::check_system_request_allow()) {
                 # 内部请求验证不通过
                 Core::show_500('system request hash error');
             }
         }
         if (!defined('URL_ASSETS')) {
             /**
              * 静态文件URL地址前缀
              *
              * @var string
              */
             define('URL_ASSETS', rtrim(Core::config('url.assets', Core::url('/assets/')), '/') . '/');
         }
         if (IS_DEBUG && isset($_REQUEST['debug']) && class_exists('Profiler', true)) {
             Profiler::setup();
         }
         if (IS_DEBUG && !IS_CLI) {
             Core::debug()->info('SERVER IP:' . $_SERVER["SERVER_ADDR"] . (function_exists('php_uname') ? '. SERVER NAME:' . php_uname('a') : ''));
             if (Core::$project) {
                 Core::debug()->info('project: ' . Core::$project);
             }
             if (IS_ADMIN_MODE) {
                 Core::debug()->info('admin mode');
             }
             if (IS_REST_MODE) {
                 Core::debug()->info('RESTFul mode');
             }
             Core::debug()->group('include path');
             foreach (Core::include_path() as $value) {
                 Core::debug()->log(Core::debug_path($value));
             }
             Core::debug()->groupEnd();
         }
     }
     /**
      * 系统加载完毕时间
      */
     define('SYSTEM_LOADED_TIME', microtime(1));
     if ($auto_execute) {
         Core::run();
     }
 }
Example #2
0
 /**
  * 系统启动
  * @param string $pathinfo
  */
 public static function setup($auto_run = true)
 {
     static $run = null;
     if (true === $run) {
         if ($auto_run) {
             Core::run();
         }
         return;
     }
     $run = true;
     Core::$charset = Core::$config['core']['charset'];
     # 注销Bootstrap的自动加载类
     spl_autoload_unregister(array('Bootstrap', 'auto_load'));
     # 注册自动加载类
     spl_autoload_register(array('Core', 'auto_load'));
     if (!IS_CLI) {
         # 输出powered by信息
         header('X-Powered-By: PHP/' . PHP_VERSION . ' MyQEE/' . Core::VERSION);
     }
     # 检查Bootstrap版本
     if (version_compare(Bootstrap::VERSION, '1.9', '<')) {
         Core::show_500('系统Bootstrap版本太低,请先升级Bootstrap。');
         exit;
     }
     Core::debug()->info('当前项目:' . INITIAL_PROJECT_NAME);
     if (IS_DEBUG) {
         Core::debug()->group('系统加载目录');
         foreach (Core::$include_path as $value) {
             Core::debug()->log(Core::debug_path($value));
         }
         Core::debug()->groupEnd();
     }
     if ((IS_CLI || IS_DEBUG) && class_exists('ErrException', true)) {
         # 注册脚本
         register_shutdown_function(array('ErrException', 'shutdown_handler'));
         # 捕获错误
         set_exception_handler(array('ErrException', 'exception_handler'));
         set_error_handler(array('ErrException', 'error_handler'), error_reporting());
     } else {
         # 注册脚本
         register_shutdown_function(array('Core', 'shutdown_handler'));
         # 捕获错误
         set_exception_handler(array('Core', 'exception_handler'));
         set_error_handler(array('Core', 'error_handler'), error_reporting());
     }
     # 初始化 HttpIO 对象
     HttpIO::setup();
     # 注册输出函数
     register_shutdown_function(array('Core', 'output'));
     # 初始化类库
     Core::ini_library();
     if (true === IS_SYSTEM_MODE) {
         if (false === Core::check_system_request_allow()) {
             # 内部请求验证不通过
             Core::show_500('system request hash error');
         }
     }
     if (IS_DEBUG && isset($_REQUEST['debug']) && class_exists('Profiler', true)) {
         Profiler::setup();
     }
     if ($auto_run) {
         Core::run();
     }
 }