Mercurial > hg > rc2
comparison program/steps/utils/error.inc @ 0:4681f974d28b
vanilla 1.3.3 distro, I hope
| author | Charlie Root |
|---|---|
| date | Thu, 04 Jan 2018 15:52:31 -0500 |
| parents | |
| children | 3a5f959af5ae |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:4681f974d28b |
|---|---|
| 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-2015, 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 = htmlentities($_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 7+<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 = mb_strtoupper($rcmail->gettext('errauthorizationfailed')); | |
| 47 $__error_text = nl2br($rcmail->gettext('errunauthorizedexplain') . "\n" . | |
| 48 $rcmail->gettext('errcontactserveradmin')); | |
| 49 } | |
| 50 | |
| 51 // forbidden due to request check | |
| 52 else if ($ERROR_CODE == 403) { | |
| 53 if ($_SERVER['REQUEST_METHOD'] == 'GET' && $rcmail->request_status == rcube::REQUEST_ERROR_URL) { | |
| 54 $url = $rcmail->url($_GET, true, false, true); | |
| 55 $add = html::a($url, $rcmail->gettext('clicktoresumesession')); | |
| 56 } | |
| 57 else { | |
| 58 $add = $rcmail->gettext('errcontactserveradmin'); | |
| 59 } | |
| 60 | |
| 61 $__error_title = mb_strtoupper($rcmail->gettext('errrequestcheckfailed')); | |
| 62 $__error_text = nl2br($rcmail->gettext('errcsrfprotectionexplain')) . '<p>' . $add . '</p>'; | |
| 63 } | |
| 64 | |
| 65 // failed request (wrong step in URL) | |
| 66 else if ($ERROR_CODE == 404) { | |
| 67 $request_url = htmlentities($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); | |
| 68 $__error_title = mb_strtoupper($rcmail->gettext('errnotfound')); | |
| 69 $__error_text = nl2br($rcmail->gettext('errnotfoundexplain') . "\n" . | |
| 70 $rcmail->gettext('errcontactserveradmin')); | |
| 71 | |
| 72 $__error_text .= '<p><i>' . $rcmail->gettext('errfailedrequest') . ":</i><br />\n<tt>//$request_url</tt></p>"; | |
| 73 } | |
| 74 | |
| 75 // invalid compose ID | |
| 76 else if ($ERROR_CODE == 450 && $_SERVER['REQUEST_METHOD'] == 'GET' && $rcmail->action == 'compose') { | |
| 77 $url = $rcmail->url('compose'); | |
| 78 | |
| 79 $__error_title = mb_strtoupper($rcmail->gettext('errcomposesession')); | |
| 80 $__error_text = nl2br($rcmail->gettext('errcomposesessionexplain')) | |
| 81 . '<p>' . html::a($url, $rcmail->gettext('clicktocompose')) . '</p>'; | |
| 82 } | |
| 83 | |
| 84 // database connection error | |
| 85 else if ($ERROR_CODE == 601) { | |
| 86 $__error_title = "CONFIGURATION ERROR"; | |
| 87 $__error_text = nl2br($ERROR_MESSAGE) . "<br />Please read the INSTALL instructions!"; | |
| 88 } | |
| 89 | |
| 90 // database connection error | |
| 91 else if ($ERROR_CODE == 603) { | |
| 92 $__error_title = "DATABASE ERROR: CONNECTION FAILED!"; | |
| 93 $__error_text = "Unable to connect to the database!<br />Please contact your server-administrator."; | |
| 94 } | |
| 95 | |
| 96 // system error | |
| 97 else { | |
| 98 $__error_title = "SERVICE CURRENTLY NOT AVAILABLE!"; | |
| 99 $__error_text = "Please contact your server-administrator."; | |
| 100 | |
| 101 if (($rcmail->config->get('debug_level') & 4) && $ERROR_MESSAGE) { | |
| 102 $__error_text = $ERROR_MESSAGE; | |
| 103 } | |
| 104 else { | |
| 105 $__error_text = sprintf('Error No. [%s]', $ERROR_CODE); | |
| 106 } | |
| 107 } | |
| 108 | |
| 109 // inform plugins | |
| 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 | |
| 123 $HTTP_ERR_CODE = $ERROR_CODE && $ERROR_CODE < 600 ? $ERROR_CODE : 500; | |
| 124 | |
| 125 // Ajax request | |
| 126 if ($rcmail->output && $rcmail->output->type == 'js') { | |
| 127 header("HTTP/1.0 $HTTP_ERR_CODE $__error_title"); | |
| 128 die; | |
| 129 } | |
| 130 | |
| 131 // compose page content | |
| 132 $__page_content = <<<EOF | |
| 133 <div> | |
| 134 <h3 class="error-title">$__error_title</h3> | |
| 135 <div class="error-text">$__error_text</div> | |
| 136 </div> | |
| 137 EOF; | |
| 138 | |
| 139 if ($rcmail->output && $rcmail->output->template_exists('error')) { | |
| 140 $rcmail->output->reset(); | |
| 141 $rcmail->output->set_env('server_error', $ERROR_CODE); | |
| 142 $rcmail->output->set_env('comm_path', $rcmail->comm_path); | |
| 143 $rcmail->output->send('error'); | |
| 144 } | |
| 145 | |
| 146 $__skin = $rcmail->config->get('skin', 'default'); | |
| 147 $__productname = $rcmail->config->get('product_name', 'Roundcube Webmail'); | |
| 148 | |
| 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> | |
| 153 <title>$__productname :: ERROR</title> | |
| 154 <link rel="stylesheet" type="text/css" href="skins/$__skin/common.css" /> | |
| 155 </head> | |
| 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 | |
| 168 exit; |
