Updated filters - internationalized some more strings
[squirrelmail.git] / src / redirect.php
CommitLineData
7392739d 1<?php
895905c0 2
23d6bd09 3 /**
895905c0 4 ** redirect.php
5 ** Derived from webmail.php by Ralf Kraudelt <kraude@wiwi.uni-rostock.de>
6 **
7 ** Copyright (c) 1999-2001 The Squirrelmail Development Team
8 ** Licensed under the GNU GPL. For full terms see the file COPYING.
9 **
10 ** Prevents users from reposting their form data after a successful logout.
11 **
12 ** $Id$
13 **/
23d6bd09 14
15 require_once('../functions/i18n.php');
16 require_once('../functions/strings.php');
17 require_once('../config/config.php');
18
19 /* Before starting the session, the base URI must be known. Assuming */
20 /* that this file is in the src/ subdirectory (or 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_unregister ('user_is_logged_in');
31 session_register ('base_uri');
32
33 if (! isset($squirrelmail_language)) {
34 $squirrelmail_language = '';
35 }
36 set_up_language($squirrelmail_language, true);
37
38 if (!isset($login_username)) {
39 echo "<HTML><BODY BGCOLOR=\"#ffffff\">\n";
40 echo "<BR><BR>\n";
41 echo "<CENTER>\n";
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>\n";
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,$base_uri);
52 }
53
54 require_once('../functions/prefs.php');
55 require_once('../functions/imap.php');
56 require_once('../functions/plugin.php');
57 require_once('../functions/constants.php');
58
59 if (!session_is_registered('user_is_logged_in')) {
60 do_hook ('login_before');
61
62 $onetimepad = OneTimePadCreate(strlen($secretkey));
63 $key = OneTimePadEncrypt($secretkey, $onetimepad);
64 session_register('onetimepad');
65
66 /* Verify that username and password are correct. */
67 if ($force_username_lowercase) {
68 $login_username = strtolower($login_username);
69 }
70
71 $imapConnection = sqimap_login($login_username, $key, $imapServerAddress, $imapPort, 0);
72 if (!$imapConnection) {
73 echo "<html><body bgcolor=\"#ffffff\">\n";
74 echo "<br><br>";
75 echo "<center>";
76 echo "<b>"._("There was an error contacting the mail server.")."</b><br>";
77 echo _("Contact your administrator for help.")."\n";
78 echo "</center>";
79 echo "</body></html>\n";
80 exit;
81 } else {
82 $delimiter = sqimap_get_delimiter ($imapConnection);
83 }
84 sqimap_logout($imapConnection);
525b7ae6 85 session_register('delimiter');
23d6bd09 86
87 $username = $login_username;
88 session_register ('username');
89 setcookie('key', $key, 0, $base_uri);
23d6bd09 90 do_hook ('login_verified');
91 }
92
93 /* Set the login variables. */
94 $user_is_logged_in = true;
95 $just_logged_in = true;
96
97 /* And register with them with the session. */
98 session_register ('user_is_logged_in');
99 session_register ('just_logged_in');
100
7baf86a9 101 /* parse the accepted content-types of the client */
102 $attachment_common_types = array();
103 $attachment_common_types_parsed = array();
104 session_register('attachment_common_types');
105 session_register('attachment_common_types_parsed');
106
bbdd6ddb 107 $debug = false;
7baf86a9 108 if (isset($HTTP_SERVER_VARS['HTTP_ACCEPT']) &&
109 !isset($attachment_common_types_parsed[$HTTP_SERVER_VARS['HTTP_ACCEPT']]))
110 attachment_common_parse($HTTP_SERVER_VARS['HTTP_ACCEPT'], $debug);
111 if (isset($HTTP_ACCEPT) &&
112 !isset($attachment_common_types_parsed[$HTTP_ACCEPT]))
113 attachment_common_parse($HTTP_ACCEPT, $debug);
114
115
23d6bd09 116 /* Complete autodetection of Javascript. */
357f1ae0 117 checkForPrefs($data_dir, $username);
23d6bd09 118 $javascript_setting = getPref($data_dir, $username, 'javascript_setting', SMPREF_JS_AUTODETECT);
119 $js_autodetect_results = (isset($js_autodetect_results) ? $js_autodetect_results : SMPREF_JS_OFF);
120 if ($javascript_setting == SMPREF_JS_AUTODETECT) {
121 if ($js_autodetect_results == SMPREF_JS_ON) {
122 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_ON);
123 } else {
124 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF);
125 }
126 } else {
127 setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF);
128 }
129
130 /* Compute the URL to forward the user to. */
131 if(isset($rcptemail)) {
132 $redirect_url = 'webmail.php?right_frame=compose.php&rcptaddress=';
133 $redirect_url .= urlencode($rcptemail);
134 } else {
135 $redirect_url = 'webmail.php';
136 }
137
138 /* Send them off to the appropriate page. */
139 header("Location: $redirect_url");
7baf86a9 140
141
142function attachment_common_parse($str, $debug)
143{
144 global $attachment_common_types, $attachment_common_types_parsed;
145
146 $attachment_common_types_parsed[$str] = true;
147 $types = explode(', ', $str);
148
149 foreach ($types as $val)
150 {
151 // Ignore the ";q=1.0" stuff
152 if (strpos($val, ';') !== false)
153 $val = substr($val, 0, strpos($val, ';'));
154
155 if (! isset($attachment_common_types[$val])) {
156 $attachment_common_types[$val] = true;
157 }
158 }
159}
160
e0dcff78 161?>