| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * page_header.php |
| 5 | * |
| 6 | * Copyright (c) 1999-2002 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('../functions/strings.php'); |
| 15 | //require_once('../functions/imap_utf7_decode_local.php'); |
| 16 | require_once('../functions/html.php'); |
| 17 | require_once('../functions/imap_mailbox.php'); |
| 18 | /* Always set up the language before calling these functions */ |
| 19 | function displayHtmlHeader( $title = 'SquirrelMail', $xtra = '', $do_hook = TRUE ) { |
| 20 | |
| 21 | global $theme_css, $custom_css, $base_uri; |
| 22 | |
| 23 | echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">' . |
| 24 | "\n\n<HTML>\n<HEAD>\n"; |
| 25 | |
| 26 | if ( !isset( $custom_css ) || $custom_css == 'none' ) { |
| 27 | if ($theme_css != '') { |
| 28 | echo "<LINK REL=\"stylesheet\" TYPE=\"text/css\" HREF=\"$theme_css\">"; |
| 29 | } |
| 30 | } else { |
| 31 | echo '<LINK REL="stylesheet" TYPE="text/css" HREF="' . |
| 32 | $base_uri . 'themes/css/'.$custom_css.'">'; |
| 33 | } |
| 34 | |
| 35 | if ($do_hook) { |
| 36 | do_hook("generic_header"); |
| 37 | } |
| 38 | |
| 39 | echo "\n<title>$title</title>$xtra</head>\n\n"; |
| 40 | } |
| 41 | |
| 42 | |
| 43 | function displayInternalLink($path, $text, $target='') { |
| 44 | global $base_uri; |
| 45 | |
| 46 | if ($target != '') { |
| 47 | $target = " target=\"$target\""; |
| 48 | } |
| 49 | echo '<a href="'.$base_uri.$path.'"'.$target.'>'.$text.'</a>'; |
| 50 | } |
| 51 | |
| 52 | function displayPageHeader($color, $mailbox, $xtra='', $session=false) { |
| 53 | |
| 54 | global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, $frame_top, |
| 55 | $compose_new_win, $username, $datadir, $compose_width, $compose_height, |
| 56 | $attachemessages, $session; |
| 57 | |
| 58 | $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 ); |
| 59 | if ($qmark = strpos($module, '?')) { |
| 60 | $module = substr($module, 0, $qmark); |
| 61 | } |
| 62 | if (!isset($frame_top)) { |
| 63 | $frame_top = '_top'; |
| 64 | } |
| 65 | |
| 66 | if ($session != false) { |
| 67 | $compose_uri = $base_uri.'src/compose.php?mailbox='. urlencode($mailbox).'&attachedmessages=true&session='."$session"; |
| 68 | } else { |
| 69 | $compose_uri = $base_uri.'src/compose.php?newmessage=1'; |
| 70 | $session = 0; |
| 71 | } |
| 72 | |
| 73 | switch ( $module ) { |
| 74 | case 'src/read_body.php': |
| 75 | $js =''; |
| 76 | if ($compose_new_win == '1') { |
| 77 | if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) { |
| 78 | $compose_width = '640'; |
| 79 | } |
| 80 | if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) { |
| 81 | $compose_height = '550'; |
| 82 | } |
| 83 | $js .= "\n".'<script language="JavaScript" type="text/javascript">' . |
| 84 | "\n<!--\n"; |
| 85 | $js .= "function comp_in_new(comp_uri) {\n". |
| 86 | " if (!comp_uri) {\n". |
| 87 | ' comp_uri = "'.$compose_uri."\";\n". |
| 88 | ' }'. "\n". |
| 89 | ' var newwin = window.open(comp_uri' . |
| 90 | ', "_blank",'. |
| 91 | '"width='.$compose_width. ',height='.$compose_height. |
| 92 | ',scrollbars=yes,resizable=yes");'."\n". |
| 93 | "}\n\n"; |
| 94 | |
| 95 | |
| 96 | $js .= 'function sendMDN() {'."\n". |
| 97 | "mdnuri=window.location+'&sendreceipt=1';". |
| 98 | "var newwin = window.open(mdnuri,'right');". |
| 99 | "\n}\n\n"; |
| 100 | |
| 101 | $js .= "// -->\n". |
| 102 | "</script>\n"; |
| 103 | |
| 104 | } |
| 105 | displayHtmlHeader ('Squirrelmail', $js); |
| 106 | $onload = $xtra; |
| 107 | break; |
| 108 | case 'src/compose.php': |
| 109 | $js = '<script language="JavaScript" type="text/javascript">' . |
| 110 | "\n<!--\n" . |
| 111 | "function checkForm() {\n". |
| 112 | "var f = document.forms.length;\n". |
| 113 | "var i = 0;\n". |
| 114 | "var pos = -1;\n". |
| 115 | "while( pos == -1 && i < f ) {\n". |
| 116 | "var e = document.forms[i].elements.length;\n". |
| 117 | "var j = 0;\n". |
| 118 | "while( pos == -1 && j < e ) {\n". |
| 119 | "if ( document.forms[i].elements[j].type == 'text' ) {\n". |
| 120 | "pos = j;\n". |
| 121 | "}\n". |
| 122 | "j++;\n". |
| 123 | "}\n". |
| 124 | "i++;\n". |
| 125 | "}\n". |
| 126 | "if( pos >= 0 ) {\n". |
| 127 | "document.forms[i-1].elements[pos].focus();\n". |
| 128 | "}\n". |
| 129 | "}\n"; |
| 130 | |
| 131 | $js .= "// -->\n". |
| 132 | "</script>\n"; |
| 133 | $onload = "onLoad=\"checkForm();\""; |
| 134 | displayHtmlHeader ('Squirrelmail', $js); |
| 135 | break; |
| 136 | |
| 137 | default: |
| 138 | $js = '<script language="JavaScript" type="text/javascript">' . |
| 139 | "\n<!--\n" . |
| 140 | "function checkForm() {\n". |
| 141 | "var f = document.forms.length;\n". |
| 142 | "var i = 0;\n". |
| 143 | "var pos = -1;\n". |
| 144 | "while( pos == -1 && i < f ) {\n". |
| 145 | "var e = document.forms[i].elements.length;\n". |
| 146 | "var j = 0;\n". |
| 147 | "while( pos == -1 && j < e ) {\n". |
| 148 | "if ( document.forms[i].elements[j].type == 'text' ) {\n". |
| 149 | "pos = j;\n". |
| 150 | "}\n". |
| 151 | "j++;\n". |
| 152 | "}\n". |
| 153 | "i++;\n". |
| 154 | "}\n". |
| 155 | "if( pos >= 0 ) {\n". |
| 156 | "document.forms[i-1].elements[pos].focus();\n". |
| 157 | "}\n". |
| 158 | "$xtra\n". |
| 159 | "}\n"; |
| 160 | |
| 161 | if ($compose_new_win == '1') { |
| 162 | if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) { |
| 163 | $compose_width = '640'; |
| 164 | } |
| 165 | if (!preg_match("/^[0-9]{3,4}$/", $compose_height)) { |
| 166 | $compose_height = '550'; |
| 167 | } |
| 168 | $js .= "function comp_in_new(comp_uri) {\n". |
| 169 | " if (!comp_uri) {\n". |
| 170 | ' comp_uri = "'.$compose_uri."\";\n". |
| 171 | ' }'. "\n". |
| 172 | ' var newwin = window.open(comp_uri' . |
| 173 | ', "_blank",'. |
| 174 | '"width='.$compose_width. ',height='.$compose_height. |
| 175 | ',scrollbars=yes,resizable=yes");'."\n". |
| 176 | "}\n\n"; |
| 177 | |
| 178 | } |
| 179 | $js .= "// -->\n". "</script>\n"; |
| 180 | |
| 181 | |
| 182 | $onload = "onLoad=\"checkForm();\""; |
| 183 | displayHtmlHeader ('Squirrelmail', $js); |
| 184 | break; |
| 185 | |
| 186 | } |
| 187 | |
| 188 | echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n"; |
| 189 | /** Here is the header and wrapping table **/ |
| 190 | $shortBoxName = imap_utf7_decode_local( |
| 191 | readShortMailboxName($mailbox, $delimiter)); |
| 192 | if ( $shortBoxName == 'INBOX' ) { |
| 193 | $shortBoxName = _("INBOX"); |
| 194 | } |
| 195 | echo "<a name=\"pagetop\"></a>\n" |
| 196 | . html_tag( 'table', '', '', $color[4], 'border="0" width="100%" cellspacing="0" cellpadding="2"' ) ."\n" |
| 197 | . html_tag( 'tr', '', '', $color[9] ) ."\n" |
| 198 | . html_tag( 'td', '', 'left' ) ."\n"; |
| 199 | if ( $shortBoxName <> '' && strtolower( $shortBoxName ) <> 'none' ) { |
| 200 | echo ' ' . _("Current Folder") . ": <b>$shortBoxName </b>\n"; |
| 201 | } else { |
| 202 | echo ' '; |
| 203 | } |
| 204 | echo " </td>\n" |
| 205 | . html_tag( 'td', '', 'right' ) ."<b>\n"; |
| 206 | displayInternalLink ('src/signout.php', _("Sign Out"), $frame_top); |
| 207 | echo "</b></td>\n" |
| 208 | . " </tr>\n" |
| 209 | . html_tag( 'tr', '', '', $color[4] ) ."\n" |
| 210 | . html_tag( 'td', '', 'left' ) ."\n"; |
| 211 | $urlMailbox = urlencode($mailbox); |
| 212 | if ($compose_new_win == '1') { |
| 213 | echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new()\">". _("Compose"). '</a>'; |
| 214 | } |
| 215 | else { |
| 216 | displayInternalLink ("src/compose.php?mailbox=$urlMailbox", _("Compose"), 'right'); |
| 217 | } |
| 218 | echo " \n"; |
| 219 | displayInternalLink ("src/addressbook.php", _("Addresses"), 'right'); |
| 220 | echo " \n"; |
| 221 | displayInternalLink ("src/folders.php", _("Folders"), 'right'); |
| 222 | echo " \n"; |
| 223 | displayInternalLink ("src/options.php", _("Options"), 'right'); |
| 224 | echo " \n"; |
| 225 | displayInternalLink ("src/search.php?mailbox=$urlMailbox", _("Search"), 'right'); |
| 226 | echo " \n"; |
| 227 | displayInternalLink ("src/help.php", _("Help"), 'right'); |
| 228 | echo " \n"; |
| 229 | |
| 230 | do_hook("menuline"); |
| 231 | |
| 232 | echo " </td>\n" |
| 233 | . html_tag( 'td', '', 'right' ) ."\n"; |
| 234 | echo ($hide_sm_attributions ? ' ' : |
| 235 | '<a href="http://www.squirrelmail.org/" target="_blank">SquirrelMail</a>'); |
| 236 | echo "</td>\n". |
| 237 | " </tr>\n". |
| 238 | "</table><br>\n\n"; |
| 239 | } |
| 240 | |
| 241 | /* blatently copied/truncated/modified from the above function */ |
| 242 | function compose_Header($color, $mailbox) { |
| 243 | |
| 244 | global $delimiter, $hide_sm_attributions, $base_uri, $PHP_SELF, $frame_top, $compose_new_win; |
| 245 | |
| 246 | |
| 247 | $module = substr( $PHP_SELF, ( strlen( $PHP_SELF ) - strlen( $base_uri ) ) * -1 ); |
| 248 | if (!isset($frame_top)) { |
| 249 | $frame_top = '_top'; |
| 250 | } |
| 251 | |
| 252 | /* |
| 253 | Locate the first displayable form element |
| 254 | */ |
| 255 | switch ( $module ) { |
| 256 | case 'src/search.php': |
| 257 | $pos = getPref($data_dir, $username, 'search_pos', 0 ) - 1; |
| 258 | $onload = "onLoad=\"document.forms[$pos].elements[2].focus();\""; |
| 259 | displayHtmlHeader (_("Compose")); |
| 260 | break; |
| 261 | default: |
| 262 | $js = '<script language="JavaScript" type="text/javascript">' . |
| 263 | "\n<!--\n" . |
| 264 | "function checkForm() {\n". |
| 265 | "var f = document.forms.length;\n". |
| 266 | "var i = 0;\n". |
| 267 | "var pos = -1;\n". |
| 268 | "while( pos == -1 && i < f ) {\n". |
| 269 | "var e = document.forms[i].elements.length;\n". |
| 270 | "var j = 0;\n". |
| 271 | "while( pos == -1 && j < e ) {\n". |
| 272 | "if ( document.forms[i].elements[j].type == 'text' ) {\n". |
| 273 | "pos = j;\n". |
| 274 | "}\n". |
| 275 | "j++;\n". |
| 276 | "}\n". |
| 277 | "i++;\n". |
| 278 | "}\n". |
| 279 | "if( pos >= 0 ) {\n". |
| 280 | "document.forms[i-1].elements[pos].focus();\n". |
| 281 | "}\n". |
| 282 | "}\n"; |
| 283 | $js .= "// -->\n". |
| 284 | "</script>\n"; |
| 285 | $onload = "onLoad=\"checkForm();\""; |
| 286 | displayHtmlHeader (_("Compose"), $js); |
| 287 | break; |
| 288 | |
| 289 | } |
| 290 | |
| 291 | echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n"; |
| 292 | } |
| 293 | ?> |