4 function lostpass_post(&$a) {
6 $email = 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'];
23 $new_password = autoname(12) . mt_rand(100,9999);
24 $new_password_encoded = hash('whirlpool',$new_password);
26 $r = q("UPDATE `user` SET `pwdreset` = '%s' WHERE `uid` = %d LIMIT 1",
27 dbesc($new_password_encoded),
31 info( t('Password reset request issued. Check your email.') . EOL);
33 $email_tpl = get_intltext_template("lostpass_eml.tpl");
34 $email_tpl = replace_macros($email_tpl, array(
35 '$sitename' => $a->config['sitename'],
36 '$siteurl' => $a->get_baseurl(),
37 '$username' => $username,
39 '$reset_link' => $a->get_baseurl() . '/lostpass?verify=' . $new_password
42 $res = mail($email, sprintf( t('Password reset requested at %s'),$a->config['sitename']),
44 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n"
45 . 'Content-type: text/plain; charset=UTF-8' . "\n"
46 . 'Content-transfer-encoding: 8bit' );
53 function lostpass_content(&$a) {
56 if(x($_GET,'verify')) {
57 $verify = $_GET['verify'];
58 $hash = hash('whirlpool', $verify);
60 $r = q("SELECT * FROM `user` WHERE `pwdreset` = '%s' LIMIT 1",
64 notice( t("Request could not be verified. \x28You may have previously submitted it.\x29 Password reset failed.") . EOL);
69 $username = $r[0]['username'];
70 $email = $r[0]['email'];
72 $new_password = autoname(6) . mt_rand(100,9999);
73 $new_password_encoded = hash('whirlpool',$new_password);
75 $r = q("UPDATE `user` SET `password` = '%s', `pwdreset` = '' WHERE `uid` = %d LIMIT 1",
76 dbesc($new_password_encoded),
80 $tpl = get_markup_template('pwdreset.tpl');
81 $o .= replace_macros($tpl,array(
82 '$lbl1' => t('Password Reset'),
83 '$lbl2' => t('Your password has been reset as requested.'),
84 '$lbl3' => t('Your new password is'),
85 '$lbl4' => t('Save or copy your new password - and then'),
86 '$lbl5' => '<a href="' . $a->get_baseurl() . '">' . t('click here to login') . '</a>.',
87 '$lbl6' => t('Your password may be changed from the <em>Settings</em> page after successful login.'),
88 '$newpass' => $new_password,
89 '$baseurl' => $a->get_baseurl()
92 info("Your password has been reset." . EOL);
96 $email_tpl = get_intltext_template("passchanged_eml.tpl");
97 $email_tpl = replace_macros($email_tpl, array(
98 '$sitename' => $a->config['sitename'],
99 '$siteurl' => $a->get_baseurl(),
100 '$username' => $username,
102 '$new_password' => $new_password,
103 '$uid' => $newuid ));
105 $res = mail($email,"Your password has changed at {$a->config['sitename']}",$email_tpl,
106 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n"
107 . 'Content-type: text/plain; charset=UTF-8' . "\n"
108 . 'Content-transfer-encoding: 8bit' );
115 $tpl = get_markup_template('lostpass.tpl');
117 $o .= replace_macros($tpl,array(
118 '$title' => t('Forgot your Password?'),
119 '$desc' => t('Enter your email address and submit to have your password reset. Then check your email for further instructions.'),
120 '$name' => t('Nickname or Email: '),
121 '$submit' => t('Reset')