page_header.php 11 KB

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