display_messages.php 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <?php
  2. /**
  3. * display_messages.php
  4. *
  5. * Copyright (c) 1999-2004 The SquirrelMail Project Team
  6. * Licensed under the GNU GPL. For full terms see the file COPYING.
  7. *
  8. * This contains all messages, including information, error, and just
  9. * about any other message you can think of.
  10. *
  11. * @version $Id$
  12. * @package squirrelmail
  13. */
  14. /**
  15. * including plugin functions
  16. */
  17. require_once(SM_PATH . 'functions/plugin.php');
  18. /**
  19. * Find out where squirrelmail lives and try to be smart about it.
  20. * The only problem would be when squirrelmail lives in directories
  21. * called "src", "functions", or "plugins", but people who do that need
  22. * to be beaten with a steel pipe anyway.
  23. *
  24. * @return string the base uri of squirrelmail installation.
  25. */
  26. function sqm_baseuri(){
  27. global $base_uri, $PHP_SELF;
  28. /**
  29. * If it is in the session, just return it.
  30. */
  31. if (isset($base_uri)){
  32. return $base_uri;
  33. }
  34. $dirs = array('|src/.*|', '|plugins/.*|', '|functions/.*|');
  35. $repl = array('', '', '');
  36. $base_uri = preg_replace($dirs, $repl, $PHP_SELF);
  37. return $base_uri;
  38. }
  39. function error_message($message, $mailbox, $sort, $startMessage, $color) {
  40. $urlMailbox = urlencode($mailbox);
  41. $string = '<tr><td ALIGN="center">' . $message . '</td></tr>'."\n".
  42. '<tr><td ALIGN="center">'.
  43. '<A HREF="' . sqm_baseuri()
  44. . "src/right_main.php?sort=$sort&amp;startMessage=$startMessage"
  45. . "&amp;mailbox=$urlMailbox\">" .
  46. sprintf (_("Click here to return to %s"), strtoupper($mailbox) == 'INBOX' ? _("INBOX") : imap_utf7_decode_local($mailbox)) .
  47. '</A></td></tr>';
  48. error_box($string, $color);
  49. }
  50. function plain_error_message($message, $color) {
  51. error_box($message, $color);
  52. }
  53. function logout_error( $errString, $errTitle = '' ) {
  54. global $frame_top, $org_logo, $org_name, $org_logo_width, $org_logo_height,
  55. $hide_sm_attributions, $version, $squirrelmail_language;
  56. $base_uri = sqm_baseuri();
  57. include_once( SM_PATH . 'functions/page_header.php' );
  58. if ( !isset( $org_logo ) ) {
  59. // Don't know yet why, but in some accesses $org_logo is not set.
  60. include( SM_PATH . 'config/config.php' );
  61. }
  62. /* Display width and height like good little people */
  63. $width_and_height = '';
  64. if (isset($org_logo_width) && is_numeric($org_logo_width) && $org_logo_width>0) {
  65. $width_and_height = " WIDTH=\"$org_logo_width\"";
  66. }
  67. if (isset($org_logo_height) && is_numeric($org_logo_height) && $org_logo_height>0) {
  68. $width_and_height .= " HEIGHT=\"$org_logo_height\"";
  69. }
  70. if (!isset($frame_top) || $frame_top == '' ) {
  71. $frame_top = '_top';
  72. }
  73. if ( !isset( $color ) ) {
  74. $color = array();
  75. $color[0] = '#DCDCDC'; /* light gray TitleBar */
  76. $color[1] = '#800000'; /* red */
  77. $color[2] = '#CC0000'; /* light red Warning/Error Messages */
  78. $color[4] = '#FFFFFF'; /* white Normal Background */
  79. $color[7] = '#0000CC'; /* blue Links */
  80. $color[8] = '#000000'; /* black Normal text */
  81. }
  82. list($junk, $errString, $errTitle) = do_hook('logout_error', $errString, $errTitle);
  83. if ( $errTitle == '' ) {
  84. $errTitle = $errString;
  85. }
  86. set_up_language($squirrelmail_language, true);
  87. displayHtmlHeader( $errTitle, '', false );
  88. echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n\n" .
  89. '<CENTER>';
  90. if (isset($org_logo) && ($org_logo != '')) {
  91. echo "<IMG SRC=\"$org_logo\" ALT=\"" . sprintf(_("%s Logo"), $org_name) .
  92. "\"$width_and_height><BR>\n";
  93. }
  94. echo ( $hide_sm_attributions ? '' :
  95. '<SMALL>' . sprintf (_("SquirrelMail version %s"), $version) . "<BR>\n".
  96. ' ' . _("By the SquirrelMail Development Team") . "<BR></SMALL>\n" ) .
  97. "<table cellspacing=1 cellpadding=0 bgcolor=\"$color[1]\" width=\"70%\"><tr><td>".
  98. "<TABLE WIDTH=\"100%\" BORDER=\"0\" BGCOLOR=\"$color[4]\" ALIGN=CENTER>".
  99. "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=\"center\">".
  100. "<FONT COLOR=\"$color[2]\"><B>" . _("ERROR") .
  101. '</B></FONT></TD></TR>'.
  102. '<TR><TD ALIGN="center">' . $errString . '</TD></TR>'.
  103. "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=\"center\">".
  104. "<FONT COLOR=\"$color[2]\"><B>".
  105. '<a href="' . $base_uri . 'src/login.php" target="' .
  106. $frame_top . '">' .
  107. _("Go to the login page") . "</a></B></FONT>".
  108. '</TD></TR>'.
  109. '</TABLE></td></tr></table></center></body></html>';
  110. }
  111. function error_box($string, $color) {
  112. global $pageheader_sent;
  113. if ( !isset( $color ) ) {
  114. $color = array();
  115. $color[0] = '#DCDCDC'; /* light gray TitleBar */
  116. $color[1] = '#800000'; /* red */
  117. $color[2] = '#CC0000'; /* light red Warning/Error Messages */
  118. $color[4] = '#FFFFFF'; /* white Normal Background */
  119. $color[7] = '#0000CC'; /* blue Links */
  120. $color[8] = '#000000'; /* black Normal text */
  121. }
  122. $err = _("ERROR");
  123. $ret = concat_hook_function('error_box', $string);
  124. if($ret != '') {
  125. $string = $ret;
  126. }
  127. /* check if the page header has been sent; if not, send it! */
  128. if(!isset($pageheader_sent) && !$pageheader_sent) {
  129. /* include this just to be sure */
  130. include_once( SM_PATH . 'functions/page_header.php' );
  131. displayHtmlHeader('SquirrelMail: '.$err);
  132. $pageheader_sent = TRUE;
  133. echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\">\n\n";
  134. }
  135. echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center"'.' border="0" bgcolor="'.$color[9].'">';
  136. echo ' <tr><td>';
  137. echo ' <table width="100%" cellpadding="0" cellspacing="0" align="center" border="0" bgcolor="'.$color[4].'">';
  138. echo ' <tr><td ALIGN="center" bgcolor="'.$color[0].'">';
  139. echo ' <font color="' . $color[2].'"><b>' . $err . ':</b></font>';
  140. echo ' </td></tr>';
  141. echo ' <tr><td>';
  142. echo ' <table cellpadding="1" cellspacing="5" align="center" border="0">';
  143. echo ' <tr>' . html_tag( 'td', $string."\n", 'left')
  144. . '</tr>';
  145. echo ' </table>';
  146. echo ' </td></tr>';
  147. echo ' </table></td></tr>';
  148. echo ' </table>';
  149. }
  150. ?>