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