display_messages.php 6.3 KB

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