5e7f9d052dafec8c7d7159530ab2d042675acd4a
4 ** redirect.php -- derived from webmail.php by Ralf Kraudelt
5 ** kraude@wiwi.uni-rostock.de
7 ** Copyright (c) 1999-2000 ...
8 ** Licensed under the GNU GPL. For full terms see the file COPYING.
10 ** prevents users from reposting their form data after a
16 include ('../functions/strings.php');
17 include('../config/config.php');
19 // Before starting the session, the base URI must be known.
20 // Assuming that this file is in the src/ subdirectory (or
22 ereg ("(^.*/)[^/]+/[^/]+$", $PHP_SELF, $regs);
25 header('Pragma: no-cache');
26 $location = get_location();
28 session_set_cookie_params (0, $base_uri);
31 session_unregister ('user_is_logged_in');
32 session_register ('base_uri');
34 if(!isset($login_username)) {
35 echo "<html><body bgcolor=\"ffffff\">\n";
38 echo "<b>"._("You must be logged in to access this page.")."</b><br>";
39 echo "<a href=\"../src/login.php\">"._("Go to the login page")."</a>\n";
41 echo "</body></html>\n";
45 // Refresh the language cookie.
46 if (isset($squirrelmail_language)) {
47 setcookie('squirrelmail_language', $squirrelmail_language, time()+
2592000);
51 include ('../functions/prefs.php');
52 include ('../functions/imap.php');
53 include ('../functions/plugin.php');
55 if (!session_is_registered('user_is_logged_in') ||
$logged_in != 1) {
56 do_hook ('login_before');
58 $onetimepad = OneTimePadCreate(strlen($secretkey));
59 $key = OneTimePadEncrypt($secretkey, $onetimepad);
60 session_register('onetimepad');
61 // verify that username and password are correct
62 if ($force_username_lowercase)
63 $login_username = strtolower($login_username);
64 $imapConnection = sqimap_login($login_username, $key, $imapServerAddress, $imapPort, 0);
65 if (!$imapConnection) {
66 echo "<html><body bgcolor=\"ffffff\">\n";
69 echo "<b>"._("There was an error contacting the mail server.")."</b><br>";
70 echo _("Contact your administrator for help.")."\n";
72 echo "</body></html>\n";
75 sqimap_logout($imapConnection);
77 setcookie('username', $login_username, 0, $base_uri);
78 setcookie('key', $key, 0, $base_uri);
79 setcookie('logged_in', 1, 0, $base_uri);
80 do_hook ('login_verified');
83 $user_is_logged_in = true;
84 session_register ('user_is_logged_in');
86 header("Location: webmail.php");