Indentation fixes and minor cleanups
[squirrelmail.git] / src / webmail.php
1 <?php
2
3 /**
4 * webmail.php -- Displays the main frameset
5 *
6 * Copyright (c) 1999-2004 The SquirrelMail development 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 sqgetGlobalVar('right_frame', $right_frame, SQ_GET);
45
46 if ( isset($_SESSION['session_expired_post']) ) {
47 sqsession_unregister('session_expired_post');
48 }
49 if(!sqgetGlobalVar('mailto', $mailto)) {
50 $mailto = '';
51 }
52
53 is_logged_in();
54
55 do_hook('webmail_top');
56
57 /**
58 * We'll need this to later have a noframes version
59 *
60 * Check if the user has a language preference, but no cookie.
61 * Send him a cookie with his language preference, if there is
62 * such discrepancy.
63 */
64 $my_language = getPref($data_dir, $username, 'language');
65 if ($my_language != $squirrelmail_language) {
66 setcookie('squirrelmail_language', $my_language, time()+2592000, $base_uri);
67 }
68
69 $err=set_up_language(getPref($data_dir, $username, 'language'));
70
71 $output = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\">\n".
72 "<html><head>\n" .
73 "<title>$org_title</title>\n".
74 "</head>";
75
76 // Japanese translation used without mbstring support
77 if ($err==2) {
78 echo $output.
79 "<body>\n".
80 "<p>You need to have php4 installed with the multibyte string function \n".
81 "enabled (using configure option --enable-mbstring).</p>\n".
82 "<p>System assumed that you accidently switched to Japanese translation \n".
83 "and reverted your language preference to English.</p>\n".
84 "<p>Please refresh this page in order to use webmail.</p>\n".
85 "</body></html>";
86 return;
87 }
88
89 $left_size = getPref($data_dir, $username, 'left_size');
90 $location_of_bar = getPref($data_dir, $username, 'location_of_bar');
91
92 if (isset($languages[$squirrelmail_language]['DIR']) &&
93 strtolower($languages[$squirrelmail_language]['DIR']) == 'rtl') {
94 $temp_location_of_bar = 'right';
95 } else {
96 $temp_location_of_bar = 'left';
97 }
98
99 if ($location_of_bar == '') {
100 $location_of_bar = $temp_location_of_bar;
101 }
102 $temp_location_of_bar = '';
103
104 if ($left_size == "") {
105 if (isset($default_left_size)) {
106 $left_size = $default_left_size;
107 }
108 else {
109 $left_size = 200;
110 }
111 }
112
113 if ($location_of_bar == 'right') {
114 $output .= "<frameset cols=\"*, $left_size\" id=\"fs1\">\n";
115 }
116 else {
117 $output .= "<frameset cols=\"$left_size, *\" id=\"fs1\">\n";
118 }
119
120 /*
121 * There are three ways to call webmail.php
122 * 1. webmail.php
123 * - This just loads the default entry screen.
124 * 2. webmail.php?right_frame=right_main.php&sort=X&startMessage=X&mailbox=XXXX
125 * - This loads the frames starting at the given values.
126 * 3. webmail.php?right_frame=folders.php
127 * - Loads the frames with the Folder options in the right frame.
128 *
129 * This was done to create a pure HTML way of refreshing the folder list since
130 * we would like to use as little Javascript as possible.
131 */
132 if (!isset($right_frame)) {
133 $right_frame = '';
134 }
135 if ($right_frame == 'right_main.php') {
136 $urlMailbox = urlencode($mailbox);
137 $right_frame_url =
138 "right_main.php?mailbox=$urlMailbox&amp;sort=$sort&amp;startMessage=$startMessage";
139 } elseif ($right_frame == 'options.php') {
140 $right_frame_url = 'options.php';
141 } elseif ($right_frame == 'folders.php') {
142 $right_frame_url = 'folders.php';
143 } elseif ($right_frame == 'compose.php') {
144 $right_frame_url = 'compose.php?' . $mailto;
145 } else if ($right_frame == '') {
146 $right_frame_url = 'right_main.php';
147 } else {
148 $right_frame_url = $right_frame;
149 }
150
151 $left_frame = '<frame src="left_main.php" name="left" frameborder="1" title="'.
152 _("Folder List") ."\" />\n";
153 $right_frame = '<frame src="'.$right_frame_url.'" name="right" frameborder="1" title="'.
154 _("Message List") ."\" />\n";
155
156 if ($location_of_bar == 'right') {
157 $output .= $right_frame . $left_frame;
158 }
159 else {
160 $output .= $left_frame . $right_frame;
161 }
162 $ret = concat_hook_function('webmail_bottom', $output);
163 if($ret != '') {
164 $output = $ret;
165 }
166 echo $output;
167 ?>
168 </frameset>
169 </html>