Aleksander Machniak
2015-10-02 aada285660afd5a296d57c910ef52983f9ccc7cb
commit | author | age
4e17e6 1 <?php
T 2
a95874 3 /**
4e17e6 4  +-----------------------------------------------------------------------+
24c91e 5  | program/steps/utils/error.inc                                         |
4e17e6 6  |                                                                       |
e019f2 7  | This file is part of the Roundcube Webmail client                     |
0bd99d 8  | Copyright (C) 2005-2015, The Roundcube Dev Team                       |
7fe381 9  |                                                                       |
T 10  | Licensed under the GNU General Public License version 3 or            |
11  | any later version with exceptions for skins & plugins.                |
12  | See the README file for a full license statement.                     |
4e17e6 13  |                                                                       |
T 14  | PURPOSE:                                                              |
15  |   Display error message page                                          |
16  |                                                                       |
17  +-----------------------------------------------------------------------+
18  | Author: Thomas Bruederli <roundcube@gmail.com>                        |
19  +-----------------------------------------------------------------------+
20 */
21
0c2596 22 $rcmail = rcmail::get_instance();
4e17e6 23
T 24 // browser is not compatible with this application
c97625 25 if ($ERROR_CODE == 409) {
AM 26     $user_agent    = htmlentities($_SERVER['HTTP_USER_AGENT']);
27     $__error_title = 'Your browser does not suit the requirements for this application';
28     $__error_text  = <<<EOF
4e17e6 29 <i>Supported browsers:</i><br />
95d289 30 &raquo; &nbsp;Microsoft Internet Explorer 7+<br />
1e09cd 31 &raquo; &nbsp;Mozilla Firefox 3+<br />
T 32 &raquo; &nbsp;Chrome 10+<br />
33 &raquo; &nbsp;Safari 4+<br />
34 &raquo; &nbsp;Opera 8+<br />
4e17e6 35 <br />
T 36 &raquo; &nbsp;JavaScript enabled<br />
a95e0e 37 &raquo; &nbsp;Support for XMLHTTPRequest<br />
4e17e6 38
T 39 <p><i>Your configuration:</i><br />
40 $user_agent</p>
41 EOF;
8c72e3 42 }
4e17e6 43
T 44 // authorization error
c97625 45 else if ($ERROR_CODE == 401) {
0bd99d 46     $__error_title = strtoupper($rcmail->gettext('errauthorizationfailed'));
TB 47     $__error_text  = nl2br($rcmail->gettext('errunauthorizedexplain') . "\n" .
48                         $rcmail->gettext('errcontactserveradmin'));
8c72e3 49 }
24c91e 50
a77cf2 51 // forbidden due to request check
c97625 52 else if ($ERROR_CODE == 403) {
681ba6 53     if ($_SERVER['REQUEST_METHOD'] == 'GET' && $rcmail->request_status == rcube::REQUEST_ERROR_URL) {
0bd99d 54         $url = $rcmail->url($_GET, true, false, true);
TB 55         $add = html::a($url, $rcmail->gettext('clicktoresumesession'));
681ba6 56     }
AM 57     else {
0bd99d 58         $add = $rcmail->gettext('errcontactserveradmin');
681ba6 59     }
AM 60
0bd99d 61     $__error_title = strtoupper($rcmail->gettext('errrequestcheckfailed'));
TB 62     $__error_text  = nl2br($rcmail->gettext('errcsrfprotectionexplain')) . '<p>' . $add . '</p>';
a77cf2 63 }
T 64
4e17e6 65 // failed request (wrong step in URL)
c97625 66 else if ($ERROR_CODE == 404) {
AM 67     $request_url   = htmlentities($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
0bd99d 68     $__error_title = strtoupper($rcmail->gettext('errnotfound'));
TB 69     $__error_text  = nl2br($rcmail->gettext('errnotfoundexplain') . "\n" .
70                         $rcmail->gettext('errcontactserveradmin'));
4e17e6 71
0bd99d 72     $__error_text .= '<p><i>' . $rcmail->gettext('errfailedrequest') . ":</i><br />\n<tt>//$request_url</tt></p>";
8c72e3 73 }
4e17e6 74
4b72a1 75 // invalid compose ID
AM 76 else if ($ERROR_CODE == 450 && $_SERVER['REQUEST_METHOD'] == 'GET' && $rcmail->action == 'compose') {
77     $url = $rcmail->url('compose');
78
79     $__error_title = strtoupper($rcmail->gettext('errcomposesession'));
80     $__error_text  = nl2br($rcmail->gettext('errcomposesessionexplain'))
81         . '<p>' . html::a($url, $rcmail->gettext('clicktocompose')) . '</p>';
82 }
83
8b0fff 84 // database connection error
c97625 85 else if ($ERROR_CODE == 601) {
AM 86     $__error_title = "CONFIGURATION ERROR";
87     $__error_text  =  nl2br($ERROR_MESSAGE) . "<br />Please read the INSTALL instructions!";
8c72e3 88 }
T 89
90 // database connection error
c97625 91 else if ($ERROR_CODE == 603) {
AM 92     $__error_title = "DATABASE ERROR: CONNECTION FAILED!";
93     $__error_text  =  "Unable to connect to the database!<br />Please contact your server-administrator.";
8c72e3 94 }
4e17e6 95
T 96 // system error
8c72e3 97 else {
c97625 98     $__error_title = "SERVICE CURRENTLY NOT AVAILABLE!";
AM 99     $__error_text  = "Please contact your server-administrator.";
e170b4 100
c97625 101     if (($rcmail->config->get('debug_level') & 4) && $ERROR_MESSAGE) {
AM 102         $__error_text = $ERROR_MESSAGE;
103     }
104     else {
105         $__error_text = sprintf('Error No. [%s]', $ERROR_CODE);
106     }
8c72e3 107 }
4e17e6 108
0bd99d 109 // inform plugins
TB 110 if ($rcmail && $rcmail->plugins) {
111     $plugin = $rcmail->plugins->exec_hook('error_page', array(
112         'code' => $ERROR_CODE,
113         'title' => $__error_title,
114         'text' => $__error_text,
115     ));
116
117     if (!empty($plugin['title']))
118         $__error_title = $plugin['title'];
119     if (!empty($plugin['text']))
120         $__error_text = $plugin['text'];
121 }
122
d7b35c 123 $HTTP_ERR_CODE = $ERROR_CODE && $ERROR_CODE < 600 ? $ERROR_CODE : 500;
4e17e6 124
ac4882 125 // Ajax request
0c2596 126 if ($rcmail->output && $rcmail->output->type == 'js') {
c97625 127     header("HTTP/1.0 $HTTP_ERR_CODE $__error_title");
AM 128     die;
ac4882 129 }
4e17e6 130
ac4882 131 // compose page content
4e17e6 132 $__page_content = <<<EOF
T 133 <div>
134 <h3 class="error-title">$__error_title</h3>
0bd99d 135 <div class="error-text">$__error_text</div>
4e17e6 136 </div>
T 137 EOF;
138
0c2596 139 if ($rcmail->output && $rcmail->output->template_exists('error')) {
c97625 140     $rcmail->output->reset();
AM 141     $rcmail->output->set_env('server_error', $ERROR_CODE);
2e713d 142     $rcmail->output->set_env('comm_path', $rcmail->comm_path);
c97625 143     $rcmail->output->send('error');
8c72e3 144 }
4e17e6 145
0c2596 146 $__skin = $rcmail->config->get('skin', 'default');
A 147 $__productname = $rcmail->config->get('product_name', 'Roundcube Webmail');
4e17e6 148
T 149 // print system error page
150 print <<<EOF
151 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
152 <html xmlns="http://www.w3.org/1999/xhtml"><head>
d7b35c 153 <title>$__productname :: ERROR</title>
bbeda8 154 <link rel="stylesheet" type="text/css" href="skins/$__skin/common.css" />
4e17e6 155 </head>
T 156 <body>
157
158 <table border="0" cellsapcing="0" cellpadding="0" width="100%" height="80%"><tr><td align="center">
159
160 $__page_content
161
162 </td></tr></table>
163
164 </body>
165 </html>
166 EOF;
167
8c72e3 168 exit;