1<?php
2
3/**
4 * display_messages.php
5 *
6 * This contains all messages, including information, error, and just
7 * about any other message you can think of.
8 *
9 * @copyright 1999-2021 The SquirrelMail Project Team
10 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
11 * @version $Id: display_messages.php 14885 2021-02-05 19:19:32Z pdontthink $
12 * @package squirrelmail
13 */
14
15/**
16 * including plugin functions
17 */
18require_once(SM_PATH . 'functions/plugin.php');
19
20function error_message($message, $mailbox, $sort, $startMessage, $color) {
21
22    global $default_folder_prefix;
23
24    $urlMailbox = urlencode($mailbox);
25    $string = '<tr><td align="center">' . $message . '</td></tr>'.
26              '<tr><td align="center">'.
27              '<a href="'.sqm_baseuri()."src/right_main.php?sort=$sort&amp;startMessage=$startMessage&amp;mailbox=$urlMailbox\">";
28
29    if (!empty($default_folder_prefix)) {
30        if (strpos($mailbox, $default_folder_prefix) === 0)
31            $mailbox = substr($mailbox, strlen($default_folder_prefix));
32    }
33
34    $string .= sprintf (_("Click here to return to %s"),
35                  sm_encode_html_special_chars(imap_utf7_decode_local($mailbox))).
36              '</a></td></tr>';
37    error_box($string, $color);
38}
39
40function plain_error_message($message, $color) {
41    error_box($message, $color);
42}
43
44function logout_error( $errString, $errTitle = '' ) {
45    global $frame_top, $org_logo, $org_name, $org_logo_width, $org_logo_height,
46           $hide_sm_attributions, $version, $squirrelmail_language,
47           $color, $theme, $theme_default;
48
49    include_once( SM_PATH . 'functions/page_header.php' );
50
51    $base_uri = sqm_baseuri();
52
53    $logout_link = $base_uri . 'src/login.php';
54
55    list($junk, $errString, $errTitle, $logout_link)
56        = do_hook('logout_error', $errString, $errTitle, $logout_link);
57
58    /* Display width and height like good little people */
59    $width_and_height = '';
60    if (isset($org_logo_width) && is_numeric($org_logo_width) && $org_logo_width>0) {
61        $width_and_height = " width=\"$org_logo_width\"";
62    }
63    if (isset($org_logo_height) && is_numeric($org_logo_height) && $org_logo_height>0) {
64        $width_and_height .= " height=\"$org_logo_height\"";
65    }
66
67    if (!isset($frame_top) || $frame_top == '' ) {
68        $frame_top = '_top';
69    }
70
71    // load default theme if possible
72    if (!isset($color) && @file_exists($theme[$theme_default]['PATH']))
73        @include ($theme[$theme_default]['PATH']);
74
75    if ( !isset( $color ) ) {
76        $color = array();
77        $color[0]  = '#dcdcdc';  /* light gray    TitleBar               */
78        $color[1]  = '#800000';  /* red                                  */
79        $color[2]  = '#cc0000';  /* light red     Warning/Error Messages */
80        $color[4]  = '#ffffff';  /* white         Normal Background      */
81        $color[7]  = '#0000cc';  /* blue          Links                  */
82        $color[8]  = '#000000';  /* black         Normal text            */
83    }
84
85    if ( $errTitle == '' ) {
86        $errTitle = $errString;
87    }
88    set_up_language($squirrelmail_language, true);
89
90    displayHtmlHeader( $org_name.' - '.$errTitle, '', false );
91
92    echo '<body text="'.$color[8].'" bgcolor="'.$color[4].'" link="'.$color[7].'" vlink="'.$color[7].'" alink="'.$color[7]."\">\n\n".
93         '<center>';
94
95    if (isset($org_logo) && ($org_logo != '')) {
96        echo '<img src="'.$org_logo.'" alt="'.sprintf(_("%s Logo"), $org_name).
97             "\"$width_and_height /><br />\n";
98    }
99    echo ( $hide_sm_attributions ? '' :
100            '<small>' . sprintf (_("SquirrelMail version %s"), $version) . '<br />'.
101            _("By the SquirrelMail Project Team") . "<br /></small>\n" ).
102         '<table cellspacing="1" cellpadding="0" bgcolor="'.$color[1].'" width="70%">'.
103         '<tr><td>'.
104         '<table width="100%" border="0" bgcolor="'.$color[4].'" align="center">'.
105         '<tr><td bgcolor="'.$color[0].'" align="center">'.
106         '<font color="'.$color[2].'"><b>' . _("ERROR") . '</b></font>'.
107         '</td></tr>'.
108         '<tr><td align="center">' . $errString . '</td></tr>'.
109         '<tr><td bgcolor="'.$color[0].'" align="center">'.
110         '<font color="'.$color[2].'"><b>'.
111         '<a href="'.$logout_link.'" target="'.$frame_top.'">'.
112         _("Go to the login page") . '</a></b></font></td></tr>'.
113         '</table></td></tr></table></center>'.
114         '<!-- logout_error -->'.
115         '</body></html>';
116}
117
118function error_box($string, $color) {
119    global $pageheader_sent, $org_title;
120
121    if ( !isset( $color ) ) {
122        $color = array();
123        $color[0]  = '#dcdcdc';  /* light gray    TitleBar               */
124        $color[1]  = '#800000';  /* red                                  */
125        $color[2]  = '#cc0000';  /* light red     Warning/Error Messages */
126        $color[4]  = '#ffffff';  /* white         Normal Background      */
127        $color[7]  = '#0000cc';  /* blue          Links                  */
128        $color[8]  = '#000000';  /* black         Normal text            */
129        $color[9]  = '#ababab';  /* mid-gray      Darker version of #0   */
130    }
131    if ( !isset( $org_title ) ) {
132        $org_title = "SquirrelMail";
133    }
134
135    $err = _("ERROR");
136
137    $ret = concat_hook_function('error_box', $string);
138    if($ret != '') {
139        $string = $ret;
140    }
141
142    /* check if the page header has been sent; if not, send it! */
143    if(!isset($pageheader_sent) || !$pageheader_sent) {
144        /* include this just to be sure */
145        include_once( SM_PATH . 'functions/page_header.php' );
146        displayHtmlHeader($org_title.': '.$err);
147        $pageheader_sent = TRUE;
148        echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\">\n\n";
149    }
150
151    echo '<table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="'.$color[9].'">'.
152         '<tr><td>'.
153         '<table width="100%" cellpadding="0" cellspacing="0" align="center" border="0" bgcolor="'.$color[4].'">'.
154         '<tr><td align="center" bgcolor="'.$color[0].'">'.
155         '<font color="'.$color[2].'"><b>' . $err . ':</b></font>'.
156         '</td></tr><tr><td>'.
157         '<table cellpadding="1" cellspacing="5" align="center" border="0">'.
158         '<tr>' . html_tag( 'td', $string."\n", 'left') . '</tr></table>'.
159         '</td></tr></table></td></tr></table>'.
160         '<!-- error_box -->';
161}
162
163/**
164 * Adds message that informs about non fatal error that can happen while saving preferences
165 * @param string $message error message
166 * @since 1.5.1 and 1.4.5
167 */
168function error_option_save($message) {
169    global $optpage_save_error;
170
171    if (! is_array($optpage_save_error) )
172        $optpage_save_error=array();
173
174    $optpage_save_error=array_merge($optpage_save_error,array($message));
175}
176