display_messages.php 6.9 KB

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