3 require('includes/header.php');
4 $page_title = 'Recover ID by e-mail';
5 $onload_javascript = 'focusId(\'e-mail\');';
7 if( ! empty($_POST['e-mail']))
9 // Validate e-mail address.
10 if ( ! filter_var($_POST['e-mail'], FILTER_VALIDATE_EMAIL
))
12 add_error('That doesn\'t look like a valid e-mail address.');
14 // Deny flooders (hack; should be done from the database for security).
15 if($_SESSION['recovery_email_count'] > 4)
17 add_error('How many times do you need to recover your password in one day?');
21 $stmt = $link->prepare('SELECT user_settings.uid, users.password FROM user_settings INNER JOIN users ON user_settings.uid = users.uid WHERE user_settings.email = ? LIMIT 50');
22 $stmt->bind_param('s', $_POST['e-mail']);
24 $stmt->bind_result($uid, $password);
26 $ids_for_email = array();
29 $ids_for_email[$uid] = $password;
33 if(empty($ids_for_email))
35 add_error('There are no IDs associated with that e-mail.');
40 $num_ids = count($ids_for_email);
43 $email_body = 'Your ID is ' . key($ids_for_email) . ' and your password is ' . current($ids_for_email) . '. To restore your ID, follow this link: ' . DOMAIN
. 'restore_ID/' . key($ids_for_email) . '/' . current($ids_for_email);
47 $email_body = 'The following IDs are associated with your e-mail address:' . "\n\n";
48 foreach($ids_for_email as $id => $password)
50 $email_body .= 'ID: ' . $id . "\n" . 'Password: ' . $password . "\n" . 'Link to restore: ' . DOMAIN
. 'restore_ID/' . $id . '/' . $password . "\n\n";
54 mail($_POST['e-mail'], SITE_TITLE
. ' ID recovery', $email_body, 'From: ' . SITE_TITLE
. '<' . MAILER_ADDRESS
. '>');
56 $_SESSION['recovery_email_count']++
;
57 redirect('ID recovery e-mail sent.', '');
65 <p
>If your ID has an e
-mail address associated with
it (as set in the
<a href
="/dashboard">dashboard
</a
>), this tool can be used to recover its password
. You will be sent a recovery link
for every ID associated with your e
-mail address
.</p
>
67 <form action
="" method
="post">
69 <label
for="e-mail">Your e
-mail address
</label
>
70 <input type
="text" id
="e-mail" name
="e-mail" size
="30" maxlength
="100" />
74 <input type
="submit" value
="Send recovery e-mail" />
80 require('includes/footer.php');