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 | ** |
245a6892 |
13 | ** $Id$ |
7392739d |
14 | **/ |
15 | |
6ee631f7 |
16 | include('../functions/i18n.php'); |
f740c049 |
17 | include ('../functions/strings.php'); |
91dc6e4e |
18 | include('../config/config.php'); |
7392739d |
19 | |
20 | // Before starting the session, the base URI must be known. |
21 | // Assuming that this file is in the src/ subdirectory (or |
22 | // something). |
23 | ereg ("(^.*/)[^/]+/[^/]+$", $PHP_SELF, $regs); |
24 | $base_uri = $regs[1]; |
25 | |
91dc6e4e |
26 | header('Pragma: no-cache'); |
7392739d |
27 | $location = get_location(); |
7392739d |
28 | |
29 | session_set_cookie_params (0, $base_uri); |
30 | session_start(); |
31 | |
f740c049 |
32 | session_unregister ('user_is_logged_in'); |
91dc6e4e |
33 | session_register ('base_uri'); |
7392739d |
34 | |
74b4e396 |
35 | if(!isset($login_username)) { |
f740c049 |
36 | echo "<html><body bgcolor=\"ffffff\">\n"; |
37 | echo "<br><br>"; |
38 | echo "<center>"; |
39 | echo "<b>"._("You must be logged in to access this page.")."</b><br>"; |
40 | echo "<a href=\"../src/login.php\">"._("Go to the login page")."</a>\n"; |
41 | echo "</center>"; |
42 | echo "</body></html>\n"; |
7392739d |
43 | exit; |
44 | } |
45 | |
46 | // Refresh the language cookie. |
47 | if (isset($squirrelmail_language)) { |
91dc6e4e |
48 | setcookie('squirrelmail_language', $squirrelmail_language, time()+2592000); |
7392739d |
49 | } |
50 | |
51 | |
91dc6e4e |
52 | include ('../functions/prefs.php'); |
53 | include ('../functions/imap.php'); |
f740c049 |
54 | include ('../functions/plugin.php'); |
7392739d |
55 | |
91dc6e4e |
56 | if (!session_is_registered('user_is_logged_in') || $logged_in != 1) { |
57 | do_hook ('login_before'); |
7392739d |
58 | |
59 | $onetimepad = OneTimePadCreate(strlen($secretkey)); |
8c42b963 |
60 | $key = OneTimePadEncrypt($secretkey, $onetimepad); |
91dc6e4e |
61 | session_register('onetimepad'); |
7392739d |
62 | // verify that username and password are correct |
74b4e396 |
63 | if ($force_username_lowercase) |
8ddd44cd |
64 | $login_username = strtolower($login_username); |
74b4e396 |
65 | $imapConnection = sqimap_login($login_username, $key, $imapServerAddress, $imapPort, 0); |
86bb3b47 |
66 | if (!$imapConnection) { |
f740c049 |
67 | echo "<html><body bgcolor=\"ffffff\">\n"; |
68 | echo "<br><br>"; |
69 | echo "<center>"; |
70 | echo "<b>"._("There was an error contacting the mail server.")."</b><br>"; |
71 | echo _("Contact your administrator for help.")."\n"; |
72 | echo "</center>"; |
73 | echo "</body></html>\n"; |
74 | exit; |
86bb3b47 |
75 | } |
7392739d |
76 | sqimap_logout($imapConnection); |
77 | |
91dc6e4e |
78 | setcookie('username', $login_username, 0, $base_uri); |
79 | setcookie('key', $key, 0, $base_uri); |
80 | setcookie('logged_in', 1, 0, $base_uri); |
81 | do_hook ('login_verified'); |
7392739d |
82 | } |
83 | |
7392739d |
84 | $user_is_logged_in = true; |
f740c049 |
85 | session_register ('user_is_logged_in'); |
7392739d |
86 | |
f740c049 |
87 | header("Location: webmail.php"); |
7392739d |
88 | ?> |