Small tweaks:
[squirrelmail.git] / functions / display_messages.php
CommitLineData
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 23function 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
ec5b189b 37function error_username_password_incorrect() {
1cf38f19 38 global $frame_top, $color;
76b684a5 39 /* XXX: Should really not start the HTML before this, or close off more
40 cleanly. */
2ba13803 41
d03f3582 42 if (!isset($frame_top)) {
43 $frame_top = '_top';
44 }
fd2611e9 45 $string = '<TR><TD ALIGN="center">'.
46 _("Unknown user or password incorrect.") .
47 '</TD></TR><TR><TD ALIGN="center">'.
48 '<A HREF="' . sqm_baseuri() . '"login.php" TARGET='.
399846ea 49 $frame_top.'>' . _("Click here to try again") .
c9062c05 50 '</A>.'.
fd2611e9 51 '</TD></TR>';
52 error_box($string,$color);
53echo '</BODY></HTML>';
ec5b189b 54}
2ba13803 55
ec5b189b 56function error_message($message, $mailbox, $sort, $startMessage, $color) {
57 $urlMailbox = urlencode($mailbox);
b6d8d08d 58
fd2611e9 59 $string = '<tr><td ALIGN="center">' . $message . '</td></tr>'."\n".
60 '<tr><td ALIGN="center">'.
61 '<A HREF="' . sqm_baseuri()
90d3887e 62 . "src/right_main.php?sort=$sort&amp;startMessage=$startMessage"
fd2611e9 63 . "&amp;mailbox=$urlMailbox\">" .
64 sprintf (_("Click here to return to %s"), $mailbox) .
65 '</A></td></tr>';
66 error_box($string, $color);
ec5b189b 67}
aa4c3749 68
ec5b189b 69function plain_error_message($message, $color) {
fd2611e9 70 error_box($message, $color);
ec5b189b 71}
b6d8d08d 72
9be8198d 73function logout_error( $errString, $errTitle = '' ) {
1f05436e 74 global $frame_top, $org_logo, $org_name, $org_logo_width, $org_logo_height,
35185c82 75 $hide_sm_attributions, $version, $squirrelmail_language;
76
399846ea 77 $base_uri = sqm_baseuri();
26f9a94a 78
79 include_once( SM_PATH . 'functions/page_header.php' );
9be8198d 80 if ( !isset( $org_logo ) ) {
81 // Don't know yet why, but in some accesses $org_logo is not set.
26f9a94a 82 include( SM_PATH . 'config/config.php' );
9be8198d 83 }
84 /* Display width and height like good little people */
85 $width_and_height = '';
e16cb07b 86 if (isset($org_logo_width) && is_numeric($org_logo_width) && $org_logo_width>0) {
9be8198d 87 $width_and_height = " WIDTH=\"$org_logo_width\"";
88 }
e16cb07b 89 if (isset($org_logo_height) && is_numeric($org_logo_height) && $org_logo_height>0) {
9be8198d 90 $width_and_height .= " HEIGHT=\"$org_logo_height\"";
91 }
92
93 if (!isset($frame_top) || $frame_top == '' ) {
94 $frame_top = '_top';
95 }
96
97 if ( !isset( $color ) ) {
98 $color = array();
99 $color[0] = '#DCDCDC'; /* light gray TitleBar */
100 $color[1] = '#800000'; /* red */
101 $color[2] = '#CC0000'; /* light red Warning/Error Messages */
9be8198d 102 $color[4] = '#FFFFFF'; /* white Normal Background */
9be8198d 103 $color[7] = '#0000CC'; /* blue Links */
104 $color[8] = '#000000'; /* black Normal text */
9be8198d 105 }
106
107 if ( $errTitle == '' ) {
108 $errTitle = $errString;
109 }
110 set_up_language($squirrelmail_language, true);
1f05436e 111
112 displayHtmlHeader( $errTitle, '', false );
113
9be8198d 114 echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n\n" .
4cbcaebd 115 '<CENTER>';
116
117 if (isset($org_logo) && ($org_logo != '')) {
118 echo "<IMG SRC=\"$org_logo\" ALT=\"" . sprintf(_("%s Logo"), $org_name) .
119 "\"$width_and_height><BR>\n";
120 }
121 echo ( $hide_sm_attributions ? '' :
9be8198d 122 '<SMALL>' . sprintf (_("SquirrelMail version %s"), $version) . "<BR>\n".
123 ' ' . _("By the SquirrelMail Development Team") . "<BR></SMALL>\n" ) .
124 "<table cellspacing=1 cellpadding=0 bgcolor=\"$color[1]\" width=\"70%\"><tr><td>".
c9062c05 125 "<TABLE WIDTH=\"100%\" BORDER=\"0\" BGCOLOR=\"$color[4]\" ALIGN=CENTER>".
126 "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=\"center\">".
127 "<FONT COLOR=\"$color[2]\"><B>" . _("ERROR") .
128 '</B></FONT></TD></TR>'.
129 '<TR><TD ALIGN="center">' . $errString . '</TD></TR>'.
130 "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=\"center\">".
131 "<FONT COLOR=\"$color[2]\"><B>".
c94b297c 132 '<a href="' . $base_uri . 'src/login.php" target="' .
133 $frame_top . '">' .
c9062c05 134 _("Go to the login page") . "</a></B></FONT>".
9be8198d 135 '</TD></TR>'.
1f05436e 136 '</TABLE></td></tr></table></center></body></html>';
9be8198d 137}
138
fd2611e9 139function error_box($string, $color) {
140 echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center"'.' border="0" bgcolor="'.$color[9].'">';
141 echo ' <tr><td>';
142 echo ' <table width="100%" cellpadding="0" cellspacing="0" align="center" border="0" bgcolor="'.$color[4].'">';
143 echo ' <tr><td ALIGN="center" bgcolor="'.$color[0].'">';
144 echo ' <font color="' . $color[2].'"><b>' . _("ERROR") . ':</b></font>';
145 echo ' </td></tr>';
146 echo ' <tr><td>';
147 echo ' <table cellpadding="1" cellspacing="5" align="center" border="0">';
148 echo ' <tr>' . html_tag( 'td', $string."\n", 'left')
149 . '</tr>';
150 echo ' </table>';
151 echo ' </table></td></tr>';
152 echo ' </table>';
153 echo ' </td></tr>';
154}
6a6ce0a3 155?>