page_header.php 11 KB

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