display_messages.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <?php
  2. /**
  3. * display_messages.php
  4. *
  5. * Copyright (c) 1999-2005 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. * @version $Id$
  12. * @package squirrelmail
  13. */
  14. /**
  15. * including plugin functions
  16. */
  17. require_once(SM_PATH . 'functions/plugin.php');
  18. /**
  19. * Find out where SquirrelMail lives and try to be smart about it.
  20. * The only problem would be when SquirrelMail lives in directories
  21. * called "src", "functions", or "plugins", but people who do that need
  22. * to be beaten with a steel pipe anyway.
  23. *
  24. * @return string the base uri of SquirrelMail installation.
  25. */
  26. function sqm_baseuri(){
  27. global $base_uri, $PHP_SELF;
  28. /**
  29. * If it is in the session, just return it.
  30. */
  31. if (isset($base_uri)){
  32. return $base_uri;
  33. }
  34. $dirs = array('|src/.*|', '|plugins/.*|', '|functions/.*|');
  35. $repl = array('', '', '');
  36. $base_uri = preg_replace($dirs, $repl, $PHP_SELF);
  37. return $base_uri;
  38. }
  39. function error_message($message, $mailbox, $sort, $startMessage, $color) {
  40. $urlMailbox = urlencode($mailbox);
  41. $string = '<tr><td align="center">' . $message . '</td></tr>'.
  42. '<tr><td align="center">'.
  43. '<a href="'.sqm_baseuri()."src/right_main.php?sort=$sort&amp;startMessage=$startMessage&amp;mailbox=$urlMailbox\">".
  44. sprintf (_("Click here to return to %s"),
  45. strtoupper($mailbox) == 'INBOX' ? _("INBOX") : imap_utf7_decode_local($mailbox)).
  46. '</a></td></tr>';
  47. error_box($string, $color);
  48. }
  49. function plain_error_message($message, $color) {
  50. error_box($message, $color);
  51. }
  52. function logout_error( $errString, $errTitle = '' ) {
  53. global $frame_top, $org_logo, $org_name, $org_logo_width, $org_logo_height,
  54. $hide_sm_attributions, $version, $squirrelmail_language, $color;
  55. $base_uri = sqm_baseuri();
  56. include_once( SM_PATH . 'functions/page_header.php' );
  57. if ( !isset( $org_logo ) ) {
  58. // Don't know yet why, but in some accesses $org_logo is not set.
  59. include( SM_PATH . 'config/config.php' );
  60. }
  61. /* Display width and height like good little people */
  62. $width_and_height = '';
  63. if (isset($org_logo_width) && is_numeric($org_logo_width) && $org_logo_width>0) {
  64. $width_and_height = " width=\"$org_logo_width\"";
  65. }
  66. if (isset($org_logo_height) && is_numeric($org_logo_height) && $org_logo_height>0) {
  67. $width_and_height .= " height=\"$org_logo_height\"";
  68. }
  69. if (!isset($frame_top) || $frame_top == '' ) {
  70. $frame_top = '_top';
  71. }
  72. if ( !isset( $color ) ) {
  73. $color = array();
  74. $color[0] = '#dcdcdc'; /* light gray TitleBar */
  75. $color[1] = '#800000'; /* red */
  76. $color[2] = '#cc0000'; /* light red Warning/Error Messages */
  77. $color[4] = '#ffffff'; /* white Normal Background */
  78. $color[7] = '#0000cc'; /* blue Links */
  79. $color[8] = '#000000'; /* black Normal text */
  80. }
  81. list($junk, $errString, $errTitle) = do_hook('logout_error', $errString, $errTitle);
  82. if ( $errTitle == '' ) {
  83. $errTitle = $errString;
  84. }
  85. set_up_language($squirrelmail_language, true);
  86. displayHtmlHeader( $org_name.' - '.$errTitle, '', false );
  87. echo '<body text="'.$color[8].'" bgcolor="'.$color[4].'" link="'.$color[7].'" vlink="'.$color[7].'" alink="'.$color[7]."\">\n\n".
  88. '<center>';
  89. if (isset($org_logo) && ($org_logo != '')) {
  90. echo '<img src="'.$org_logo.'" alt="'.sprintf(_("%s Logo"), $org_name).
  91. "\"$width_and_height /><br />\n";
  92. }
  93. echo ( $hide_sm_attributions ? '' :
  94. '<small>' . _("SquirrelMail Webmail Application") . '<br />'.
  95. _("By the SquirrelMail Project Team") . "<br /></small>\n" ).
  96. '<table cellspacing="1" cellpadding="0" bgcolor="'.$color[1].'" width="70%">'.
  97. '<tr><td>'.
  98. '<table width="100%" border="0" bgcolor="'.$color[4].'" align="center">'.
  99. '<tr><td bgcolor="'.$color[0].'" align="center">'.
  100. '<font color="'.$color[2].'"><b>' . _("ERROR") . '</b></font>'.
  101. '</td></tr>'.
  102. '<tr><td align="center">' . $errString . '</td></tr>'.
  103. '<tr><td bgcolor="'.$color[0].'" align="center">'.
  104. '<font color="'.$color[2].'"><b>'.
  105. '<a href="'.$base_uri.'src/login.php" target="'.$frame_top.'">'.
  106. _("Go to the login page") . '</a></b></font></td></tr>'.
  107. '</table></td></tr></table></center></body></html>';
  108. }
  109. function error_box($string, $color) {
  110. global $pageheader_sent;
  111. if ( !isset( $color ) ) {
  112. $color = array();
  113. $color[0] = '#dcdcdc'; /* light gray TitleBar */
  114. $color[1] = '#800000'; /* red */
  115. $color[2] = '#cc0000'; /* light red Warning/Error Messages */
  116. $color[4] = '#ffffff'; /* white Normal Background */
  117. $color[7] = '#0000cc'; /* blue Links */
  118. $color[8] = '#000000'; /* black Normal text */
  119. $color[9] = '#ababab'; /* mid-gray Darker version of #0 */
  120. }
  121. $err = _("ERROR");
  122. $ret = concat_hook_function('error_box', $string);
  123. if($ret != '') {
  124. $string = $ret;
  125. }
  126. /* check if the page header has been sent; if not, send it! */
  127. if(!isset($pageheader_sent) && !$pageheader_sent) {
  128. /* include this just to be sure */
  129. include_once( SM_PATH . 'functions/page_header.php' );
  130. displayHtmlHeader('SquirrelMail: '.$err);
  131. $pageheader_sent = TRUE;
  132. echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\">\n\n";
  133. }
  134. echo '<table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="'.$color[9].'">'.
  135. '<tr><td>'.
  136. '<table width="100%" cellpadding="0" cellspacing="0" align="center" border="0" bgcolor="'.$color[4].'">'.
  137. '<tr><td align="center" bgcolor="'.$color[0].'">'.
  138. '<font color="'.$color[2].'"><b>' . $err . ':</b></font>'.
  139. '</td></tr><tr><td>'.
  140. '<table cellpadding="1" cellspacing="5" align="center" border="0">'.
  141. '<tr>' . html_tag( 'td', $string."\n", 'left') . '</tr></table>'.
  142. '</td></tr></table></td></tr></table>';
  143. }
  144. /**
  145. * Adds message that informs about non fatal error that can happen while saving preferences
  146. * @param string $message error message
  147. * @since 1.5.1 and 1.4.5
  148. */
  149. function error_option_save($message) {
  150. global $optpage_save_error;
  151. if (! is_array($optpage_save_error) )
  152. $optpage_save_error=array();
  153. $optpage_save_error=array_merge($optpage_save_error,array($message));
  154. }
  155. // vim: et ts=4
  156. ?>