Trimming whitespace and replacing tabs
[squirrelmail.git] / src / webmail.php
1 <?php
2
3 /**
4 * webmail.php -- Displays the main frameset
5 *
6 * Copyright (c) 1999-2005 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * This file generates the main frameset. The files that are
10 * shown can be given as parameters. If the user is not logged in
11 * this file will verify username and password.
12 *
13 * @version $Id$
14 * @package squirrelmail
15 */
16
17 /**
18 * Path for SquirrelMail required files.
19 * @ignore
20 */
21 define('SM_PATH','../');
22
23 /* SquirrelMail required files. */
24 require_once(SM_PATH . 'functions/strings.php');
25 require_once(SM_PATH . 'config/config.php');
26 require_once(SM_PATH . 'functions/prefs.php');
27 require_once(SM_PATH . 'functions/imap.php');
28 require_once(SM_PATH . 'functions/plugin.php');
29 require_once(SM_PATH . 'functions/i18n.php');
30 require_once(SM_PATH . 'functions/auth.php');
31 require_once(SM_PATH . 'functions/global.php');
32
33 if (!function_exists('sqm_baseuri')){
34 require_once(SM_PATH . 'functions/display_messages.php');
35 }
36 $base_uri = sqm_baseuri();
37
38 sqsession_is_active();
39
40 sqgetGlobalVar('username', $username, SQ_SESSION);
41 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
42 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
43
44 if (sqgetGlobalVar('sort', $sort)) {
45 $sort = (int) $sort;
46 }
47
48 if (sqgetGlobalVar('startMessage', $startMessage)) {
49 $startMessage = (int) $startMessage;
50 }
51
52 if (!sqgetGlobalVar('mailbox',$mailbox)) {
53 $mailbox = 'INBOX';
54 }
55
56 sqgetGlobalVar('right_frame', $right_frame, SQ_GET);
57
58 if ( isset($_SESSION['session_expired_post']) ) {
59 sqsession_unregister('session_expired_post');
60 }
61 if(!sqgetGlobalVar('mailto', $mailto)) {
62 $mailto = '';
63 }
64
65 is_logged_in();
66
67 do_hook('webmail_top');
68
69 /**
70 * We'll need this to later have a noframes version
71 *
72 * Check if the user has a language preference, but no cookie.
73 * Send him a cookie with his language preference, if there is
74 * such discrepancy.
75 */
76 $my_language = getPref($data_dir, $username, 'language');
77 if ($my_language != $squirrelmail_language) {
78 setcookie('squirrelmail_language', $my_language, time()+2592000, $base_uri);
79 }
80
81 $err=set_up_language(getPref($data_dir, $username, 'language'));
82
83 $output = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\">\n".
84 "<html><head>\n" .
85 "<meta name=\"robots\" content=\"noindex,nofollow\">\n" .
86 "<title>$org_title</title>\n".
87 "</head>";
88
89 // Japanese translation used without mbstring support
90 if ($err==2) {
91 echo $output.
92 "<body>\n".
93 "<p>You need to have php4 installed with the multibyte string function \n".
94 "enabled (using configure option --enable-mbstring).</p>\n".
95 "<p>System assumed that you accidently switched to Japanese translation \n".
96 "and reverted your language preference to English.</p>\n".
97 "<p>Please refresh this page in order to use webmail.</p>\n".
98 "</body></html>";
99 return;
100 }
101
102 $left_size = getPref($data_dir, $username, 'left_size');
103 $location_of_bar = getPref($data_dir, $username, 'location_of_bar');
104
105 if (isset($languages[$squirrelmail_language]['DIR']) &&
106 strtolower($languages[$squirrelmail_language]['DIR']) == 'rtl') {
107 $temp_location_of_bar = 'right';
108 } else {
109 $temp_location_of_bar = 'left';
110 }
111
112 if ($location_of_bar == '') {
113 $location_of_bar = $temp_location_of_bar;
114 }
115 $temp_location_of_bar = '';
116
117 if ($left_size == "") {
118 if (isset($default_left_size)) {
119 $left_size = $default_left_size;
120 }
121 else {
122 $left_size = 200;
123 }
124 }
125
126 if ($location_of_bar == 'right') {
127 $output .= "<frameset cols=\"*, $left_size\" id=\"fs1\">\n";
128 }
129 else {
130 $output .= "<frameset cols=\"$left_size, *\" id=\"fs1\">\n";
131 }
132
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.
144 */
145
146 if (empty($right_frame) || (strpos(urldecode($right_frame), '://'))) {
147 $right_frame = '';
148 }
149
150 if ($right_frame == 'right_main.php') {
151 $urlMailbox = urlencode($mailbox);
152 $right_frame_url = "right_main.php?mailbox=$urlMailbox"
153 . (!empty($sort)?"&amp;sort=$sort":'')
154 . (!empty($startMessage)?"&amp;startMessage=$startMessage":'');
155 } elseif ($right_frame == 'options.php') {
156 $right_frame_url = 'options.php';
157 } elseif ($right_frame == 'folders.php') {
158 $right_frame_url = 'folders.php';
159 } elseif ($right_frame == 'compose.php') {
160 $right_frame_url = 'compose.php?' . $mailto;
161 } else if ($right_frame == '') {
162 $right_frame_url = 'right_main.php';
163 } else {
164 $right_frame_url = htmlspecialchars($right_frame);
165 }
166
167 $left_frame = '<frame src="left_main.php" name="left" frameborder="1" title="'.
168 _("Folder List") ."\" />\n";
169 $right_frame = '<frame src="'.$right_frame_url.'" name="right" frameborder="1" title="'.
170 _("Message List") ."\" />\n";
171
172 if ($location_of_bar == 'right') {
173 $output .= $right_frame . $left_frame;
174 }
175 else {
176 $output .= $left_frame . $right_frame;
177 }
178 $ret = concat_hook_function('webmail_bottom', $output);
179 if($ret != '') {
180 $output = $ret;
181 }
182 echo $output;
183 ?>
184 </frameset>
185 </html>