59177427 |
1 | <?php |
2ba13803 |
2 | |
35586184 |
3 | /** |
4 | * display_messages.php |
5 | * |
82d304a0 |
6 | * Copyright (c) 1999-2004 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 | * |
12 | * $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 | /** |
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 | * |
d6c32258 |
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); |
fd2611e9 |
45 | $string = '<tr><td ALIGN="center">' . $message . '</td></tr>'."\n". |
46 | '<tr><td ALIGN="center">'. |
47 | '<A HREF="' . sqm_baseuri() |
90d3887e |
48 | . "src/right_main.php?sort=$sort&startMessage=$startMessage" |
fd2611e9 |
49 | . "&mailbox=$urlMailbox\">" . |
42c2281a |
50 | sprintf (_("Click here to return to %s"), strtoupper($mailbox) == 'INBOX' ? _("INBOX") : imap_utf7_decode_local($mailbox)) . |
fd2611e9 |
51 | '</A></td></tr>'; |
52 | error_box($string, $color); |
ec5b189b |
53 | } |
aa4c3749 |
54 | |
ec5b189b |
55 | function plain_error_message($message, $color) { |
fd2611e9 |
56 | error_box($message, $color); |
ec5b189b |
57 | } |
b6d8d08d |
58 | |
9be8198d |
59 | function logout_error( $errString, $errTitle = '' ) { |
1f05436e |
60 | global $frame_top, $org_logo, $org_name, $org_logo_width, $org_logo_height, |
35185c82 |
61 | $hide_sm_attributions, $version, $squirrelmail_language; |
62 | |
399846ea |
63 | $base_uri = sqm_baseuri(); |
26f9a94a |
64 | |
65 | include_once( SM_PATH . 'functions/page_header.php' ); |
9be8198d |
66 | if ( !isset( $org_logo ) ) { |
67 | // Don't know yet why, but in some accesses $org_logo is not set. |
26f9a94a |
68 | include( SM_PATH . 'config/config.php' ); |
9be8198d |
69 | } |
70 | /* Display width and height like good little people */ |
71 | $width_and_height = ''; |
e16cb07b |
72 | if (isset($org_logo_width) && is_numeric($org_logo_width) && $org_logo_width>0) { |
9be8198d |
73 | $width_and_height = " WIDTH=\"$org_logo_width\""; |
74 | } |
e16cb07b |
75 | if (isset($org_logo_height) && is_numeric($org_logo_height) && $org_logo_height>0) { |
9be8198d |
76 | $width_and_height .= " HEIGHT=\"$org_logo_height\""; |
77 | } |
78 | |
79 | if (!isset($frame_top) || $frame_top == '' ) { |
80 | $frame_top = '_top'; |
81 | } |
82 | |
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 */ |
9be8198d |
88 | $color[4] = '#FFFFFF'; /* white Normal Background */ |
9be8198d |
89 | $color[7] = '#0000CC'; /* blue Links */ |
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 == '' ) { |
96 | $errTitle = $errString; |
97 | } |
98 | set_up_language($squirrelmail_language, true); |
1f05436e |
99 | |
100 | displayHtmlHeader( $errTitle, '', false ); |
101 | |
9be8198d |
102 | echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n\n" . |
4cbcaebd |
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 ? '' : |
9be8198d |
110 | '<SMALL>' . sprintf (_("SquirrelMail version %s"), $version) . "<BR>\n". |
111 | ' ' . _("By the SquirrelMail Development Team") . "<BR></SMALL>\n" ) . |
112 | "<table cellspacing=1 cellpadding=0 bgcolor=\"$color[1]\" width=\"70%\"><tr><td>". |
c9062c05 |
113 | "<TABLE WIDTH=\"100%\" BORDER=\"0\" BGCOLOR=\"$color[4]\" ALIGN=CENTER>". |
114 | "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=\"center\">". |
115 | "<FONT COLOR=\"$color[2]\"><B>" . _("ERROR") . |
116 | '</B></FONT></TD></TR>'. |
117 | '<TR><TD ALIGN="center">' . $errString . '</TD></TR>'. |
118 | "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=\"center\">". |
119 | "<FONT COLOR=\"$color[2]\"><B>". |
c94b297c |
120 | '<a href="' . $base_uri . 'src/login.php" target="' . |
121 | $frame_top . '">' . |
c9062c05 |
122 | _("Go to the login page") . "</a></B></FONT>". |
9be8198d |
123 | '</TD></TR>'. |
1f05436e |
124 | '</TABLE></td></tr></table></center></body></html>'; |
9be8198d |
125 | } |
126 | |
fd2611e9 |
127 | function error_box($string, $color) { |
b6c283c4 |
128 | global $pageheader_sent; |
129 | |
130 | $err = _("ERROR"); |
131 | |
7753dac4 |
132 | $ret = concat_hook_function('error_box', $string); |
133 | if($ret != '') { |
134 | $string = $ret; |
135 | } |
8d42e09a |
136 | |
b6c283c4 |
137 | /* check if the page header has been sent; if not, send it! */ |
138 | if(!isset($pageheader_sent) && !$pageheader_sent) { |
139 | /* include this just to be sure */ |
140 | include_once( SM_PATH . 'functions/page_header.php' ); |
141 | displayHtmlHeader('SquirrelMail: '.$err); |
142 | $pageheader_sent = TRUE; |
143 | echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\">\n\n"; |
144 | } |
145 | |
36ec6865 |
146 | echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center"'.' border="0" bgcolor="'.$color[9].'">'; |
147 | echo ' <tr><td>'; |
148 | echo ' <table width="100%" cellpadding="0" cellspacing="0" align="center" border="0" bgcolor="'.$color[4].'">'; |
149 | echo ' <tr><td ALIGN="center" bgcolor="'.$color[0].'">'; |
472e7acb |
150 | echo ' <font color="' . $color[2].'"><b>' . $err . ':</b></font>'; |
36ec6865 |
151 | echo ' </td></tr>'; |
152 | echo ' <tr><td>'; |
153 | echo ' <table cellpadding="1" cellspacing="5" align="center" border="0">'; |
154 | echo ' <tr>' . html_tag( 'td', $string."\n", 'left') |
155 | . '</tr>'; |
156 | echo ' </table>'; |
bbc2c67d |
157 | echo ' </td></tr>'; |
36ec6865 |
158 | echo ' </table></td></tr>'; |
159 | echo ' </table>'; |
fd2611e9 |
160 | } |
6a6ce0a3 |
161 | ?> |