5 // Mark Huang <mlhuang@cs.princeton.edu>
6 // Copyright (C) 2006 The Trustees of Princeton University
11 // Get session and API handles
12 require_once 'plc_session.php';
16 require_once 'plc_drupal.php';
17 drupal_set_title('Login');
18 include 'plc_header.php';
20 if (!empty($_REQUEST['email']) &&
21 !empty($_REQUEST['password'])) {
22 $plc = new PLCSession($_REQUEST['email'], $_REQUEST['password']);
25 // Login admins to Drupal as the superuser
26 if (in_array('admin', $plc->person['roles']) &&
27 function_exists('user_load')) {
29 $user = user_load(array('uid' => 1));
32 if (empty($_REQUEST['url'])) {
33 // XXX Redirect to default home page
34 header("Location: /");
37 // Make sure that redirections are always local
38 $url = urldecode($_REQUEST['url']);
42 header("Location: $url");
46 // XXX Use our own stylesheet instead of drupal.css
47 print '<div class="messages error">Sorry. Unrecognized username or password.</div>';
51 $self = $_SERVER['PHP_SELF'];
52 if (!empty($_SERVER['QUERY_STRING'])) {
53 $self .= "?" . $_SERVER['QUERY_STRING'];
56 $url = htmlspecialchars($_REQUEST['url']);
58 // XXX Use our own stylesheet instead of drupal.css
61 <form action="$self" method="post">
63 <table border="0" cellpadding="0" cellspacing="0">
66 <div class="form-item">
67 <label for="edit-name">E-mail: <span class="form-required" title="This field is required.">*</span></label>
68 <input type="text" maxlength="60" name="email" id="edit-name" size="30" value="" class="form-text required" />
70 <div class="form-item">
71 <label for="edit-password">Password: <span class="form-required" title="This field is required.">*</span></label>
72 <input type="password" maxlength="" name="password" id="edit-password" size="30" class="form-text required" />
74 <input type="submit" name="op" value="Log in" class="form-submit" />
75 <p><p><a href="/db/persons/reset_password.php">Forgot your password?</a></p>
76 <p><a href="/db/persons/register.php">Create an account</a></p>
77 <p><a href="/db/sites/register.php">File a site registration</a></p>
78 <input type="hidden" name="url" value="$url" />
88 include 'plc_footer.php';