private function checkLogin() { $user = M('user'); $data = $user->where('level =1')->select(); $verify = new Verify(); if ($verify->check(I('post.verify'))) { $uname = I('post.uname'); $pass = I('post.pass'); if (empty($uname)) { $this->error("账号不能为空"); } elseif (empty($pass)) { $this->error("密码不能为空"); } foreach ($data as $value) { if (I('post.uname') == $value['name'] && md5(md5(I('post.pass'))) == $value['pass']) { session('uname', I('post.uname')); header('Location:' . __APP__); } else { alert('密码错误', ''); return false; } } } else { $this->error("验证码错误!"); } }
/** * 验证码 */ public function vertifyHandle() { if (get_opinion('vertify_code', true, true)) { $verify = new Verify(); if (!$verify->check(I('post.vertify'), "AdminLogin")) { $this->error("验证码错误"); } } }
public function login_do() { //检测验证码 $code = I('code'); $verify = new Verify(); if ($verify->check($code)) { $this->success('验证成功'); } else { $this->error('验证码错误'); } }
public function login() { $modle = M('userinfo'); if (!($name = $_POST['userName'])) { $error = '请输入账号'; //echo $error; // $this->assign('error',$error); // $this->display('Index:login'); $this->error($error); exit; } else { if (!($pwd = $_POST['Passard'])) { $error = '请输入密码'; //echo $error; // $this->assign('error',$error); // $this->display('Index:login'); $this->error($error); exit; } else { //$modle->where('userName = loujie AND passard = jiege')->select(); //$modle->select(); $verify = new Verify(); $code = $_POST['verify']; if ($verify->check($code)) { $condition['userName'] = $name; $condition['Password'] = md5($pwd); $condition['_logic'] = 'and'; $result = $modle->where($condition)->getField('userID'); //dump($result); if ($result) { session('userName', $name); session('userID', $result); //$this->jump('登陆成功','welcome'); $this->success('登陆成功', U('Home/Index/message_feedback')); } else { $this->assign('info', '登陆失败'); $this->error('登陆失败,用户或密码不正确'); } } else { if (empty($code)) { $error = '请输入验证码'; } else { $error = '验证码输入错误'; } $this->error($error); } } } }
public function login($username = null, $password = null, $code) { if (IS_POST) { $v = new Verify(); if (!$v->check($code, "")) { $this->error("验证码有误!"); } $admin = M("AdminUser"); $result = $admin->where("username='******' and password='******'", $username, $password)->select(); if (count($result) == 0) { $this->error("错误的用户名或密码!"); } $auth = array(); $auth["username"] = $username; session("user_auth", $auth); $this->success("登录成功", U("Index/admin")); } else { $this->index(); } }
public function login() { if (IS_POST) { $loginModel = D('Admin'); if ($data = $loginModel->validate($loginModel->LoginRules)->create()) { $verify = new Verify(); if ($verify->check($_POST['verify'])) { if ($loginModel->login()) { $admin_info = $loginModel->get_admin_info($data['username']); $_SESSION['last_login'] = $admin_info[0]['last_login']; $this->success('登录成功', U('Admin/Index/index')); exit; } } else { $this->error('验证码错误'); } } $this->error($loginModel->getError()); } $this->display('login'); }
/** * 登录 */ public function login() { if (IS_AJAX) { $code = trim(I('post.captcha')); $verify = new Verify(); if ($verify->check($code)) { $account = I('post.account'); $password = I('post.password'); $admin = M('Admin')->where(array('account' => $account))->find(); if (!empty($admin)) { $password = md5(md5($password) . C('DATA_AUTH_KEY')); if ($password == $admin['password']) { session('_admin_id', $admin['id']); $remember = I('post.remember'); if (!empty($remember)) { cookie('_account', Crypt::encode($admin['account']), 7 * 24 * 3600); cookie('_psd', Crypt::encode($admin['password']), 7 * 24 * 3600); } $result = array('code' => 1, 'msg' => '验证成功'); } else { $result = array('code' => 0, 'msg' => '密码不正确'); } } else { $result = array('code' => 0, 'msg' => '用户名不存在'); } } else { $result = array('code' => 0, 'msg' => '验证码不正确'); } $this->ajaxReturn($result); } else { $admin_id = session('_admin_id'); if (!empty($admin_id)) { $this->redirect('/'); //跳转首页 } else { $this->display(); } } }
public function savemsg() { if (IS_POST) { $code = $_POST["code"]; $v = new Verify(); if (!$v->check($code, "")) { $this->error("验证码有误!"); } $m = M("Message"); $data["title"] = $_POST["title"]; $data["content"] = $_POST["content"]; $data["contact_name"] = $_POST["contact_name"]; $data["contact_phone"] = $_POST["contact_phone"]; $data["email"] = trim($_POST["email"]); $data["submit_time"] = date("Y-m-d H:i:s", time()); $m->add($data); loadFixedItem(); $this->display(); } else { $this->error("非法访问!"); } }
public function accept() { $data = I('post.'); $verify = new Verify(); if (!$verify->check($data['code'])) { $this->ajaxReturn(array('status' => 403, 'info' => '验证码错误')); } if (mb_strlen($data['stunum'], 'utf-8') != 10) { $this->ajaxReturn(array('status' => 403, 'info' => '学号/教师一卡通号错误')); } $email = M('user_member')->where(array('stu_num' => $data['stunum']))->getField('email'); if (!$email) { $this->ajaxReturn(array('status' => 403, 'info' => '无此学号/教师一卡通号')); } else { if ($this->mail($email, $data['stunum'])) { $this->ajaxReturn(array('status' => 200, 'info' => '成功', 'data' => $email)); // $this->success('邮件发送成功, 请12小时内前往邮箱('.$email.')收取检查', '', 10); } else { $this->ajaxReturn(array('status' => 500, 'info' => '邮件发送发生错误, 请联系红岩网校工作站或稍后再试!')); } } }
/** * 验证验证码 * @param $checkcode */ public function checkCode($checkcode) { $verify = new Verify(); $rst = $verify->check($checkcode); $this->ajaxReturn($rst); }
/** * 忘记密码发送重置邮件(支持 ajax). * status: 0 用户名, 1 邮箱, 2 验证码, 8 发送失败, 9 发送成功 * * @access public * @return void * @author Liuping <*****@*****.**> */ public function forgotPasswdSendEmail() { $verifyCode = I('post.code', ''); $username = I('post.username', ''); $email = I('post.email', ''); $result = []; $vcode = new Verify(); if (empty($username)) { $result['status'] = 0; $result['msg'] = L('CONTROLLER_MSG25'); } elseif (empty($email)) { $result['status'] = 1; $result['msg'] = L('CONTROLLER_MSG1'); } elseif (empty($verifyCode)) { $result['status'] = 2; $result['msg'] = L('CONTROLLER_MSG1'); } elseif (IS_AJAX && !$vcode->check($verifyCode)) { $result['status'] = 2; $result['msg'] = L('CONTROLLER_MSG27'); } else { // 验证用户与邮箱是否匹配 $model = new UserModel(); if (!$model->checkUserAndEmail($username, $email)) { $result['status'] = 1; $result['msg'] = L('CONTROLLER_MSG36'); } else { // 用户名和邮箱匹配发送邮件 if (!IS_AJAX && IS_POST) { // 如果能 post 提交代表已经 ajax 请求该方法已验证验证码了 if ($this->sendResetPwdEmail($username, $email)) { $result['status'] = 9; $result['msg'] = L('CONTROLLER_MSG23'); $result['url'] = U('Home/Index/index'); } else { $result['status'] = 8; $result['msg'] = L('CONTROLLER_MSG24'); } } else { $result['status'] = 9; $result['msg'] = L('CONTROLLER_MSG48'); } } } if (IS_AJAX) { $this->ajaxReturn($result, 'json'); } elseif ($result['status'] == 9) { //$this->success($result['msg'], $result['url']); // 发送成功, 显示邮箱验证提示页面 $this->assign('jumpUrl', $result['url']); $this->display('successSendEmail'); } else { $this->error($result['msg']); } }
public function check_code($code) { $Verify = new Verify(); $Verify->check($code); }
function Register() { if (!empty($_POST)) { $verify = new Verify(); if ($verify->check($_POST['captcha'])) { $stu = D("Student"); if (!empty($_POST)) { $stuInfo = $stu->create(); if ($stuInfo) { if ($stu->add($stuInfo)) { $this->redirect("login"); } } else { $this->assign('errorInfo', $stu->getError()); } } } else { $this->display(); } } else { $this->display(); } }
public function loginAction() { if (IS_POST) { $Verify = new \Think\Verify(); if (!$Verify->check(I('post.verify'))) { //处理验证码错误 session('verifyErr', '验证码错误'); redirect(U('index')); return; } if (!empty($_POST)) { $User = M('user'); if (!($data = $User->create())) { echo 'many form'; die; } //$pwd = md5(I('post.password')); $username = $data['username']; $pwd = I('post.password'); $info = $User->where(array(username => I('post.username')))->find(); if (!$info) { session('userErr', '用户名错误'); redirect(U('index')); return; } else { if ($info['password'] === $pwd) { $data = array('id' => $info['id'], 'logintime' => time(), 'loginip' => get_client_ip()); M('user')->save($data); //更新用户登陆信息 session(C('USER_AUTH_KEY'), $info['id']); if ($username == C('RBAC_SUPERADMIN')) { session(C('ADMIN_AUTH_KEY'), true); } Rbac::saveAccessList(); //dump($_SESSION);die; redirect(U('Admin/index/index', '', '')); return; } //处理密码错误 session('pwdErr', '密码错误'); redirect(U('index')); return; } } } $this->display(); /*if(IS_POST){ $Verify = new \Think\Verify(); if($Verify->check(I('verify'))){ if(I('username') != '' && I('password') != ''){ $data = array ( $username => I('username') ); $password = I('password'); $Model = new \Think\Model(); $user = $Model->query('select * from user where username = "******"'); //$user = M('user')->where($data)->find(); if($user) { if($user[0]['password'] == md5($password)){ session('uid', $user[0]['id']); session('username', $user[0]['username']); redirect(U('Home/index/index', '', '')); }else{ //密码错误 $pwderr = '密码错误'; $this->assign('pwderr', $pwderr); $this->display(); } }else { //用户名不存在 $nouser = '******'; $this->assign('nouser', $nouser); $this->display(); } } }else{ //验证码错误 $verifyErr = '验证码错误'; $this->assign('verifyErr', $verifyErr); $this->display(); } }else { $this->display(); }*/ }
function check_verify($code, $id = 1) { $Verify = new \Think\Verify(); $Verify->reset = false; return $Verify->check($code, $id); }
function passwordEdit() { $role = session('roleId'); $id = session('userId'); if (!empty($_POST)) { $verify = new Verify(); if ($verify->check($_POST['captcha'])) { if ($role === "0") { if (!empty($_POST)) { if ($_POST['password'] != $_POST['password_affirm']) { $this->assign('error', "密码不一致!"); $this->display(); } else { $admin = D("Admin"); if ($admin->where("adminId='{$id}'")->save($_POST)) { $this->assign("status", "修改成功!"); $this->display(); } else { $this->assign("status", "修改失败!"); $this->display(); } } } } else { if ($role == "1") { if (!empty($_POST)) { if ($_POST['password'] != $_POST['password_affirm']) { $this->assign('error', "密码不一致!"); $this->display(); } else { $teacher = D("Teacher"); if ($teacher->where("teacherId='{$id}'")->save($_POST)) { $this->assign("status", "修改成功!"); $this->display(); } else { $this->assign("status", "修改失败!"); $this->display(); } } } } else { if ($role == "2") { if (!empty($_POST)) { if ($_POST['password'] != $_POST['password_affirm']) { $this->assign('error', "密码不一致!"); $this->display(); } else { $stu = D("Student"); if ($stu->where("studentId='{$id}'")->save($_POST)) { $this->assign("status", "修改成功!"); $this->display(); } else { $this->assign("status", "修改失败!"); $this->display(); } } } } } } } else { $this->display(); } } else { $this->display(); } }
public function checkVer() { $code = trim($_GET['code']); if ($code != "") { $path = __ROOT__ . "/Public/Image"; // 文件路径 $verify = new Verify(); $verify->reset = false; // 禁用重置,方便多次验证 $r = $verify->check($code); if ($r) { echo "<img src='" . $path . "/gou.png' style='width: 50px;height: 32px;'>"; } else { echo "<img src='" . $path . "/cha.png' style='width: 50px;height: 32px;'>"; } } }
function check_verify($code, $id = '') { $verify = new \Think\Verify(); return $verify->check($code, $id); }
public function addAuctionMsg() { if (IS_POST) { $code = $_POST["code"]; $v = new Verify(); if (!$v->check($code, "")) { $this->error("验证码有误!"); } $data["auction_uid"] = session("auction_id"); $data["goods_uid"] = $_POST["goods_uid"]; $author = session("user"); if ($author == null) { $author = "游客"; // 游客才需要显示IP及位置 // 获取IP所在地 if (isMobile()) { $data["author_location"] = "手机用户"; } else { $ipLocation = new \Org\Net\IpLocation('QQWry.dat'); // 实例化类 参数表示IP地址库文件 $ip = get_client_ip(); $data["author_ip"] = $ip; $area = $ipLocation->getlocation($ip); // '203.34.5.66'); // 获取某个IP地址所在的位置 $author_location = iconv('gbk', 'utf-8', $area['country'] . $area['area']); $data["author_location"] = $author_location; } } $data["author"] = $author; $data["post_time"] = date("Y-m-d H:i:s", time()); $data["message"] = $_POST["message"]; $m = M("AuctionMessage"); $m->add($data); if ($_POST["goods_uid"] == null) { $this->redirect("Home/Auction/viewAuction/uid/" . session("auction_id")); } else { $this->redirect("Home/Auction/viewAuctionGoods/uid/" . $_POST["goods_uid"]); } } else { $this->error("非法访问!"); } }
/** * 验证验证码 * @param string $code 验证码 * @param string $id 标示id * @return boolean */ function check_verify($code, $id = '') { $verify = new \Think\Verify(); if (!empty($_GET['captcha'])) { $code = $_GET['captcha']; $res = $verify->check($code); $data = json_encode($res); echo $data; } return $verify->check($code, $id); }
public function dologin($verifycode, $id = '') { $admin = M("Admin"); $pwd = md5($_POST['admin_pwd']); $info = $admin->where(array('admin_name' => "{$_POST['admin_name']}", 'admin_pwd' => "{$pwd}"))->select(); if (!$info) { echo "<meta charset='utf-8'>"; echo "<script>alert('用户名或者密码错误')</script>"; $this->redirect('Index/index'); } /* if(!$this->check_verify($_POST['verifycode'], $id)) { }else{ echo "<meta charset=utf-8>"; echo "<script>alert('验证码错误')</script>"; $this->redirect('Index/index'); } */ /* $verifyCode =I('verifycode'); if (!$this->check_verify ( $verifyCode )) { $this->success ( '验证码输入错误!' ); echo '错误'; exit; } else { $this->success ( '验证码输入正确!' ); echo '正确'; exit; } */ // $code = $_POST['verifycode']; $verify = new \Think\Verify(); $verifyCheck = $verify->check($verifycode, $id); if ($verifyCheck) { } else { echo "<meta charset=utf-8>"; echo "<script>alert('验证码错误')</script>"; $this->redirect('Index/index'); } /* if(!checkVerify($code)){ $this->error('验证码错误'); redirect('index',2,'2秒内返回登录页面。。'); } */ /* if(md5($_POST['verifycode'])!=$_SESSION['verify']){ } */ $data['last_login_time'] = time(); $data['last_login_ip'] = ip2long("{$_SERVER['REMOTE_ADDR']}"); $admin->where(array('admin_name' => "{$_POST['admin_name']}"))->save($data); $_SESSION['admin']['name'] = $_POST['admin_name']; $_SESSION['admin']['id'] = $info[0]['id']; //echo '111'; //exit; //写入权限 //$role_node=new \Login\Model(); $role_node = D('User'); $nodes = $role_node->query("select rn.node_id from qd_role_node as rn,qd_admin_role as ar where ar.role_id=rn.role_id and ar.admin_id=" . $_SESSION['admin']['id']); foreach ($nodes as $key => $value) { $arr[] = $value['node_id']; } $_SESSION['admin']['nodes'] = $arr; $this->redirect('Index/Manage'); }
/** * 验证验证码 * @param string $checkCode 用户输入的验证码 * @return bool */ public static function checkCaptcha($checkCode) { $captcha = new Verify(); return $captcha->check($checkCode); }
public function dologin() { if (IS_POST) { $code = $_POST["code"]; $v = new Verify(); if (!$v->check($code, "")) { $this->error("验证码有误!"); } $m = M("User"); $user_id = $_POST["user_id"]; $password = encrypt($_POST["password"]); $result = $m->where("user_id='%s' and password='******'", $user_id, $password)->find(); if ($result == null) { $this->error("错误的用户名或密码!"); } $result["last_logon_time"] = date("Y-m-d H:i:s", time()); $m->save($result); session("user", $_POST["user_id"]); $this->redirect("Index/index"); } else { $this->index(); } }
/** * */ public function getbackPasswd() { if (IS_POST) { $data['captcha'] = I('post.captcha', ''); $data['email'] = I('post.email', ''); $verify = new Verify(); $checkRs = $verify->check($data['captcha']); if (!$checkRs) { $this->ajaxReturn(array('status' => false, 'message' => '提示:验证码不正确')); } if (!Validation::IsEmailAdress($data['email'])) { $this->ajaxReturn(array('status' => false, 'message' => '提示:邮箱地址不合法')); } $rs = M('Users')->where("email = '" . $data['email'] . "'")->find(); if (!$rs) { $this->ajaxReturn(array('status' => false, 'message' => '提示:该账号不存在')); } $token = authcode($rs['userid'] . ',' . time() . ',' . $data['email'], "ENCODE", SESSION_AUTH); $this->assign('url', SITE_URL . '/Web/Login/modifyPasswd?token=' . base64_encode($token)); $this->assign('username', $rs['nickname']); $res = ACPopedom::sendEmail($data['email'], $rs['nickname'], '旅之沙修改密码邮件', $this->fetch('modifyPasswdEmailContent')); if ($res) { cookie('__getback__', authcode($rs['userid'] . ',' . time() . ',' . $data['email'], "ENCODE", SESSION_AUTH), C('ACTIVATION_TIME')); $this->ajaxReturn(array('status' => true, 'message' => '提示:邮件发送成功', 'url' => SITE_URL . U('Web/Login/gbStep2'))); } else { $this->ajaxReturn(array('status' => false, 'message' => '提示:发送邮件失败')); } } $this->display('getbackPasswdStep1'); }
/** * 检测验证码 * @param integer $id 验证码ID * @return boolean 检测结果 */ function check_verify($code, $vid = 1) { $verify = new Verify(); return $verify->check($code, $vid); }
/** * 验证码检测 */ public function checkverify($code, $id = '') { $Verify = new Verify(); return $Verify->check($code, $id); }
public static function checkCaptcha($captcha, $identify = self::REGISTR_CAPTCHA) { $verify = new Verify(); return $verify->check($captcha, $identify); }