* Moved load_prefs.php and display_page.php (or whatever it is called) into
[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 ** $Id$
14 **/
15
16 include('../functions/i18n.php');
17 include ('../functions/strings.php');
18 include('../config/config.php');
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
26 header('Pragma: no-cache');
27 $location = get_location();
28
29 session_set_cookie_params (0, $base_uri);
30 session_start();
31
32 session_unregister ('user_is_logged_in');
33 session_register ('base_uri');
34
35 if(!isset($login_username)) {
36 if (! isset($squirrelmail_language))
37 $squirrelmail_language = '';
38 set_up_language($squirrelmail_language, true);
39 echo "<html><body bgcolor=\"ffffff\">\n";
40 echo "<br><br>";
41 echo "<center>";
42 echo "<b>"._("You must be logged in to access this page.")."</b><br>";
43 echo "<a href=\"../src/login.php\">"._("Go to the login page")."</a>\n";
44 echo "</center>";
45 echo "</body></html>\n";
46 exit;
47 }
48
49 // Refresh the language cookie.
50 if (isset($squirrelmail_language)) {
51 setcookie('squirrelmail_language', $squirrelmail_language, time()+2592000);
52 }
53
54
55 include ('../functions/prefs.php');
56 include ('../functions/imap.php');
57 include ('../functions/plugin.php');
58
59 if (!session_is_registered('user_is_logged_in') || $logged_in != 1) {
60 do_hook ('login_before');
61
62 $onetimepad = OneTimePadCreate(strlen($secretkey));
63 $key = OneTimePadEncrypt($secretkey, $onetimepad);
64 session_register('onetimepad');
65 // verify that username and password are correct
66 if ($force_username_lowercase)
67 $login_username = strtolower($login_username);
68 $imapConnection = sqimap_login($login_username, $key, $imapServerAddress, $imapPort, 0);
69 if (!$imapConnection) {
70 echo "<html><body bgcolor=\"ffffff\">\n";
71 echo "<br><br>";
72 echo "<center>";
73 echo "<b>"._("There was an error contacting the mail server.")."</b><br>";
74 echo _("Contact your administrator for help.")."\n";
75 echo "</center>";
76 echo "</body></html>\n";
77 exit;
78 }
79 sqimap_logout($imapConnection);
80
81 setcookie('username', $login_username, 0, $base_uri);
82 setcookie('key', $key, 0, $base_uri);
83 setcookie('logged_in', 1, 0, $base_uri);
84 do_hook ('login_verified');
85 }
86
87 $user_is_logged_in = true;
88 session_register ('user_is_logged_in');
89
90 if(isset($rcptemail))
91 header("Location: webmail.php?right_frame=compose.php&rcptaddress=$rcptemail");
92 else
93 header("Location: webmail.php");
94 ?>