| 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 |
|---|
| 25 | if ($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 | » Microsoft Internet Explorer 6+<br /> |
|---|
| 31 | » Mozilla Firefox 3+<br /> |
|---|
| 32 | » Chrome 10+<br /> |
|---|
| 33 | » Safari 4+<br /> |
|---|
| 34 | » Opera 8+<br /> |
|---|
| 35 | <br /> |
|---|
| 36 | » JavaScript enabled<br /> |
|---|
| 37 | » Support for XMLHTTPRequest<br /> |
|---|
| 38 | |
|---|
| 39 | <p><i>Your configuration:</i><br /> |
|---|
| 40 | $user_agent</p> |
|---|
| 41 | EOF; |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | // authorization error |
|---|
| 45 | else 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 |
|---|
| 52 | else 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) |
|---|
| 59 | else 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 |
|---|
| 63 | The requested page was not found!<br /> |
|---|
| 64 | Please contact your server-administrator. |
|---|
| 65 | |
|---|
| 66 | <p><i>Failed request:</i><br /> |
|---|
| 67 | http://$request_url</p> |
|---|
| 68 | EOF; |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | // database connection error |
|---|
| 72 | else 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 |
|---|
| 79 | else 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 |
|---|
| 85 | else { |
|---|
| 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 |
|---|
| 98 | if ($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> |
|---|
| 109 | EOF; |
|---|
| 110 | |
|---|
| 111 | if ($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 |
|---|
| 120 | print <<<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> |
|---|
| 136 | EOF; |
|---|
| 137 | |
|---|
| 138 | exit; |
|---|
| 139 | |
|---|