<?php /** * 后台登录控制器 */ Class LoginAction extends Action{ /** * 登录视图 */ Public function index(){ $this->display(); } Public function login(){ // if(!IS_POST) halt(‘页面不存在‘); if(I(‘code‘,‘‘,‘md5‘) != Session(‘verify‘)){ $this->error(‘验证码错误‘); } $username = I(‘username‘); $pwd = I(‘password‘,‘‘,‘md5‘); $user =M(‘member‘)->where(array(‘username‘ => $username))->find(); if(!$user || $user[‘password‘] != $pwd){ $this->error(‘账号名称或密码错误!‘); } if($user[‘lock‘]) $this->error(‘账号被锁定‘); $data = array( ‘id‘ =>$user[‘id‘], ‘logintime‘ =>time(), ‘loginip‘ =>get_client_ip(),//获取IP地址 ); M(‘member‘)->save($data);//更新数据库内容 session(‘uid‘,$user[‘id‘]); Session(‘username‘,$user[‘username‘]); Session(‘logintime‘,date(‘Y-m-d H:i:s‘,$user[‘logintime‘])); session(‘loginip‘,$user[‘loginip‘]); $this->redirect(‘Admin/Index/index‘); } /** * 显示验证码 * */ Public function verify(){ //确保gd2库打开 import(‘ORG.Util.Image‘); Image::buildImageVerify(1,1,‘png‘); } } ?>
时间: 2024-11-06 21:17:02