59177427 |
1 | <?php |
2ba13803 |
2 | |
35586184 |
3 | /** |
4 | * display_messages.php |
5 | * |
6c84ba1e |
6 | * Copyright (c) 1999-2005 The SquirrelMail Project Team |
35586184 |
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 | * |
31841a9e |
12 | * @version $Id$ |
d6c32258 |
13 | * @package squirrelmail |
35586184 |
14 | */ |
3302d0d4 |
15 | |
5100f68f |
16 | /** |
17 | * including plugin functions |
18 | */ |
ebb9eaaf |
19 | require_once(SM_PATH . 'functions/plugin.php'); |
20 | |
c94b297c |
21 | /** |
598294a7 |
22 | * Find out where SquirrelMail lives and try to be smart about it. |
23 | * The only problem would be when SquirrelMail lives in directories |
c94b297c |
24 | * called "src", "functions", or "plugins", but people who do that need |
25 | * to be beaten with a steel pipe anyway. |
26 | * |
598294a7 |
27 | * @return string the base uri of SquirrelMail installation. |
c94b297c |
28 | */ |
399846ea |
29 | function sqm_baseuri(){ |
30 | global $base_uri, $PHP_SELF; |
c94b297c |
31 | /** |
32 | * If it is in the session, just return it. |
33 | */ |
399846ea |
34 | if (isset($base_uri)){ |
35 | return $base_uri; |
36 | } |
7e156b3d |
37 | $dirs = array('|src/.*|', '|plugins/.*|', '|functions/.*|'); |
38 | $repl = array('', '', ''); |
399846ea |
39 | $base_uri = preg_replace($dirs, $repl, $PHP_SELF); |
40 | return $base_uri; |
41 | } |
42 | |
ec5b189b |
43 | function error_message($message, $mailbox, $sort, $startMessage, $color) { |
44 | $urlMailbox = urlencode($mailbox); |
2ea16421 |
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>'; |
fd2611e9 |
51 | error_box($string, $color); |
ec5b189b |
52 | } |
aa4c3749 |
53 | |
ec5b189b |
54 | function plain_error_message($message, $color) { |
fd2611e9 |
55 | error_box($message, $color); |
ec5b189b |
56 | } |
b6d8d08d |
57 | |
9be8198d |
58 | function logout_error( $errString, $errTitle = '' ) { |
1f05436e |
59 | global $frame_top, $org_logo, $org_name, $org_logo_width, $org_logo_height, |
35185c82 |
60 | $hide_sm_attributions, $version, $squirrelmail_language; |
61 | |
399846ea |
62 | $base_uri = sqm_baseuri(); |
26f9a94a |
63 | |
64 | include_once( SM_PATH . 'functions/page_header.php' ); |
9be8198d |
65 | if ( !isset( $org_logo ) ) { |
66 | // Don't know yet why, but in some accesses $org_logo is not set. |
26f9a94a |
67 | include( SM_PATH . 'config/config.php' ); |
9be8198d |
68 | } |
69 | /* Display width and height like good little people */ |
70 | $width_and_height = ''; |
e16cb07b |
71 | if (isset($org_logo_width) && is_numeric($org_logo_width) && $org_logo_width>0) { |
2ea16421 |
72 | $width_and_height = " width=\"$org_logo_width\""; |
9be8198d |
73 | } |
e16cb07b |
74 | if (isset($org_logo_height) && is_numeric($org_logo_height) && $org_logo_height>0) { |
2ea16421 |
75 | $width_and_height .= " height=\"$org_logo_height\""; |
9be8198d |
76 | } |
77 | |
78 | if (!isset($frame_top) || $frame_top == '' ) { |
79 | $frame_top = '_top'; |
80 | } |
81 | |
c4ea392c |
82 | // Since $color never is set, this is always true |
9be8198d |
83 | if ( !isset( $color ) ) { |
84 | $color = array(); |
2ea16421 |
85 | $color[0] = '#dcdcdc'; /* light gray TitleBar */ |
9be8198d |
86 | $color[1] = '#800000'; /* red */ |
2ea16421 |
87 | $color[2] = '#cc0000'; /* light red Warning/Error Messages */ |
88 | $color[4] = '#ffffff'; /* white Normal Background */ |
89 | $color[7] = '#0000cc'; /* blue Links */ |
9be8198d |
90 | $color[8] = '#000000'; /* black Normal text */ |
9be8198d |
91 | } |
92 | |
8d42e09a |
93 | list($junk, $errString, $errTitle) = do_hook('logout_error', $errString, $errTitle); |
94 | |
9be8198d |
95 | if ( $errTitle == '' ) { |
c4ea392c |
96 | $errTitle = $errString; |
9be8198d |
97 | } |
98 | set_up_language($squirrelmail_language, true); |
1f05436e |
99 | |
c4ea392c |
100 | displayHtmlHeader( $org_name.' - '.$errTitle, '', false ); |
1f05436e |
101 | |
2ea16421 |
102 | echo '<body text="'.$color[8].'" bgcolor="'.$color[4].'" link="'.$color[7].'" vlink="'.$color[7].'" alink="'.$color[7]."\">\n\n". |
103 | '<center>'; |
4cbcaebd |
104 | |
105 | if (isset($org_logo) && ($org_logo != '')) { |
2ea16421 |
106 | echo '<img src="'.$org_logo.'" alt="'.sprintf(_("%s Logo"), $org_name). |
107 | "\"$width_and_height /><br />\n"; |
4cbcaebd |
108 | } |
109 | echo ( $hide_sm_attributions ? '' : |
2ea16421 |
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>'; |
9be8198d |
124 | } |
125 | |
fd2611e9 |
126 | function error_box($string, $color) { |
b6c283c4 |
127 | global $pageheader_sent; |
128 | |
a429618b |
129 | if ( !isset( $color ) ) { |
130 | $color = array(); |
2ea16421 |
131 | $color[0] = '#dcdcdc'; /* light gray TitleBar */ |
a429618b |
132 | $color[1] = '#800000'; /* red */ |
2ea16421 |
133 | $color[2] = '#cc0000'; /* light red Warning/Error Messages */ |
134 | $color[4] = '#ffffff'; /* white Normal Background */ |
135 | $color[7] = '#0000cc'; /* blue Links */ |
a429618b |
136 | $color[8] = '#000000'; /* black Normal text */ |
2ea16421 |
137 | $color[9] = '#ababab'; /* mid-gray Darker version of #0 */ |
a429618b |
138 | } |
139 | |
b6c283c4 |
140 | $err = _("ERROR"); |
141 | |
7753dac4 |
142 | $ret = concat_hook_function('error_box', $string); |
143 | if($ret != '') { |
144 | $string = $ret; |
145 | } |
8d42e09a |
146 | |
b6c283c4 |
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 | |
2ea16421 |
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>'; |
fd2611e9 |
165 | } |
6c92ca88 |
166 | |
288df1a0 |
167 | /** |
168 | * Adds message that informs about non fatal error that can happen while saving preferences |
169 | * @param string $message error message |
b31af6df |
170 | * @since 1.5.1 and 1.4.5 |
288df1a0 |
171 | */ |
172 | function error_option_save($message) { |
173 | global $optpage_save_error; |
174 | |
175 | if (! is_array($optpage_save_error) ) |
91e0dccc |
176 | $optpage_save_error=array(); |
288df1a0 |
177 | |
178 | $optpage_save_error=array_merge($optpage_save_error,array($message)); |
179 | } |
6c92ca88 |
180 | // vim: et ts=4 |
2ea16421 |
181 | ?> |