Modified to return bcc header if available, for save as draft.
[squirrelmail.git] / src / redirect.php
CommitLineData
7392739d 1<?php
2
3 /**
4 ** redirect.php -- derived from webmail.php by Ralf Kraudelt
5 ** kraude@wiwi.uni-rostock.de
6 **
7 ** Copyright (c) 1999-2000 ...
8 ** Licensed under the GNU GPL. For full terms see the file COPYING.
9 **
10 ** prevents users from reposting their form data after a
11 ** successful logout
12 **
245a6892 13 ** $Id$
7392739d 14 **/
15
ff8a98e7 16 require_once('../functions/i18n.php');
17 require_once('../functions/strings.php');
18 require_once('../config/config.php');
7392739d 19
20 // Before starting the session, the base URI must be known.
21 // Assuming that this file is in the src/ subdirectory (or
22 // something).
23 ereg ("(^.*/)[^/]+/[^/]+$", $PHP_SELF, $regs);
24 $base_uri = $regs[1];
25
91dc6e4e 26 header('Pragma: no-cache');
7392739d 27 $location = get_location();
7392739d 28
29 session_set_cookie_params (0, $base_uri);
30 session_start();
31
f740c049 32 session_unregister ('user_is_logged_in');
91dc6e4e 33 session_register ('base_uri');
7392739d 34
9487c2ff 35 if (! isset($squirrelmail_language))
1026ec43 36 $squirrelmail_language = '';
37 set_up_language($squirrelmail_language, true);
9487c2ff 38
74b4e396 39 if(!isset($login_username)) {
9487c2ff 40 echo "<html><body bgcolor=\"#ffffff\">\n";
f740c049 41 echo "<br><br>";
42 echo "<center>";
43 echo "<b>"._("You must be logged in to access this page.")."</b><br>";
44 echo "<a href=\"../src/login.php\">"._("Go to the login page")."</a>\n";
45 echo "</center>";
46 echo "</body></html>\n";
7392739d 47 exit;
48 }
49
50 // Refresh the language cookie.
51 if (isset($squirrelmail_language)) {
88fa922a 52 setcookie('squirrelmail_language', $squirrelmail_language, time()+2592000,$base_uri);
7392739d 53 }
54
55
ff8a98e7 56 require_once('../functions/prefs.php');
57 require_once('../functions/imap.php');
58 require_once('../functions/plugin.php');
7392739d 59
1026ec43 60 if (!session_is_registered('user_is_logged_in')) {
91dc6e4e 61 do_hook ('login_before');
7392739d 62
63 $onetimepad = OneTimePadCreate(strlen($secretkey));
8c42b963 64 $key = OneTimePadEncrypt($secretkey, $onetimepad);
91dc6e4e 65 session_register('onetimepad');
7392739d 66 // verify that username and password are correct
74b4e396 67 if ($force_username_lowercase)
8ddd44cd 68 $login_username = strtolower($login_username);
814e501a 69
74b4e396 70 $imapConnection = sqimap_login($login_username, $key, $imapServerAddress, $imapPort, 0);
9487c2ff 71 if (!$imapConnection) {
72 echo "<html><body bgcolor=\"#ffffff\">\n";
73 echo "<br><br>";
74 echo "<center>";
75 echo "<b>"._("There was an error contacting the mail server.")."</b><br>";
76 echo _("Contact your administrator for help.")."\n";
77 echo "</center>";
78 echo "</body></html>\n";
79 exit;
80 }
7392739d 81 sqimap_logout($imapConnection);
82
814e501a 83 $username = $login_username;
84 session_register ('username');
91dc6e4e 85 setcookie('key', $key, 0, $base_uri);
91dc6e4e 86 do_hook ('login_verified');
7392739d 87 }
88
7392739d 89 $user_is_logged_in = true;
f740c049 90 session_register ('user_is_logged_in');
8061a3fb 91 $just_logged_in = true;
92 session_register ('just_logged_in');
7392739d 93
6978d355 94 if(isset($rcptemail))
870fb6d3 95 header("Location: webmail.php?right_frame=compose.php&rcptaddress=" .
96 urlencode($rcptemail));
6978d355 97 else
98 header("Location: webmail.php");
ff8a98e7 99?>