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