4 function lostpass_post(&$a) {
6 $loginame = notags(trim($_POST['login-name']));
10 $r = q("SELECT * FROM `user` WHERE ( `email` = '%s' OR `nickname` = '%s' ) AND `verified` = 1 AND `blocked` = 0 LIMIT 1",
16 notice( t('No valid account found.') . EOL);
21 $username = $r[0]['username'];
22 $email = $r[0]['email'];
24 $new_password = autoname(12) . mt_rand(100,9999);
25 $new_password_encoded = hash('whirlpool',$new_password);
27 $r = q("UPDATE `user` SET `pwdreset` = '%s' WHERE `uid` = %d LIMIT 1",
28 dbesc($new_password_encoded),
32 info( t('Password reset request issued. Check your email.') . EOL);
34 $email_tpl = get_intltext_template("lostpass_eml.tpl");
35 $email_tpl = replace_macros($email_tpl, array(
36 '$sitename' => $a->config['sitename'],
37 '$siteurl' => $a->get_baseurl(),
38 '$username' => $username,
40 '$reset_link' => $a->get_baseurl() . '/lostpass?verify=' . $new_password
43 $res = mail($email, sprintf( t('Password reset requested at %s'),$a->config['sitename']),
45 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n"
46 . 'Content-type: text/plain; charset=UTF-8' . "\n"
47 . 'Content-transfer-encoding: 8bit' );
54 function lostpass_content(&$a) {
57 if(x($_GET,'verify')) {
58 $verify = $_GET['verify'];
59 $hash = hash('whirlpool', $verify);
61 $r = q("SELECT * FROM `user` WHERE `pwdreset` = '%s' LIMIT 1",
65 notice( t("Request could not be verified. \x28You may have previously submitted it.\x29 Password reset failed.") . EOL);
70 $username = $r[0]['username'];
71 $email = $r[0]['email'];
73 $new_password = autoname(6) . mt_rand(100,9999);
74 $new_password_encoded = hash('whirlpool',$new_password);
76 $r = q("UPDATE `user` SET `password` = '%s', `pwdreset` = '' WHERE `uid` = %d LIMIT 1",
77 dbesc($new_password_encoded),
81 $tpl = get_markup_template('pwdreset.tpl');
82 $o .= replace_macros($tpl,array(
83 '$lbl1' => t('Password Reset'),
84 '$lbl2' => t('Your password has been reset as requested.'),
85 '$lbl3' => t('Your new password is'),
86 '$lbl4' => t('Save or copy your new password - and then'),
87 '$lbl5' => '<a href="' . $a->get_baseurl() . '">' . t('click here to login') . '</a>.',
88 '$lbl6' => t('Your password may be changed from the <em>Settings</em> page after successful login.'),
89 '$newpass' => $new_password,
90 '$baseurl' => $a->get_baseurl()
93 info("Your password has been reset." . EOL);
97 $email_tpl = get_intltext_template("passchanged_eml.tpl");
98 $email_tpl = replace_macros($email_tpl, array(
99 '$sitename' => $a->config['sitename'],
100 '$siteurl' => $a->get_baseurl(),
101 '$username' => $username,
103 '$new_password' => $new_password,
104 '$uid' => $newuid ));
106 $res = mail($email,"Your password has changed at {$a->config['sitename']}",$email_tpl,
107 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n"
108 . 'Content-type: text/plain; charset=UTF-8' . "\n"
109 . 'Content-transfer-encoding: 8bit' );
116 $tpl = get_markup_template('lostpass.tpl');
118 $o .= replace_macros($tpl,array(
119 '$title' => t('Forgot your Password?'),
120 '$desc' => t('Enter your email address and submit to have your password reset. Then check your email for further instructions.'),
121 '$name' => t('Nickname or Email: '),
122 '$submit' => t('Reset')