01 | class
Getpass extends
CI_Controller { |
02 | function
__construct(){ |
03 |
04 | parent::__construct(); |
05 | $this ->load->helper( 'captcha' ); |
06 | $this ->load->library( 'form_validation' ); |
07 | $this ->load->model( 'register_model' ); |
08 | } |
09 |
10 | public
function index(){ |
11 |
12 | checkLogin( '您已经登录,请退出后再进行注册' , site_url( '/' ),
true); |
13 | $content [ 'captcha' ] =
$this ->_getCaptcha(); |
14 | $content [ 'title' ] =
'用户注册' ; |
15 | $this ->load->view( 'mail_view' , $content ); //这是输入email发邮件页面 |
16 |
17 | } |
18 |
19 | public
function sendmail(){ |
20 | $data
= $this ->input->post( 'email' ); |
21 | $user
= $this ->register_model->wjpass( $data ); |
22 | // $uid = $user['id']; |
23 | $username
= explode ( "@" , $user [ 'email' ])[0]; |
24 | $token
= md5( $user [ 'id' ]. $user [ 'username' ]. $user [ 'password' ]); |
25 | $url
= "http://www.lqx.cc/topass/resets?email=" . $data . "&token=" . $token ; |
26 | $time
= date ( 'Y-m-d H:i' ); |
27 |
28 | $this ->load->library( 'email' ); |
29 | $this ->email->mailtype= 'html' ;
|
30 | $this ->email->from( 'root@lqx.com' ,
'家明' ); |
31 | $this ->email->to( "$data" ); |
32 | //$this->email->cc('xiejiamingqq@163.com'); |
33 | //$this->email->bcc('them@xjmroot.com'); |
34 |
35 | $this ->email->subject( '找回密码' ); |
36 | $message
= " |
37 | <html> |
38 | <head> |
39 | <title>家明-找回密码</title> |
40 | </head> |
41 | <body> |
42 | <p>找回密码</p> |
43 | 亲爱的 ".$username." :<br/>您在 ".$time." 提交了找回密码请求。请点击下面的链接重置密码 |
44 | (按钮24小时内有效)。<br/><a href= '".$url."' target= '_blank' > ".$url." </a> |
45 | </body> |
46 | </html> |
47 | "; |
48 | $this ->email->message( "$message" ); |
49 | $this ->email->send(); |
50 | echo
$this ->email->print_debugger(); //看详细信息 |
51 | } |
52 |
53 | public
function resets(){ |
54 | $token
= stripslashes (trim( $_GET [ 'token' ])); |
55 | $email
= stripslashes (trim( $_GET [ 'email' ])); |
56 | $user
= $this ->register_model->wjpass( $email ); |
57 | if ( $user ){ |
58 | $mt
= md5( $user [ 'id' ]. $user [ 'username' ]. $user [ 'password' ]); |
59 | if ( $mt == $token ){ |
60 | checkLogin( '您已经登录,请退出后再进行操作' , site_url( '/' ),
true); |
61 | $content [ 'title' ] =
'找回密码' ; |
62 | $this ->load->view( 'reset' , $content );
//这是我在注册页面里面截取出来的输入新密码页面 |
63 | }
|
64 | else {
echo '无效的链接!' ;} |
65 | } else { echo
"无效的链接!" ;} |
66 | $this ->form_validation->set_rules( 'passwd' ,
'密码' , 'trim|required|matches[passwdConfirm]' ); |
67 | $this ->form_validation->set_rules( 'passwdConfirm' ,
'确认密码' ,
'trim|required' ); |
68 | $data
= array ( |
69 | 'password'
=> md5(trim( $this ->input->post( 'passwd' ))) |
70 | ); |
71 | // $email = trim($this->input->post('email')); |
72 | $this ->register_model->updeUser( $data , $email ); |
73 |
74 | } |
75 | } |