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