Drop obsolete function
[squirrelmail.git] / functions / display_messages.php
1 <?php
2
3 /**
4 * display_messages.php
5 *
6 * Copyright (c) 1999-2003 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 * $Id$
13 */
14
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 */
23 function sqm_baseuri(){
24 global $base_uri, $PHP_SELF;
25 /**
26 * If it is in the session, just return it.
27 */
28 if (isset($base_uri)){
29 return $base_uri;
30 }
31 $dirs = array('|src/.*|', '|plugins/.*|', '|functions/.*|');
32 $repl = array('', '', '');
33 $base_uri = preg_replace($dirs, $repl, $PHP_SELF);
34 return $base_uri;
35 }
36
37 function error_message($message, $mailbox, $sort, $startMessage, $color) {
38 $urlMailbox = urlencode($mailbox);
39
40 $string = '<tr><td ALIGN="center">' . $message . '</td></tr>'."\n".
41 '<tr><td ALIGN="center">'.
42 '<A HREF="' . sqm_baseuri()
43 . "src/right_main.php?sort=$sort&amp;startMessage=$startMessage"
44 . "&amp;mailbox=$urlMailbox\">" .
45 sprintf (_("Click here to return to %s"), $mailbox) .
46 '</A></td></tr>';
47 error_box($string, $color);
48 }
49
50 function plain_error_message($message, $color) {
51 error_box($message, $color);
52 }
53
54 function logout_error( $errString, $errTitle = '' ) {
55 global $frame_top, $org_logo, $org_name, $org_logo_width, $org_logo_height,
56 $hide_sm_attributions, $version, $squirrelmail_language;
57
58 $base_uri = sqm_baseuri();
59
60 include_once( SM_PATH . 'functions/page_header.php' );
61 if ( !isset( $org_logo ) ) {
62 // Don't know yet why, but in some accesses $org_logo is not set.
63 include( SM_PATH . 'config/config.php' );
64 }
65 /* Display width and height like good little people */
66 $width_and_height = '';
67 if (isset($org_logo_width) && is_numeric($org_logo_width) && $org_logo_width>0) {
68 $width_and_height = " WIDTH=\"$org_logo_width\"";
69 }
70 if (isset($org_logo_height) && is_numeric($org_logo_height) && $org_logo_height>0) {
71 $width_and_height .= " HEIGHT=\"$org_logo_height\"";
72 }
73
74 if (!isset($frame_top) || $frame_top == '' ) {
75 $frame_top = '_top';
76 }
77
78 if ( !isset( $color ) ) {
79 $color = array();
80 $color[0] = '#DCDCDC'; /* light gray TitleBar */
81 $color[1] = '#800000'; /* red */
82 $color[2] = '#CC0000'; /* light red Warning/Error Messages */
83 $color[4] = '#FFFFFF'; /* white Normal Background */
84 $color[7] = '#0000CC'; /* blue Links */
85 $color[8] = '#000000'; /* black Normal text */
86 }
87
88 if ( $errTitle == '' ) {
89 $errTitle = $errString;
90 }
91 set_up_language($squirrelmail_language, true);
92
93 displayHtmlHeader( $errTitle, '', false );
94
95 echo "<BODY TEXT=\"$color[8]\" BGCOLOR=\"$color[4]\" LINK=\"$color[7]\" VLINK=\"$color[7]\" ALINK=\"$color[7]\">\n\n" .
96 '<CENTER>';
97
98 if (isset($org_logo) && ($org_logo != '')) {
99 echo "<IMG SRC=\"$org_logo\" ALT=\"" . sprintf(_("%s Logo"), $org_name) .
100 "\"$width_and_height><BR>\n";
101 }
102 echo ( $hide_sm_attributions ? '' :
103 '<SMALL>' . sprintf (_("SquirrelMail version %s"), $version) . "<BR>\n".
104 ' ' . _("By the SquirrelMail Development Team") . "<BR></SMALL>\n" ) .
105 "<table cellspacing=1 cellpadding=0 bgcolor=\"$color[1]\" width=\"70%\"><tr><td>".
106 "<TABLE WIDTH=\"100%\" BORDER=\"0\" BGCOLOR=\"$color[4]\" ALIGN=CENTER>".
107 "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=\"center\">".
108 "<FONT COLOR=\"$color[2]\"><B>" . _("ERROR") .
109 '</B></FONT></TD></TR>'.
110 '<TR><TD ALIGN="center">' . $errString . '</TD></TR>'.
111 "<TR><TD BGCOLOR=\"$color[0]\" ALIGN=\"center\">".
112 "<FONT COLOR=\"$color[2]\"><B>".
113 '<a href="' . $base_uri . 'src/login.php" target="' .
114 $frame_top . '">' .
115 _("Go to the login page") . "</a></B></FONT>".
116 '</TD></TR>'.
117 '</TABLE></td></tr></table></center></body></html>';
118 }
119
120 function error_box($string, $color) {
121 global $pageheader_sent;
122
123 $err = _("ERROR");
124
125 /* check if the page header has been sent; if not, send it! */
126 if(!isset($pageheader_sent) && !$pageheader_sent) {
127 /* include this just to be sure */
128 include_once( SM_PATH . 'functions/page_header.php' );
129 displayHtmlHeader('SquirrelMail: '.$err);
130 $pageheader_sent = TRUE;
131 echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\">\n\n";
132 }
133
134 echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center"'.' border="0" bgcolor="'.$color[9].'">';
135 echo ' <tr><td>';
136 echo ' <table width="100%" cellpadding="0" cellspacing="0" align="center" border="0" bgcolor="'.$color[4].'">';
137 echo ' <tr><td ALIGN="center" bgcolor="'.$color[0].'">';
138 echo ' <font color="' . $color[2].'"><b>' . $err . ':</b></font>';
139 echo ' </td></tr>';
140 echo ' <tr><td>';
141 echo ' <table cellpadding="1" cellspacing="5" align="center" border="0">';
142 echo ' <tr>' . html_tag( 'td', $string."\n", 'left')
143 . '</tr>';
144 echo ' </table>';
145 echo ' </table></td></tr>';
146 echo ' </table>';
147 echo ' </td></tr>';
148 }
149 ?>