fixed comp_in_new handling
[squirrelmail.git] / src / redirect.php
CommitLineData
7392739d 1<?php
895905c0 2
35586184 3/**
cab99c3a 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*/
35586184 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');
5a545dda 22require_once('../functions/page_header.php');
cb48c245 23
26707265 24// Remove slashes if PHP added them
25if (get_magic_quotes_gpc()) {
26 global $REQUEST_METHOD;
cab99c3a 27
5cc0b70e 28 if ($REQUEST_METHOD == 'POST') {
26707265 29 global $HTTP_POST_VARS;
30 RemoveSlashes($HTTP_POST_VARS);
5cc0b70e 31 } else if ($REQUEST_METHOD == 'GET') {
26707265 32 global $HTTP_GET_VARS;
33 RemoveSlashes($HTTP_GET_VARS);
34 }
35}
36
5c3b0995 37/* Before starting the session, the base URI must be known. Assuming */
38/* that this file is in the src/ subdirectory (or something). */
f3bc099d 39if (!function_exists('sqm_baseuri')){
40 require_once('../functions/display_messages.php');
41}
42$base_uri = sqm_baseuri();
5c3b0995 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. */
85b454a0 59setcookie('squirrelmail_language', $squirrelmail_language, time()+2592000,
60 $base_uri);
5c3b0995 61
62if (!isset($login_username)) {
9be8198d 63 include_once( '../functions/display_messages.php' );
64 logout_error( _("You must be logged in to access this page.") );
5c3b0995 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);
23d6bd09 78 }
79
5c3b0995 80 $imapConnection = sqimap_login($login_username, $key, $imapServerAddress, $imapPort, 0);
81 if (!$imapConnection) {
9be8198d 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.") );
5c3b0995 87 exit;
23d6bd09 88 } else {
5c3b0995 89 $delimiter = sqimap_get_delimiter ($imapConnection);
23d6bd09 90 }
5c3b0995 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']) &&
9be8198d 117 !isset($attachment_common_types_parsed[$HTTP_SERVER_VARS['HTTP_ACCEPT']])) {
5c3b0995 118 attachment_common_parse($HTTP_SERVER_VARS['HTTP_ACCEPT'], $debug);
9be8198d 119}
5c3b0995 120if (isset($HTTP_ACCEPT) &&
9be8198d 121 !isset($attachment_common_types_parsed[$HTTP_ACCEPT])) {
5c3b0995 122 attachment_common_parse($HTTP_ACCEPT, $debug);
9be8198d 123}
5c3b0995 124
125/* Complete autodetection of Javascript. */
165829a3 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);
18f734b9 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 }
23d6bd09 137 } else {
18f734b9 138 $js_pref = SMPREF_JS_OFF;
23d6bd09 139 }
5c3b0995 140}
18f734b9 141/* Update the prefs */
142setPref($data_dir, $username, 'javascript_on', $js_pref);
5c3b0995 143
144/* Compute the URL to forward the user to. */
145if(isset($rcptemail)) {
146 $redirect_url = 'webmail.php?right_frame=compose.php&rcptaddress=';
594d29a1 147 $redirect_url .= $rcptemail;
5c3b0995 148} else {
149 $redirect_url = 'webmail.php';
150}
151
152/* Send them off to the appropriate page. */
153header("Location: $redirect_url");
7baf86a9 154
cab99c3a 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
9be8198d 175?>