page_header.php 11 KB

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