root/releases/0.65/login/index.php

Revision 480, 1.8 kB (checked in by ben, 2 years ago)

Logins now redirect to index.php rather than home.php by default.

  • Property svn:eol-style set to native
Line 
1 <?php
2
3 define("context","login");
4
5 require_once(dirname(dirname(__FILE__)).'/includes.php');
6 global $CFG;
7
8 $redirect_url = trim(optional_param('passthru_url'));
9 if (empty($redirect_url)) {
10     $redirect_url = $CFG->wwwroot . "index.php";
11 }
12
13
14 // if we're already logged in, redirect away again.
15 if (logged_on) {
16     $messages[] = gettext("You are already logged on.");
17     define('redirect_url', $redirect_url);
18     $_SESSION['messages'] = $messages;
19     header("Location: " . redirect_url);
20     exit;
21 }
22
23 $l = optional_param('username');
24 $p = optional_param('password');
25
26 if (!empty($l) && !empty($p)) {
27     $ok = authenticate_account($l, md5($p));
28     if ($ok) {
29         $messages[] = gettext("You have been logged on.");
30         define('redirect_url', $redirect_url);
31         $_SESSION['messages'] = $messages;
32         header("Location: " . redirect_url);
33         exit;
34     } else {
35         $messages[] = gettext("Unrecognised username or password. The system could not log you on, or you may not have activated your account.");
36     }
37 } else if (!empty($l) || !empty($p)) { // if ONLY one was entered, make the error message.
38     $messages[] = gettext("Either the username or password were not specified. The system could not log you on.");
39 }
40
41 $body = gettext('Please log in');
42 templates_page_setup();
43 // display the form.
44 echo templates_page_draw( array(
45                                       sitename,
46                                       templates_draw(array(
47                                                            'body' => $body,
48                                                            'title' => gettext('Log On'),
49                                                            'context' => 'contentholder'
50                                                            )
51                                                      )
52                                       )
53         );
54
55 ?>
Note: See TracBrowser for help on using the browser.