功能更新,bug修复

This commit is contained in:
2016-06-29 15:01:55 +08:00
parent 6f1790bc3b
commit c8e979b159
14 changed files with 277 additions and 128 deletions

View File

@@ -71,11 +71,79 @@ class Login extends Fornt{
}
}
public function forget(){
public function forget($email = '', $verify = ''){
if (IS_POST) {
//验证码验证
$this->checkVerify($verify);
if (!$email) {
return $this->error('邮件必填!', url('index/index/index'));
}
$result = false;
$user = db('Member')->where(array('email'=>$email))->find();
if (!empty($user)){
$time = time();
$token = authcode($user['uid'] . "\n\r" . $user['email'] . "\n\r" . $time, 'ENCODE');
config('url_common_param', true);
$url = url('user/login/find',array('time'=>$time, 'token'=>$token), 'html', true);
$html = \think\Lang::get('find_password', array('url'=>$url));
$result = send_email($user['email'], '找回密码确认邮件', $html);
}
if ($result) {
return $this->success("已发送邮件至您邮箱,请登录您的邮箱!", url('index/index/index'));
}else{
return $this->error('发送失败!', '');
}
}else{
return $this->fetch();
}
}
public function find(){
//http://127.0.0.2/user/login/find.html?time=1467174578&token=b561PJhVI2OjWUPNLsAMdeW8AKZLw/RcqyXUHBa1mCiX2OUzvq0D69Rt40F/n7zfJKR05d7qA41G6/33NQ
if (IS_POST) {
$data = $this->request->post();
//验证码验证
$this->checkVerify($data['verify']);
if ($data['password'] !== $data['repassword']) {
return $this->error('确认密码和密码不同!','');
}
$token_decode = authcode($data['token']);
list($uid, $email, $time) = explode("\n\r", $token_decode);
$save['salt'] = rand_string(6);
$save['password'] = md5($data['password'].$save['salt']);
$result = db('Member')->where(array('uid'=>$uid))->update($save);
if (false != $result) {
return $this->success('重置成功!');
}else{
return $this->success('重置失败!');
}
}else{
$time = input('get.time', '', 'trim');
$token = input('get.token', '', 'trim');
if (!$time || !$token) {
return $this->error('参数错误!','');
}
$token_decode = authcode($token);
list($uid, $email, $time) = explode("\n\r", $token_decode);
if ((time() - $time) > 3600 || (time() - $time) < 0) {
return $this->error('链接已失效!', '');
}
if ($time != $time) {
return $this->error('非法操作!', '');
}
$data = array(
'token' => $token,
'email' => $email,
'uid' => $uid,
);
$this->assign($data);
return $this->fetch();
}
}
}

View File

@@ -57,7 +57,7 @@ class Upload extends User {
}
public function avatar(){
$file = \think\Input::file('UpFile');
$file = $this->request->file('UpFile');
$info = $file->rule('uniqid')->move('./uploads/avatar/'.setavatardir(session('user_auth.uid')), true, true);
$image = new \org\Image();

View File

@@ -4,7 +4,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta charset="UTF-8">
<title>用户注册</title>
<title>用户登录</title>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/libs/font-awesome.css"/>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/common.css"/>
<!-- <link href='//fonts.googleapis.com/css?family=Open+Sans:400,600,700,300|Titillium+Web:200,300,400' rel='stylesheet' type='text/css'> -->
@@ -75,13 +75,8 @@
</div>
<div id="footer" class="wrapper">
<p><a href="http://s.dxpd.cn/shop">首页</a>
| <a href="http://s.dxpd.cn/index.php?act=article&article_id=24">招聘英才</a>
| <a href="http://s.dxpd.cn/index.php?act=article&article_id=25">合作及洽谈</a>
| <a href="http://s.dxpd.cn/index.php?act=article&article_id=23">联系我们</a>
| <a href="http://s.dxpd.cn/index.php?act=article&article_id=22">关于我们</a>
| <a href="http://s.dxpd.cn/delivery">物流自取</a>
| <a href="http://s.dxpd.cn/index.php?act=link">友情链接</a>
<p><a href="{:url('index/index/index')}">首页</a>
| <a href="{:url('user/index/index')}">会员中心</a>
</p>
Copyright 2015 <a href="http://www.tensent.cn" target="_blank">腾速科技</a> All rights reserved.<br/>
</div>
@@ -123,12 +118,12 @@ $(function(){
//初始化选中用户名输入框
$("#itemBox").find("input[name=username]").focus();
//刷新验证码
var verifyimg = $(".codeimage").attr("src");
var verifyimg = $("#codeimage").attr("src");
$(".makecode").click(function(){
if( verifyimg.indexOf('?')>0){
$(".codeimage").attr("src", verifyimg+'&random='+Math.random());
$("#codeimage").attr("src", verifyimg+'&random='+Math.random());
}else{
$(".codeimage").attr("src", verifyimg.replace(/\?.*$/,'')+'?'+Math.random());
$("#codeimage").attr("src", verifyimg.replace(/\?.*$/,'')+'?'+Math.random());
}
});

View File

@@ -97,13 +97,8 @@
</div>
</div>
<div id="footer" class="wrapper">
<p><a href="http://s.dxpd.cn/shop">首页</a>
| <a href="http://s.dxpd.cn/index.php?act=article&article_id=24">招聘英才</a>
| <a href="http://s.dxpd.cn/index.php?act=article&article_id=25">合作及洽谈</a>
| <a href="http://s.dxpd.cn/index.php?act=article&article_id=23">联系我们</a>
| <a href="http://s.dxpd.cn/index.php?act=article&article_id=22">关于我们</a>
| <a href="http://s.dxpd.cn/delivery">物流自取</a>
| <a href="http://s.dxpd.cn/index.php?act=link">友情链接</a>
<p><a href="{:url('index/index/index')}">首页</a>
| <a href="{:url('user/index/index')}">会员中心</a>
</p>
Copyright 2015 <a href="http://www.tensent.cn" target="_blank">腾速科技</a> All rights reserved.<br/>
</div>