2015-07-28 15:15:57 +08:00
|
|
|
|
<?php
|
|
|
|
|
|
namespace Admin\Controller;
|
|
|
|
|
|
use Think\Controller;
|
|
|
|
|
|
|
2016-01-24 11:54:16 +08:00
|
|
|
|
/**
|
2016-12-03 21:42:04 +08:00
|
|
|
|
* @Author: Zhou Yuyang <1009465756@qq.com> 10:28 2016/12/03
|
|
|
|
|
|
* @Copyright 2015-2020 SISMO
|
|
|
|
|
|
* @Project homepage https://github.com/CNSISMO
|
|
|
|
|
|
* @Version 1.8
|
2016-01-24 11:54:16 +08:00
|
|
|
|
*/
|
|
|
|
|
|
|
2015-07-28 15:15:57 +08:00
|
|
|
|
class LoginController extends Controller {
|
|
|
|
|
|
//登陆主页
|
|
|
|
|
|
public function index(){
|
|
|
|
|
|
$this->display();
|
|
|
|
|
|
}
|
|
|
|
|
|
//登陆验证
|
|
|
|
|
|
public function login(){
|
|
|
|
|
|
if(!IS_POST)$this->error("非法请求");
|
2016-01-26 14:09:59 +08:00
|
|
|
|
$member = M('manager');
|
2015-07-28 15:15:57 +08:00
|
|
|
|
$username =I('username');
|
|
|
|
|
|
$password =I('password','','md5');
|
|
|
|
|
|
$code = I('verify','','strtolower');
|
|
|
|
|
|
//验证验证码是否正确
|
|
|
|
|
|
if(!($this->check_verify($code))){
|
|
|
|
|
|
$this->error('验证码错误');
|
|
|
|
|
|
}
|
|
|
|
|
|
//验证账号密码是否正确
|
|
|
|
|
|
$user = $member->where(array('username'=>$username,'password'=>$password))->find();
|
|
|
|
|
|
|
|
|
|
|
|
if(!$user) {
|
|
|
|
|
|
$this->error('账号或密码错误 :(') ;
|
|
|
|
|
|
}
|
|
|
|
|
|
//验证账户是否被禁用
|
2016-01-26 14:09:59 +08:00
|
|
|
|
//if($user['status'] == 0){
|
|
|
|
|
|
//$this->error('账号被禁用,请联系超级管理员 :(') ;
|
|
|
|
|
|
//}
|
|
|
|
|
|
//if($user['type'] == 1){
|
|
|
|
|
|
//$this->error('您没权限登陆后台 :(') ;
|
|
|
|
|
|
//}
|
2015-07-28 15:15:57 +08:00
|
|
|
|
//验证是否为管理员
|
|
|
|
|
|
//更新登陆信息
|
|
|
|
|
|
$data =array(
|
|
|
|
|
|
'id' => $user['id'],
|
|
|
|
|
|
'update_at' => time(),
|
|
|
|
|
|
'login_ip' => get_client_ip(),
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
//如果数据更新成功 跳转到后台主页
|
|
|
|
|
|
if($member->save($data)){
|
|
|
|
|
|
session('adminId',$user['id']);
|
2016-12-02 12:24:27 +08:00
|
|
|
|
session('adminname',$user['username']);
|
2015-10-06 20:25:13 +08:00
|
|
|
|
//发送验证码邮件
|
2016-12-02 12:24:27 +08:00
|
|
|
|
//import('ORG.Net.Mail');
|
|
|
|
|
|
require "./././././ThinkPHP/Library/Org/Net/Mail.class.php";
|
2015-10-06 20:25:13 +08:00
|
|
|
|
$ip = get_client_ip();
|
|
|
|
|
|
$time = date("Y-m-d h:i:sa");
|
|
|
|
|
|
$con='您好,您的后台管理账户 '.$username.' 于 '.$time.' 被登录,登录IP地址为 '.$ip.' 如果该操作非您本人操作,可能帐号信息已经被泄露,请您及时修改密码。 ';
|
2016-01-26 14:09:59 +08:00
|
|
|
|
SendMail($user['email'],'应急响应中心后台登录提示',$con,'应急响应中心');
|
2015-07-28 15:15:57 +08:00
|
|
|
|
$this->success("登陆成功",U('Index/index'));
|
|
|
|
|
|
}
|
|
|
|
|
|
//定向之后台主页
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
//验证码
|
|
|
|
|
|
public function verify(){
|
2016-01-26 14:09:59 +08:00
|
|
|
|
ob_clean();
|
2015-07-28 15:15:57 +08:00
|
|
|
|
$Verify = new \Think\Verify();
|
2016-01-26 14:09:59 +08:00
|
|
|
|
$Verify->codeSet = 'AECDEFGHIGJ123456';
|
|
|
|
|
|
$Verify->fontSize = 16;
|
2015-07-28 15:15:57 +08:00
|
|
|
|
$Verify->length = 4;
|
|
|
|
|
|
$Verify->entry();
|
|
|
|
|
|
}
|
|
|
|
|
|
protected function check_verify($code){
|
|
|
|
|
|
$verify = new \Think\Verify();
|
|
|
|
|
|
return $verify->check($code);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function logout(){
|
|
|
|
|
|
session('adminId',null);
|
2016-12-02 12:24:27 +08:00
|
|
|
|
session('adminname',null);
|
2015-07-28 15:15:57 +08:00
|
|
|
|
redirect(U('Login/index'));
|
|
|
|
|
|
}
|
2016-01-26 14:09:59 +08:00
|
|
|
|
}
|