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