Example #1
0
 public static function config()
 {
     $site = iPHP_MULTI_SITE ? $_SERVER['HTTP_HOST'] : iPHP_APP;
     if (iPHP_MULTI_DOMAIN) {
         //只绑定主域
         preg_match("/[^\\.\\/][\\w\\-]+\\.[^\\.\\/]+\$/", $site, $matches);
         $site = $matches[0];
     }
     iPHP_MULTI_SITE && define('iPHP_APP_SITE', $site);
     strpos($site, '..') === false or exit('<h1>What are you doing?(code:001)</h1>');
     //config.php 中开启iPHP_APP_CONF后 此处设置无效,
     define('iPHP_APP_CONF', iPHP_CONF_DIR . '/' . $site);
     //网站配置目录
     define('iPHP_APP_CONFIG', iPHP_APP_CONF . '/config.php');
     //网站配置文件
     @is_file(iPHP_APP_CONFIG) or exit('<h1>' . iPHP_APP . ' 运行出错.找不到"' . $site . '"网站的配置文件!(code:002)</h1>');
     $config = (require iPHP_APP_CONFIG);
     //config.php 中开启后 此处设置无效
     defined('iPHP_DEBUG') or define('iPHP_DEBUG', $config['debug']['php']);
     //程序调试模式
     defined('iPHP_TPL_DEBUG') or define('iPHP_TPL_DEBUG', $config['debug']['tpl']);
     //模板调试
     defined('iPHP_SQL_DEBUG') or define('iPHP_SQL_DEBUG', $config['debug']['sql']);
     //模板调试
     defined('iPHP_TIME_CORRECT') or define('iPHP_TIME_CORRECT', $config['time']['cvtime']);
     defined('iPHP_ROUTER_REWRITE') or define('iPHP_ROUTER_REWRITE', $config['router']['rewrite']);
     defined('iPHP_APP_SITE') && ($config['cache']['prefix'] = iPHP_APP_SITE);
     define('iPHP_ROUTER_USER', $config['router']['user_url']);
     define('iPHP_URL_404', $config['router']['404']);
     //404定义
     //config.php --END--
     ini_set('display_errors', 'OFF');
     error_reporting(0);
     if (iPHP_DEBUG || iPHP_TPL_DEBUG) {
         ini_set('display_errors', 'ON');
         error_reporting(E_ALL & ~E_NOTICE);
     }
     $timezone = $config['time']['zone'];
     $timezone or $timezone = 'Asia/Shanghai';
     //设置中国时区
     @ini_set('date.timezone', $timezone);
     function_exists('date_default_timezone_set') && @date_default_timezone_set($timezone);
     self::multiple_device($config);
     iFS::init($config['FS'], $config['watermark'], 'filedata');
     iCache::init($config['cache']);
     iPHP::template_start();
     iPHP_DEBUG && (iDB::$show_errors = true);
     iPHP_TPL_DEBUG && self::clear_compiled_tpl();
     self::$apps = $config['apps'];
     return $config;
 }