59177427 |
1 | <?php |
2ba13803 |
2 | |
35586184 |
3 | /** |
4 | * display_messages.php |
5 | * |
76911253 |
6 | * Copyright (c) 1999-2003 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$ |
13 | */ |
3302d0d4 |
14 | |
c94b297c |
15 | /** |
16 | * Find out where squirrelmail lives and try to be smart about it. |
17 | * The only problem would be when squirrelmail lives in directories |
18 | * called "src", "functions", or "plugins", but people who do that need |
19 | * to be beaten with a steel pipe anyway. |
20 | * |
21 | * @return the base uri of squirrelmail installation. |
22 | */ |
399846ea |
23 | function sqm_baseuri(){ |
24 | global $base_uri, $PHP_SELF; |
c94b297c |
25 | /** |
26 | * If it is in the session, just return it. |
27 | */ |
399846ea |
28 | if (isset($base_uri)){ |
29 | return $base_uri; |
30 | } |
7e156b3d |
31 | $dirs = array('|src/.*|', '|plugins/.*|', '|functions/.*|'); |
32 | $repl = array('', '', ''); |
399846ea |
33 | $base_uri = preg_replace($dirs, $repl, $PHP_SELF); |
34 | return $base_uri; |
35 | } |
36 | |
7e156b3d |
37 | /** |
38 | * Find out the top REAL path of the squirrelmail installation. |
39 | * |
40 | * @return the real installation directory of squirrelmail. |
41 | */ |
42 | |
43 | function sqm_topdir(){ |
44 | $topdir = ''; |
45 | /** |
46 | * $levels is just to avoid a potential infinite loop in case |
47 | * things are REALLY broken. Shouldn't really ever happen. |
48 | */ |
49 | $levels = 0; |
50 | while (!(is_dir("$topdir/functions") && is_dir("$topdir/src")) |
51 | && $levels < 10){ |
52 | $topdir .= '../'; |
53 | $levels++; |
54 | } |
55 | return $topdir; |
56 | } |
57 | |
ec5b189b |
58 | function error_username_password_incorrect() { |
1cf38f19 |
59 | global $frame_top, $color; |
76b684a5 |
60 | /* XXX: Should really not start the HTML before this, or close off more |
61 | cleanly. */ |
2ba13803 |
62 | |
d03f3582 |
63 | if (!isset($frame_top)) { |
64 | $frame_top = '_top'; |
65 | } |
fd2611e9 |
66 | $string = '<TR><TD ALIGN="center">'. |
67 | _("Unknown user or password incorrect.") . |
68 | '</TD></TR><TR><TD ALIGN="center">'. |
69 | '<A HREF="' . sqm_baseuri() . '"login.php" TARGET='. |
399846ea |
70 | $frame_top.'>' . _("Click here to try again") . |
c9062c05 |
71 | '</A>.'. |
fd2611e9 |
72 | '</TD></TR>'; |
73 | error_box($string,$color); |
74 | echo '</BODY></HTML>'; |
ec5b189b |
75 | } |
2ba13803 |
76 | |
ec5b189b |
77 | function error_message($message, $mailbox, $sort, $startMessage, $color) { |
78 | $urlMailbox = urlencode($mailbox); |
b6d8d08d |
79 | |
fd2611e9 |
80 | $string = '<tr><td ALIGN="center">' . $message . '</td></tr>'."\n". |
81 | '<tr><td ALIGN="center">'. |
82 | '<A HREF="' . sqm_baseuri() |
90d3887e |
83 | . "src/right_main.php?sort=$sort&startMessage=$startMessage" |
fd2611e9 |
84 | . "&mailbox=$urlMailbox\">" . |
85 | sprintf (_("Click here to return to %s"), $mailbox) . |
86 | '</A></td></tr>'; |
87 | error_box($string, $color); |
ec5b189b |
88 | } |
aa4c3749 |
89 | |
ec5b189b |
90 | function plain_error_message($message, $color) { |
fd2611e9 |
91 | error_box($message, $color); |
ec5b189b |
92 | } |
b6d8d08d |
93 | |
9be8198d |
94 | function logout_error( $errString, $errTitle = '' ) { |
1f05436e |
95 | global $frame_top, $org_logo, $org_name, $org_logo_width, $org_logo_height, |
35185c82 |
96 | $hide_sm_attributions, $version, $squirrelmail_language; |
97 | |
399846ea |
98 | $base_uri = sqm_baseuri(); |
7e156b3d |
99 | $topdir = sqm_topdir(); |
100 | include_once( "$topdir/functions/page_header.php" ); |
9be8198d |
101 | if ( !isset( $org_logo ) ) { |
102 | // Don't know yet why, but in some accesses $org_logo is not set. |
7e156b3d |
103 | include( "$topdir/config/config.php" ); |
9be8198d |
104 | } |
105 | /* Display width and height like good little people */ |
106 | $width_and_height = ''; |
e16cb07b |
107 | if (isset($org_logo_width) && is_numeric($org_logo_width) && $org_logo_width>0) { |
9be8198d |
108 | $width_and_height = " WIDTH=\"$org_logo_width\""; |
109 | } |
e16cb07b |
110 | if (isset($org_logo_height) && is_numeric($org_logo_height) && $org_logo_height>0) { |
9be8198d |
111 | $width_and_height .= " HEIGHT=\"$org_logo_height\""; |
112 | } |
113 | |
114 | if (!isset($frame_top) || $frame_top == '' ) { |
115 | $frame_top = '_top'; |
116 | } |
117 | |
118 | if ( !isset( $color ) ) { |
119 | $color = array(); |
120 | $color[0] = '#DCDCDC'; /* light gray TitleBar */ |
121 | $color[1] = '#800000'; /* red */ |
122 | $color[2] = '#CC0000'; /* light red Warning/Error Messages */ |
123 | $color[3] = '#A0B8C8'; /* green-blue Left Bar Background */ |
124 | $color[4] = '#FFFFFF'; /* white Normal Background */ |
125 | $color[5] = '#FFFFCC'; /* light yellow Table Headers */ |
126 | $color[6] = '#000000'; /* black Text on left bar */ |
127 | $color[7] = '#0000CC'; /* blue Links */ |
128 | $color[8] = '#000000'; /* black Normal text */ |
129 | $color[9] = '#ABABAB'; /* mid-gray Darker version of #0 */ |
130 | $color[10] = '#666666'; /* dark gray Darker version of #9 */ |
131 | $color[11] = '#770000'; /* dark red Special Folders color */ |
132 | $color[12] = '#EDEDED'; |
133 | $color[15] = '#002266'; /* (dark blue) Unselectable folders */ |
134 | } |
135 | |
136 | if ( $errTitle == '' ) { |
137 | $errTitle = $errString; |
138 | } |
139 | set_up_language($squirrelmail_language, true); |
1f05436e |
140 | |
141 | displayHtmlHeader( $errTitle, '', false ); |
142 | |
9be8198d |
143 | echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n\n" . |
144 | '<CENTER>'. |
145 | "<IMG SRC=\"$org_logo\" ALT=\"" . sprintf(_("%s Logo"), $org_name) . |
146 | "\"$width_and_height><BR>\n". |
147 | ( $hide_sm_attributions ? '' : |
148 | '<SMALL>' . sprintf (_("SquirrelMail version %s"), $version) . "<BR>\n". |
149 | ' ' . _("By the SquirrelMail Development Team") . "<BR></SMALL>\n" ) . |
150 | "<table cellspacing=1 cellpadding=0 bgcolor=\"$color[1]\" width=\"70%\"><tr><td>". |
c9062c05 |
151 | "<TABLE WIDTH=\"100%\" BORDER=\"0\" BGCOLOR=\"$color[4]\" ALIGN=CENTER>". |
152 | "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=\"center\">". |
153 | "<FONT COLOR=\"$color[2]\"><B>" . _("ERROR") . |
154 | '</B></FONT></TD></TR>'. |
155 | '<TR><TD ALIGN="center">' . $errString . '</TD></TR>'. |
156 | "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=\"center\">". |
157 | "<FONT COLOR=\"$color[2]\"><B>". |
c94b297c |
158 | '<a href="' . $base_uri . 'src/login.php" target="' . |
159 | $frame_top . '">' . |
c9062c05 |
160 | _("Go to the login page") . "</a></B></FONT>". |
9be8198d |
161 | '</TD></TR>'. |
1f05436e |
162 | '</TABLE></td></tr></table></center></body></html>'; |
9be8198d |
163 | } |
164 | |
fd2611e9 |
165 | function error_box($string, $color) { |
166 | echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center"'.' border="0" bgcolor="'.$color[9].'">'; |
167 | echo ' <tr><td>'; |
168 | echo ' <table width="100%" cellpadding="0" cellspacing="0" align="center" border="0" bgcolor="'.$color[4].'">'; |
169 | echo ' <tr><td ALIGN="center" bgcolor="'.$color[0].'">'; |
170 | echo ' <font color="' . $color[2].'"><b>' . _("ERROR") . ':</b></font>'; |
171 | echo ' </td></tr>'; |
172 | echo ' <tr><td>'; |
173 | echo ' <table cellpadding="1" cellspacing="5" align="center" border="0">'; |
174 | echo ' <tr>' . html_tag( 'td', $string."\n", 'left') |
175 | . '</tr>'; |
176 | echo ' </table>'; |
177 | echo ' </table></td></tr>'; |
178 | echo ' </table>'; |
179 | echo ' </td></tr>'; |
180 | } |
6a6ce0a3 |
181 | ?> |