display_messages.php 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <?php
  2. /**
  3. * display_messages.php
  4. *
  5. * This contains all messages, including information, error, and just
  6. * about any other message you can think of.
  7. *
  8. * @copyright &copy; 1999-2006 The SquirrelMail Project Team
  9. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  10. * @version $Id$
  11. * @package squirrelmail
  12. */
  13. /** @ignore */
  14. if (! defined('SM_PATH')) define('SM_PATH','../');
  15. /**
  16. * including plugin functions
  17. */
  18. include_once(SM_PATH . 'functions/plugin.php');
  19. /**
  20. * Displays error message and URL to message listing
  21. * @param string $message error message
  22. * @param string $mailbox mailbox name
  23. * @param integer $sort sort order
  24. * @param integer $startMessage first message
  25. * @param array $color color theme
  26. * @since 1.0
  27. */
  28. function error_message($message, $mailbox, $sort, $startMessage, $color) {
  29. $urlMailbox = urlencode($mailbox);
  30. $string = '<tr><td align="center">' . $message . '</td></tr>'.
  31. '<tr><td align="center">'.
  32. '<a href="'.sqm_baseuri()."src/right_main.php?sort=$sort&amp;startMessage=$startMessage&amp;mailbox=$urlMailbox\">".
  33. sprintf (_("Click here to return to %s"),
  34. strtoupper($mailbox) == 'INBOX' ? _("INBOX") : imap_utf7_decode_local($mailbox)).
  35. '</a></td></tr>';
  36. error_box($string, $color);
  37. }
  38. /**
  39. * Displays error message
  40. * @param string $message error message
  41. * @param array $color color theme
  42. * @since 1.0
  43. */
  44. function plain_error_message($message, $color) {
  45. error_box($message, $color);
  46. }
  47. /**
  48. * Displays error when user is logged out
  49. *
  50. * Error strings can be overriden by logout_error hook
  51. * @param string $errString error message
  52. * @param string $errTitle title of page with error message
  53. * @since 1.2.6
  54. */
  55. function logout_error( $errString, $errTitle = '' ) {
  56. global $frame_top, $org_logo, $org_name, $org_logo_width, $org_logo_height,
  57. $hide_sm_attributions, $version, $squirrelmail_language,
  58. $color, $theme, $theme_default;
  59. $base_uri = sqm_baseuri();
  60. include_once( SM_PATH . 'functions/page_header.php' );
  61. if ( !isset( $org_logo ) ) {
  62. // Don't know yet why, but in some accesses $org_logo is not set.
  63. include( SM_PATH . 'config/config.php' );
  64. }
  65. /* Display width and height like good little people */
  66. $width_and_height = '';
  67. if (isset($org_logo_width) && is_numeric($org_logo_width) && $org_logo_width>0) {
  68. $width_and_height = " width=\"$org_logo_width\"";
  69. }
  70. if (isset($org_logo_height) && is_numeric($org_logo_height) && $org_logo_height>0) {
  71. $width_and_height .= " height=\"$org_logo_height\"";
  72. }
  73. if (!isset($frame_top) || $frame_top == '' ) {
  74. $frame_top = '_top';
  75. }
  76. // load default theme if possible
  77. if (!isset($color) && @file_exists($theme[$theme_default]['PATH']))
  78. @include ($theme[$theme_default]['PATH']);
  79. if ( !isset( $color ) ) {
  80. $color = array();
  81. $color[0] = '#dcdcdc'; /* light gray TitleBar */
  82. $color[1] = '#800000'; /* red */
  83. $color[2] = '#cc0000'; /* light red Warning/Error Messages */
  84. $color[4] = '#ffffff'; /* white Normal Background */
  85. $color[7] = '#0000cc'; /* blue Links */
  86. $color[8] = '#000000'; /* black Normal text */
  87. }
  88. list($junk, $errString, $errTitle) = do_hook('logout_error', $errString, $errTitle);
  89. if ( $errTitle == '' ) {
  90. $errTitle = $errString;
  91. }
  92. set_up_language($squirrelmail_language, true);
  93. displayHtmlHeader( $org_name.' - '.$errTitle, '', false );
  94. echo '<body text="'.$color[8].'" bgcolor="'.$color[4].'" link="'.$color[7].'" vlink="'.$color[7].'" alink="'.$color[7]."\">\n\n".
  95. '<div style="text-align: center;">';
  96. if (isset($org_logo) && ($org_logo != '')) {
  97. echo '<img src="'.$org_logo.'" alt="'.sprintf(_("%s Logo"), $org_name).
  98. "\"$width_and_height /><br />\n";
  99. }
  100. echo ( $hide_sm_attributions ? '' :
  101. '<small>' . _("SquirrelMail Webmail Application") . '<br />'.
  102. _("By the SquirrelMail Project Team") . "<br /></small>\n" ).
  103. '<table cellspacing="1" cellpadding="0" bgcolor="'.$color[1].'" width="70%">'.
  104. '<tr><td>'.
  105. '<table width="100%" border="0" bgcolor="'.$color[4].'" align="center">'.
  106. '<tr><td bgcolor="'.$color[0].'" align="center">'.
  107. '<font color="'.$color[2].'"><b>' . _("ERROR") . '</b></font>'.
  108. '</td></tr>'.
  109. '<tr><td align="center">' . $errString . '</td></tr>'.
  110. '<tr><td bgcolor="'.$color[0].'" align="center">'.
  111. '<font color="'.$color[2].'"><b>'.
  112. '<a href="'.$base_uri.'src/login.php" target="'.$frame_top.'">'.
  113. _("Go to the login page") . '</a></b></font></td></tr>'.
  114. '</table></td></tr></table></div></body></html>';
  115. }
  116. /**
  117. * Displays error message
  118. *
  119. * Since 1.4.1 function checks if page header is already displayed.
  120. * Since 1.4.3 and 1.5.1 function contains error_box hook.
  121. * Use plain_error_message() and make sure that page header is created,
  122. * if you want compatibility with 1.4.0 and older.
  123. * @param string $string
  124. * @param array $color
  125. * @since 1.3.2
  126. */
  127. function error_box($string, $color) {
  128. global $pageheader_sent;
  129. if ( !isset( $color ) ) {
  130. $color = array();
  131. $color[0] = '#dcdcdc'; /* light gray TitleBar */
  132. $color[1] = '#800000'; /* red */
  133. $color[2] = '#cc0000'; /* light red Warning/Error Messages */
  134. $color[4] = '#ffffff'; /* white Normal Background */
  135. $color[7] = '#0000cc'; /* blue Links */
  136. $color[8] = '#000000'; /* black Normal text */
  137. $color[9] = '#ababab'; /* mid-gray Darker version of #0 */
  138. }
  139. $err = _("ERROR");
  140. $ret = concat_hook_function('error_box', $string);
  141. if($ret != '') {
  142. $string = $ret;
  143. }
  144. /* check if the page header has been sent; if not, send it! */
  145. if(!isset($pageheader_sent) && !$pageheader_sent) {
  146. /* include this just to be sure */
  147. include_once( SM_PATH . 'functions/page_header.php' );
  148. displayHtmlHeader('SquirrelMail: '.$err);
  149. $pageheader_sent = TRUE;
  150. echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\">\n\n";
  151. }
  152. echo '<table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="'.$color[9].'">'.
  153. '<tr><td>'.
  154. '<table width="100%" cellpadding="0" cellspacing="0" align="center" border="0" bgcolor="'.$color[4].'">'.
  155. '<tr><td align="center" bgcolor="'.$color[0].'">'.
  156. '<font color="'.$color[2].'"><b>' . $err . ':</b></font>'.
  157. '</td></tr><tr><td>'.
  158. '<table cellpadding="1" cellspacing="5" align="center" border="0">'.
  159. '<tr>' . html_tag( 'td', $string."\n", 'left') . '</tr></table>'.
  160. '</td></tr></table></td></tr></table>';
  161. }
  162. /**
  163. * Adds message that informs about non fatal error that can happen while saving preferences
  164. * @param string $message error message
  165. * @since 1.5.1 and 1.4.5
  166. */
  167. function error_option_save($message) {
  168. global $optpage_save_error;
  169. if (! is_array($optpage_save_error) )
  170. $optpage_save_error=array();
  171. $optpage_save_error=array_merge($optpage_save_error,array($message));
  172. }
  173. // vim: et ts=4
  174. ?>