/** * 注册 * @return [type] [description] */ public function signup() { if (IS_POST) { $login_ask = 'User/login'; $signup_ask = 'User/signup'; $verify = new \Think\Verify(); if ($verify->check(I('post.verify'))) { $this->redirect($signup_ask, '', 3, '验证码错误!'); return; } $username = I('post.username'); $password = I('post.password'); $repassword = I('post.repassword'); if ($username == '' || $password == '') { $this->redirect($signup_ask, '', 3, '用户名和密码不能为空!'); return; } if ($password !== $repassword) { $this->redirect($signup_ask, '', 3, '两次输入的密码不一致!'); return; } $data['username'] = $username; $data['user_pwd'] = $password; $model = D('User'); if ($model->create($data) && $model->add()) { $this->redirect($login_ask, '', 1, '注册成功!跳转至登录页面...'); return; } else { $this->redirect($signup_ask, '', 3, $model->getError()); return; } } else { $this->display(); } }
public function prologin() { $code = I('code'); $verify = new \Think\Verify(); $res = $verify->check($code); if (!$res) { $this->error('验证码错误!'); exit; } if (!$_POST['password']) { $this->error("请输入密码!"); exit; } $users = M("users"); $map['username'] = array("EQ", $_POST['username']); $data = $users->where($map)->find(); //dump($data['password']); //dump(md5($_POST['password'])); //exit; if ($data) { if ($data['password'] == md5($_POST['password'])) { //登录成功!将用户 'id' / 'username' 信息存入到session 中 session("uid", $data['id']); session('username', $data['username']); $this->redirect('index/index'); //echo "成功!"; } else { $this->error("密码不正确!"); exit; } } else { $this->error("账号不存在!"); exit; } }
/** * 修改密码 * @access public * @return void */ public function chpwd() { if (IS_POST) { $cur_ask = 'Mycenter/chpwd'; $verify = new \Think\Verify(); if ($verify->check(I('post.verify'))) { $this->redirect($cur_ask, '', 3, '验证码错误!'); return; } $old_pwd = I('post.oldpassword'); if ($old_pwd == '') { $this->redirect($cur_ask, '', 3, '原密码不能为空!'); return; } $new_pwd = I('post.password'); $renew_pwd = I('post.repassword'); if ($new_pwd !== $renew_pwd) { $this->redirect($cur_ask, '', 3, '两次输入的密码不一致!'); return; } $model = D('User'); if ($model->chpwd(self::$user_id, $old_pwd, $new_pwd)) { $this->redirect($cur_ask, '', 3, '修改密码成功'); return; } else { $this->redirect($cur_ask, '', 3, $model->getError()); return; } } else { $this->display(); } }
public function login() { //mima if ($_POST) { $code = I('post.code'); $user = I('post.name'); $password = I('post.pass'); $userobj = M('Member'); $res1 = $userobj->where(array('vip_username' => $user))->select(); if ($res1[0]['vip_password'] == $password) { $res_pass = $userobj->where(array('vip_password' => $password))->select(); if (TRUE) { $verify = new \Think\Verify(); $res = $verify->check($code); if ($res) { session('name', $_POST['name']); //设置session echo "<script>window.location.href='/index.php/Home/Index/index';</script>"; } else { echo "<script>alert('验证码错误');window.location.href='/index.php/Home/Index/index';</script>"; } } } else { echo "<script>alert('用户名或密码错误');window.location.href='/index.php/Home/Index/index';</script>"; } } }
public function treg() { $m = M("Teachers"); $data['teacher_tel'] = $_POST['tel']; $arr = $m->where($data)->find(); $code = $_POST['verification']; $verify = new \Think\Verify(); if ($verify->check($code, "") == 1) { if ($arr['teacher_id']) { $this->assign("currentMode", "reg"); $this->assign("currentUserMode", "t"); $this->assign("tip", "抱歉,该手机号已被注册,您可以直接登录"); $this->display("index"); } else { echo "注册成功!手机号:" . $data['teacher_tel']; $data['teacher_id'] = $m->max('teacher_id') + 1; $data['teacher_name'] = $_POST['name']; $data['teacher_password'] = md5($_POST['password']); $m->add($data); session('is_logged_in', true); session('user_name', $data['teacher_name']); session('user_id', $data['teacher_id']); } } else { $this->assign("currentMode", "reg"); $this->assign("currentUserMode", "t"); $this->assign("tip", "抱歉,验证码错误,请重新输入"); $this->display("index"); } }
function index() { if (!empty($_POST)) { $verify = new \Think\Verify(); if ($verify->check($_POST['captcha'])) { $user = new \Home\Model\AdminModel(); if ($user->create($POST, 4)) { $rz = $user->user_verify($_POST); if ($rz == true) { $this->success('登录成功', U('Index/index')); } elseif ($rz == -1) { $this->error('用户名不存在'); } elseif ($rz == -2) { $this->error('密码错误'); } } else { $this->error($user->getError()); } } else { $this->error('验证码错误'); } } else { $this->display(); } }
public function login() { if (IS_POST) { $username = I("username"); $password = I("password"); $captcha = I("captcha"); $verify = new \Think\Verify(); //实现输入密码超过三次用验证码 if (!isset($_SESSION['retry_count'])) { $_SESSION['retry_count'] = 1; } if (!$verify->check($captcha) && $_SESSION['retry_count'] > 3) { $this->error("验证码错误"); } if (D("admin")->checkUser($username, $password)) { $_SESSION['retry_count'] = 0; $adminM = M("admin"); $adminM->logintime = time(); $adminM->where(array("admin_name" => $username))->setInc('logincount'); $adminM->where(array("admin_name" => $username))->save(); $this->success("登录成功", U("Index/index")); } else { $_SESSION['retry_count']++; $this->error("用户名或者密码错误", '', 1); } } else { $this->display(); } }
public function insert() { //dump($_POST); //exit; $code = I('code'); $verify = new \Think\Verify(); $res = $verify->check($code); if (!$res) { $this->error("验证码错误!"); exit; } $_POST['password'] = md5($_POST['password']); $_POST['password2'] = md5($_POST['password2']); //信息验证 $rule = array(array('username', 'require', '用户名不能为空'), array('password', 'password2', '确认密码不正确!', 0, 'confirm'), array('email', 'email', '邮箱格式不正确!')); $users = M('users'); //dump($_POST); //exit; if ($users->validate($rule)->create()) { if ($users->add()) { $this->redirect("login/login"); } else { $this->error("e!"); } } else { $this->error("a"); } }
public function register() { $email = I('email'); $User = D("User"); if (!$User->create()) { $this->assign("error", $User->getError()); $this->assign("typed", $_POST); $this->display('User:register'); return; } else { $verify = new \Think\Verify(); if (!$verify->check($_POST['verify'], "")) { $this->assign("typed", $_POST); $this->assign("verifyError", "验证码错误"); $this->display('User:register'); return; } $User->password = substr(md5($User->password), 0, 16) . substr(sha1($User->password), 16, 24); $User->icon = 'default.jpg'; $User->score = 10; $User->registerTime = date('Y-m-d H:i:s', time()); $User->lastLoginTime = date('Y-m-d H:i:s', time()); $User->add(); $user = $User->where("email='{$email}'")->find(); session('userId', $user['userId']); session('userName', $user['userName']); session('icon', $user['icon']); session('email', $user['email']); session('signature', $user['signature']); session('score', $user['score']); session('registerTime', format_date($user['registerTime'])); session('lastLoginTime', format_date($user['lastLoginTime'])); $this->success('注册成功,正在跳转...', U('Index/index')); } }
public function login() { $admin = new \Model\AdminModel(); if (!empty($_POST)) { //检验验证码 $verify = new \Think\Verify(); if ($verify->check($_POST['captcha'])) { //检验用户名和密码 //通过返回值判断是否成功 //成功:返回用户信息 失败:flase $info = $admin->checkNamePwd($_POST['admin_user'], $_POST['admin_psd']); if ($info) { //如果检验通过保存session session('mg_id', $info['mg_id']); session('mg_name', $info['mg_name']); session('mg_time', $info['mg_time']); $this->redirect('Index/index'); } else { $this->redirect('Admin/login', array(), 2, '用户名或密码错误'); } } else { $this->redirect('Admin/login', array(), 2, '验证码错误'); } } $this->display(); }
function login(){ if(!empty($_POST)){ //验证码校验 $verify = new \Think\Verify(); if(!$verify->check($_POST['captcha'])){ echo "验证码错误"; } else { //判断用户名和密码,在model模型里边制作一个专门方法进行验证 $user = new \Model\ManagerModel(); $rst = $user -> checkNamePwd($_POST['mg_username'],$_POST['mg_password']); if($rst === false){ echo "用户名或密码错误"; } else { //登录信息持久化$_SESSION session('mg_username',$rst['mg_name']); session('mg_id',$rst['mg_id']); //$this ->redirect($url, $params, $delay, $msg) //$this -> redirect('Index/index',array('id'=>100,'name'=>'tom'),2,'用户马上登陆到后台'); $this -> redirect('Index/index'); } } } $this -> assign('lang',L()); $this -> display(); }
public function login() { header("Content-Type:text/html; charset=utf-8"); $Login = D('Login'); // 实例化User对象 if ($_POST) { $data = $Login->create(); // 组合查询条件 $where = array(); $where['mg_name'] = $data['mg_name']; $result = $Login->where($where)->field('mg_id,mg_name,mg_pwd,mg_time,mg_role_id')->find(); $ver = new \Think\Verify(); if ($ver->check($_POST['captcha'])) { // 验证用户名 对比 密码 if ($result && $data['mg_pwd'] == $result['mg_pwd']) { // 存储session session('mg_id', $result['mg_id']); // 当前用户id session('mg_name', $result['mg_name']); // 当前用户名 //$this->success('登录成功,正跳转至系统首页...', U('Index/index'), 3); $this->redirect('Index/index', '登录成功,正跳转至系统首页...'); } else { $this->error('登录失败,用户名或密码不正确!'); } } else { $this->error('亲,验证码输入错误!'); } } else { $this->display(); } }
public function addu() { $Verify = new \Think\Verify(); $code = I("code"); $res = $Verify->check($code); if ($res) { if ($_POST['users_pass'] == $_POST['pass']) { $_POST['users_pass'] = md5($_POST['pass']); } else { $this->error("两次输入密码不同"); } $user = M("users"); if ($user->create()) { $res = $user->add(); if ($res) { $grade = M('grade'); $data['grade_userid'] = $res; $data['grade_score'] = 500; $grade->create($data); $grade->add(); $this->success("添加用户成功", U('login/index')); } } else { $this->error($user->getError()); } } else { $this->error("验证码错误", U("Zhuce/index")); } }
public function login() { $user = new \Model\UserModel(); if (!empty($_POST)) { //检验验证码 $verify = new \Think\Verify(); if ($verify->check($_POST['captcha'])) { //检验用户名和密码 //通过返回值判断是否成功 //成功:返回用户信息 失败:flase $info = $user->checkNamePwd($_POST['username'], $_POST['password']); if ($info) { //如果检验通过保存session session('user_id', $info['user_id']); session('username', $info['username']); //移动购物车数据 $cart = new \Model\CartModel(); $cart->moveData(); $this->redirect('buy/cartlist'); } else { $this->redirect('User/login', array(), 2, '用户名或密码错误'); } } else { $this->redirect('User/login', array(), 2, '验证码错误'); } } $this->display(); }
public function check() { $verify = new \Think\Verify(); $test = $_POST['verify']; if ($verify->check($_POST['verify'])) { //echo 'CC'; } else { //echo 'sbsbsbsbbbbbbbb'; $this->error('验证码输入错误!'); } $User = D('user'); if ($User->create()) { //$Form->create() $condition['username'] = $_POST['username']; $condition['password'] = md5($_POST['password']); $result = $User->where($condition)->select(); if ($result) { $result1 = $User->where($condition)->find(); session('uid', $result1['id']); //$auth = new Auth(); //echo 'login success:'.$result1['username'].session('uid'); //echo MODULE_NAME.'/'.CONTROLLER_NAME.'/'.ACTION_NAME; //if(!$auth->check("Home/Form/read",1)){ // echo "stop the foolish!"; //} $this->success('登入成功,跳转中...', U('Home/Form/read')); } else { //echo 'error'.$_POST['username']; $this->error('密码错误!!'); } } else { //exit($User->getError()); $this->error($User->getError()); } }
function check_verify($code, $id = '') { $verify = new \Think\Verify(); //var_dump($verify); //exit; return $verify->check($code, $id); }
public function reset() { if (IS_POST) { if ('' != I('post.code')) { $verify = new \Think\Verify(); $checksurepwd = $verify->check(I('post.code'), $id); if (!$checksurepwd) { $json['code'] = false; $json['msg'] = '验证码错误!'; $this->ajaxreturn($json); exit; } $emailinfo = M('user')->where(array('email' => I('post.email')))->field('email')->find(); if (!$emailinfo) { $json['code'] = false; $json['msg'] = '邮箱不在记录列表中'; $this->ajaxreturn($_POST); exit; } $json['code'] = true; $this->ajaxreturn($json); } else { $data['to'] = I('post.email'); $data['subject'] = '邮箱验证'; $data['message'] = 'yzm'; think_send_mail($data); $json['code'] = true; $json['msg'] = '验证码已成功发送至邮箱'; $this->ajaxreturn($json); } } else { $this->display('Public/reset'); } }
public function login() { header("Content-type: text/html; charset=utf-8"); if (trim(I('post.admin'))) { $admin = M('User'); $user = $admin->where("username='******'", I('post.admin'))->find(); $verify = new \Think\Verify(); if (!$verify->check(I('post.verifycode'))) { $info = "验证码错误!"; $this->error($info, 'login', 1); } if (empty($user)) { $info = "用户不存在!"; $this->error($info, 'login', 1); } elseif ($user['password'] != md5(I('post.password'))) { $info = "密码错误!"; $this->error($info, 'login', 1); } else { $info = "登录成功!"; cookie('auser', md5($user['username'] . C('SALT')), 14400); session('auser', $user['username']); $this->success($info, 'index'); } exit; } $this->display(); }
public function do_code() { $code = I('code'); $verify = new \Think\Verify(); $data = $verify->check($code); return $data; }
public function check_login() { $username = I('post.username'); $password = I('post.password'); $code = I('post.verify'); if ($username && $password && $code) { $verify = new \Think\Verify(); if ($verify->check($code)) { if (C($username)) { if (C($username . ".password") == $password) { session('login_name', $username); echo 'success'; } else { echo '密码错误'; } } else { echo '账号错误'; } } else { echo "验证码错误!"; } } else { echo "非法操作"; } }
public function checkverify() { $code = $_GET['code']; $verify = new \Think\Verify(); $result = $verify->check($code); dump($result); }
function login() { //display()没有参数,那么获得的模板名称与当前操作的名称一致 //display('hello'); Admin/View/Manager/hello.html // show_bug(L()); $message = array(); if (!empty($_POST)) { //验证码校验 //show_bug($_POST); $VerifyIMG = new \Think\Verify(); if (!$VerifyIMG->check($_POST['captcha'])) { //echo '验证码错误'; $message[0] = '验证码错误'; } else { //echo '验证码正确'; $user = new \Model\ManagerModel(); $result = $user->CheckUP($_POST['admin_user'], $_POST['admin_psd']); if ($result != false) { //show_bug($result);exit(); session('username', $result['mg_name']); session('user_id', $result['mg_id']); //跳转方法 $this->redirect('Index/index'); } else { //echo '用户名或者密码错误'; $message[0] = '用户名或者密码错误'; } } } $this->assign('message', $message); $this->assign('lang', L()); //将语言传递到模板 $this->display(); }
public function loginDo() { //接收数据 过滤和验证 此处无法使用模型z中的自动验证,自动完成功能,因为login并不完整对应一个用户表,且不对表进行增加和更新操作 $username = I('post.username'); $userpwd = I('post.userpwd'); $code = I('post.verify'); $verify = new \Think\Verify(); if (!$verify->check($code, $id)) { $this->error('验证码不正确'); } //判断用户是否重复 $user = M('user'); $where['username'] = $username; $where['userpwd'] = md5($userpwd); $arr = $user->field('id')->where($where)->find(); if ($arr) { //存在 允许登陆 $_SESSION['username'] = $username; $_SESSION['userid'] = $arr['id']; $this->success('用户登陆成功', U('Admin/Index/index')); } else { //不存在显示错误消息 $this->error('该用户不存在'); } }
public function login() { if (!IS_POST) { $this->ajaxReturn(2); } $ip = get_client_ip(); $ban_times = S('ban_' . $ip); if ($ban_times > 5) { $this->ajaxReturn(4); } $username = I('post.username'); $password = I('post.password'); if ($username == '' || $password == '') { $this->ajaxReturn(3); } $verify = new \Think\Verify(); if (!$verify->check(I('post.verify_code'))) { $this->ajaxReturn(5); } $id = D('User')->checkPassword($username, $password); if ($id == 0) { S('ban_' . $GLOBALS['ip'], $ban_times + 1, 900); $this->ajaxReturn(3); } session('user_id', $id); session('username', $username); $this->ajaxReturn(1, array('url' => __APP__)); }
protected function CheckVerify($data) { $verify = new \Think\Verify(); if ($verify->check($data, null)) { return true; } else { return false; } }
/** * 验证码,用于自动验证 */ function checkVerify() { $verify = new \Think\Verify(); if ($verify->check(I('post.verify'), 1)) { return true; } else { return false; } }
public function ajax_add() { $UserInfo = isLogin(); $verify = new \Think\Verify(); if (!$verify->check(I('post.verify'))) { die('验证码错误'); } $first_domain = I('post.first_domain'); $sub_domain = I('post.sub_domain'); $record_type = I('post.record_type'); $value = I('post.value'); $conf = D('Admin'); $conf_first_domain = json_decode($conf->getConf('first_domain'), true); $conf_important_sub_domain = json_decode($conf->getConf('important_sub_domain'), true); $record = D('Record'); if (!($limit_number = $conf->getConf('limit_number'))) { $limit = 0; } else { $limit = 1; } if (!in_array($first_domain, $conf_first_domain)) { die('顶级域错误'); } elseif (strrpos($sub_domain, "*") !== false) { die('禁止泛解析'); } elseif (in_array($sub_domain, $conf_important_sub_domain)) { die('域名前缀被保留'); } elseif (!$record->CheckRecord(array("sub_domain" => $sub_domain, "first_domain" => $first_domain))) { die('域名前缀已被使用'); } elseif ($record->CountRecord($UserInfo['id']) >= $limit_number and $limit) { die('域名数超过限制'); } else { $conf_domain_info = json_decode($conf->getConf('domain_info_' . $first_domain), true); $d = new \Org\Util\Dnspod($conf_domain_info); $d->record_type = $record_type; $d->sub_domain = $sub_domain; $d->value = $value; $d->record_line = "默认"; $d->dns_add(); $result = $d->result; if ($result['status']['code'] != "1") { if ($result['status']['code'] == 34) { die("记录值非法"); } else { die("失败" . $result['status']['message']); } } else { $data = array("record_id" => $result['record']['id'], "sub_domain" => $sub_domain, "first_domain" => $first_domain, "record_type" => $record_type, "value" => $value, "userid" => $UserInfo['id'], "ttl" => '600'); $re = $record->AddRecord($data); if (!$re[0]) { die($re[1]); } else { die('1'); } } } }
public function checkVerify() { $verify = I('verify'); $code = new \Think\Verify(); if ($code->check($verify, '')) { $this->ajaxReturn(true, 'json'); } else { $this->ajaxReturn(false, 'json'); } }
protected function checkFormVerifyCode($data) { $verify = new \Think\Verify(); $res = $verify->check($data); if ($res) { return true; } else { return false; } }
/** * 插入并发送短讯记录 */ public function sendSMS($smsSrc, $phoneNumber, $content, $smsFunc, $verfyCode) { $USER = session('WST_USER'); $userId = empty($USER) ? 0 : $USER['userId']; $m = M('log_sms'); $ip = get_client_ip(); //检测短信验证码验证是否正确 if ($GLOBALS['CONFIG']['smsVerfy'] == 1) { $smsverfy = I('smsVerfy'); $verify = new \Think\Verify(array('reset' => false)); $rs = $verify->check($smsverfy); if (!$rs) { return array('status' => -29999, 'msg' => '验证码不正确!'); } } //检测是否超过每日短信发送数 $date = date('Y-m-d'); $sql = 'select count(smsId) counts,max(createTime) createTime from __PREFIX__log_sms where smsPhoneNumber=' . $phoneNumber . ' and createTime>"' . $date . ' 00:00:00" and createTime<="' . $date . ' 23:59:59"'; $smsRs = $this->queryRow($sql); if ($smsRs['counts'] > (int) $GLOBALS['CONFIG']['smsLimit']) { return array('status' => -20000, 'msg' => '请勿频繁发送短信验证!'); } if ($smsRs['createTime'] != '' && time() - strtotime($smsRs['createTime']) < 120) { return array('status' => -20001, 'msg' => '请勿频繁发送短信验证!'); } //检测IP是否超过发短信次数 $sql = 'select count(smsId) counts,max(createTime) createTime from __PREFIX__log_sms where smsIP="' . $ip . '" and createTime>"' . $date . ' 00:00:00" and createTime<="' . $date . ' 23:59:59"'; $ipRs = $this->queryRow($sql); if ($ipRs['counts'] > (int) $GLOBALS['CONFIG']['smsLimit']) { return array('status' => -20003, 'msg' => '请勿频繁发送短信验证!'); } if ($ipRs['createTime'] != '' && time() - strtotime($ipRs['createTime']) < 120) { return array('status' => -20004, 'msg' => '请勿频繁发送短信验证!'); } $code = WSTSendSMS($phoneNumber, $content); $data = array(); $data['smsSrc'] = $smsSrc; $data['smsUserId'] = $userId; $data['smsPhoneNumber'] = $phoneNumber; $data['smsContent'] = $content; $data['smsReturnCode'] = $code; $data['smsCode'] = $verfyCode; $data['smsIP'] = $ip; $data['smsFunc'] = $smsFunc; $data['createTime'] = date('Y-m-d H:i:s'); $m->add($data); $xml = simplexml_load_string($code); if ($xml->State == 1) { return array('status' => 1, 'msg' => '短信发送成功!'); } else { return array('status' => -1, 'msg' => '短信发送失败!'); } }