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 verify()
 {
     ob_clean();
     //清除缓存
     $Verify = new \Think\Verify(C('VERIFY'));
     $Verify->entry();
 }
Example #3
0
 public function verify()
 {
     $verify = new \Think\Verify();
     $verify->fontSize = 50;
     $verify->length = 4;
     $verify->entry();
 }
Example #4
0
 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 checkverify()
 {
     $code = $_GET['code'];
     $verify = new \Think\Verify();
     $result = $verify->check($code);
     dump($result);
 }
Example #6
0
function check_verify($code, $id = '')
{
    $verify = new \Think\Verify();
    //var_dump($verify);
    //exit;
    return $verify->check($code, $id);
}
Example #7
0
 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');
     }
 }
Example #8
0
 public function verify()
 {
     $Verify = new \Think\Verify();
     $Verify->bg = array(255, 255, 255);
     $Verify->useNoise = false;
     $Verify->entry();
 }
Example #9
0
 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();
 }
Example #10
0
 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>";
         }
     }
 }
Example #11
0
 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 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");
     }
 }
Example #14
0
 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 index()
 {
     $Verify_config = array('fontSize' => 16, 'length' => 4, 'useNoise' => false, 'imageW' => 120, 'imageH' => 36, 'useCurve' => false);
     ob_clean();
     $Verify = new \Think\Verify($Verify_config);
     $Verify->entry();
 }
 public function index()
 {
     $Verify = new \Think\Verify();
     // 验证码字体使用 ThinkPHP/Library/Think/Verify/ttfs/5.ttf
     $Verify->useZh = true;
     $Verify->entry();
 }
 public function do_code()
 {
     $code = I('code');
     $verify = new \Think\Verify();
     $data = $verify->check($code);
     return $data;
 }
 public function verify_c()
 {
     $config = array('fontSize' => 15, 'length' => 4, 'useNoise' => false, 'fontttf' => '5.ttf', 'useImgBg' => true);
     ob_clean();
     $verify = new \Think\Verify($config);
     $verify->entry();
 }
Example #19
0
 public function verify()
 {
     ob_end_clean();
     $config = array('fontSize' => 30, 'length' => 4, 'useCurve' => false, 'useNoise' => false, 'codeSet' => '0123456789');
     $verify = new \Think\Verify($config);
     $verify->entry();
 }
Example #20
0
 public function imgCode()
 {
     $Verify = new \Think\Verify();
     $config = array('fontSize' => 35, 'length' => 4, 'useCurve' => false, 'fontttf' => '1.ttf', 'bg' => array(243, 251, 254));
     $Verify = new \Think\Verify($config);
     $Verify->entry();
 }
Example #21
0
 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());
     }
 }
Example #22
0
 public function Verify()
 {
     ob_clean();
     $config = array('imageW' => I('width'), 'imageH' => I('height'), 'expire' => 180, 'fontSize' => I('font_size'), 'length' => I('code_len'));
     $Verify = new \Think\Verify($config);
     $Verify->entry($id);
 }
Example #23
0
 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 captcha()
 {
     $Verify = new \Think\Verify();
     $Verify->length = 4;
     $Verify->useNoise = false;
     $Verify->entry();
 }
Example #25
0
 /**
  * 生成验证码
  */
 public function verify()
 {
     $config = array('fontSize' => '16', 'imageW' => '160', 'imageH' => '40', 'length' => '4', 'useCurve' => true, 'useNoise' => false, 'fontttf' => '5.ttf', 'bg' => array(243, 243, 243));
     ob_clean();
     $Verify = new \Think\Verify($config);
     $Verify->entry();
 }
Example #26
0
 /**
  * 验证码
  */
 public function verify()
 {
     ob_end_clean();
     $config = array('length' => 4, 'useImgBg' => false, 'imageW' => 120, 'imageH' => 32, 'fontSize' => 18, 'expire' => 180);
     $verify = new \Think\Verify($config);
     $verify->entry(1);
 }
 public function verify()
 {
     ob_clean();
     $config = array('fontSize' => 160, 'length' => 4, 'useNoise' => false, 'reset' => false);
     $Verify = new \Think\Verify($config);
     $Verify->entry();
 }
 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 checkcode()
 {
     //创建验证码类
     $Verify = new \Think\Verify(array('length' => 4, 'useNoise' => FALSE, 'imageH' => 36, 'imageW' => 150, 'fontSize' => 20, 'fontttf' => '1.ttf', 'useCurve' => FALSE));
     //验证码的生成
     $Verify->entry();
 }
 public function verify()
 {
     $config = array('length' => 4, 'imageW' => 238);
     ob_end_clean();
     $verify = new \Think\Verify($config);
     $verify->entry(1);
 }