fixed an error that wouldn't display "Password Incorrect". This cropped
[squirrelmail.git] / src / redirect.php
CommitLineData
7392739d 1<?php
2
3 /**
4 ** redirect.php -- derived from webmail.php by Ralf Kraudelt
5 ** kraude@wiwi.uni-rostock.de
6 **
7 ** Copyright (c) 1999-2000 ...
8 ** Licensed under the GNU GPL. For full terms see the file COPYING.
9 **
10 ** prevents users from reposting their form data after a
11 ** successful logout
12 **
13 **/
14
15 if (!isset($strings_php))
16 include ("../functions/strings.php");
17
18 // Before starting the session, the base URI must be known.
19 // Assuming that this file is in the src/ subdirectory (or
20 // something).
21 ereg ("(^.*/)[^/]+/[^/]+$", $PHP_SELF, $regs);
22 $base_uri = $regs[1];
23
24 header("Pragma: no-cache");
25 $location = get_location();
7392739d 26
27 session_set_cookie_params (0, $base_uri);
28 session_start();
29
30 session_register ("base_uri");
31
74b4e396 32 if(!isset($login_username)) {
7392739d 33 exit;
34 }
35
36 // Refresh the language cookie.
37 if (isset($squirrelmail_language)) {
38 setcookie("squirrelmail_language", $squirrelmail_language, time()+2592000);
39 }
40
41
42 include ("../config/config.php");
43 include ("../functions/prefs.php");
44 include ("../functions/imap.php");
45 if (!isset($plugin_php))
46 include ("../functions/plugin.php");
47 if (!isset($auth_php))
48 include ("../functions/auth.php");
49 if (!isset($strings_php))
50 include ("../functions/strings.php");
51
52 if (!session_is_registered("user_is_logged_in") || $logged_in != 1) {
53 do_hook ("login_before");
54
55 $onetimepad = OneTimePadCreate(strlen($secretkey));
8c42b963 56 $key = OneTimePadEncrypt($secretkey, $onetimepad);
7392739d 57 session_register("onetimepad");
58 // verify that username and password are correct
74b4e396 59 if ($force_username_lowercase)
53d0181e 60 $username = strtolower($login_username);
74b4e396 61 $imapConnection = sqimap_login($login_username, $key, $imapServerAddress, $imapPort, 0);
86bb3b47 62 if (!$imapConnection) {
63 exit;
64 }
7392739d 65 sqimap_logout($imapConnection);
66
74b4e396 67 setcookie("username", $login_username, 0, $base_uri);
7392739d 68 setcookie("key", $key, 0, $base_uri);
69 setcookie("logged_in", 1, 0, $base_uri);
70 do_hook ("login_verified");
71 }
72
73 session_register ("user_is_logged_in");
74 $user_is_logged_in = true;
75
0168fcf3 76 header("Location: $location/webmail.php");
7392739d 77?>