display_messages.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <?php
  2. /**
  3. * display_messages.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. * 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. echo '<BR>'.
  42. '<TABLE COLS=1 WIDTH="75%" BORDER="0" BGCOLOR="' . $color[4] . '" ALIGN=CENTER>'.
  43. '<TR BGCOLOR="' . $color[0] . '">'.
  44. '<TH>' . _("ERROR") . '</TH>'.
  45. '</TR>' .
  46. '<TR><TD ALIGN="center">'.
  47. '<BR>' . _("Unknown user or password incorrect.") .
  48. '<BR><A HREF="' . sqm_baseuri() . '"login.php" TARGET='.
  49. $frame_top.'>' . _("Click here to try again") .
  50. '</A>.'.
  51. '</TD></TR>'.
  52. '</TABLE>'.
  53. '</BODY></HTML>';
  54. }
  55. function error_message($message, $mailbox, $sort, $startMessage, $color) {
  56. $urlMailbox = urlencode($mailbox);
  57. echo '<BR>'.
  58. "<TABLE WIDTH=\"70%\" BORDER=\"0\" BGCOLOR=\"$color[4]\" ALIGN=CENTER>".
  59. '<TR>'.
  60. "<TD BGCOLOR=\"$color[0]\" ALIGN=\"center\">".
  61. "<FONT COLOR=\"$color[2]\"><B>" . _("ERROR") . '</B></FONT>'.
  62. '</TD></TR><TR><TD ALIGN="center">'.
  63. "<BR>$message<BR>\n".
  64. '<BR>'.
  65. "<A HREF=\"" . sqm_baseuri()
  66. . "src/right_main.php?sort=$sort&amp;startMessage=$startMessage"
  67. . "&amp;mailbox=$urlMailbox\">";
  68. printf (_("Click here to return to %s"), $mailbox);
  69. echo '</A>.'.
  70. '</TD></TR>'.
  71. '</TABLE>';
  72. }
  73. function plain_error_message($message, $color) {
  74. echo "<br><TABLE WIDTH=\"70%\" BORDER=\"0\" BGCOLOR=\"$color[4]\" ALIGN=CENTER>".
  75. '<TR>'.
  76. "<TD BGCOLOR=\"$color[0]\" ALIGN=\"center\">".
  77. "<FONT COLOR=\"$color[2]\"><B>" . _("ERROR") . '</B></FONT>'.
  78. '</TD></TR><TR><TD ALIGN="center">'.
  79. "<BR>$message".
  80. '</TD></TR>'.
  81. '</TABLE>';
  82. }
  83. function logout_error( $errString, $errTitle = '' ) {
  84. GLOBAL $frame_top, $org_logo, $org_name, $org_logo_width, $org_logo_height,
  85. $hide_sm_attributions, $version, $DOCUMENT_ROOT,
  86. $squirrelmail_language;
  87. $base_uri = sqm_baseuri();
  88. include_once($DOCUMENT_ROOT . $base_uri . 'functions/page_header.php' );
  89. if ( !isset( $org_logo ) ) {
  90. // Don't know yet why, but in some accesses $org_logo is not set.
  91. include( $DOCUMENT_ROOT . $base_uri . 'config/config.php' );
  92. }
  93. /* Display width and height like good little people */
  94. $width_and_height = '';
  95. if (isset($org_logo_width) && is_int($org_logo_width) && $org_logo_width>0) {
  96. $width_and_height = " WIDTH=\"$org_logo_width\"";
  97. }
  98. if (isset($org_logo_height) && is_int($org_logo_height) && $org_logo_height>0) {
  99. $width_and_height .= " HEIGHT=\"$org_logo_height\"";
  100. }
  101. if (!isset($frame_top) || $frame_top == '' ) {
  102. $frame_top = '_top';
  103. }
  104. if ( !isset( $color ) ) {
  105. $color = array();
  106. $color[0] = '#DCDCDC'; /* light gray TitleBar */
  107. $color[1] = '#800000'; /* red */
  108. $color[2] = '#CC0000'; /* light red Warning/Error Messages */
  109. $color[3] = '#A0B8C8'; /* green-blue Left Bar Background */
  110. $color[4] = '#FFFFFF'; /* white Normal Background */
  111. $color[5] = '#FFFFCC'; /* light yellow Table Headers */
  112. $color[6] = '#000000'; /* black Text on left bar */
  113. $color[7] = '#0000CC'; /* blue Links */
  114. $color[8] = '#000000'; /* black Normal text */
  115. $color[9] = '#ABABAB'; /* mid-gray Darker version of #0 */
  116. $color[10] = '#666666'; /* dark gray Darker version of #9 */
  117. $color[11] = '#770000'; /* dark red Special Folders color */
  118. $color[12] = '#EDEDED';
  119. $color[15] = '#002266'; /* (dark blue) Unselectable folders */
  120. }
  121. if ( $errTitle == '' ) {
  122. $errTitle = $errString;
  123. }
  124. set_up_language($squirrelmail_language, true);
  125. displayHtmlHeader( $errTitle );
  126. echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n\n" .
  127. '<CENTER>'.
  128. "<IMG SRC=\"$org_logo\" ALT=\"" . sprintf(_("%s Logo"), $org_name) .
  129. "\"$width_and_height><BR>\n".
  130. ( $hide_sm_attributions ? '' :
  131. '<SMALL>' . sprintf (_("SquirrelMail version %s"), $version) . "<BR>\n".
  132. ' ' . _("By the SquirrelMail Development Team") . "<BR></SMALL>\n" ) .
  133. "<table cellspacing=1 cellpadding=0 bgcolor=\"$color[1]\" width=\"70%\"><tr><td>".
  134. "<TABLE WIDTH=\"100%\" BORDER=\"0\" BGCOLOR=\"$color[4]\" ALIGN=CENTER>".
  135. "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=\"center\">".
  136. "<FONT COLOR=\"$color[2]\"><B>" . _("ERROR") .
  137. '</B></FONT></TD></TR>'.
  138. '<TR><TD ALIGN="center">' . $errString . '</TD></TR>'.
  139. "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=\"center\">".
  140. "<FONT COLOR=\"$color[2]\"><B>".
  141. '<a href="' . $base_uri . 'src/login.php" target="' .
  142. $frame_top . '">' .
  143. _("Go to the login page") . "</a></B></FONT>".
  144. '</TD></TR>'.
  145. '</TABLE></td></tr></table></center></body></html>';
  146. }
  147. ?>