public function _initialize()
 {
     parent::_initialize();
     $this->captcha = new Captcha();
     //Captcha::getInstance();
     $this->logs = D('Logs');
 }
 /**
  * 登录验证和权限验证
  */
 public function _initialize()
 {
     parent::_initialize();
     //日志记录
     $this->logWriter = D('Logs');
     //检查用户是否登录
     $user = D('Useradmin');
     $this->userId = $user->isLogin();
     if (!$this->userId) {
         //exit($this->error('你还没有登录!', U('/Admin/Login')));
         $this->redirect(U('/Admin/System/Login', null, 0, '你还没有登录!'));
         exit;
     }
     if (!($this->loginUser = $user->getUserById($this->userId))) {
         exit($this->error('用户信息有误!', U('/Admin/System/Login')));
         //$this->redirect(U('/Admin/System/Login', null, 0, '用户信息有误!'));
         exit;
     }
     //是否管理员
     $this->isAdmin = $user->isAdmin($this->userId);
     //echo MODULE_NAME,' - ',CONTROLLER_NAME,' - ',ACTION_NAME;exit;
     //检查用户权限
     //$auth = new ExtAuth();
     //if (!in_array($this->userId, C('ADMINISTRATOR'))) {
     //if (!$auth->check(MODULE_NAME.'/'.CONTROLLER_NAME.'/'.ACTION_NAME, $this->userId)) {
     //exit($this->show('没有权限访问,请联系管理员!'));
     //}
     //}
     //检查用户权限
     $menuModel = D('Menu');
     $access = $this->accessControl();
     if ($access === false) {
         $this->error('403:禁止访问');
     } elseif ($access === null) {
         $dynamic = $this->checkDynamic();
         //检测分类栏目有关的各项动态权限
         if ($dynamic === null) {
             //检测非动态权限
             $rule = strtolower(MODULE_NAME . '/' . CONTROLLER_NAME . '/' . ACTION_NAME);
             if (!$menuModel->checkRule($rule, array('in', '1,2'))) {
                 $this->error('未授权访问!');
             }
         } elseif ($dynamic === false) {
             $this->error('未授权访问!');
         }
     }
     //用户名首字母大写,用于显示
     $this->assign('uname', ucwords($this->loginUser['uname']));
     //生成系统菜单
     $this->assign('__MENU__', $this->getMenus());
     //----------->>> 没有子菜单的分组单独做处理 <<<---------------------------
     //获取专家系统权限
     $dataModelMenu = $menuModel->checkRule('Admin/Datamodel/index');
     $this->assign('showDataModelMenu', $this->isAdmin || $dataModelMenu);
     //获取专家系统权限
     $showExpsysMenu = $menuModel->checkRule('Admin/Faultdiagnosis/index');
     $this->assign('showExpsysMenu', $this->isAdmin || $showExpsysMenu);
     //获取案例法规库权限
     $showCaseLibrary = $menuModel->checkRule('Admin/Caselibrary/index');
     $this->assign('showCaseLibrary', $this->isAdmin || $showCaseLibrary);
     //----------->>> 没有子菜单的分组单独做处理 END <<<---------------------------
     //生成面包屑
     $this->nav($this->getNav());
 }