Erase login IP addresses after seven days
[aur.git] / web / html / passreset.php
blob9e7cee88f5ffa431cd76da87242770a93aea4689
1 <?php
3 set_include_path(get_include_path() . PATH_SEPARATOR . '../lib');
5 include_once("aur.inc.php"); # access AUR common functions
7 if (isset($_COOKIE["AURSID"])) {
8 header('Location: /');
9 exit();
12 $error = '';
14 if (isset($_GET['resetkey'], $_POST['email'], $_POST['password'], $_POST['confirm'])) {
15 $resetkey = $_GET['resetkey'];
16 $email = $_POST['email'];
17 $password = $_POST['password'];
18 $confirm = $_POST['confirm'];
19 $uid = uid_from_email($email);
21 if (empty($email) || empty($password)) {
22 $error = __('Missing a required field.');
23 } elseif ($password != $confirm) {
24 $error = __('Password fields do not match.');
25 } elseif (!good_passwd($password)) {
26 $length_min = config_get_int('options', 'passwd_min_len');
27 $error = __("Your password must be at least %s characters.",
28 $length_min);
29 } elseif ($uid == null) {
30 $error = __('Invalid e-mail.');
33 if (empty($error)) {
34 $error = password_reset($password, $resetkey, $email);
36 } elseif (isset($_POST['email'])) {
37 $email = $_POST['email'];
38 $username = username_from_id(uid_from_email($email));
40 if (empty($email)) {
41 $error = __('Missing a required field.');
42 } else {
43 send_resetkey($email);
44 header('Location: ' . get_uri('/passreset/') . '?step=confirm');
45 exit();
49 $step = isset($_GET['step']) ? $_GET['step'] : NULL;
51 html_header(__("Password Reset"));
55 <div class="box">
56 <h2><?= __("Password Reset"); ?></h2>
58 <?php if ($step == 'confirm'): ?>
59 <p><?= __('Check your e-mail for the confirmation link.') ?></p>
60 <?php elseif ($step == 'complete'): ?>
61 <p><?= __('Your password has been reset successfully.') ?></p>
62 <?php elseif (isset($_GET['resetkey'])): ?>
63 <?php if ($error): ?>
64 <ul class="errorlist"><li><?= $error ?></li></ul>
65 <?php endif; ?>
66 <form action="" method="post">
67 <table>
68 <tr>
69 <td><?= __("Confirm your e-mail address:"); ?></td>
70 <td><input type="text" name="email" size="30" maxlength="64" /></td>
71 </tr>
72 <tr>
73 <td><?= __("Enter your new password:"); ?></td>
74 <td><input type="password" name="password" size="30" /></td>
75 </tr>
76 <tr>
77 <td><?= __("Confirm your new password:"); ?></td>
78 <td><input type="password" name="confirm" size="30" /></td>
79 </tr>
80 </table>
81 <br />
82 <input type="submit" class="button" value="<?= __('Continue') ?>" />
83 </form>
84 <?php else: ?>
85 <p><?= __('If you have forgotten the e-mail address you used to register, please send a message to the %saur-general%s mailing list.',
86 '<a href="https://mailman.archlinux.org/mailman/listinfo/aur-general">',
87 '</a>'); ?></p>
88 <?php if ($error): ?>
89 <ul class="errorlist"><li><?= $error ?></li></ul>
90 <?php endif; ?>
91 <form action="" method="post">
92 <p><?= __("Enter your e-mail address:"); ?>
93 <input type="text" name="email" size="30" maxlength="64" /></p>
94 <input type="submit" class="button" value="<?= __('Continue') ?>" />
95 </form>
96 <?php endif; ?>
97 </div>
99 <?php
101 html_footer(AURWEB_VERSION);