disable regexp compilation error
[squirrelmail.git] / src / webmail.php
1 <?php
2
3 /**
4 * webmail.php -- Displays the main frameset
5 *
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 *
10 * @copyright &copy; 1999-2006 The SquirrelMail Project Team
11 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
12 * @version $Id$
13 * @package squirrelmail
14 */
15
16 /**
17 * Path for SquirrelMail required files.
18 * @ignore
19 */
20 define('SM_PATH','../');
21
22 /* SquirrelMail required files. */
23 require_once(SM_PATH . 'functions/strings.php');
24 require_once(SM_PATH . 'config/config.php');
25 require_once(SM_PATH . 'functions/prefs.php');
26 require_once(SM_PATH . 'functions/imap.php');
27 require_once(SM_PATH . 'functions/plugin.php');
28 require_once(SM_PATH . 'functions/i18n.php');
29 require_once(SM_PATH . 'functions/auth.php');
30 require_once(SM_PATH . 'functions/global.php');
31
32 if (!function_exists('sqm_baseuri')){
33 require_once(SM_PATH . 'functions/display_messages.php');
34 }
35 $base_uri = sqm_baseuri();
36
37 sqsession_is_active();
38
39 sqgetGlobalVar('username', $username, SQ_SESSION);
40 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
41 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
42
43 if (sqgetGlobalVar('sort', $sort)) {
44 $sort = (int) $sort;
45 }
46
47 if (sqgetGlobalVar('startMessage', $startMessage)) {
48 $startMessage = (int) $startMessage;
49 }
50
51 if (!sqgetGlobalVar('mailbox', $mailbox)) {
52 $mailbox = 'INBOX';
53 }
54
55 sqgetGlobalVar('right_frame', $right_frame, SQ_GET);
56
57 if ( isset($_SESSION['session_expired_post']) ) {
58 sqsession_unregister('session_expired_post');
59 }
60 if(!sqgetGlobalVar('mailto', $mailto)) {
61 $mailto = '';
62 }
63
64 is_logged_in();
65
66 do_hook('webmail_top');
67
68 /**
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 */
75 $my_language = getPref($data_dir, $username, 'language');
76 if ($my_language != $squirrelmail_language) {
77 sqsetcookie('squirrelmail_language', $my_language, time()+2592000, $base_uri);
78 }
79
80 $err=set_up_language(getPref($data_dir, $username, 'language'));
81
82 $output = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\">\n".
83 "<html><head>\n" .
84 "<meta name=\"robots\" content=\"noindex,nofollow\">\n" .
85 "<title>$org_title</title>\n".
86 "</head>";
87
88 // Japanese translation used without mbstring support
89 if ($err==2) {
90 echo $output.
91 "<body>\n".
92 "<p>You need to have PHP installed with the multibyte string function \n".
93 "enabled (using configure option --enable-mbstring).</p>\n".
94 "<p>System assumed that you accidently switched to Japanese translation \n".
95 "and reverted your language preference to English.</p>\n".
96 "<p>Please refresh this page in order to use webmail.</p>\n".
97 "</body></html>";
98 return;
99 }
100
101 $left_size = getPref($data_dir, $username, 'left_size');
102 $location_of_bar = getPref($data_dir, $username, 'location_of_bar');
103
104 if (isset($languages[$squirrelmail_language]['DIR']) &&
105 strtolower($languages[$squirrelmail_language]['DIR']) == 'rtl') {
106 $temp_location_of_bar = 'right';
107 } else {
108 $temp_location_of_bar = 'left';
109 }
110
111 if ($location_of_bar == '') {
112 $location_of_bar = $temp_location_of_bar;
113 }
114 $temp_location_of_bar = '';
115
116 if ($left_size == "") {
117 if (isset($default_left_size)) {
118 $left_size = $default_left_size;
119 }
120 else {
121 $left_size = 200;
122 }
123 }
124
125 if ($location_of_bar == 'right') {
126 $output .= "<frameset cols=\"*, $left_size\" id=\"fs1\">\n";
127 }
128 else {
129 $output .= "<frameset cols=\"$left_size, *\" id=\"fs1\">\n";
130 }
131
132 /*
133 * There are three ways to call webmail.php
134 * 1. webmail.php
135 * - This just loads the default entry screen.
136 * 2. webmail.php?right_frame=right_main.php&sort=X&startMessage=X&mailbox=XXXX
137 * - This loads the frames starting at the given values.
138 * 3. webmail.php?right_frame=folders.php
139 * - Loads the frames with the Folder options in the right frame.
140 *
141 * This was done to create a pure HTML way of refreshing the folder list since
142 * we would like to use as little Javascript as possible.
143 *
144 * The test for // should catch any attempt to include off-site webpages into
145 * our frameset.
146 */
147
148 if (empty($right_frame) || (strpos(urldecode($right_frame), '//') !== false)) {
149 $right_frame = '';
150 }
151
152 switch($right_frame) {
153 case 'right_main.php':
154 $right_frame_url = "right_main.php?mailbox=".urlencode($mailbox)
155 . (!empty($sort)?"&amp;sort=$sort":'')
156 . (!empty($startMessage)?"&amp;startMessage=$startMessage":'');
157 break;
158 case 'options.php':
159 $right_frame_url = 'options.php';
160 break;
161 case 'folders.php':
162 $right_frame_url = 'folders.php';
163 break;
164 case 'compose.php':
165 $right_frame_url = 'compose.php?' . $mailto;
166 break;
167 case '':
168 $right_frame_url = 'right_main.php';
169 break;
170 default:
171 $right_frame_url = urlencode($right_frame);
172 break;
173 }
174
175 $left_frame = '<frame src="left_main.php" name="left" frameborder="1" title="'.
176 _("Folder List") ."\" />\n";
177 $right_frame = '<frame src="'.$right_frame_url.'" name="right" frameborder="1" title="'.
178 _("Message List") ."\" />\n";
179
180 if ($location_of_bar == 'right') {
181 $output .= $right_frame . $left_frame;
182 }
183 else {
184 $output .= $left_frame . $right_frame;
185 }
186 $ret = concat_hook_function('webmail_bottom', $output);
187 if($ret != '') {
188 $output = $ret;
189 }
190 echo $output;
191
192 ?>
193 </frameset>
194 </html>