4 * Derived from webmail.php by Ralf Kraudelt <kraude@wiwi.uni-rostock.de>
6 * Copyright (c) 1999-2001 The Squirrelmail Development Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * Prevents users from reposting their form data after a successful logout.
14 require_once('../functions/i18n.php');
15 require_once('../functions/strings.php');
16 require_once('../config/config.php');
18 /* Before starting the session, the base URI must be known. Assuming */
19 /* that this file is in the src/ subdirectory (or something). */
20 ereg ("(^.*/)[^/]+/[^/]+$", $PHP_SELF, $regs);
23 header('Pragma: no-cache');
24 $location = get_location();
26 session_set_cookie_params (0, $base_uri);
29 session_unregister ('user_is_logged_in');
30 session_register ('base_uri');
32 if (! isset($squirrelmail_language)) {
33 $squirrelmail_language = '';
35 set_up_language($squirrelmail_language, true);
37 if (!isset($login_username)) {
38 echo "<HTML><BODY BGCOLOR=\"#ffffff\">\n";
41 echo ' <B>' . _("You must be logged in to access this page.") . "</B><BR>";
42 echo ' <A HREF="../src/login.php">' . _("Go to the login page") . "</A>\n";
44 echo "</BODY></HTML>\n";
48 /* Refresh the language cookie. */
49 if (isset($squirrelmail_language)) {
50 setcookie('squirrelmail_language', $squirrelmail_language, time()+
2592000,$base_uri);
53 require_once('../functions/prefs.php');
54 require_once('../functions/imap.php');
55 require_once('../functions/plugin.php');
56 require_once('../functions/constants.php');
58 if (!session_is_registered('user_is_logged_in')) {
59 do_hook ('login_before');
61 $onetimepad = OneTimePadCreate(strlen($secretkey));
62 $key = OneTimePadEncrypt($secretkey, $onetimepad);
63 session_register('onetimepad');
65 /* Verify that username and password are correct. */
66 if ($force_username_lowercase) {
67 $login_username = strtolower($login_username);
70 $imapConnection = sqimap_login($login_username, $key, $imapServerAddress, $imapPort, 0);
71 if (!$imapConnection) {
72 echo "<html><body bgcolor=\"#ffffff\">\n";
75 echo "<b>"._("There was an error contacting the mail server.")."</b><br>";
76 echo _("Contact your administrator for help.")."\n";
78 echo "</body></html>\n";
81 $delimiter = sqimap_get_delimiter ($imapConnection);
83 sqimap_logout($imapConnection);
85 $username = $login_username;
86 session_register ('username');
87 setcookie('key', $key, 0, $base_uri);
88 setcookie('delimiter', $delimiter, 0, $base_uri);
89 do_hook ('login_verified');
92 /* Set the login variables. */
93 $user_is_logged_in = true;
94 $just_logged_in = true;
96 /* And register with them with the session. */
97 session_register ('user_is_logged_in');
98 session_register ('just_logged_in');
100 /* Complete autodetection of Javascript. */
101 checkForPrefs($data_dir, $username);
102 $javascript_setting = getPref($data_dir, $username, 'javascript_setting', SMPREF_JS_AUTODETECT
);
103 $js_autodetect_results = (isset($js_autodetect_results) ?
$js_autodetect_results : SMPREF_JS_OFF
);
104 if ($javascript_setting == SMPREF_JS_AUTODETECT
) {
105 if ($js_autodetect_results == SMPREF_JS_ON
) {
106 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_ON
);
108 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF
);
111 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF
);
114 /* Compute the URL to forward the user to. */
115 if(isset($rcptemail)) {
116 $redirect_url = 'webmail.php?right_frame=compose.php&rcptaddress=';
117 $redirect_url .= urlencode($rcptemail);
119 $redirect_url = 'webmail.php';
122 /* Send them off to the appropriate page. */
123 header("Location: $redirect_url");