thomascube
2012-03-14 a621a9d7ecf334c4894ef8f5168eb6208e5ae0e4
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                     |
a77cf2 8  | Copyright (C) 2005-2011, 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  $Id$
22
23 */
24
25
26 // browser is not compatible with this application
8c72e3 27 if ($ERROR_CODE==409) {
4e17e6 28   $user_agent = $GLOBALS['HTTP_SERVER_VARS']['HTTP_USER_AGENT'];
T 29   $__error_title = 'Your browser does not suit the requirements for this application';
30   $__error_text = <<<EOF
31 <i>Supported browsers:</i><br />
32 &raquo; &nbsp;Microsoft Internet Explorer 6+<br />
1e09cd 33 &raquo; &nbsp;Mozilla Firefox 3+<br />
T 34 &raquo; &nbsp;Chrome 10+<br />
35 &raquo; &nbsp;Safari 4+<br />
36 &raquo; &nbsp;Opera 8+<br />
4e17e6 37 <br />
T 38 &raquo; &nbsp;JavaScript enabled<br />
a95e0e 39 &raquo; &nbsp;Support for XMLHTTPRequest<br />
4e17e6 40
T 41 <p><i>Your configuration:</i><br />
42 $user_agent</p>
43 EOF;
8c72e3 44 }
4e17e6 45
T 46 // authorization error
8c72e3 47 else if ($ERROR_CODE==401) {
4e17e6 48   $__error_title = "AUTHORIZATION FAILED";
T 49   $__error_text  = "Could not verify that you are authorized to access this service!<br />\n".
50                    "Please contact your server-administrator.";
8c72e3 51 }
24c91e 52
a77cf2 53 // forbidden due to request check
T 54 else if ($ERROR_CODE==403) {
55   $__error_title = "REQUEST CHECK FAILED";
56   $__error_text  = "Access to this service was denied due to failing security checks!<br />\n".
57                    "Please contact your server-administrator.";
58 }
59
4e17e6 60 // failed request (wrong step in URL)
8c72e3 61 else if ($ERROR_CODE==404) {
4e17e6 62   $__error_title = "REQUEST FAILED/FILE NOT FOUND";
89406f 63   $request_url = htmlentities($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
4e17e6 64   $__error_text  = <<<EOF
T 65 The requested page was not found!<br />
66 Please contact your server-administrator.
67
68 <p><i>Failed request:</i><br />
69 http://$request_url</p>
70 EOF;
8c72e3 71 }
4e17e6 72
8b0fff 73 // database connection error
8c72e3 74 else if ($ERROR_CODE==601)
T 75 {
76   $__error_title = "CONFIGURATION ERROR";
77   $__error_text  =  nl2br($ERROR_MESSAGE) . "<br />Please read the INSTALL instructions!";
78 }
79
80 // database connection error
81 else if ($ERROR_CODE==603) {
8b0fff 82   $__error_title = "DATABASE ERROR: CONNECTION FAILED!";
8c72e3 83   $__error_text  =  "Unable to connect to the database!<br />Please contact your server-administrator.";
T 84 }
4e17e6 85
T 86 // system error
8c72e3 87 else {
4e17e6 88   $__error_title = "SERVICE CURRENTLY NOT AVAILABLE!";
T 89   $__error_text  = "Please contact your server-administrator.";
e170b4 90
4e17e6 91   if (($CONFIG['debug_level'] & 4) && $ERROR_MESSAGE)
T 92     $__error_text = $ERROR_MESSAGE;
93   else
c73b19 94     $__error_text = sprintf('Error No. [%s]', $ERROR_CODE);
8c72e3 95 }
4e17e6 96
d7b35c 97 $HTTP_ERR_CODE = $ERROR_CODE && $ERROR_CODE < 600 ? $ERROR_CODE : 500;
4e17e6 98
ac4882 99 // Ajax request
A 100 if ($OUTPUT && ($OUTPUT instanceof rcube_json_output)) {
d7b35c 101   header("HTTP/1.0 $HTTP_ERR_CODE $__error_title");
ac4882 102   die;
A 103 }
4e17e6 104
ac4882 105 // compose page content
4e17e6 106 $__page_content = <<<EOF
T 107 <div>
108 <h3 class="error-title">$__error_title</h3>
109 <p class="error-text">$__error_text</p>
110 </div>
111 EOF;
112
8c72e3 113 if ($OUTPUT && $OUTPUT->template_exists('error')) {
4c6b66 114   $OUTPUT->reset();
47124c 115   $OUTPUT->send('error');
8c72e3 116 }
4e17e6 117
bbeda8 118 $__skin = $CONFIG->skin ? $CONFIG->skin : 'default';
d7b35c 119 $__productname = $CONFIG['product_name'] ? $CONFIG['product_name'] : 'Roundcube Webmail';
4e17e6 120
T 121 // print system error page
122 print <<<EOF
123 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
124 <html xmlns="http://www.w3.org/1999/xhtml"><head>
d7b35c 125 <title>$__productname :: ERROR</title>
bbeda8 126 <link rel="stylesheet" type="text/css" href="skins/$__skin/common.css" />
4e17e6 127 </head>
T 128 <body>
129
130 <table border="0" cellsapcing="0" cellpadding="0" width="100%" height="80%"><tr><td align="center">
131
132 $__page_content
133
134 </td></tr></table>
135
136 </body>
137 </html>
138 EOF;
139
8c72e3 140 exit;
b25dfd 141