12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- namespace Home\Controller;
- use Base\Controller\BaseController;
- use User\Model\AdminModel;
- use Think\Verify;
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- * 登录控制器
- */
- class LoginController extends BaseController {
-
- private $adminModel;
-
- public function _initialize(){
- $this->adminModel = new AdminModel();
- }
- public function login() {
- layout(false);
-
- if (IS_POST) {
- $res = checkVerify(I('verify'));
- if(empty($res)){
- $this->error('验证码错误', __APP__.'/Home/Login/login', 2);
- exit;
- }
-
- if(empty(I('username')) || empty(I('password'))){
- $this->error('用户名或者密码不能为空', __APP__.'/Home/Login/login', 2);
- exit;
- }
-
- $admin = $this->adminModel->onLogin();
- if(empty($admin)) {
- $this->error('用户名或者密码错误', __APP__.'/Home/Login/login', 2);
- exit;
- }
-
- session('admin', $admin);
- header("location: " . __APP__ . "/User/User/index");
- exit;
- }
-
- $this->display();
- }
-
-
- public function createVerify(){
- $Verify = new Verify();
- $Verify->fontSize = 20;
- $Verify->length = 4;
- $Verify->useNoise = false;
- $Verify->imageW = 150;
- $Verify->imageH = 50;
- $Verify->entry();
- }
-
- public function outLogin(){
- session(null);
- layout(false);
- $this->display("login");
- }
- }
|