private function initSite()
{
//初始化语言包
$cacheFile = DATA_PATH . '/lang/_initSiteLang.lock';
if (!file_exists($cacheFile)) {
model('Lang')->initSiteLang();
}
$GLOBALS['time_run_detail']['action_init_site_start'] = microtime(true);
//载入网站全局配置
$this->site = F('global_site_config');
if ($this->site === false) {
//载入站点配置全局变量
$this->site = model('Xdata')->get('admin_Config:site');
$GLOBALS['time_run_detail']['action_init_site_siteconfig'] = microtime(true);
$GLOBALS['time_run_detail']['action_init_site_language'] = microtime(true);
//LOGO处理
$this->site['logo'] = getSiteLogo($this->site['site_logo']);
$GLOBALS['time_run_detail']['action_init_site_logo'] = microtime(true);
//默认登录后首页
if (intval($this->site['home_page'])) {
$appInfo = model('App')->where('app_id=' . intval($this->site['home_page']))->find();
$this->site['home_url'] = U($appInfo['app_name'] . '/' . $appInfo['app_entry']);
} else {
$this->site['home_url'] = U('public/Index/index');
}
$GLOBALS['time_run_detail']['action_init_site_homepage'] = microtime(true);
//网站导航
$this->site['site_top_nav'] = model('Navi')->getTopNav();
$this->site['site_bottom_nav'] = model('Navi')->getBottomNav();
$this->site['site_bottom_child_nav'] = model('Navi')->getBottomChildNav($GLOBALS['ts']['site_bottom_nav']);
if (!$this->mid) {
//游客导航
$this->site['site_guest_nav'] = model('Navi')->getGuestNav();
}
$GLOBALS['time_run_detail']['action_init_site_language'] = microtime(true);
//获取可搜索的内容列表
$this->site['search_menu_list'] = D('SearchSelect')->findAll();
$GLOBALS['time_run_detail']['action_init_site_search'] = microtime(true);
//网站所有的应用
$this->site['site_nav_apps'] = model('App')->getAppList(array('status' => 1, 'add_front_top' => 1), 9);
$GLOBALS['time_run_detail']['action_init_site_applist'] = microtime(true);
//获取当前Js语言包
$this->site['langJsList'] = setLangJavsScript();
//分享字数
$this->site['initNums'] = model('Xdata')->getConfig('weibo_nums', 'feed');
//赋值给全局变量
F('global_site_config', $this->site);
}
//检查站点是否关闭
if ($this->site['site_closed'] == 0 && APP_NAME != 'admin') {
$this->page404($this->site['site_closed_reason']);
exit;
}
// 检查网页端是否关闭
if ($this->site['web_closed'] == 0 && APP_NAME != 'admin' && APP_NAME != 'w3g' && IS_GET) {
$this->page404('网页版已经关闭');
exit;
}
$GLOBALS['time_run_detail']['action_init_site_closed'] = microtime(true);
//检查是否启用IP控制
// if (!isIpAccess('ipaccess') && APP_NAME !='admin') {
// $this->site['site_closed'] = 0;
// $this->page404('你的IP地址已被禁止'); exit();
// }
// $GLOBALS['time_run_detail']['action_init_site_ipaccess'] = microtime(true);
//检查是否启用rewrite
if (isset($this->site['site_rewrite_on'])) {
C('URL_ROUTER_ON', $this->site['site_rewrite_on'] == 1);
}
$GLOBALS['time_run_detail']['action_init_site_rewrite'] = microtime(true);
$this->langJsList = $this->site['langJsList'];
$this->site['sys_version'] = C('VERSION');
$GLOBALS['ts']['site'] = $this->site;
//网站全局变量过滤插件
Addons::hook('core_filter_init_site');
$this->assign('site', $this->site);
$this->assign('site_top_nav', $this->site['site_top_nav']);
$this->assign('site_bottom_nav', $this->site['site_bottom_nav']);
$this->assign('site_bottom_child_nav', $this->site['site_bottom_child_nav']);
$this->assign('site_guest_nav', $this->site['site_guest_nav']);
$this->assign('site_nav_apps', $this->site['site_nav_apps']);
$this->assign('menuList', $this->site['search_menu_list']);
$this->assign('initNums', $this->site['initNums']);
$GLOBALS['time_run_detail']['action_init_site_end'] = microtime(true);
return true;
}