59177427 |
1 | <?php |
7350889b |
2 | |
35586184 |
3 | /** |
4 | * page_header.php |
5 | * |
76911253 |
6 | * Copyright (c) 1999-2003 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='') { |
1d80c108 |
90 | global $use_frames; |
0365891c |
91 | sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION); |
1d80c108 |
92 | if (isset($use_frames) && $use_frames) { |
93 | if ($target != '') |
94 | $target = " target=\"$target\""; |
95 | } else |
96 | $target=''; |
97 | |
d3714d3a |
98 | $hooktext = do_hook_function('internal_link',$text); |
99 | if ($hooktext != '') |
100 | $text = $hooktext; |
d62c4938 |
101 | return '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>'; |
102 | } |
103 | |
8b096f0a |
104 | /** |
105 | * Same as makeInternalLink, but echoes it too |
106 | */ |
d62c4938 |
107 | function displayInternalLink($path, $text, $target='') { |
b26d81e5 |
108 | echo makeInternalLink($path, $text, $target); |
a07cd1a4 |
109 | } |
110 | |
8b096f0a |
111 | /** |
112 | * Outputs a complete SquirrelMail page header, starting with <!doctype> and |
113 | * including the default menu bar. Uses displayHtmlHeader and takes |
114 | * JavaScript and locale settings into account. |
115 | * |
116 | * @param array color the array of theme colors |
117 | * @param string mailbox the current mailbox name to display |
118 | * @param string xtra extra html code to add |
119 | * @param bool session |
120 | * @return void |
121 | */ |
aca403fa |
122 | function displayPageHeader($color, $mailbox, $xtra='', $session=false) { |
715225af |
123 | |
0b97a708 |
124 | global $hide_sm_attributions, $PHP_SELF, $frame_top, |
1ba8cd6b |
125 | $compose_new_win, $compose_width, $compose_height, |
d62c4938 |
126 | $attachemessages, $provider_name, $provider_uri, |
32485e5e |
127 | $javascript_on, $default_use_mdn, $mdn_user_support; |
715225af |
128 | |
0365891c |
129 | sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION ); |
130 | sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION ); |
715225af |
131 | $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 ); |
f3e14140 |
132 | if ($qmark = strpos($module, '?')) { |
133 | $module = substr($module, 0, $qmark); |
134 | } |
d03f3582 |
135 | if (!isset($frame_top)) { |
136 | $frame_top = '_top'; |
137 | } |
715225af |
138 | |
735f6b9c |
139 | if ($session) { |
d68323ff |
140 | $compose_uri = $base_uri.'src/compose.php?mailbox='.urlencode($mailbox).'&attachedmessages=true&session='."$session"; |
aca403fa |
141 | } else { |
087ce5f8 |
142 | $compose_uri = $base_uri.'src/compose.php?newmessage=1'; |
d7f8e6e6 |
143 | $session = 0; |
aca403fa |
144 | } |
d62c4938 |
145 | |
146 | if($javascript_on) { |
147 | |
148 | switch ( $module ) { |
149 | case 'src/read_body.php': |
150 | $js =''; |
32485e5e |
151 | |
152 | // compose in new window code |
d62c4938 |
153 | if ($compose_new_win == '1') { |
154 | if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) { |
155 | $compose_width = '640'; |
156 | } |
157 | if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) { |
158 | $compose_height = '550'; |
159 | } |
d62c4938 |
160 | $js .= "function comp_in_new(comp_uri) {\n". |
161 | " if (!comp_uri) {\n". |
162 | ' comp_uri = "'.$compose_uri."\";\n". |
163 | ' }'. "\n". |
164 | ' var newwin = window.open(comp_uri' . |
165 | ', "_blank",'. |
166 | '"width='.$compose_width. ',height='.$compose_height. |
167 | ',scrollbars=yes,resizable=yes");'."\n". |
168 | "}\n\n"; |
32485e5e |
169 | } |
d62c4938 |
170 | |
32485e5e |
171 | // javascript for sending read receipts |
172 | if($default_use_mdn && $mdn_user_support) { |
d62c4938 |
173 | $js .= 'function sendMDN() {'."\n". |
32485e5e |
174 | " mdnuri=window.location+'&sendreceipt=1'; ". |
d62c4938 |
175 | "var newwin = window.open(mdnuri,'right');". |
176 | "\n}\n\n"; |
32485e5e |
177 | } |
178 | |
179 | // if any of the above passes, add the JS tags too. |
180 | if($js) { |
181 | $js = "\n".'<script language="JavaScript" type="text/javascript">' . |
182 | "\n<!--\n" . $js . "// -->\n</script>\n"; |
183 | } |
d62c4938 |
184 | |
32485e5e |
185 | displayHtmlHeader ('SquirrelMail', $js); |
186 | $onload = $xtra; |
d62c4938 |
187 | break; |
188 | case 'src/compose.php': |
189 | $js = '<script language="JavaScript" type="text/javascript">' . |
190 | "\n<!--\n" . |
9f2f6126 |
191 | "function checkForm() {\n"; |
192 | |
193 | global $action, $reply_focus; |
194 | if (strpos($action, 'reply') !== FALSE && $reply_focus) |
195 | { |
196 | if ($reply_focus == 'select') $js .= "document.forms['compose'].body.select();}\n"; |
197 | else if ($reply_focus == 'focus') $js .= "document.forms['compose'].body.focus();}\n"; |
198 | } |
199 | else |
200 | $js .= "var f = document.forms.length;\n". |
d62c4938 |
201 | "var i = 0;\n". |
202 | "var pos = -1;\n". |
203 | "while( pos == -1 && i < f ) {\n". |
204 | "var e = document.forms[i].elements.length;\n". |
205 | "var j = 0;\n". |
206 | "while( pos == -1 && j < e ) {\n". |
207 | "if ( document.forms[i].elements[j].type == 'text' ) {\n". |
208 | "pos = j;\n". |
209 | "}\n". |
210 | "j++;\n". |
d7f8e6e6 |
211 | "}\n". |
d62c4938 |
212 | "i++;\n". |
d7f8e6e6 |
213 | "}\n". |
d62c4938 |
214 | "if( pos >= 0 ) {\n". |
215 | "document.forms[i-1].elements[pos].focus();\n". |
216 | "}\n". |
217 | "}\n"; |
d7f8e6e6 |
218 | |
d62c4938 |
219 | $js .= "// -->\n". |
220 | "</script>\n"; |
221 | $onload = 'onload="checkForm();"'; |
222 | displayHtmlHeader ('SquirrelMail', $js); |
223 | break; |
224 | |
225 | default: |
226 | $js = '<script language="JavaScript" type="text/javascript">' . |
227 | "\n<!--\n" . |
228 | "function checkForm() {\n". |
229 | "var f = document.forms.length;\n". |
230 | "var i = 0;\n". |
231 | "var pos = -1;\n". |
232 | "while( pos == -1 && i < f ) {\n". |
233 | "var e = document.forms[i].elements.length;\n". |
234 | "var j = 0;\n". |
235 | "while( pos == -1 && j < e ) {\n". |
236 | "if ( document.forms[i].elements[j].type == 'text' " . |
237 | "|| document.forms[i].elements[j].type == 'password' ) {\n". |
238 | "pos = j;\n". |
239 | "}\n". |
240 | "j++;\n". |
353616c4 |
241 | "}\n". |
d62c4938 |
242 | "i++;\n". |
243 | "}\n". |
244 | "if( pos >= 0 ) {\n". |
245 | "document.forms[i-1].elements[pos].focus();\n". |
353616c4 |
246 | "}\n". |
d62c4938 |
247 | "$xtra\n". |
248 | "}\n"; |
f3e14140 |
249 | |
d62c4938 |
250 | if ($compose_new_win == '1') { |
251 | if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) { |
252 | $compose_width = '640'; |
253 | } |
254 | if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) { |
255 | $compose_height = '550'; |
256 | } |
257 | $js .= "function comp_in_new(comp_uri) {\n". |
258 | " if (!comp_uri) {\n". |
259 | ' comp_uri = "'.$compose_uri."\";\n". |
260 | ' }'. "\n". |
261 | ' var newwin = window.open(comp_uri' . |
262 | ', "_blank",'. |
263 | '"width='.$compose_width. ',height='.$compose_height. |
264 | ',scrollbars=yes,resizable=yes");'."\n". |
265 | "}\n\n"; |
266 | |
9c3e6cd4 |
267 | } |
d62c4938 |
268 | $js .= "// -->\n". "</script>\n"; |
0cba960a |
269 | |
d62c4938 |
270 | $onload = 'onload="checkForm();"'; |
271 | displayHtmlHeader ('SquirrelMail', $js); |
272 | break; |
0cba960a |
273 | |
d62c4938 |
274 | } |
275 | } else { |
276 | /* do not use JavaScript */ |
277 | displayHtmlHeader ('SquirrelMail'); |
278 | $onload = ''; |
715225af |
279 | } |
280 | |
b01b21d0 |
281 | echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n"; |
1d80c108 |
282 | noframes_top(); |
283 | |
a07cd1a4 |
284 | /** Here is the header and wrapping table **/ |
f3e14140 |
285 | $shortBoxName = imap_utf7_decode_local( |
286 | readShortMailboxName($mailbox, $delimiter)); |
3b7d68e6 |
287 | if ( $shortBoxName == 'INBOX' ) { |
7da23762 |
288 | $shortBoxName = _("INBOX"); |
289 | } |
b01b21d0 |
290 | echo "<a name=\"pagetop\"></a>\n" |
291 | . html_tag( 'table', '', '', $color[4], 'border="0" width="100%" cellspacing="0" cellpadding="2"' ) ."\n" |
292 | . html_tag( 'tr', '', '', $color[9] ) ."\n" |
293 | . html_tag( 'td', '', 'left' ) ."\n"; |
5bb2a991 |
294 | if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) { |
b01b21d0 |
295 | echo ' ' . _("Current Folder") . ": <b>$shortBoxName </b>\n"; |
5bb2a991 |
296 | } else { |
297 | echo ' '; |
298 | } |
b01b21d0 |
299 | echo " </td>\n" |
300 | . html_tag( 'td', '', 'right' ) ."<b>\n"; |
80e86e94 |
301 | displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top); |
b01b21d0 |
302 | echo "</b></td>\n" |
303 | . " </tr>\n" |
304 | . html_tag( 'tr', '', '', $color[4] ) ."\n" |
99ea51d3 |
305 | . ($hide_sm_attributions ? html_tag( 'td', '', 'left', '', 'colspan="2"' ) |
306 | : html_tag( 'td', '', 'left' ) ) |
307 | . "\n"; |
a07cd1a4 |
308 | $urlMailbox = urlencode($mailbox); |
d62c4938 |
309 | echo makeComposeLink('src/compose.php?mailbox='.$urlMailbox); |
a07cd1a4 |
310 | echo " \n"; |
d68323ff |
311 | displayInternalLink ('src/addressbook.php', _("Addresses"), 'right'); |
a07cd1a4 |
312 | echo " \n"; |
d68323ff |
313 | displayInternalLink ('src/folders.php', _("Folders"), 'right'); |
a07cd1a4 |
314 | echo " \n"; |
d68323ff |
315 | displayInternalLink ('src/options.php', _("Options"), 'right'); |
a07cd1a4 |
316 | echo " \n"; |
317 | displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"), 'right'); |
318 | echo " \n"; |
d68323ff |
319 | displayInternalLink ('src/help.php', _("Help"), 'right'); |
a07cd1a4 |
320 | echo " \n"; |
321 | |
d68323ff |
322 | do_hook('menuline'); |
a07cd1a4 |
323 | |
99ea51d3 |
324 | echo " </td>\n"; |
325 | |
326 | if (!$hide_sm_attributions) |
327 | { |
328 | echo html_tag( 'td', '', 'right' ) ."\n"; |
329 | if (!isset($provider_uri)) $provider_uri= 'http://www.squirrelmail.org/'; |
330 | if (!isset($provider_name)) $provider_name= 'SquirrelMail'; |
331 | echo '<a href="'.$provider_uri.'" target="_blank">'.$provider_name.'</a>'; |
332 | echo "</td>\n"; |
333 | } |
334 | echo " </tr>\n". |
6206f6c4 |
335 | "</table><br>\n\n"; |
a07cd1a4 |
336 | } |
2ba13803 |
337 | |
8b096f0a |
338 | /** |
339 | * Blatantly copied/truncated/modified from displayPageHeader. |
340 | * Outputs a page header specifically for the compose_in_new popup window |
341 | * |
342 | * @param array color the array of theme colors |
343 | * @param string mailbox the current mailbox name to display |
344 | * @return void |
345 | */ |
9c3e6cd4 |
346 | function compose_Header($color, $mailbox) { |
347 | |
d62c4938 |
348 | global $javascript_on; |
9c3e6cd4 |
349 | |
350 | /* |
d62c4938 |
351 | * Locate the first displayable form element (only when JavaScript on) |
352 | */ |
353 | if($javascript_on) { |
354 | global $delimiter, $base_uri, $PHP_SELF, $data_dir, $username; |
355 | |
356 | $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 ); |
357 | |
358 | switch ( $module ) { |
359 | case 'src/search.php': |
360 | $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1; |
361 | $onload = "onload=\"document.forms[$pos].elements[2].focus();\""; |
362 | displayHtmlHeader (_("Compose")); |
363 | break; |
364 | default: |
365 | $js = '<script language="JavaScript" type="text/javascript">' . |
366 | "\n<!--\n" . |
9f2f6126 |
367 | "function checkForm() {\n"; |
368 | |
369 | global $action, $reply_focus; |
370 | if (strpos($action, 'reply') !== FALSE && $reply_focus) |
371 | { |
372 | if ($reply_focus == 'select') $js .= "document.forms['compose'].body.select();}\n"; |
373 | else if ($reply_focus == 'focus') $js .= "document.forms['compose'].body.focus();}\n"; |
374 | } |
375 | else |
376 | $js .= "var f = document.forms.length;\n". |
d62c4938 |
377 | "var i = 0;\n". |
378 | "var pos = -1;\n". |
379 | "while( pos == -1 && i < f ) {\n". |
380 | "var e = document.forms[i].elements.length;\n". |
381 | "var j = 0;\n". |
382 | "while( pos == -1 && j < e ) {\n". |
383 | "if ( document.forms[i].elements[j].type == 'text' ) {\n". |
384 | "pos = j;\n". |
385 | "}\n". |
386 | "j++;\n". |
9c3e6cd4 |
387 | "}\n". |
d62c4938 |
388 | "i++;\n". |
9c3e6cd4 |
389 | "}\n". |
d62c4938 |
390 | "if( pos >= 0 ) {\n". |
391 | "document.forms[i-1].elements[pos].focus();\n". |
392 | "}\n". |
393 | "}\n"; |
394 | $js .= "// -->\n". |
395 | "</script>\n"; |
396 | $onload = 'onload="checkForm();"'; |
397 | displayHtmlHeader (_("Compose"), $js); |
398 | break; |
399 | } |
400 | } else { |
401 | /* javascript off */ |
402 | displayHtmlHeader(_("Compose")); |
403 | $onload = ''; |
9c3e6cd4 |
404 | } |
405 | |
b01b21d0 |
406 | echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n"; |
1d80c108 |
407 | |
408 | |
9c3e6cd4 |
409 | } |
e842b215 |
410 | |
1d80c108 |
411 | ?> |