display_messages.php 7.7 KB

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