fix right_main checking for right_main's that pass mailbox parameters.
[squirrelmail.git] / src / webmail.php
CommitLineData
59177427 1<?php
c6d6fe73 2
864b1c33 3/**
15e6162e 4 * webmail.php -- Displays the main frameset
5 *
15e6162e 6 * This file generates the main frameset. The files that are
7 * shown can be given as parameters. If the user is not logged in
8 * this file will verify username and password.
9 *
47ccfad4 10 * @copyright &copy; 1999-2006 The SquirrelMail Project Team
4b4abf93 11 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
30967a1e 12 * @version $Id$
8f6f9ba5 13 * @package squirrelmail
15e6162e 14 */
21c3249f 15
30967a1e 16/**
17 * Path for SquirrelMail required files.
18 * @ignore
19 */
86725763 20define('SM_PATH','../');
21
22/* SquirrelMail required files. */
23require_once(SM_PATH . 'functions/strings.php');
24require_once(SM_PATH . 'config/config.php');
25require_once(SM_PATH . 'functions/prefs.php');
26require_once(SM_PATH . 'functions/imap.php');
27require_once(SM_PATH . 'functions/plugin.php');
28require_once(SM_PATH . 'functions/i18n.php');
29require_once(SM_PATH . 'functions/auth.php');
a32985a5 30require_once(SM_PATH . 'functions/global.php');
245a6892 31
f3bc099d 32if (!function_exists('sqm_baseuri')){
86725763 33 require_once(SM_PATH . 'functions/display_messages.php');
f3bc099d 34}
35$base_uri = sqm_baseuri();
88fa922a 36
748ba6c0 37sqsession_is_active();
a32985a5 38
f38b7cf0 39sqgetGlobalVar('username', $username, SQ_SESSION);
40sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
41sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
dcc1cc82 42
ef8d36ad 43if (sqgetGlobalVar('sort', $sort)) {
44 $sort = (int) $sort;
45}
46
47if (sqgetGlobalVar('startMessage', $startMessage)) {
48 $startMessage = (int) $startMessage;
49}
50
a2b193bc 51if (!sqgetGlobalVar('mailbox', $mailbox)) {
ef8d36ad 52 $mailbox = 'INBOX';
53}
54
f38b7cf0 55sqgetGlobalVar('right_frame', $right_frame, SQ_GET);
56
db6a9192 57if ( isset($_SESSION['session_expired_post']) ) {
58 sqsession_unregister('session_expired_post');
59}
c67e4479 60if(!sqgetGlobalVar('mailto', $mailto)) {
61 $mailto = '';
62}
a32985a5 63
864b1c33 64is_logged_in();
1b187352 65
148ee1ef 66do_hook('webmail_top');
67
15e6162e 68/**
864b1c33 69 * We'll need this to later have a noframes version
70 *
71 * Check if the user has a language preference, but no cookie.
72 * Send him a cookie with his language preference, if there is
73 * such discrepancy.
74 */
871ab9eb 75$my_language = getPref($data_dir, $username, 'language');
864b1c33 76if ($my_language != $squirrelmail_language) {
3a1de9f1 77 sqsetcookie('squirrelmail_language', $my_language, time()+2592000, $base_uri);
864b1c33 78}
cf47d363 79
53da506b 80$err=set_up_language(getPref($data_dir, $username, 'language'));
441f2d33 81
151562a7 82$output = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\"\n".
83 " \"http://www.w3.org/TR/1999/REC-html401-19991224/frameset.dtd\">\n".
0e3b9a5a 84 "<html><head>\n" .
f8a1ed5a 85 "<meta name=\"robots\" content=\"noindex,nofollow\">\n" .
0e3b9a5a 86 "<title>$org_title</title>\n".
87 "</head>";
65c3ec94 88
53da506b 89// Japanese translation used without mbstring support
90if ($err==2) {
0e3b9a5a 91 echo $output.
92 "<body>\n".
238d4cfc 93 "<p>You need to have PHP installed with the multibyte string function \n".
134e4174 94 "enabled (using configure option --enable-mbstring).</p>\n".
95 "<p>System assumed that you accidently switched to Japanese translation \n".
53da506b 96 "and reverted your language preference to English.</p>\n".
134e4174 97 "<p>Please refresh this page in order to use webmail.</p>\n".
98 "</body></html>";
53da506b 99 return;
100}
101
871ab9eb 102$left_size = getPref($data_dir, $username, 'left_size');
103$location_of_bar = getPref($data_dir, $username, 'location_of_bar');
fab3baa6 104
0c660770 105if (isset($languages[$squirrelmail_language]['DIR']) &&
106 strtolower($languages[$squirrelmail_language]['DIR']) == 'rtl') {
fab3baa6 107 $temp_location_of_bar = 'right';
108} else {
109 $temp_location_of_bar = 'left';
110}
111
864b1c33 112if ($location_of_bar == '') {
fab3baa6 113 $location_of_bar = $temp_location_of_bar;
864b1c33 114}
fab3baa6 115$temp_location_of_bar = '';
116
864b1c33 117if ($left_size == "") {
118 if (isset($default_left_size)) {
f740c049 119 $left_size = $default_left_size;
864b1c33 120 }
121 else {
122 $left_size = 200;
123 }
65c3ec94 124}
125
864b1c33 126if ($location_of_bar == 'right') {
0e3b9a5a 127 $output .= "<frameset cols=\"*, $left_size\" id=\"fs1\">\n";
864b1c33 128}
129else {
0e3b9a5a 130 $output .= "<frameset cols=\"$left_size, *\" id=\"fs1\">\n";
864b1c33 131}
ad6787f0 132
864b1c33 133/*
134 * There are three ways to call webmail.php
135 * 1. webmail.php
136 * - This just loads the default entry screen.
137 * 2. webmail.php?right_frame=right_main.php&sort=X&startMessage=X&mailbox=XXXX
138 * - This loads the frames starting at the given values.
139 * 3. webmail.php?right_frame=folders.php
140 * - Loads the frames with the Folder options in the right frame.
141 *
142 * This was done to create a pure HTML way of refreshing the folder list since
143 * we would like to use as little Javascript as possible.
0a03f924 144 *
145 * The test for // should catch any attempt to include off-site webpages into
146 * our frameset.
864b1c33 147 */
f3fa1c10 148
0a03f924 149if (empty($right_frame) || (strpos(urldecode($right_frame), '//') !== false)) {
793cc001 150 $right_frame = '';
91e0dccc 151}
f3fa1c10 152
9a186afe 153if ( strpos($right_frame,'?') ) {
154 $right_frame_file = substr($right_frame,0,strpos($right_frame,'?'));
155} else {
156 $right_frame_file = $right_frame;
157}
158
02d8345e 159switch($right_frame) {
160 case 'right_main.php':
161 $right_frame_url = "right_main.php?mailbox=".urlencode($mailbox)
ef8d36ad 162 . (!empty($sort)?"&amp;sort=$sort":'')
163 . (!empty($startMessage)?"&amp;startMessage=$startMessage":'');
02d8345e 164 break;
165 case 'options.php':
166 $right_frame_url = 'options.php';
167 break;
168 case 'folders.php':
169 $right_frame_url = 'folders.php';
170 break;
171 case 'compose.php':
172 $right_frame_url = 'compose.php?' . $mailto;
173 break;
174 case '':
175 $right_frame_url = 'right_main.php';
176 break;
177 default:
178 $right_frame_url = urlencode($right_frame);
179 break;
180}
9a732bb6 181
da9a8410 182$left_frame = '<frame src="left_main.php" name="left" frameborder="1" title="'.
183 _("Folder List") ."\" />\n";
184$right_frame = '<frame src="'.$right_frame_url.'" name="right" frameborder="1" title="'.
185 _("Message List") ."\" />\n";
186
864b1c33 187if ($location_of_bar == 'right') {
0e3b9a5a 188 $output .= $right_frame . $left_frame;
864b1c33 189}
190else {
0e3b9a5a 191 $output .= $left_frame . $right_frame;
864b1c33 192}
0e3b9a5a 193$ret = concat_hook_function('webmail_bottom', $output);
194if($ret != '') {
195 $output = $ret;
196}
197echo $output;
a2b193bc 198
ad6787f0 199?>
d68323ff 200</frameset>
0a03f924 201</html>