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"); |
d9ca5b40 |
17 | include("../config/config.php"); |
7392739d |
18 | |
19 | // Before starting the session, the base URI must be known. |
20 | // Assuming that this file is in the src/ subdirectory (or |
21 | // something). |
22 | ereg ("(^.*/)[^/]+/[^/]+$", $PHP_SELF, $regs); |
23 | $base_uri = $regs[1]; |
24 | |
25 | header("Pragma: no-cache"); |
26 | $location = get_location(); |
7392739d |
27 | |
28 | session_set_cookie_params (0, $base_uri); |
29 | session_start(); |
30 | |
31 | session_register ("base_uri"); |
32 | |
74b4e396 |
33 | if(!isset($login_username)) { |
7392739d |
34 | exit; |
35 | } |
36 | |
37 | // Refresh the language cookie. |
38 | if (isset($squirrelmail_language)) { |
39 | setcookie("squirrelmail_language", $squirrelmail_language, time()+2592000); |
40 | } |
41 | |
42 | |
43 | include ("../config/config.php"); |
44 | include ("../functions/prefs.php"); |
45 | include ("../functions/imap.php"); |
46 | if (!isset($plugin_php)) |
47 | include ("../functions/plugin.php"); |
48 | if (!isset($auth_php)) |
49 | include ("../functions/auth.php"); |
50 | if (!isset($strings_php)) |
51 | include ("../functions/strings.php"); |
52 | |
53 | if (!session_is_registered("user_is_logged_in") || $logged_in != 1) { |
54 | do_hook ("login_before"); |
55 | |
56 | $onetimepad = OneTimePadCreate(strlen($secretkey)); |
8c42b963 |
57 | $key = OneTimePadEncrypt($secretkey, $onetimepad); |
7392739d |
58 | session_register("onetimepad"); |
59 | // verify that username and password are correct |
74b4e396 |
60 | if ($force_username_lowercase) |
8ddd44cd |
61 | $login_username = strtolower($login_username); |
74b4e396 |
62 | $imapConnection = sqimap_login($login_username, $key, $imapServerAddress, $imapPort, 0); |
86bb3b47 |
63 | if (!$imapConnection) { |
64 | exit; |
65 | } |
7392739d |
66 | sqimap_logout($imapConnection); |
67 | |
74b4e396 |
68 | setcookie("username", $login_username, 0, $base_uri); |
7392739d |
69 | setcookie("key", $key, 0, $base_uri); |
70 | setcookie("logged_in", 1, 0, $base_uri); |
71 | do_hook ("login_verified"); |
72 | } |
73 | |
74 | session_register ("user_is_logged_in"); |
75 | $user_is_logged_in = true; |
76 | |
0168fcf3 |
77 | header("Location: $location/webmail.php"); |
7392739d |
78 | ?> |