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