Aleksander Machniak
2014-12-16 681ba6fc3c296cd6cd11050531b8f4e785141786
commit | author | age
4e17e6 1 <?php
T 2
3 /*
4  +-----------------------------------------------------------------------+
24c91e 5  | program/steps/utils/error.inc                                         |
4e17e6 6  |                                                                       |
e019f2 7  | This file is part of the Roundcube Webmail client                     |
c97625 8  | Copyright (C) 2005-2013, 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) {
AM 46     $__error_title = "AUTHORIZATION FAILED";
47     $__error_text  = "Could not verify that you are authorized to access this service!<br />\n"
48         . "Please contact your server-administrator.";
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) {
AM 54         parse_str($_SERVER['QUERY_STRING'], $url);
55         $url = $rcmail->url($url, true, false, true);
56         $add = "<br /><a href=\"$url\">Click here to try again.<a/>";
57     }
58     else {
59         $add = "Please contact your server-administrator.";
60     }
61
c97625 62     $__error_title = "REQUEST CHECK FAILED";
681ba6 63     $__error_text  = "Access to this service was denied due to failing security checks!<br />\n$add";
a77cf2 64 }
T 65
4e17e6 66 // failed request (wrong step in URL)
c97625 67 else if ($ERROR_CODE == 404) {
AM 68     $request_url   = htmlentities($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
69     $__error_title = "REQUEST FAILED/FILE NOT FOUND";
70     $__error_text  = <<<EOF
4e17e6 71 The requested page was not found!<br />
T 72 Please contact your server-administrator.
73
74 <p><i>Failed request:</i><br />
75 http://$request_url</p>
76 EOF;
8c72e3 77 }
4e17e6 78
8b0fff 79 // database connection error
c97625 80 else if ($ERROR_CODE == 601) {
AM 81     $__error_title = "CONFIGURATION ERROR";
82     $__error_text  =  nl2br($ERROR_MESSAGE) . "<br />Please read the INSTALL instructions!";
8c72e3 83 }
T 84
85 // database connection error
c97625 86 else if ($ERROR_CODE == 603) {
AM 87     $__error_title = "DATABASE ERROR: CONNECTION FAILED!";
88     $__error_text  =  "Unable to connect to the database!<br />Please contact your server-administrator.";
8c72e3 89 }
4e17e6 90
T 91 // system error
8c72e3 92 else {
c97625 93     $__error_title = "SERVICE CURRENTLY NOT AVAILABLE!";
AM 94     $__error_text  = "Please contact your server-administrator.";
e170b4 95
c97625 96     if (($rcmail->config->get('debug_level') & 4) && $ERROR_MESSAGE) {
AM 97         $__error_text = $ERROR_MESSAGE;
98     }
99     else {
100         $__error_text = sprintf('Error No. [%s]', $ERROR_CODE);
101     }
8c72e3 102 }
4e17e6 103
d7b35c 104 $HTTP_ERR_CODE = $ERROR_CODE && $ERROR_CODE < 600 ? $ERROR_CODE : 500;
4e17e6 105
ac4882 106 // Ajax request
0c2596 107 if ($rcmail->output && $rcmail->output->type == 'js') {
c97625 108     header("HTTP/1.0 $HTTP_ERR_CODE $__error_title");
AM 109     die;
ac4882 110 }
4e17e6 111
ac4882 112 // compose page content
4e17e6 113 $__page_content = <<<EOF
T 114 <div>
115 <h3 class="error-title">$__error_title</h3>
116 <p class="error-text">$__error_text</p>
117 </div>
118 EOF;
119
0c2596 120 if ($rcmail->output && $rcmail->output->template_exists('error')) {
c97625 121     $rcmail->output->reset();
AM 122     $rcmail->output->set_env('server_error', $ERROR_CODE);
2e713d 123     $rcmail->output->set_env('comm_path', $rcmail->comm_path);
c97625 124     $rcmail->output->send('error');
8c72e3 125 }
4e17e6 126
0c2596 127 $__skin = $rcmail->config->get('skin', 'default');
A 128 $__productname = $rcmail->config->get('product_name', 'Roundcube Webmail');
4e17e6 129
T 130 // print system error page
131 print <<<EOF
132 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
133 <html xmlns="http://www.w3.org/1999/xhtml"><head>
d7b35c 134 <title>$__productname :: ERROR</title>
bbeda8 135 <link rel="stylesheet" type="text/css" href="skins/$__skin/common.css" />
4e17e6 136 </head>
T 137 <body>
138
139 <table border="0" cellsapcing="0" cellpadding="0" width="100%" height="80%"><tr><td align="center">
140
141 $__page_content
142
143 </td></tr></table>
144
145 </body>
146 </html>
147 EOF;
148
8c72e3 149 exit;