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