/** * 控制器方法执行前的操作 * */ public function before() { parent::before(); if (!($this->dir = $this->request->directory)) { $this->dir = 'default'; } else { $this->dir = $this->request->directory; $this->template_dir = $this->request->directory; } if (!($this->ctrl = $this->request->controller)) { $this->ctrl = 'index'; } if (!($this->act = $this->request->action)) { $this->act = 'index'; } /* 初始化模板对象 */ $this->template = new View(); $this->template->script = ''; $this->template->css = ''; $this->template->directory = $this->dir; $this->template->controller = $this->ctrl; $this->template->action = $this->act; //缩略图 $this->template->thumb = $this->thumb = Thumb::getInstance(); /* 判断是否已登录 */ $this->template->auth = $this->auth = Session::instance()->get('user', false); $this->template->auth_field = $this->auth_field = isset($this->auth['field']) ? $this->auth['field'] : array(); $sys_configs = Cache::instance()->get('sys_configs'); if (null == $sys_configs) { $sys_configs = ORM::factory('user')->setConfig(); } $this->template->configs = $this->configs = $sys_configs; /* xss过滤 */ if (!empty($_POST)) { $_POST = Security::xss_clean($_POST); } if (!empty($_GET)) { $_GET = Security::xss_clean($_GET); } }