source: github/program/steps/utils/error.inc @ b97d0e1

Last change on this file since b97d0e1 was b97d0e1, checked in by Aleksander Machniak <alec@…>, 11 months ago

Fix empty user agent string on error page for "incompatible browser" error

  • Property mode set to 100644
File size: 4.5 KB
Line 
1<?php
2
3/*
4 +-----------------------------------------------------------------------+
5 | program/steps/utils/error.inc                                         |
6 |                                                                       |
7 | This file is part of the Roundcube Webmail client                     |
8 | Copyright (C) 2005-2011, The Roundcube Dev Team                       |
9 |                                                                       |
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.                     |
13 |                                                                       |
14 | PURPOSE:                                                              |
15 |   Display error message page                                          |
16 |                                                                       |
17 +-----------------------------------------------------------------------+
18 | Author: Thomas Bruederli <roundcube@gmail.com>                        |
19 +-----------------------------------------------------------------------+
20*/
21
22$rcmail = rcmail::get_instance();
23
24// browser is not compatible with this application
25if ($ERROR_CODE==409) {
26  $user_agent = $_SERVER['HTTP_USER_AGENT'];
27  $__error_title = 'Your browser does not suit the requirements for this application';
28  $__error_text = <<<EOF
29<i>Supported browsers:</i><br />
30&raquo; &nbsp;Microsoft Internet Explorer 6+<br />
31&raquo; &nbsp;Mozilla Firefox 3+<br />
32&raquo; &nbsp;Chrome 10+<br />
33&raquo; &nbsp;Safari 4+<br />
34&raquo; &nbsp;Opera 8+<br />
35<br />
36&raquo; &nbsp;JavaScript enabled<br />
37&raquo; &nbsp;Support for XMLHTTPRequest<br />
38
39<p><i>Your configuration:</i><br />
40$user_agent</p>
41EOF;
42}
43
44// authorization error
45else if ($ERROR_CODE==401) {
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.";
49}
50
51// forbidden due to request check
52else if ($ERROR_CODE==403) {
53  $__error_title = "REQUEST CHECK FAILED";
54  $__error_text  = "Access to this service was denied due to failing security checks!<br />\n".
55                   "Please contact your server-administrator.";
56}
57
58// failed request (wrong step in URL)
59else if ($ERROR_CODE==404) {
60  $__error_title = "REQUEST FAILED/FILE NOT FOUND";
61  $request_url = htmlentities($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
62  $__error_text  = <<<EOF
63The requested page was not found!<br />
64Please contact your server-administrator.
65
66<p><i>Failed request:</i><br />
67http://$request_url</p>
68EOF;
69}
70
71// database connection error
72else if ($ERROR_CODE==601)
73{
74  $__error_title = "CONFIGURATION ERROR";
75  $__error_text  =  nl2br($ERROR_MESSAGE) . "<br />Please read the INSTALL instructions!";
76}
77
78// database connection error
79else if ($ERROR_CODE==603) {
80  $__error_title = "DATABASE ERROR: CONNECTION FAILED!";
81  $__error_text  =  "Unable to connect to the database!<br />Please contact your server-administrator.";
82}
83
84// system error
85else {
86  $__error_title = "SERVICE CURRENTLY NOT AVAILABLE!";
87  $__error_text  = "Please contact your server-administrator.";
88
89  if (($rcmail->config->get('debug_level') & 4) && $ERROR_MESSAGE)
90    $__error_text = $ERROR_MESSAGE;
91  else
92    $__error_text = sprintf('Error No. [%s]', $ERROR_CODE);
93}
94
95$HTTP_ERR_CODE = $ERROR_CODE && $ERROR_CODE < 600 ? $ERROR_CODE : 500;
96
97// Ajax request
98if ($rcmail->output && $rcmail->output->type == 'js') {
99  header("HTTP/1.0 $HTTP_ERR_CODE $__error_title");
100  die;
101}
102
103// compose page content
104$__page_content = <<<EOF
105<div>
106<h3 class="error-title">$__error_title</h3>
107<p class="error-text">$__error_text</p>
108</div>
109EOF;
110
111if ($rcmail->output && $rcmail->output->template_exists('error')) {
112  $rcmail->output->reset();
113  $rcmail->output->send('error');
114}
115
116$__skin = $rcmail->config->get('skin', 'default');
117$__productname = $rcmail->config->get('product_name', 'Roundcube Webmail');
118
119// print system error page
120print <<<EOF
121<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
122<html xmlns="http://www.w3.org/1999/xhtml"><head>
123<title>$__productname :: ERROR</title>
124<link rel="stylesheet" type="text/css" href="skins/$__skin/common.css" />
125</head>
126<body>
127
128<table border="0" cellsapcing="0" cellpadding="0" width="100%" height="80%"><tr><td align="center">
129
130$__page_content
131
132</td></tr></table>
133
134</body>
135</html>
136EOF;
137
138exit;
139
Note: See TracBrowser for help on using the repository browser.