59177427 |
1 | <?php |
7350889b |
2 | |
35586184 |
3 | /** |
4 | * page_header.php |
5 | * |
15e6162e |
6 | * Copyright (c) 1999-2002 The SquirrelMail Project Team |
35586184 |
7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
8 | * |
9 | * Prints the page header (duh) |
10 | * |
11 | * $Id$ |
12 | */ |
13 | |
b68edc75 |
14 | require_once(SM_PATH . 'functions/strings.php'); |
15 | require_once(SM_PATH . 'functions/html.php'); |
16 | require_once(SM_PATH . 'functions/imap_mailbox.php'); |
0b97a708 |
17 | require_once(SM_PATH . 'functions/global.php'); |
b68edc75 |
18 | |
34c90574 |
19 | /* Always set up the language before calling these functions */ |
a07cd1a4 |
20 | function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE ) { |
692155b7 |
21 | |
fb694681 |
22 | if ( !check_php_version(4,1) ) { |
0b97a708 |
23 | global $_SESSION; |
24 | } |
25 | if (isset($_SESSION['base_uri'])) { |
26 | $base_uri = $_SESSION['base_uri']; |
27 | } |
28 | else { |
29 | global $base_uri; |
30 | } |
31 | global $theme_css, $custom_css; |
2c21ef20 |
32 | |
12ff1cab |
33 | echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">' . |
8f1ba72b |
34 | "\n\n<HTML>\n<HEAD>\n"; |
2c21ef20 |
35 | |
a714cb95 |
36 | if ( !isset( $custom_css ) || $custom_css == 'none' ) { |
692155b7 |
37 | if ($theme_css != '') { |
34c90574 |
38 | echo "<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"$theme_css\">"; |
692155b7 |
39 | } |
8f1ba72b |
40 | } else { |
2c21ef20 |
41 | echo '<LINK REL="stylesheet" TYPE="text/css" HREF="' . |
67dfe419 |
42 | $base_uri . 'themes/css/'.$custom_css.'">'; |
8f1ba72b |
43 | } |
85f4ce52 |
44 | |
237470b4 |
45 | if ($do_hook) { |
46 | do_hook("generic_header"); |
47 | } |
8f1ba72b |
48 | |
5ca4b1ee |
49 | echo "\n<title>$title</title>$xtra\n"; |
50 | |
51 | /* work around IE6's scrollbar bug */ |
52 | echo <<<ECHO |
53 | <style type="text/css"> |
54 | <!-- |
55 | /* avoid stupid IE6 bug with frames and scrollbars */ |
56 | body { |
57 | voice-family: "\"}\""; |
58 | voice-family: inherit; |
59 | width: expression(document.documentElement.clientWidth - 30); |
60 | } |
61 | --> |
62 | </style> |
63 | |
64 | ECHO; |
65 | |
66 | echo "\n</head>\n\n"; |
a07cd1a4 |
67 | } |
68 | |
85f4ce52 |
69 | |
a07cd1a4 |
70 | function displayInternalLink($path, $text, $target='') { |
fb694681 |
71 | if ( !check_php_version(4,1) ) { |
0b97a708 |
72 | global $_SESSION; |
73 | } |
a07cd1a4 |
74 | |
0b97a708 |
75 | $base_uri = $_SESSION['base_uri']; |
a07cd1a4 |
76 | if ($target != '') { |
77 | $target = " target=\"$target\""; |
78 | } |
a07cd1a4 |
79 | echo '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>'; |
80 | } |
81 | |
aca403fa |
82 | function displayPageHeader($color, $mailbox, $xtra='', $session=false) { |
715225af |
83 | |
0b97a708 |
84 | global $hide_sm_attributions, $PHP_SELF, $frame_top, |
1ba8cd6b |
85 | $compose_new_win, $compose_width, $compose_height, |
735f6b9c |
86 | $attachemessages, $provider_name, $provider_uri; |
715225af |
87 | |
fb694681 |
88 | if ( !check_php_version(4,1) ) { |
0b97a708 |
89 | global $_SESSION; |
90 | } |
91 | |
92 | $base_uri = $_SESSION['base_uri']; |
93 | $delimiter = $_SESSION['delimiter']; |
715225af |
94 | $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 ); |
f3e14140 |
95 | if ($qmark = strpos($module, '?')) { |
96 | $module = substr($module, 0, $qmark); |
97 | } |
d03f3582 |
98 | if (!isset($frame_top)) { |
99 | $frame_top = '_top'; |
100 | } |
715225af |
101 | |
735f6b9c |
102 | if ($session) { |
087ce5f8 |
103 | $compose_uri = $base_uri.'src/compose.php?mailbox='. urlencode($mailbox).'&attachedmessages=true&session='."$session"; |
aca403fa |
104 | } else { |
087ce5f8 |
105 | $compose_uri = $base_uri.'src/compose.php?newmessage=1'; |
d7f8e6e6 |
106 | $session = 0; |
aca403fa |
107 | } |
cb6b53c6 |
108 | |
715225af |
109 | switch ( $module ) { |
f3e14140 |
110 | case 'src/read_body.php': |
087ce5f8 |
111 | $js =''; |
f3e14140 |
112 | if ($compose_new_win == '1') { |
113 | if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) { |
114 | $compose_width = '640'; |
115 | } |
116 | if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) { |
117 | $compose_height = '550'; |
118 | } |
087ce5f8 |
119 | $js .= "\n".'<script language="JavaScript" type="text/javascript">' . |
f3e14140 |
120 | "\n<!--\n"; |
087ce5f8 |
121 | $js .= "function comp_in_new(comp_uri) {\n". |
122 | " if (!comp_uri) {\n". |
123 | ' comp_uri = "'.$compose_uri."\";\n". |
d7f8e6e6 |
124 | ' }'. "\n". |
d7f8e6e6 |
125 | ' var newwin = window.open(comp_uri' . |
087ce5f8 |
126 | ', "_blank",'. |
127 | '"width='.$compose_width. ',height='.$compose_height. |
602b2bdf |
128 | ',scrollbars=yes,resizable=yes");'."\n". |
087ce5f8 |
129 | "}\n\n"; |
d7f8e6e6 |
130 | |
087ce5f8 |
131 | |
132 | $js .= 'function sendMDN() {'."\n". |
133 | "mdnuri=window.location+'&sendreceipt=1';". |
134 | "var newwin = window.open(mdnuri,'right');". |
135 | "\n}\n\n"; |
136 | |
137 | $js .= "// -->\n". |
138 | "</script>\n"; |
139 | |
140 | } |
5e8de8b6 |
141 | displayHtmlHeader ('SquirrelMail', $js); |
087ce5f8 |
142 | $onload = $xtra; |
f3e14140 |
143 | break; |
d7f8e6e6 |
144 | case 'src/compose.php': |
145 | $js = '<script language="JavaScript" type="text/javascript">' . |
146 | "\n<!--\n" . |
147 | "function checkForm() {\n". |
148 | "var f = document.forms.length;\n". |
149 | "var i = 0;\n". |
150 | "var pos = -1;\n". |
151 | "while( pos == -1 && i < f ) {\n". |
152 | "var e = document.forms[i].elements.length;\n". |
153 | "var j = 0;\n". |
154 | "while( pos == -1 && j < e ) {\n". |
155 | "if ( document.forms[i].elements[j].type == 'text' ) {\n". |
156 | "pos = j;\n". |
157 | "}\n". |
158 | "j++;\n". |
159 | "}\n". |
160 | "i++;\n". |
161 | "}\n". |
162 | "if( pos >= 0 ) {\n". |
163 | "document.forms[i-1].elements[pos].focus();\n". |
164 | "}\n". |
165 | "}\n"; |
166 | |
167 | $js .= "// -->\n". |
168 | "</script>\n"; |
169 | $onload = "onLoad=\"checkForm();\""; |
5e8de8b6 |
170 | displayHtmlHeader ('SquirrelMail', $js); |
d7f8e6e6 |
171 | break; |
172 | |
715225af |
173 | default: |
aaf16822 |
174 | $js = '<script language="JavaScript" type="text/javascript">' . |
353616c4 |
175 | "\n<!--\n" . |
176 | "function checkForm() {\n". |
177 | "var f = document.forms.length;\n". |
178 | "var i = 0;\n". |
179 | "var pos = -1;\n". |
180 | "while( pos == -1 && i < f ) {\n". |
181 | "var e = document.forms[i].elements.length;\n". |
182 | "var j = 0;\n". |
183 | "while( pos == -1 && j < e ) {\n". |
184 | "if ( document.forms[i].elements[j].type == 'text' ) {\n". |
185 | "pos = j;\n". |
186 | "}\n". |
187 | "j++;\n". |
188 | "}\n". |
189 | "i++;\n". |
190 | "}\n". |
191 | "if( pos >= 0 ) {\n". |
192 | "document.forms[i-1].elements[pos].focus();\n". |
193 | "}\n". |
de19cd73 |
194 | "$xtra\n". |
9c3e6cd4 |
195 | "}\n"; |
f3e14140 |
196 | |
9c3e6cd4 |
197 | if ($compose_new_win == '1') { |
07687736 |
198 | if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) { |
199 | $compose_width = '640'; |
9c3e6cd4 |
200 | } |
07687736 |
201 | if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) { |
202 | $compose_height = '550'; |
9c3e6cd4 |
203 | } |
087ce5f8 |
204 | $js .= "function comp_in_new(comp_uri) {\n". |
205 | " if (!comp_uri) {\n". |
206 | ' comp_uri = "'.$compose_uri."\";\n". |
d7f8e6e6 |
207 | ' }'. "\n". |
d7f8e6e6 |
208 | ' var newwin = window.open(comp_uri' . |
087ce5f8 |
209 | ', "_blank",'. |
210 | '"width='.$compose_width. ',height='.$compose_height. |
602b2bdf |
211 | ',scrollbars=yes,resizable=yes");'."\n". |
087ce5f8 |
212 | "}\n\n"; |
213 | |
9c3e6cd4 |
214 | } |
087ce5f8 |
215 | $js .= "// -->\n". "</script>\n"; |
0cba960a |
216 | |
217 | |
715225af |
218 | $onload = "onLoad=\"checkForm();\""; |
5e8de8b6 |
219 | displayHtmlHeader ('SquirrelMail', $js); |
715225af |
220 | break; |
221 | |
222 | } |
223 | |
b01b21d0 |
224 | echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n"; |
a07cd1a4 |
225 | /** Here is the header and wrapping table **/ |
f3e14140 |
226 | $shortBoxName = imap_utf7_decode_local( |
227 | readShortMailboxName($mailbox, $delimiter)); |
3b7d68e6 |
228 | if ( $shortBoxName == 'INBOX' ) { |
7da23762 |
229 | $shortBoxName = _("INBOX"); |
230 | } |
b01b21d0 |
231 | echo "<a name=\"pagetop\"></a>\n" |
232 | . html_tag( 'table', '', '', $color[4], 'border="0" width="100%" cellspacing="0" cellpadding="2"' ) ."\n" |
233 | . html_tag( 'tr', '', '', $color[9] ) ."\n" |
234 | . html_tag( 'td', '', 'left' ) ."\n"; |
5bb2a991 |
235 | if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) { |
b01b21d0 |
236 | echo ' ' . _("Current Folder") . ": <b>$shortBoxName </b>\n"; |
5bb2a991 |
237 | } else { |
238 | echo ' '; |
239 | } |
b01b21d0 |
240 | echo " </td>\n" |
241 | . html_tag( 'td', '', 'right' ) ."<b>\n"; |
80e86e94 |
242 | displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top); |
b01b21d0 |
243 | echo "</b></td>\n" |
244 | . " </tr>\n" |
245 | . html_tag( 'tr', '', '', $color[4] ) ."\n" |
246 | . html_tag( 'td', '', 'left' ) ."\n"; |
a07cd1a4 |
247 | $urlMailbox = urlencode($mailbox); |
9c3e6cd4 |
248 | if ($compose_new_win == '1') { |
087ce5f8 |
249 | echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new()\">". _("Compose"). '</a>'; |
9c3e6cd4 |
250 | } |
251 | else { |
252 | displayInternalLink ("src/compose.php?mailbox=$urlMailbox", _("Compose"), 'right'); |
253 | } |
a07cd1a4 |
254 | echo " \n"; |
255 | displayInternalLink ("src/addressbook.php", _("Addresses"), 'right'); |
256 | echo " \n"; |
257 | displayInternalLink ("src/folders.php", _("Folders"), 'right'); |
258 | echo " \n"; |
259 | displayInternalLink ("src/options.php", _("Options"), 'right'); |
260 | echo " \n"; |
261 | displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"), 'right'); |
262 | echo " \n"; |
263 | displayInternalLink ("src/help.php", _("Help"), 'right'); |
264 | echo " \n"; |
265 | |
266 | do_hook("menuline"); |
267 | |
b01b21d0 |
268 | echo " </td>\n" |
269 | . html_tag( 'td', '', 'right' ) ."\n"; |
1f2eaa02 |
270 | if (!isset($provider_uri)) $provider_uri= 'http://www.squirrelmail.org/'; |
271 | if (!isset($provider_name)) $provider_name= 'SquirrelMail'; |
a07cd1a4 |
272 | echo ($hide_sm_attributions ? ' ' : |
1f2eaa02 |
273 | '<a href="'.$provider_uri.'" target="_blank">'.$provider_name.'</a>'); |
b01b21d0 |
274 | echo "</td>\n". |
275 | " </tr>\n". |
6206f6c4 |
276 | "</table><br>\n\n"; |
a07cd1a4 |
277 | } |
2ba13803 |
278 | |
9c3e6cd4 |
279 | /* blatently copied/truncated/modified from the above function */ |
280 | function compose_Header($color, $mailbox) { |
281 | |
1ba8cd6b |
282 | global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, |
283 | $data_dir, $username, $frame_top, $compose_new_win; |
9c3e6cd4 |
284 | |
9c3e6cd4 |
285 | |
286 | $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 ); |
287 | if (!isset($frame_top)) { |
288 | $frame_top = '_top'; |
289 | } |
290 | |
291 | /* |
292 | Locate the first displayable form element |
293 | */ |
294 | switch ( $module ) { |
295 | case 'src/search.php': |
296 | $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1; |
297 | $onload = "onLoad=\"document.forms[$pos].elements[2].focus();\""; |
aaf16822 |
298 | displayHtmlHeader (_("Compose")); |
9c3e6cd4 |
299 | break; |
300 | default: |
aaf16822 |
301 | $js = '<script language="JavaScript" type="text/javascript">' . |
9c3e6cd4 |
302 | "\n<!--\n" . |
303 | "function checkForm() {\n". |
304 | "var f = document.forms.length;\n". |
305 | "var i = 0;\n". |
306 | "var pos = -1;\n". |
307 | "while( pos == -1 && i < f ) {\n". |
308 | "var e = document.forms[i].elements.length;\n". |
309 | "var j = 0;\n". |
310 | "while( pos == -1 && j < e ) {\n". |
311 | "if ( document.forms[i].elements[j].type == 'text' ) {\n". |
312 | "pos = j;\n". |
313 | "}\n". |
314 | "j++;\n". |
315 | "}\n". |
316 | "i++;\n". |
317 | "}\n". |
318 | "if( pos >= 0 ) {\n". |
319 | "document.forms[i-1].elements[pos].focus();\n". |
320 | "}\n". |
321 | "}\n"; |
aaf16822 |
322 | $js .= "// -->\n". |
de19cd73 |
323 | "</script>\n"; |
9c3e6cd4 |
324 | $onload = "onLoad=\"checkForm();\""; |
aaf16822 |
325 | displayHtmlHeader (_("Compose"), $js); |
9c3e6cd4 |
326 | break; |
327 | |
328 | } |
329 | |
b01b21d0 |
330 | echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n"; |
9c3e6cd4 |
331 | } |
43fdb2a4 |
332 | ?> |