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