Esempio n. 1
0
 /**
  * 设置网站配置信息
  */
 private function _init()
 {
     $config = (require CONFIG_DIR . 'config.ini.php');
     $site = array_flip(require CONFIG_DIR . 'site.ini.php');
     $name = strtolower($_SERVER['HTTP_HOST']) . ($_SERVER['SERVER_PORT'] == '80' ? '' : ':' . (int) $_SERVER['SERVER_PORT']);
     $info = array();
     $path = str_replace(array('\\', '//'), '/', dirname($_SERVER['SCRIPT_NAME']));
     $path = substr($path, -1) == '/' ? $path : $path . '/';
     //URL以反斜杠("/")结尾
     $siteid = isset($_GET['siteid']) ? (int) $_GET['siteid'] : (isset($site[$name]) ? $site[$name] : 1);
     foreach ($site as $url => $sid) {
         $f = CONFIG_DIR . 'site' . DIRECTORY_SEPARATOR . $sid . '.ini.php';
         if (file_exists($f) && is_file($f)) {
             $info[$sid] = (require $f);
             $info[$sid]['URL'] = 'http://' . $url . $path;
             $info[$sid]['DOMAIN'] = $url;
         } else {
             if ($siteid == $sid) {
                 $siteid = 1;
             }
         }
     }
     $site = isset($info[$siteid]) ? $info[$siteid] : array();
     $config = array_merge($config, $site);
     $config['PLUGIN_DIR'] = basename(PLUGIN_DIR);
     if (isset($config['SITE_MOBILE']) && $config['SITE_MOBILE'] == true && App::get_mobile()) {
         //手机客服端修改系统模板目录
         $config['SITE_THEME'] = is_dir(VIEW_DIR . 'mobile_' . $siteid) ? 'mobile_' . $siteid : (is_dir(VIEW_DIR . 'mobile') ? 'mobile' : $config['SITE_THEME']);
     }
     define('TIME_FORMAT', isset($config['SITE_TIME_FORMAT']) && $config['SITE_TIME_FORMAT'] ? $config['SITE_TIME_FORMAT'] : 'Y-m-d H:i:s');
     //输出时间格式化
     define('SYS_LANGUAGE', isset($config['SITE_LANGUAGE']) && $config['SITE_LANGUAGE'] ? $config['SITE_LANGUAGE'] : 'zh-cn');
     //网站语言设置
     define('LANGUAGE_DIR', EXTENSION_DIR . 'language' . DIRECTORY_SEPARATOR . SYS_LANGUAGE . DIRECTORY_SEPARATOR);
     //网站语言文件
     define('SYS_THEME_DIR', $config['SITE_THEME'] . DIRECTORY_SEPARATOR);
     //模板风格
     define('SYS_TIME_ZONE', 'Etc/GMT' . ($config['SITE_TIMEZONE'] > 0 ? '-' : '+') . abs($config['SITE_TIMEZONE']));
     //时区
     date_default_timezone_set(SYS_TIME_ZONE);
     if (!file_exists(LANGUAGE_DIR)) {
         exit('语言目录不存在:' . LANGUAGE_DIR);
     }
     $language = (require LANGUAGE_DIR . 'lang.php');
     if (file_exists(LANGUAGE_DIR . 'custom.php')) {
         //如果存在自定义语言包,则引入
         $custom_lang = (require LANGUAGE_DIR . 'custom.php');
         $language = array_merge($language, $custom_lang);
         //若有重复,自定义语言会覆盖系统语言
     }
     $this->siteid = $siteid;
     define('SITE_ID', $this->siteid);
     $this->site = $this->config = $config;
     $this->language = $language;
     $this->site_info = $info;
     App::$siteid = $siteid;
     App::$config = $config;
     App::$language = $language;
     App::$site_info = $info;
     $config = (require CONFIG_DIR . 'database.ini.php');
     $config['hostname'] = $config['host'];
     $config['database'] = $config['dbname'];
     $config['dbdriver'] = function_exists('mysqli_init') ? "mysqli" : "mysql";
     $config['dbprefix'] = $config['prefix'];
     $config['pconnect'] = FALSE;
     $config['db_debug'] = TRUE;
     $config['cache_on'] = FALSE;
     $config['cachedir'] = "";
     $config['char_set'] = "utf8";
     $config['dbcollat'] = "utf8_general_ci";
     $this->load->database($config);
 }
