59177427 |
1 | <?php |
7350889b |
2 | |
35586184 |
3 | /** |
4 | * page_header.php |
5 | * |
82d304a0 |
6 | * Copyright (c) 1999-2004 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$ |
d6c32258 |
12 | * @package squirrelmail |
35586184 |
13 | */ |
14 | |
d6c32258 |
15 | /** Include required files from SM */ |
b68edc75 |
16 | require_once(SM_PATH . 'functions/strings.php'); |
17 | require_once(SM_PATH . 'functions/html.php'); |
18 | require_once(SM_PATH . 'functions/imap_mailbox.php'); |
0b97a708 |
19 | require_once(SM_PATH . 'functions/global.php'); |
b68edc75 |
20 | |
d6c32258 |
21 | /** |
8b096f0a |
22 | * Output a SquirrelMail page header, from <!doctype> to </head> |
23 | * Always set up the language before calling these functions. |
24 | * |
25 | * @param string title the page title, default SquirrelMail. |
26 | * @param string xtra extra HTML to insert into the header |
27 | * @param bool do_hook whether to execute hooks, default true |
28 | * @return void |
d6c32258 |
29 | */ |
a07cd1a4 |
30 | function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE ) { |
e842b215 |
31 | global $squirrelmail_language; |
692155b7 |
32 | |
0365891c |
33 | if ( !sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION) ) { |
0b97a708 |
34 | global $base_uri; |
35 | } |
b6c283c4 |
36 | global $theme_css, $custom_css, $pageheader_sent; |
2c21ef20 |
37 | |
12ff1cab |
38 | echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">' . |
da9a8410 |
39 | "\n\n" . html_tag( 'html' ,'' , '', '', 'lang="'.$squirrelmail_language.'"' ) . "\n<head>\n"; |
2c21ef20 |
40 | |
a714cb95 |
41 | if ( !isset( $custom_css ) || $custom_css == 'none' ) { |
692155b7 |
42 | if ($theme_css != '') { |
d68323ff |
43 | echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"$theme_css\" />"; |
692155b7 |
44 | } |
8f1ba72b |
45 | } else { |
d68323ff |
46 | echo '<link rel="stylesheet" type="text/css" href="' . |
47 | $base_uri . 'themes/css/'.$custom_css.'" />'; |
8f1ba72b |
48 | } |
85f4ce52 |
49 | |
e842b215 |
50 | if ($squirrelmail_language == 'ja_JP') { |
51 | echo "<!-- \xfd\xfe -->\n"; |
da9a8410 |
52 | echo '<meta http-equiv="Content-type" content="text/html; charset=euc-jp">' . "\n"; |
e842b215 |
53 | } |
54 | |
237470b4 |
55 | if ($do_hook) { |
d68323ff |
56 | do_hook('generic_header'); |
237470b4 |
57 | } |
8f1ba72b |
58 | |
5ca4b1ee |
59 | echo "\n<title>$title</title>$xtra\n"; |
60 | |
61 | /* work around IE6's scrollbar bug */ |
62 | echo <<<ECHO |
63 | <style type="text/css"> |
64 | <!-- |
65 | /* avoid stupid IE6 bug with frames and scrollbars */ |
66 | body { |
67 | voice-family: "\"}\""; |
68 | voice-family: inherit; |
69 | width: expression(document.documentElement.clientWidth - 30); |
70 | } |
71 | --> |
72 | </style> |
73 | |
74 | ECHO; |
75 | |
76 | echo "\n</head>\n\n"; |
b6c283c4 |
77 | |
78 | /* this is used to check elsewhere whether we should call this function */ |
79 | $pageheader_sent = TRUE; |
a07cd1a4 |
80 | } |
81 | |
8b096f0a |
82 | /** |
83 | * Given a path to a SquirrelMail file, return a HTML link to it |
84 | * |
85 | * @param string path the SquirrelMail file to link to |
86 | * @param string text the link text |
87 | * @param string target the target frame for this link |
88 | */ |
d62c4938 |
89 | function makeInternalLink($path, $text, $target='') { |
0365891c |
90 | sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION); |
dcc1cc82 |
91 | if ($target != '') { |
92 | $target = " target=\"$target\""; |
93 | } |
d3714d3a |
94 | $hooktext = do_hook_function('internal_link',$text); |
95 | if ($hooktext != '') |
96 | $text = $hooktext; |
d62c4938 |
97 | return '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>'; |
98 | } |
99 | |
8b096f0a |
100 | /** |
101 | * Same as makeInternalLink, but echoes it too |
102 | */ |
d62c4938 |
103 | function displayInternalLink($path, $text, $target='') { |
b26d81e5 |
104 | echo makeInternalLink($path, $text, $target); |
a07cd1a4 |
105 | } |
106 | |
8b096f0a |
107 | /** |
108 | * Outputs a complete SquirrelMail page header, starting with <!doctype> and |
109 | * including the default menu bar. Uses displayHtmlHeader and takes |
110 | * JavaScript and locale settings into account. |
111 | * |
112 | * @param array color the array of theme colors |
113 | * @param string mailbox the current mailbox name to display |
114 | * @param string xtra extra html code to add |
115 | * @param bool session |
116 | * @return void |
117 | */ |
aca403fa |
118 | function displayPageHeader($color, $mailbox, $xtra='', $session=false) { |
715225af |
119 | |
0b97a708 |
120 | global $hide_sm_attributions, $PHP_SELF, $frame_top, |
1ba8cd6b |
121 | $compose_new_win, $compose_width, $compose_height, |
d62c4938 |
122 | $attachemessages, $provider_name, $provider_uri, |
95878c5e |
123 | $javascript_on, $default_use_mdn, $mdn_user_support, |
124 | $startMessage; |
715225af |
125 | |
0365891c |
126 | sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION ); |
127 | sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION ); |
715225af |
128 | $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 ); |
f3e14140 |
129 | if ($qmark = strpos($module, '?')) { |
130 | $module = substr($module, 0, $qmark); |
131 | } |
d03f3582 |
132 | if (!isset($frame_top)) { |
133 | $frame_top = '_top'; |
134 | } |
715225af |
135 | |
735f6b9c |
136 | if ($session) { |
d68323ff |
137 | $compose_uri = $base_uri.'src/compose.php?mailbox='.urlencode($mailbox).'&attachedmessages=true&session='."$session"; |
aca403fa |
138 | } else { |
087ce5f8 |
139 | $compose_uri = $base_uri.'src/compose.php?newmessage=1'; |
d7f8e6e6 |
140 | $session = 0; |
aca403fa |
141 | } |
d62c4938 |
142 | |
143 | if($javascript_on) { |
144 | |
145 | switch ( $module ) { |
146 | case 'src/read_body.php': |
147 | $js =''; |
32485e5e |
148 | |
149 | // compose in new window code |
d62c4938 |
150 | if ($compose_new_win == '1') { |
151 | if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) { |
152 | $compose_width = '640'; |
153 | } |
154 | if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) { |
155 | $compose_height = '550'; |
156 | } |
d62c4938 |
157 | $js .= "function comp_in_new(comp_uri) {\n". |
158 | " if (!comp_uri) {\n". |
159 | ' comp_uri = "'.$compose_uri."\";\n". |
160 | ' }'. "\n". |
161 | ' var newwin = window.open(comp_uri' . |
162 | ', "_blank",'. |
163 | '"width='.$compose_width. ',height='.$compose_height. |
164 | ',scrollbars=yes,resizable=yes");'."\n". |
165 | "}\n\n"; |
32485e5e |
166 | } |
d62c4938 |
167 | |
32485e5e |
168 | // javascript for sending read receipts |
169 | if($default_use_mdn && $mdn_user_support) { |
d62c4938 |
170 | $js .= 'function sendMDN() {'."\n". |
32485e5e |
171 | " mdnuri=window.location+'&sendreceipt=1'; ". |
d62c4938 |
172 | "var newwin = window.open(mdnuri,'right');". |
173 | "\n}\n\n"; |
32485e5e |
174 | } |
175 | |
176 | // if any of the above passes, add the JS tags too. |
177 | if($js) { |
178 | $js = "\n".'<script language="JavaScript" type="text/javascript">' . |
179 | "\n<!--\n" . $js . "// -->\n</script>\n"; |
180 | } |
d62c4938 |
181 | |
32485e5e |
182 | displayHtmlHeader ('SquirrelMail', $js); |
183 | $onload = $xtra; |
d62c4938 |
184 | break; |
185 | case 'src/compose.php': |
186 | $js = '<script language="JavaScript" type="text/javascript">' . |
187 | "\n<!--\n" . |
9f2f6126 |
188 | "function checkForm() {\n"; |
189 | |
190 | global $action, $reply_focus; |
191 | if (strpos($action, 'reply') !== FALSE && $reply_focus) |
192 | { |
193 | if ($reply_focus == 'select') $js .= "document.forms['compose'].body.select();}\n"; |
194 | else if ($reply_focus == 'focus') $js .= "document.forms['compose'].body.focus();}\n"; |
195 | } |
196 | else |
197 | $js .= "var f = document.forms.length;\n". |
d62c4938 |
198 | "var i = 0;\n". |
199 | "var pos = -1;\n". |
200 | "while( pos == -1 && i < f ) {\n". |
201 | "var e = document.forms[i].elements.length;\n". |
202 | "var j = 0;\n". |
203 | "while( pos == -1 && j < e ) {\n". |
204 | "if ( document.forms[i].elements[j].type == 'text' ) {\n". |
205 | "pos = j;\n". |
206 | "}\n". |
207 | "j++;\n". |
d7f8e6e6 |
208 | "}\n". |
d62c4938 |
209 | "i++;\n". |
d7f8e6e6 |
210 | "}\n". |
d62c4938 |
211 | "if( pos >= 0 ) {\n". |
212 | "document.forms[i-1].elements[pos].focus();\n". |
213 | "}\n". |
214 | "}\n"; |
d7f8e6e6 |
215 | |
d62c4938 |
216 | $js .= "// -->\n". |
217 | "</script>\n"; |
218 | $onload = 'onload="checkForm();"'; |
219 | displayHtmlHeader ('SquirrelMail', $js); |
220 | break; |
221 | |
222 | default: |
223 | $js = '<script language="JavaScript" type="text/javascript">' . |
224 | "\n<!--\n" . |
225 | "function checkForm() {\n". |
226 | "var f = document.forms.length;\n". |
227 | "var i = 0;\n". |
228 | "var pos = -1;\n". |
229 | "while( pos == -1 && i < f ) {\n". |
230 | "var e = document.forms[i].elements.length;\n". |
231 | "var j = 0;\n". |
232 | "while( pos == -1 && j < e ) {\n". |
233 | "if ( document.forms[i].elements[j].type == 'text' " . |
234 | "|| document.forms[i].elements[j].type == 'password' ) {\n". |
235 | "pos = j;\n". |
236 | "}\n". |
237 | "j++;\n". |
353616c4 |
238 | "}\n". |
d62c4938 |
239 | "i++;\n". |
240 | "}\n". |
241 | "if( pos >= 0 ) {\n". |
242 | "document.forms[i-1].elements[pos].focus();\n". |
353616c4 |
243 | "}\n". |
d62c4938 |
244 | "$xtra\n". |
245 | "}\n"; |
f3e14140 |
246 | |
d62c4938 |
247 | if ($compose_new_win == '1') { |
248 | if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) { |
249 | $compose_width = '640'; |
250 | } |
251 | if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) { |
252 | $compose_height = '550'; |
253 | } |
254 | $js .= "function comp_in_new(comp_uri) {\n". |
255 | " if (!comp_uri) {\n". |
256 | ' comp_uri = "'.$compose_uri."\";\n". |
257 | ' }'. "\n". |
258 | ' var newwin = window.open(comp_uri' . |
259 | ', "_blank",'. |
260 | '"width='.$compose_width. ',height='.$compose_height. |
261 | ',scrollbars=yes,resizable=yes");'."\n". |
262 | "}\n\n"; |
263 | |
9c3e6cd4 |
264 | } |
d62c4938 |
265 | $js .= "// -->\n". "</script>\n"; |
0cba960a |
266 | |
d62c4938 |
267 | $onload = 'onload="checkForm();"'; |
268 | displayHtmlHeader ('SquirrelMail', $js); |
269 | break; |
0cba960a |
270 | |
d62c4938 |
271 | } |
272 | } else { |
273 | /* do not use JavaScript */ |
274 | displayHtmlHeader ('SquirrelMail'); |
275 | $onload = ''; |
715225af |
276 | } |
277 | |
b01b21d0 |
278 | echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n"; |
a07cd1a4 |
279 | /** Here is the header and wrapping table **/ |
f3e14140 |
280 | $shortBoxName = imap_utf7_decode_local( |
281 | readShortMailboxName($mailbox, $delimiter)); |
3b7d68e6 |
282 | if ( $shortBoxName == 'INBOX' ) { |
7da23762 |
283 | $shortBoxName = _("INBOX"); |
284 | } |
b01b21d0 |
285 | echo "<a name=\"pagetop\"></a>\n" |
286 | . html_tag( 'table', '', '', $color[4], 'border="0" width="100%" cellspacing="0" cellpadding="2"' ) ."\n" |
287 | . html_tag( 'tr', '', '', $color[9] ) ."\n" |
288 | . html_tag( 'td', '', 'left' ) ."\n"; |
5bb2a991 |
289 | if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) { |
b01b21d0 |
290 | echo ' ' . _("Current Folder") . ": <b>$shortBoxName </b>\n"; |
5bb2a991 |
291 | } else { |
292 | echo ' '; |
293 | } |
b01b21d0 |
294 | echo " </td>\n" |
295 | . html_tag( 'td', '', 'right' ) ."<b>\n"; |
80e86e94 |
296 | displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top); |
b01b21d0 |
297 | echo "</b></td>\n" |
298 | . " </tr>\n" |
299 | . html_tag( 'tr', '', '', $color[4] ) ."\n" |
99ea51d3 |
300 | . ($hide_sm_attributions ? html_tag( 'td', '', 'left', '', 'colspan="2"' ) |
301 | : html_tag( 'td', '', 'left' ) ) |
302 | . "\n"; |
a07cd1a4 |
303 | $urlMailbox = urlencode($mailbox); |
95878c5e |
304 | echo makeComposeLink('src/compose.php?mailbox='.$urlMailbox.'&startMessage='.$startMessage); |
a07cd1a4 |
305 | echo " \n"; |
21a957a9 |
306 | displayInternalLink ('src/addressbook.php', _("Addresses")); |
a07cd1a4 |
307 | echo " \n"; |
21a957a9 |
308 | displayInternalLink ('src/folders.php', _("Folders")); |
a07cd1a4 |
309 | echo " \n"; |
21a957a9 |
310 | displayInternalLink ('src/options.php', _("Options")); |
a07cd1a4 |
311 | echo " \n"; |
21a957a9 |
312 | displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search")); |
a07cd1a4 |
313 | echo " \n"; |
21a957a9 |
314 | displayInternalLink ('src/help.php', _("Help")); |
a07cd1a4 |
315 | echo " \n"; |
316 | |
d68323ff |
317 | do_hook('menuline'); |
a07cd1a4 |
318 | |
99ea51d3 |
319 | echo " </td>\n"; |
320 | |
321 | if (!$hide_sm_attributions) |
322 | { |
323 | echo html_tag( 'td', '', 'right' ) ."\n"; |
324 | if (!isset($provider_uri)) $provider_uri= 'http://www.squirrelmail.org/'; |
325 | if (!isset($provider_name)) $provider_name= 'SquirrelMail'; |
326 | echo '<a href="'.$provider_uri.'" target="_blank">'.$provider_name.'</a>'; |
327 | echo "</td>\n"; |
328 | } |
329 | echo " </tr>\n". |
6206f6c4 |
330 | "</table><br>\n\n"; |
a07cd1a4 |
331 | } |
2ba13803 |
332 | |
8b096f0a |
333 | /** |
334 | * Blatantly copied/truncated/modified from displayPageHeader. |
335 | * Outputs a page header specifically for the compose_in_new popup window |
336 | * |
337 | * @param array color the array of theme colors |
338 | * @param string mailbox the current mailbox name to display |
339 | * @return void |
340 | */ |
9c3e6cd4 |
341 | function compose_Header($color, $mailbox) { |
342 | |
d62c4938 |
343 | global $javascript_on; |
9c3e6cd4 |
344 | |
345 | /* |
d62c4938 |
346 | * Locate the first displayable form element (only when JavaScript on) |
347 | */ |
348 | if($javascript_on) { |
349 | global $delimiter, $base_uri, $PHP_SELF, $data_dir, $username; |
350 | |
351 | $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 ); |
352 | |
353 | switch ( $module ) { |
354 | case 'src/search.php': |
355 | $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1; |
356 | $onload = "onload=\"document.forms[$pos].elements[2].focus();\""; |
357 | displayHtmlHeader (_("Compose")); |
358 | break; |
359 | default: |
360 | $js = '<script language="JavaScript" type="text/javascript">' . |
361 | "\n<!--\n" . |
9f2f6126 |
362 | "function checkForm() {\n"; |
363 | |
364 | global $action, $reply_focus; |
365 | if (strpos($action, 'reply') !== FALSE && $reply_focus) |
366 | { |
367 | if ($reply_focus == 'select') $js .= "document.forms['compose'].body.select();}\n"; |
368 | else if ($reply_focus == 'focus') $js .= "document.forms['compose'].body.focus();}\n"; |
369 | } |
370 | else |
371 | $js .= "var f = document.forms.length;\n". |
d62c4938 |
372 | "var i = 0;\n". |
373 | "var pos = -1;\n". |
374 | "while( pos == -1 && i < f ) {\n". |
375 | "var e = document.forms[i].elements.length;\n". |
376 | "var j = 0;\n". |
377 | "while( pos == -1 && j < e ) {\n". |
378 | "if ( document.forms[i].elements[j].type == 'text' ) {\n". |
379 | "pos = j;\n". |
380 | "}\n". |
381 | "j++;\n". |
9c3e6cd4 |
382 | "}\n". |
d62c4938 |
383 | "i++;\n". |
9c3e6cd4 |
384 | "}\n". |
d62c4938 |
385 | "if( pos >= 0 ) {\n". |
386 | "document.forms[i-1].elements[pos].focus();\n". |
387 | "}\n". |
388 | "}\n"; |
389 | $js .= "// -->\n". |
390 | "</script>\n"; |
391 | $onload = 'onload="checkForm();"'; |
392 | displayHtmlHeader (_("Compose"), $js); |
393 | break; |
394 | } |
395 | } else { |
396 | /* javascript off */ |
397 | displayHtmlHeader(_("Compose")); |
398 | $onload = ''; |
9c3e6cd4 |
399 | } |
400 | |
b01b21d0 |
401 | echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n"; |
9c3e6cd4 |
402 | } |
e842b215 |
403 | |
dcc1cc82 |
404 | ?> |