7392739d |
1 | <?php |
895905c0 |
2 | |
35586184 |
3 | /** |
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 | */ |
14 | |
15 | /*****************************************************************/ |
16 | /*** THIS FILE NEEDS TO HAVE ITS FORMATTING FIXED!!! ***/ |
17 | /*** PLEASE DO SO AND REMOVE THIS COMMENT SECTION. ***/ |
18 | /*** + Base level indent should begin at left margin, as ***/ |
19 | /*** the require_once below looks. ***/ |
20 | /*** + All identation should consist of four space blocks ***/ |
21 | /*** + Tab characters are evil. ***/ |
22 | /*** + all comments should use "slash-star ... star-slash" ***/ |
23 | /*** style -- no pound characters, no slash-slash style ***/ |
24 | /*** + FLOW CONTROL STATEMENTS (if, while, etc) SHOULD ***/ |
25 | /*** ALWAYS USE { AND } CHARACTERS!!! ***/ |
26 | /*** + Please use ' instead of ", when possible. Note " ***/ |
27 | /*** should always be used in _( ) function calls. ***/ |
28 | /*** Thank you for your help making the SM code more readable. ***/ |
29 | /*****************************************************************/ |
30 | |
31 | require_once('../functions/i18n.php'); |
32 | require_once('../functions/strings.php'); |
33 | require_once('../config/config.php'); |
34 | require_once('../functions/prefs.php'); |
35 | require_once('../functions/imap.php'); |
36 | require_once('../functions/plugin.php'); |
37 | require_once('../functions/constants.php'); |
5a545dda |
38 | require_once('../functions/page_header.php'); |
cb48c245 |
39 | |
5c3b0995 |
40 | function attachment_common_parse($str, $debug) { |
41 | global $attachment_common_types, $attachment_common_types_parsed; |
cb48c245 |
42 | |
5c3b0995 |
43 | $attachment_common_types_parsed[$str] = true; |
44 | $types = explode(', ', $str); |
cb48c245 |
45 | |
5a545dda |
46 | foreach ($types as $val) { |
5c3b0995 |
47 | // Ignore the ";q=1.0" stuff |
48 | if (strpos($val, ';') !== false) |
49 | $val = substr($val, 0, strpos($val, ';')); |
cb48c245 |
50 | |
5c3b0995 |
51 | if (! isset($attachment_common_types[$val])) { |
52 | $attachment_common_types[$val] = true; |
cb48c245 |
53 | } |
54 | } |
5c3b0995 |
55 | } |
56 | |
57 | |
58 | /* Before starting the session, the base URI must be known. Assuming */ |
59 | /* that this file is in the src/ subdirectory (or something). */ |
60 | ereg ("(^.*/)[^/]+/[^/]+$", $PHP_SELF, $regs); |
61 | $base_uri = $regs[1]; |
62 | |
63 | header('Pragma: no-cache'); |
64 | $location = get_location(); |
65 | |
66 | session_set_cookie_params (0, $base_uri); |
67 | session_start(); |
68 | |
69 | session_unregister ('user_is_logged_in'); |
70 | session_register ('base_uri'); |
71 | |
72 | if (! isset($squirrelmail_language) || |
73 | $squirrelmail_language == '' ) { |
74 | $squirrelmail_language = $squirrelmail_default_language; |
75 | } |
76 | set_up_language($squirrelmail_language, true); |
77 | /* Refresh the language cookie. */ |
78 | setcookie('squirrelmail_language', $squirrelmail_language, time()+2592000,$base_uri); |
79 | |
80 | if (!isset($login_username)) { |
5a545dda |
81 | displayHtmlHeader( _("You must be logged in to access this page.") ); |
82 | echo "<BODY BGCOLOR=\"#ffffff\">\n" . |
5c3b0995 |
83 | "<BR> <BR>\n" . |
84 | "<CENTER>\n" . |
85 | '<B>' . _("You must be logged in to access this page.") . "</B><BR>" . |
86 | '<A HREF="../src/login.php">' . _("Go to the login page") . "</A>\n" . |
87 | "</CENTER>\n" . |
88 | "</BODY></HTML>\n"; |
89 | exit; |
90 | } |
91 | |
92 | if (!session_is_registered('user_is_logged_in')) { |
93 | do_hook ('login_before'); |
94 | |
95 | $onetimepad = OneTimePadCreate(strlen($secretkey)); |
96 | $key = OneTimePadEncrypt($secretkey, $onetimepad); |
97 | session_register('onetimepad'); |
98 | |
99 | /* Verify that username and password are correct. */ |
100 | if ($force_username_lowercase) { |
101 | $login_username = strtolower($login_username); |
23d6bd09 |
102 | } |
103 | |
5c3b0995 |
104 | $imapConnection = sqimap_login($login_username, $key, $imapServerAddress, $imapPort, 0); |
105 | if (!$imapConnection) { |
5a545dda |
106 | displayHtmlHeader( _("There was an error contacting the mail server.") ); |
107 | echo "<body bgcolor=\"#ffffff\">\n". |
5c3b0995 |
108 | "<br> <br>\n". |
109 | "<center>\n". |
110 | '<b>' . _("There was an error contacting the mail server.") . "</b><br>\n". |
111 | _("Contact your administrator for help.") . "\n". |
112 | "</center>\n". |
113 | "</body></html>\n"; |
114 | exit; |
23d6bd09 |
115 | } else { |
5c3b0995 |
116 | $delimiter = sqimap_get_delimiter ($imapConnection); |
23d6bd09 |
117 | } |
5c3b0995 |
118 | sqimap_logout($imapConnection); |
119 | session_register('delimiter'); |
120 | |
121 | $username = $login_username; |
122 | session_register ('username'); |
123 | setcookie('key', $key, 0, $base_uri); |
124 | do_hook ('login_verified'); |
125 | |
126 | } |
127 | |
128 | /* Set the login variables. */ |
129 | $user_is_logged_in = true; |
130 | $just_logged_in = true; |
131 | |
132 | /* And register with them with the session. */ |
133 | session_register ('user_is_logged_in'); |
134 | session_register ('just_logged_in'); |
135 | |
136 | /* parse the accepted content-types of the client */ |
137 | $attachment_common_types = array(); |
138 | $attachment_common_types_parsed = array(); |
139 | session_register('attachment_common_types'); |
140 | session_register('attachment_common_types_parsed'); |
141 | |
142 | $debug = false; |
143 | if (isset($HTTP_SERVER_VARS['HTTP_ACCEPT']) && |
144 | !isset($attachment_common_types_parsed[$HTTP_SERVER_VARS['HTTP_ACCEPT']])) |
145 | attachment_common_parse($HTTP_SERVER_VARS['HTTP_ACCEPT'], $debug); |
146 | if (isset($HTTP_ACCEPT) && |
147 | !isset($attachment_common_types_parsed[$HTTP_ACCEPT])) |
148 | attachment_common_parse($HTTP_ACCEPT, $debug); |
149 | |
150 | |
151 | /* Complete autodetection of Javascript. */ |
165829a3 |
152 | $javascript_setting = getPref |
153 | ($data_dir, $username, 'javascript_setting', SMPREF_JS_AUTODETECT); |
154 | $js_autodetect_results = (isset($js_autodetect_results) ? |
155 | $js_autodetect_results : SMPREF_JS_OFF); |
5c3b0995 |
156 | if ($javascript_setting == SMPREF_JS_AUTODETECT) { |
157 | if ($js_autodetect_results == SMPREF_JS_ON) { |
158 | setPref($data_dir, $username, 'javascript_on', SMPREF_JS_ON); |
23d6bd09 |
159 | } else { |
5c3b0995 |
160 | setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF); |
23d6bd09 |
161 | } |
5c3b0995 |
162 | } else { |
163 | setPref($data_dir, $username, 'javascript_on', SMPREF_JS_OFF); |
164 | } |
165 | |
166 | /* Compute the URL to forward the user to. */ |
167 | if(isset($rcptemail)) { |
168 | $redirect_url = 'webmail.php?right_frame=compose.php&rcptaddress='; |
169 | $redirect_url .= urlencode($rcptemail); |
170 | } else { |
171 | $redirect_url = 'webmail.php'; |
172 | } |
173 | |
174 | /* Send them off to the appropriate page. */ |
175 | header("Location: $redirect_url"); |
7baf86a9 |
176 | |
e0dcff78 |
177 | ?> |