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';
13 require_once 'plekit-utils.php';
17 require_once 'plc_drupal.php';
18 drupal_set_title('Login');
19 include 'plc_header.php';
21 if (!empty($_REQUEST['email']) &&
22 !empty($_REQUEST['password'])) {
23 $plc = new PLCSession($_REQUEST['email'], $_REQUEST['password']);
26 // Login admins to Drupal as the superuser
27 if (in_array('admin', $plc->person['roles']) &&
28 function_exists('user_load')) {
30 $user = user_load(array('uid' => 1));
33 if (empty($_REQUEST['url'])) {
34 // XXX Redirect to default home page
35 header("Location: /");
38 // Make sure that redirections are always local
39 $url = urldecode($_REQUEST['url']);
43 header("Location: $url");
47 // XXX Use our own stylesheet instead of drupal.css
48 print '<div class="messages error">Sorry. Unrecognized username or password.</div>';
52 $self = $_SERVER['PHP_SELF'];
53 if (!empty($_SERVER['QUERY_STRING'])) {
54 $self .= "?" . $_SERVER['QUERY_STRING'];
57 $url = htmlspecialchars(get_array($_REQUEST, 'url'));
59 // XXX Use our own stylesheet instead of drupal.css
62 <form action="$self" method="post">
64 <table border="0" cellpadding="0" cellspacing="0">
67 <div class="form-item">
68 <label for="edit-name">E-mail: <span class="form-required" title="This field is required.">*</span></label>
69 <input type="text" maxlength="60" name="email" id="edit-name" size="30" value="" class="form-text required" />
71 <div class="form-item">
72 <label for="edit-password">Password: <span class="form-required" title="This field is required.">*</span></label>
73 <input type="password" maxlength="" name="password" id="edit-password" size="30" class="form-text required" />
75 <input type="submit" name="op" value="Log in" class="form-submit" />
76 <p><p><a href="/db/persons/reset_password.php">Forgot your password?</a></p>
77 <p><a href="/db/persons/register.php">Create an account</a></p>
78 <p><a href="/db/sites/register.php">File a site registration</a></p>
79 <input type="hidden" name="url" value="$url" />
89 include 'plc_footer.php';