Esempio n. 2
0
 /**
  * 设置网站配置信息
  */
 private static function set_config($config)
 {
     $site = array_flip(require CONFIG_DIR . 'site.ini.php');
     $name = strtolower($_SERVER['HTTP_HOST']) . ($_SERVER['SERVER_PORT'] == '80' ? '' : ':' . (int) $_SERVER['SERVER_PORT']);
     $info = array();
     $path = str_replace(array('\\', '//'), '/', dirname($_SERVER['SCRIPT_NAME']));
     $path = substr($path, -1) == '/' ? $path : $path . '/';
     //URL以反斜杠("/")结尾
     $siteid = isset($_GET['siteid']) ? (int) $_GET['siteid'] : (isset($site[$name]) ? $site[$name] : 1);
     foreach ($site as $url => $sid) {
         $f = CONFIG_DIR . 'site' . DIRECTORY_SEPARATOR . $sid . '.ini.php';
         if (file_exists($f) && is_file($f)) {
             $info[$sid] = (require $f);
             $info[$sid]['URL'] = 'http://' . $url . $path;
             $info[$sid]['DOMAIN'] = $url;
         } else {
             if ($siteid == $sid) {
                 $siteid = 1;
             }
         }
     }
     $site = isset($info[$siteid]) ? $info[$siteid] : array();
     $config = array_merge($config, $site);
     $config['PLUGIN_DIR'] = basename(PLUGIN_DIR);
     if (isset($config['SITE_MOBILE']) && $config['SITE_MOBILE'] == true && self::get_mobile()) {
         //手机客服端修改系统模板目录
         $config['SITE_THEME'] = is_dir(VIEW_DIR . 'mobile_' . $siteid) ? 'mobile_' . $siteid : (is_dir(VIEW_DIR . 'mobile') ? 'mobile' : $config['SITE_THEME']);
     }
     define('TIME_FORMAT', isset($config['SITE_TIME_FORMAT']) && $config['SITE_TIME_FORMAT'] ? $config['SITE_TIME_FORMAT'] : 'Y-m-d H:i:s');
     //输出时间格式化
     define('SYS_LANGUAGE', isset($config['SITE_LANGUAGE']) && $config['SITE_LANGUAGE'] ? $config['SITE_LANGUAGE'] : 'zh-cn');
     //网站语言设置
     define('LANGUAGE_DIR', EXTENSION_DIR . 'language' . DIRECTORY_SEPARATOR . SYS_LANGUAGE . DIRECTORY_SEPARATOR);
     //网站语言文件
     define('SYS_THEME_DIR', $config['SITE_THEME'] . DIRECTORY_SEPARATOR);
     //模板风格
     define('SYS_TIME_ZONE', 'Etc/GMT' . ($config['SITE_TIMEZONE'] > 0 ? '-' : '+') . abs($config['SITE_TIMEZONE']));
     //时区
     date_default_timezone_set(SYS_TIME_ZONE);
     if (!file_exists(LANGUAGE_DIR)) {
         exit('语言目录不存在:' . LANGUAGE_DIR);
     }
     $language = (require LANGUAGE_DIR . 'lang.php');
     if (file_exists(LANGUAGE_DIR . 'custom.php')) {
         //如果存在自定义语言包,则引入
         $custom_lang = (require LANGUAGE_DIR . 'custom.php');
         $language = array_merge($language, $custom_lang);
         //若有重复,自定义语言会覆盖系统语言
     }
     self::$siteid = $siteid;
     self::$config = $config;
     self::$language = $language;
     self::$site_info = $info;
 }