You havta do http redirect at the end of page.
[squirrelmail.git] / src / redirect.php
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();
26
27 session_set_cookie_params (0, $base_uri);
28 session_start();
29
30 session_register ("base_uri");
31
32 if(!isset($username)) {
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));
56 $key = OneTimePadEncrypt($secretkey, $onetimepad);
57 session_register("onetimepad");
58 // verify that username and password are correct
59 $imapConnection = sqimap_login($username, quotemeta($key), $imapServerAddress, $imapPort, 0);
60 sqimap_logout($imapConnection);
61
62 setcookie("username", $username, 0, $base_uri);
63 setcookie("key", $key, 0, $base_uri);
64 setcookie("logged_in", 1, 0, $base_uri);
65 do_hook ("login_verified");
66 }
67
68 session_register ("user_is_logged_in");
69 $user_is_logged_in = true;
70
71 header("Location: $location/webmail.php");
72 ?>