/** * @brief 构造函数 * @param array or string $config 配置数组或者配置文件名称 */ public function __construct($config) { echo 'ccccccccccc<br>'; IWeb::setApplication($this); echo __CLASS__ . ':555555555555<br>'; if (is_string($config) && is_file($config)) { $config = (require $config); } $this->config = is_array($config) ? $config : array(); //产品实际根路径 if (isset($this->config['basePath']) && $this->config['basePath']) { $basePath = $this->config['basePath']; } else { if (isset($_SERVER['SCRIPT_FILENAME'])) { $basePath = dirname($_SERVER['SCRIPT_FILENAME']) . DIRECTORY_SEPARATOR; } else { //document_root 不存在 if (!isset($_SERVER['DOCUMENT_ROOT'])) { if (isset($_SERVER['PATH_TRANSLATED'])) { $_SERVER['DOCUMENT_ROOT'] = dirname($_SERVER['PATH_TRANSLATED']); } } $basePath = rtrim(rtrim($_SERVER['DOCUMENT_ROOT'], '\\/') . dirname($_SERVER['SCRIPT_NAME']), '\\/') . DIRECTORY_SEPARATOR; } } echo '项目跟路径:' . $basePath . '<br>'; $this->setBasePath($basePath); ini_set('upload_tmp_dir', $basePath . 'runtime' . DIRECTORY_SEPARATOR); ini_set('session.save_path', $basePath . 'backup' . DIRECTORY_SEPARATOR); date_default_timezone_set(isset($config['timezone']) ? $config['timezone'] : 'Asia/Shanghai'); // 设置自动加载目录 IWeb::setClasses(isset($config['classes']) ? $config['classes'] : 'classes.*'); echo '<br>自定义类入口:' . print_r(IWeb::$_classes) . '<br>'; $this->charset = isset($config['charset']) ? $config['charset'] : $this->charset; $this->language = isset($config['lang']) ? $config['lang'] : $this->language; // Debug模式开关 $this->setDebugMode(isset($config['debug']) && $config['debug'] === true ? true : false); // POST,GET,REQUEST,COOKIE 自动过滤 $this->disableMagicQuotes(); // 开始向拦截器里注册类 if (isset($config['interceptor']) && is_array($config['interceptor'])) { IInterceptor::reg($config['interceptor']); register_shutdown_function(array('IInterceptor', "shutDown")); } }
/** * @brief 构造函数 * @param array or string $config 配置数组或者配置文件名称 */ public function __construct($config) { IWeb::setApplication($this); if (is_file($config)) { $config = (require $config); } $this->config = is_array($config) ? $config : array(); //设为if true为了标注以后要再解决cli模式下的basePath;产品实际根路径 if (isset($_SERVER['SCRIPT_FILENAME'])) { $basePath = dirname($_SERVER['SCRIPT_FILENAME']) . DIRECTORY_SEPARATOR; } else { //document_root 不存在 if (!isset($_SERVER['DOCUMENT_ROOT'])) { if (isset($_SERVER['PATH_TRANSLATED'])) { $_SERVER['DOCUMENT_ROOT'] = dirname($_SERVER['PATH_TRANSLATED']); } } $basePath = rtrim(rtrim($_SERVER['DOCUMENT_ROOT'], '\\/') . dirname($_SERVER['SCRIPT_NAME']), '\\/') . DIRECTORY_SEPARATOR; } //echo $basePath; $this->setBasePath($basePath); ini_set('upload_tmp_dir', $basePath . 'runtime' . DIRECTORY_SEPARATOR); //echo $basePath.'runtime'.DIRECTORY_SEPARATOR; ini_set('session.save_path', $basePath . 'backup' . DIRECTORY_SEPARATOR); date_default_timezone_set(isset($config['timezone']) ? $config['timezone'] : 'Asia/Shanghai'); IWeb::setClasses(isset($config['classes']) ? $config['classes'] : 'classes.*'); $this->charset = isset($config['charset']) ? $config['charset'] : $this->charset; $this->language = isset($config['lang']) ? $config['lang'] : $this->language; $this->setDebugMode(isset($config['debug']) && $config['debug'] === true ? true : false); //删除魔法转义 $this->disableMagicQuotes(); //开始向拦截器里注册类 //print_r($config); if (isset($config['interceptor']) && is_array($config['interceptor'])) { IInterceptor::reg($config['interceptor']); register_shutdown_function(array('IInterceptor', "shutDown")); } }