display_messages.php 6.9 KB

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