/** * !CodeTemplates.overridecomment.nonjd! * @see CController::init() */ public function init() { parent::init(); if ($this->_setting['site_status'] == 'close') { //网站关闭 $encode_intro = CHtml::encode($this->_setting['site_status_intro']); $site_name = CHtml::encode($this->_setting['site_name']); echo <<<EOT <html xmlns="http://www.w3.org/1999/xhtml"> <head> \t<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> \t<title>{$site_name}</title> </head> <body> \t<p style="width:800px; line-height:40px; margin:0 auto; margin-top:50px; color:#FFFFFF; text-align:center; background-color:#3C5880;">{$encode_intro}</p> </body> </html>\t EOT; exit; } //前端ip访问控制 $cur_ip = $this->_request->userHostAddress; $access_ips = $this->_setting['deny_access_ip']; $access_ips && ($access_ips = explode("\r\n", trim($access_ips))); $access = Helper::ipAccess($cur_ip, $access_ips); if (!$access) { throw new CHttpException(403, '403 Forbidden!'); exit; } //主题设置 Yii::app()->theme = $this->_setting['theme']; $this->_stylePath = Yii::app()->theme->baseUrl . '/styles'; //菜单导航 $this->_public_menu = Yii::app()->cache->get('global_menus'); if ($this->_public_menu == false) { $menus = Menu::model()->findAll('status_is =:status ORDER BY sort_order, id', array(':status' => 'Y')); $tree = new Xtree(); foreach ((array) $menus as $menu) { $data[] = $menu->attributes; } $tree->setTree($data, 'id', 'parent_id', array('menu_name', 'menu_link', 'unique', 'target')); $this->_public_menu = $tree->getArrayList(0); Yii::app()->cache->set('global_menus', $this->_public_menu, 3600 * 24 * 7); } $this->_cur_url = Yii::app()->request->getUrl(); //登录状态 if (!Yii::app()->user->getIsGuest()) { $this->_login_status = true; } //加载公共资源 //不需要加载bootstrap的页面,要小写 $not_need_bootstrap = array('goods/buy'); //Yii::app()->clientScript->registerCssFile($this->_stylePath . "/bootstrap3/css/bootstrap.min.css"); //Yii::app()->clientScript->registerCssFile($this->_stylePath . "/css/global.css"); Yii::app()->clientScript->registerScriptFile($this->_static_public . "/js/jquery/jquery.js"); }
/** * !CodeTemplates.overridecomment.nonjd! * @see CController::init() */ public function init() { parent::init(); if ($this->_setting['site_status'] == 'close') { //网站关闭 $encode_intro = CHtml::encode($this->_setting['site_status_intro']); $site_name = CHtml::encode($this->_setting['site_name']); echo <<<EOT <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"> <title>{$site_name}</title> </head> <body> <p style="width:800px; line-height:40px; margin:0 auto; margin-top:50px; color:#FFFFFF; text-align:center; background-color:#3C5880;">{$encode_intro}</p> </body> </html>\t EOT; exit; } //前端ip访问控制 $cur_ip = Yii::app()->request->userHostAddress; if ($this->_setting['deny_access_ip']) { $access_ips = explode("\r\n", trim($this->_setting['deny_access_ip'])); $access = Helper::ipAccess($cur_ip, $access_ips); if (!$access) { throw new CHttpException(403, '403 Forbidden!'); } } //主题设置 Yii::app()->theme = $this->_setting['theme']; $this->_stylePath = Yii::app()->theme->baseUrl . '/styles'; //菜单导航 $menus = Menu::model()->findAll('status =:status ORDER BY sort_order, id', array(':status' => 'Y')); $tree = new Xtree(); foreach ((array) $menus as $menu) { $data[] = $menu->attributes; } $tree->setTree($data, 'id', 'parent_id', array('menu_name', 'menu_link', 'unique', 'target')); $this->_public_menu = $tree->getArrayList(0); $this->_cur_url = Yii::app()->request->getUrl(); //登录状态 if (!Yii::app()->user->getIsGuest()) { $this->_login_status = true; } //加载公共资源 Yii::app()->clientScript->registerCssFile($this->_stylePath . "/css/global.css"); }