fixed comp_in_new handling
[squirrelmail.git] / src / redirect.php
... / ...
CommitLineData
1<?php
2
3/**
4* redirect.php
5* Derived from webmail.php by Ralf Kraudelt <kraude@wiwi.uni-rostock.de>
6*
7* Copyright (c) 1999-2002 The SquirrelMail Project 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
15require_once('../functions/i18n.php');
16require_once('../functions/strings.php');
17require_once('../config/config.php');
18require_once('../functions/prefs.php');
19require_once('../functions/imap.php');
20require_once('../functions/plugin.php');
21require_once('../functions/constants.php');
22require_once('../functions/page_header.php');
23
24// Remove slashes if PHP added them
25if (get_magic_quotes_gpc()) {
26 global $REQUEST_METHOD;
27
28 if ($REQUEST_METHOD == 'POST') {
29 global $HTTP_POST_VARS;
30 RemoveSlashes($HTTP_POST_VARS);
31 } else if ($REQUEST_METHOD == 'GET') {
32 global $HTTP_GET_VARS;
33 RemoveSlashes($HTTP_GET_VARS);
34 }
35}
36
37/* Before starting the session, the base URI must be known. Assuming */
38/* that this file is in the src/ subdirectory (or something). */
39if (!function_exists('sqm_baseuri')){
40 require_once('../functions/display_messages.php');
41}
42$base_uri = sqm_baseuri();
43
44header('Pragma: no-cache');
45$location = get_location();
46
47session_set_cookie_params (0, $base_uri);
48session_start();
49
50session_unregister ('user_is_logged_in');
51session_register ('base_uri');
52
53if (! isset($squirrelmail_language) ||
54 $squirrelmail_language == '' ) {
55 $squirrelmail_language = $squirrelmail_default_language;
56}
57set_up_language($squirrelmail_language, true);
58/* Refresh the language cookie. */
59setcookie('squirrelmail_language', $squirrelmail_language, time()+2592000,
60 $base_uri);
61
62if (!isset($login_username)) {
63 include_once( '../functions/display_messages.php' );
64 logout_error( _("You must be logged in to access this page.") );
65 exit;
66}
67
68if (!session_is_registered('user_is_logged_in')) {
69 do_hook ('login_before');
70
71 $onetimepad = OneTimePadCreate(strlen($secretkey));
72 $key = OneTimePadEncrypt($secretkey, $onetimepad);
73 session_register('onetimepad');
74
75 /* Verify that username and password are correct. */
76 if ($force_username_lowercase) {
77 $login_username = strtolower($login_username);
78 }
79
80 $imapConnection = sqimap_login($login_username, $key, $imapServerAddress, $imapPort, 0);
81 if (!$imapConnection) {
82 $errTitle = _("There was an error contacting the mail server.");
83 $errString = $errTitle . "<br>\n".
84 _("Contact your administrator for help.");
85 include_once( '../functions/display_messages.php' );
86 logout_error( _("You must be logged in to access this page.") );
87 exit;
88 } else {
89 $delimiter = sqimap_get_delimiter ($imapConnection);
90 }
91 sqimap_logout($imapConnection);
92 session_register('delimiter');
93
94 $username = $login_username;
95 session_register ('username');
96 setcookie('key', $key, 0, $base_uri);
97 do_hook ('login_verified');
98
99}
100
101/* Set the login variables. */
102$user_is_logged_in = true;
103$just_logged_in = true;
104
105/* And register with them with the session. */
106session_register ('user_is_logged_in');
107session_register ('just_logged_in');
108
109/* parse the accepted content-types of the client */
110$attachment_common_types = array();
111$attachment_common_types_parsed = array();
112session_register('attachment_common_types');
113session_register('attachment_common_types_parsed');
114
115$debug = false;
116if (isset($HTTP_SERVER_VARS['HTTP_ACCEPT']) &&
117 !isset($attachment_common_types_parsed[$HTTP_SERVER_VARS['HTTP_ACCEPT']])) {
118 attachment_common_parse($HTTP_SERVER_VARS['HTTP_ACCEPT'], $debug);
119}
120if (isset($HTTP_ACCEPT) &&
121 !isset($attachment_common_types_parsed[$HTTP_ACCEPT])) {
122 attachment_common_parse($HTTP_ACCEPT, $debug);
123}
124
125/* Complete autodetection of Javascript. */
126$javascript_setting = getPref
127 ($data_dir, $username, 'javascript_setting', SMPREF_JS_AUTODETECT);
128$js_autodetect_results = (isset($js_autodetect_results) ?
129 $js_autodetect_results : SMPREF_JS_OFF);
130/* See if it's set to "Always on" */
131$js_pref = SMPREF_JS_ON;
132if ($javascript_setting != SMPREF_JS_ON){
133 if ($javascript_setting == SMPREF_JS_AUTODETECT) {
134 if ($js_autodetect_results == SMPREF_JS_OFF) {
135 $js_pref = SMPREF_JS_OFF;
136 }
137 } else {
138 $js_pref = SMPREF_JS_OFF;
139 }
140}
141/* Update the prefs */
142setPref($data_dir, $username, 'javascript_on', $js_pref);
143
144/* Compute the URL to forward the user to. */
145if(isset($rcptemail)) {
146 $redirect_url = 'webmail.php?right_frame=compose.php&rcptaddress=';
147 $redirect_url .= $rcptemail;
148} else {
149 $redirect_url = 'webmail.php';
150}
151
152/* Send them off to the appropriate page. */
153header("Location: $redirect_url");
154
155/* --------------------- end main ----------------------- */
156
157function attachment_common_parse($str, $debug) {
158 global $attachment_common_types, $attachment_common_types_parsed;
159
160 $attachment_common_types_parsed[$str] = true;
161 $types = explode(', ', $str);
162
163 foreach ($types as $val) {
164 // Ignore the ";q=1.0" stuff
165 if (strpos($val, ';') !== false)
166 $val = substr($val, 0, strpos($val, ';'));
167
168 if (! isset($attachment_common_types[$val])) {
169 $attachment_common_types[$val] = true;
170 }
171 }
172}
173
174
175?>