pkgfuncs.inc.php: Remove a conflict marker
[aur.git] / web / html / passreset.php
blob29f2c6486e66fafef84a91edad0c3076751c8543
1 <?php
3 set_include_path(get_include_path() . PATH_SEPARATOR . '../lib');
5 include_once("aur.inc.php"); # access AUR common functions
7 set_lang(); # this sets up the visitor's language
8 check_sid(); # see if they're still logged in
10 if (isset($_COOKIE["AURSID"])) {
11 header('Location: /');
12 exit();
15 $error = '';
17 if (isset($_GET['resetkey'], $_POST['email'], $_POST['password'], $_POST['confirm'])) {
18 $resetkey = $_GET['resetkey'];
19 $email = $_POST['email'];
20 $password = $_POST['password'];
21 $confirm = $_POST['confirm'];
22 $uid = uid_from_email($email);
24 if (empty($email) || empty($password)) {
25 $error = __('Missing a required field.');
26 } elseif ($password != $confirm) {
27 $error = __('Password fields do not match.');
28 } elseif (!good_passwd($password)) {
29 $length_min = config_get_int('options', 'passwd_min_len');
30 $error = __("Your password must be at least %s characters.",
31 $length_min);
32 } elseif ($uid == null) {
33 $error = __('Invalid e-mail.');
36 if (empty($error)) {
37 $salt = generate_salt();
38 $hash = salted_hash($password, $salt);
40 $error = password_reset($hash, $salt, $resetkey, $email);
42 } elseif (isset($_POST['email'])) {
43 $email = $_POST['email'];
44 $username = username_from_id(uid_from_email($email));
46 if (empty($email)) {
47 $error = __('Missing a required field.');
48 } else {
49 $subject = 'AUR Password Reset';
50 $body = __('A password reset request was submitted for the ' .
51 'account %s associated with your e-mail address. ' .
52 'If you wish to reset your password follow the ' .
53 'link below, otherwise ignore this message and ' .
54 'nothing will happen.', $username);
55 send_resetkey($email, $subject, $body);
57 header('Location: ' . get_uri('/passreset/') . '?step=confirm');
58 exit();
62 $step = isset($_GET['step']) ? $_GET['step'] : NULL;
64 html_header(__("Password Reset"));
68 <div class="box">
69 <h2><?= __("Password Reset"); ?></h2>
71 <?php if ($step == 'confirm'): ?>
72 <p><?= __('Check your e-mail for the confirmation link.') ?></p>
73 <?php elseif ($step == 'complete'): ?>
74 <p><?= __('Your password has been reset successfully.') ?></p>
75 <?php elseif (isset($_GET['resetkey'])): ?>
76 <?php if ($error): ?>
77 <ul class="errorlist"><li><?= $error ?></li></ul>
78 <?php endif; ?>
79 <form action="" method="post">
80 <table>
81 <tr>
82 <td><?= __("Confirm your e-mail address:"); ?></td>
83 <td><input type="text" name="email" size="30" maxlength="64" /></td>
84 </tr>
85 <tr>
86 <td><?= __("Enter your new password:"); ?></td>
87 <td><input type="password" name="password" size="30" /></td>
88 </tr>
89 <tr>
90 <td><?= __("Confirm your new password:"); ?></td>
91 <td><input type="password" name="confirm" size="30" /></td>
92 </tr>
93 </table>
94 <br />
95 <input type="submit" class="button" value="<?= __('Continue') ?>" />
96 </form>
97 <?php else: ?>
98 <p><?= __('If you have forgotten the e-mail address you used to register, please send a message to the %saur-general%s mailing list.',
99 '<a href="https://mailman.archlinux.org/mailman/listinfo/aur-general">',
100 '</a>'); ?></p>
101 <?php if ($error): ?>
102 <ul class="errorlist"><li><?= $error ?></li></ul>
103 <?php endif; ?>
104 <form action="" method="post">
105 <p><?= __("Enter your e-mail address:"); ?>
106 <input type="text" name="email" size="30" maxlength="64" /></p>
107 <input type="submit" class="button" value="<?= __('Continue') ?>" />
108 </form>
109 <?php endif; ?>
110 </div>
112 <?php
114 html_footer(AURWEB_VERSION);