page_header.php 11 KB

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