6 * Copyright (c) 1999-2005 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * This contains all messages, including information, error, and just
10 * about any other message you can think of.
13 * @package squirrelmail
17 if (! defined('SM_PATH')) define('SM_PATH','../');
20 * including plugin functions
22 include_once(SM_PATH
. 'functions/plugin.php');
25 * Find out where SquirrelMail lives and try to be smart about it.
26 * The only problem would be when SquirrelMail lives in directories
27 * called "src", "functions", or "plugins", but people who do that need
28 * to be beaten with a steel pipe anyway.
30 * @return string the base uri of SquirrelMail installation.
33 function sqm_baseuri(){
34 global $base_uri, $PHP_SELF;
36 * If it is in the session, just return it.
38 if (isset($base_uri)){
41 $dirs = array('|src/.*|', '|plugins/.*|', '|functions/.*|');
42 $repl = array('', '', '');
43 $base_uri = preg_replace($dirs, $repl, $PHP_SELF);
48 * Displays error message and URL to message listing
49 * @param string $message error message
50 * @param string $mailbox mailbox name
51 * @param integer $sort sort order
52 * @param integer $startMessage first message
53 * @param array $color color theme
56 function error_message($message, $mailbox, $sort, $startMessage, $color) {
57 $urlMailbox = urlencode($mailbox);
58 $string = '<tr><td align="center">' . $message . '</td></tr>'.
59 '<tr><td align="center">'.
60 '<a href="'.sqm_baseuri()."src/right_main.php?sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox\">".
61 sprintf (_("Click here to return to %s"),
62 strtoupper($mailbox) == 'INBOX' ?
_("INBOX") : imap_utf7_decode_local($mailbox)).
64 error_box($string, $color);
68 * Displays error message
69 * @param string $message error message
70 * @param array $color color theme
73 function plain_error_message($message, $color) {
74 error_box($message, $color);
78 * Displays error when user is logged out
80 * Error strings can be overriden by logout_error hook
81 * @param string $errString error message
82 * @param string $errTitle title of page with error message
85 function logout_error( $errString, $errTitle = '' ) {
86 global $frame_top, $org_logo, $org_name, $org_logo_width, $org_logo_height,
87 $hide_sm_attributions, $version, $squirrelmail_language, $color;
89 $base_uri = sqm_baseuri();
91 include_once( SM_PATH
. 'functions/page_header.php' );
92 if ( !isset( $org_logo ) ) {
93 // Don't know yet why, but in some accesses $org_logo is not set.
94 include( SM_PATH
. 'config/config.php' );
96 /* Display width and height like good little people */
97 $width_and_height = '';
98 if (isset($org_logo_width) && is_numeric($org_logo_width) && $org_logo_width>0) {
99 $width_and_height = " width=\"$org_logo_width\"";
101 if (isset($org_logo_height) && is_numeric($org_logo_height) && $org_logo_height>0) {
102 $width_and_height .= " height=\"$org_logo_height\"";
105 if (!isset($frame_top) ||
$frame_top == '' ) {
109 // TODO: load default theme if possible
110 if ( !isset( $color ) ) {
112 $color[0] = '#dcdcdc'; /* light gray TitleBar */
113 $color[1] = '#800000'; /* red */
114 $color[2] = '#cc0000'; /* light red Warning/Error Messages */
115 $color[4] = '#ffffff'; /* white Normal Background */
116 $color[7] = '#0000cc'; /* blue Links */
117 $color[8] = '#000000'; /* black Normal text */
120 list($junk, $errString, $errTitle) = do_hook('logout_error', $errString, $errTitle);
122 if ( $errTitle == '' ) {
123 $errTitle = $errString;
125 set_up_language($squirrelmail_language, true);
127 displayHtmlHeader( $org_name.' - '.$errTitle, '', false );
129 echo '<body text="'.$color[8].'" bgcolor="'.$color[4].'" link="'.$color[7].'" vlink="'.$color[7].'" alink="'.$color[7]."\">\n\n".
132 if (isset($org_logo) && ($org_logo != '')) {
133 echo '<img src="'.$org_logo.'" alt="'.sprintf(_("%s Logo"), $org_name).
134 "\"$width_and_height /><br />\n";
136 echo ( $hide_sm_attributions ?
'' :
137 '<small>' . _("SquirrelMail Webmail Application") . '<br />'.
138 _("By the SquirrelMail Project Team") . "<br /></small>\n" ).
139 '<table cellspacing="1" cellpadding="0" bgcolor="'.$color[1].'" width="70%">'.
141 '<table width="100%" border="0" bgcolor="'.$color[4].'" align="center">'.
142 '<tr><td bgcolor="'.$color[0].'" align="center">'.
143 '<font color="'.$color[2].'"><b>' . _("ERROR") . '</b></font>'.
145 '<tr><td align="center">' . $errString . '</td></tr>'.
146 '<tr><td bgcolor="'.$color[0].'" align="center">'.
147 '<font color="'.$color[2].'"><b>'.
148 '<a href="'.$base_uri.'src/login.php" target="'.$frame_top.'">'.
149 _("Go to the login page") . '</a></b></font></td></tr>'.
150 '</table></td></tr></table></center></body></html>';
154 * Displays error message
156 * Since 1.4.1 function checks if page header is already displayed.
157 * Since 1.4.3 and 1.5.1 function contains error_box hook.
158 * Use plain_error_message() and make sure that page header is created,
159 * if you want compatibility with 1.4.0 and older.
160 * @param string $string
161 * @param array $color
164 function error_box($string, $color) {
165 global $pageheader_sent;
167 if ( !isset( $color ) ) {
169 $color[0] = '#dcdcdc'; /* light gray TitleBar */
170 $color[1] = '#800000'; /* red */
171 $color[2] = '#cc0000'; /* light red Warning/Error Messages */
172 $color[4] = '#ffffff'; /* white Normal Background */
173 $color[7] = '#0000cc'; /* blue Links */
174 $color[8] = '#000000'; /* black Normal text */
175 $color[9] = '#ababab'; /* mid-gray Darker version of #0 */
180 $ret = concat_hook_function('error_box', $string);
185 /* check if the page header has been sent; if not, send it! */
186 if(!isset($pageheader_sent) && !$pageheader_sent) {
187 /* include this just to be sure */
188 include_once( SM_PATH
. 'functions/page_header.php' );
189 displayHtmlHeader('SquirrelMail: '.$err);
190 $pageheader_sent = TRUE;
191 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\">\n\n";
194 echo '<table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="'.$color[9].'">'.
196 '<table width="100%" cellpadding="0" cellspacing="0" align="center" border="0" bgcolor="'.$color[4].'">'.
197 '<tr><td align="center" bgcolor="'.$color[0].'">'.
198 '<font color="'.$color[2].'"><b>' . $err . ':</b></font>'.
199 '</td></tr><tr><td>'.
200 '<table cellpadding="1" cellspacing="5" align="center" border="0">'.
201 '<tr>' . html_tag( 'td', $string."\n", 'left') . '</tr></table>'.
202 '</td></tr></table></td></tr></table>';
206 * Adds message that informs about non fatal error that can happen while saving preferences
207 * @param string $message error message
208 * @since 1.5.1 and 1.4.5
210 function error_option_save($message) {
211 global $optpage_save_error;
213 if (! is_array($optpage_save_error) )
214 $optpage_save_error=array();
216 $optpage_save_error=array_merge($optpage_save_error,array($message));