1a0b5b24f9cf4afc8f8fc571a39993bc1fec0d8c
[plewww.git] / planetlab / persons / reset_password.php
1 <?php
2 //
3 // Reset password form
4 //
5 // Mark Huang <mlhuang@cs.princeton.edu>
6 // Copyright (C) 2007 The Trustees of Princeton University
7 //
8 // $Id$ $
9 //
10
11 // Get session and API handles
12 require_once 'plc_session.php';
13 global $plc, $api, $adm;
14
15 // Print header
16 require_once 'plc_drupal.php';
17 drupal_set_title('Reset Password');
18 include 'plc_header.php';
19
20 if (!empty($_REQUEST['id']) && !empty($_REQUEST['key'])) {
21   $person_id = intval($_REQUEST['id']);
22   if ($adm->ResetPassword($person_id, $_REQUEST['key']) != 1) {
23     print '<div class="messages error">' . $adm->error() . '.</div>';
24   } else {
25     drupal_set_html_head("<meta http-equiv=\"refresh\" content=\"5; URL=/db/common/login.php\"");
26     print '<div class="messages status">';
27     print "An e-mail has been sent to you with your new temporary password. ";
28     print "Please change this password as soon as possible. ";
29     print "You will be re-directed to the login page in 5 seconds.";
30     print '</div>';
31   }
32 } elseif (!empty($_REQUEST['email'])) {
33   if ($adm->ResetPassword($_REQUEST['email']) != 1) {
34     print '<div class="messages error">' . $adm->error() . '.</div>';
35   } else {
36     drupal_set_html_head("<meta http-equiv=\"refresh\" content=\"5; URL=/db/common/login.php\"");
37     print '<div class="messages status">';
38     print "An e-mail has been sent to " . $_REQUEST['email'] . " with further instructions. ";
39     print "You will be re-directed to the login page in 5 seconds.";
40     print '</div>';
41   }
42 }
43
44 $self = $_SERVER['PHP_SELF'];
45 if (!empty($_SERVER['QUERY_STRING'])) {
46   $self .= "?" . $_SERVER['QUERY_STRING'];
47 }
48
49 // XXX Use our own stylesheet instead of drupal.css
50 print <<<EOF
51 <div class="content">
52 <form action="$self" method="post">
53
54 <table border="0" cellpadding="0" cellspacing="0" id="content">
55   <tr>
56     <td>
57       <div class="form-item">
58         E-mail: <span class="form-required" title="This field is required.">*</span></label>
59         <input type="text" maxlength="60" name="email" id="edit-name" size="30" value="" class="form-text required" />
60       </div>
61       <input type="submit" name="op" value="Reset password"  class="form-submit" />
62     </td>
63   </tr>
64 </table>
65
66 </form>
67 </div>
68
69 EOF;
70
71 include 'plc_footer.php';
72
73 ?>