Login.php
1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
namespace app\admin\controller;
use think\Controller;
use app\admin\model\Admin;
use think\captcha\Captcha;
class Login extends Controller
{
private $cache_model,$system;
public function initialize(){
if (session('aid')) {
$this->redirect('admin/index/index');
}
$this->cache_model=array('Module','AuthRule','Category','Posid','Field','System');
$this->system = cache('System');
$this->assign('system',$this->system);
if(empty($this->system)){
foreach($this->cache_model as $r){
savecache($r);
}
}
}
public function index(){
if(request()->isPost()) {
$data = input('post.');
$admin = new Admin();
$return = $admin->login($data,$this->system['code'],$this->system['ticket']);
return ['code' => $return['code'], 'msg' => $return['msg']];
}else{
return $this->fetch();
}
}
public function verify(){
$config = [
// 验证码字体大小
'fontSize' => 25,
// 验证码位数
'length' => 4,
// 关闭验证码杂点
'useNoise' => true,
'bg' => [255,255,255],
];
$captcha = new Captcha($config);
return $captcha->entry();
}
}