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); |
7392739d |
62 | sqimap_logout($imapConnection); |
63 | |
74b4e396 |
64 | setcookie("username", $login_username, 0, $base_uri); |
7392739d |
65 | setcookie("key", $key, 0, $base_uri); |
66 | setcookie("logged_in", 1, 0, $base_uri); |
67 | do_hook ("login_verified"); |
68 | } |
69 | |
70 | session_register ("user_is_logged_in"); |
71 | $user_is_logged_in = true; |
72 | |
0168fcf3 |
73 | header("Location: $location/webmail.php"); |
7392739d |
74 | ?> |