Replace PHP4 -> PHP since we also support upcoming PHP versions
[squirrelmail.git] / src / webmail.php
CommitLineData
59177427 1<?php
c6d6fe73 2
864b1c33 3/**
15e6162e 4 * webmail.php -- Displays the main frameset
5 *
9eb3fcb3 6 * Copyright (c) 1999-2005 The SquirrelMail Project Team
15e6162e 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 *
30967a1e 13 * @version $Id$
8f6f9ba5 14 * @package squirrelmail
15e6162e 15 */
21c3249f 16
30967a1e 17/**
18 * Path for SquirrelMail required files.
19 * @ignore
20 */
86725763 21define('SM_PATH','../');
22
23/* SquirrelMail required files. */
24require_once(SM_PATH . 'functions/strings.php');
25require_once(SM_PATH . 'config/config.php');
26require_once(SM_PATH . 'functions/prefs.php');
27require_once(SM_PATH . 'functions/imap.php');
28require_once(SM_PATH . 'functions/plugin.php');
29require_once(SM_PATH . 'functions/i18n.php');
30require_once(SM_PATH . 'functions/auth.php');
a32985a5 31require_once(SM_PATH . 'functions/global.php');
245a6892 32
f3bc099d 33if (!function_exists('sqm_baseuri')){
86725763 34 require_once(SM_PATH . 'functions/display_messages.php');
f3bc099d 35}
36$base_uri = sqm_baseuri();
88fa922a 37
748ba6c0 38sqsession_is_active();
a32985a5 39
f38b7cf0 40sqgetGlobalVar('username', $username, SQ_SESSION);
41sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
42sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
dcc1cc82 43
ef8d36ad 44if (sqgetGlobalVar('sort', $sort)) {
45 $sort = (int) $sort;
46}
47
48if (sqgetGlobalVar('startMessage', $startMessage)) {
49 $startMessage = (int) $startMessage;
50}
51
a2b193bc 52if (!sqgetGlobalVar('mailbox', $mailbox)) {
ef8d36ad 53 $mailbox = 'INBOX';
54}
55
f38b7cf0 56sqgetGlobalVar('right_frame', $right_frame, SQ_GET);
57
db6a9192 58if ( isset($_SESSION['session_expired_post']) ) {
59 sqsession_unregister('session_expired_post');
60}
c67e4479 61if(!sqgetGlobalVar('mailto', $mailto)) {
62 $mailto = '';
63}
a32985a5 64
864b1c33 65is_logged_in();
1b187352 66
148ee1ef 67do_hook('webmail_top');
68
15e6162e 69/**
864b1c33 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 */
871ab9eb 76$my_language = getPref($data_dir, $username, 'language');
864b1c33 77if ($my_language != $squirrelmail_language) {
78 setcookie('squirrelmail_language', $my_language, time()+2592000, $base_uri);
79}
cf47d363 80
53da506b 81$err=set_up_language(getPref($data_dir, $username, 'language'));
441f2d33 82
0e3b9a5a 83$output = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\">\n".
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.
144 */
f3fa1c10 145
146if (empty($right_frame) || (strpos(urldecode($right_frame), '://'))) {
793cc001 147 $right_frame = '';
91e0dccc 148}
f3fa1c10 149
864b1c33 150if ($right_frame == 'right_main.php') {
151 $urlMailbox = urlencode($mailbox);
ef8d36ad 152 $right_frame_url = "right_main.php?mailbox=$urlMailbox"
153 . (!empty($sort)?"&amp;sort=$sort":'')
154 . (!empty($startMessage)?"&amp;startMessage=$startMessage":'');
65c3ec94 155} elseif ($right_frame == 'options.php') {
864b1c33 156 $right_frame_url = 'options.php';
65c3ec94 157} elseif ($right_frame == 'folders.php') {
864b1c33 158 $right_frame_url = 'folders.php';
c67e4479 159} elseif ($right_frame == 'compose.php') {
160 $right_frame_url = 'compose.php?' . $mailto;
78194072 161} else if ($right_frame == '') {
871ab9eb 162 $right_frame_url = 'right_main.php';
78194072 163} else {
ef8d36ad 164 $right_frame_url = htmlspecialchars($right_frame);
864b1c33 165}
9a732bb6 166
da9a8410 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
864b1c33 172if ($location_of_bar == 'right') {
0e3b9a5a 173 $output .= $right_frame . $left_frame;
864b1c33 174}
175else {
0e3b9a5a 176 $output .= $left_frame . $right_frame;
864b1c33 177}
0e3b9a5a 178$ret = concat_hook_function('webmail_bottom', $output);
179if($ret != '') {
180 $output = $ret;
181}
182echo $output;
a2b193bc 183
ad6787f0 184?>
d68323ff 185</frameset>
238d4cfc 186</html>