public function _initialize()
 {
     $curr_action = strtolower(__ACTION__);
     //忽略
     $ignore_arr = array("/admin/getvcode");
     foreach ($ignore_arr as $v) {
         if (strpos($curr_action, $v) !== false) {
             return;
         }
     }
     //检查是否已登录
     if (!cookie("curr_user_name")) {
         if (!session('?user')) {
             if (strpos($curr_action, "/admin/login") === false) {
                 //没有登录
                 header(strtolower("location: " . __ROOT__ . "/" . MODULE_NAME . "/admin/login"));
             }
         } else {
             //如果是已登录状态,停留在登录页面的话,就跳到后台首页
             if (strpos($curr_action, "/admin/login") !== false) {
                 header(strtolower("location: " . __ROOT__ . "/" . MODULE_NAME . "/admin/main"));
             }
         }
     } else {
         $curr_user_name = \Common\Encrypt::decode(cookie("curr_user_name"));
         $where = array("name" => $curr_user_name);
         $user = D("User")->where($where)->find();
         session("user", $user);
     }
     //公用部分
     $this->assign("admin_path", dirname(__APP__) . "/" . strtolower(MODULE_NAME) . "/" . strtolower(CONTROLLER_NAME));
 }
 public function login()
 {
     if (cookie("curr_user_name")) {
         //一周内自动登录
         $name = str_filter(cookie("curr_user_name"));
         $name = \Common\Encrypt::decode($name);
         $where = array("name" => $name, "is_admin" => 1);
         $user = D("User")->where($where)->find();
         unset($user["pwd"]);
         session("user", $user);
         $user["err_login"] = 0;
         D("User")->where(array("id" => $user["id"]))->save($user);
         header("location:main");
         exit;
     }
     if (IS_POST) {
         $name = I("post.name", NULL, "str_filter");
         $pwd = I("post.pwd", NULL, "str_filter");
         //提交登录
         $remember = I("post.remember", 0, "intval");
         $vcode = I("post.vcode", "", "str_filter");
         $this->ajaxReturn(D("User")->adminLogin($name, $pwd, $remember, $vcode), "JSON");
     }
     $this->display();
 }