You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

error.inc 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <?php
  2. /**
  3. +-----------------------------------------------------------------------+
  4. | program/steps/utils/error.inc |
  5. | |
  6. | This file is part of the Roundcube Webmail client |
  7. | Copyright (C) 2005-2015, The Roundcube Dev Team |
  8. | |
  9. | Licensed under the GNU General Public License version 3 or |
  10. | any later version with exceptions for skins & plugins. |
  11. | See the README file for a full license statement. |
  12. | |
  13. | PURPOSE: |
  14. | Display error message page |
  15. | |
  16. +-----------------------------------------------------------------------+
  17. | Author: Thomas Bruederli <roundcube@gmail.com> |
  18. +-----------------------------------------------------------------------+
  19. */
  20. $rcmail = rcmail::get_instance();
  21. // browser is not compatible with this application
  22. if ($ERROR_CODE == 409) {
  23. $user_agent = htmlentities($_SERVER['HTTP_USER_AGENT']);
  24. $__error_title = 'Your browser does not suit the requirements for this application';
  25. $__error_text = <<<EOF
  26. <i>Supported browsers:</i><br />
  27. &raquo; &nbsp;Microsoft Internet Explorer 7+<br />
  28. &raquo; &nbsp;Mozilla Firefox 3+<br />
  29. &raquo; &nbsp;Chrome 10+<br />
  30. &raquo; &nbsp;Safari 4+<br />
  31. &raquo; &nbsp;Opera 8+<br />
  32. <br />
  33. &raquo; &nbsp;JavaScript enabled<br />
  34. &raquo; &nbsp;Support for XMLHTTPRequest<br />
  35. <p><i>Your configuration:</i><br />
  36. $user_agent</p>
  37. EOF;
  38. }
  39. // authorization error
  40. else if ($ERROR_CODE == 401) {
  41. $__error_title = mb_strtoupper($rcmail->gettext('errauthorizationfailed'));
  42. $__error_text = nl2br($rcmail->gettext('errunauthorizedexplain') . "\n" .
  43. $rcmail->gettext('errcontactserveradmin'));
  44. }
  45. // forbidden due to request check
  46. else if ($ERROR_CODE == 403) {
  47. if ($_SERVER['REQUEST_METHOD'] == 'GET' && $rcmail->request_status == rcube::REQUEST_ERROR_URL) {
  48. $url = $rcmail->url($_GET, true, false, true);
  49. $add = html::a($url, $rcmail->gettext('clicktoresumesession'));
  50. }
  51. else {
  52. $add = $rcmail->gettext('errcontactserveradmin');
  53. }
  54. $__error_title = mb_strtoupper($rcmail->gettext('errrequestcheckfailed'));
  55. $__error_text = nl2br($rcmail->gettext('errcsrfprotectionexplain')) . '<p>' . $add . '</p>';
  56. }
  57. // failed request (wrong step in URL)
  58. else if ($ERROR_CODE == 404) {
  59. $request_url = htmlentities($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
  60. $__error_title = mb_strtoupper($rcmail->gettext('errnotfound'));
  61. $__error_text = nl2br($rcmail->gettext('errnotfoundexplain') . "\n" .
  62. $rcmail->gettext('errcontactserveradmin'));
  63. $__error_text .= '<p><i>' . $rcmail->gettext('errfailedrequest') . ":</i><br />\n<tt>//$request_url</tt></p>";
  64. }
  65. // invalid compose ID
  66. else if ($ERROR_CODE == 450 && $_SERVER['REQUEST_METHOD'] == 'GET' && $rcmail->action == 'compose') {
  67. $url = $rcmail->url('compose');
  68. $__error_title = mb_strtoupper($rcmail->gettext('errcomposesession'));
  69. $__error_text = nl2br($rcmail->gettext('errcomposesessionexplain'))
  70. . '<p>' . html::a($url, $rcmail->gettext('clicktocompose')) . '</p>';
  71. }
  72. // database connection error
  73. else if ($ERROR_CODE == 601) {
  74. $__error_title = "CONFIGURATION ERROR";
  75. $__error_text = nl2br($ERROR_MESSAGE) . "<br />Please read the INSTALL instructions!";
  76. }
  77. // database connection error
  78. else if ($ERROR_CODE == 603) {
  79. $__error_title = "DATABASE ERROR: CONNECTION FAILED!";
  80. $__error_text = "Unable to connect to the database!<br />Please contact your server-administrator.";
  81. }
  82. // system error
  83. else {
  84. $__error_title = "SERVICE CURRENTLY NOT AVAILABLE!";
  85. $__error_text = "Please contact your server-administrator.";
  86. if (($rcmail->config->get('debug_level') & 4) && $ERROR_MESSAGE) {
  87. $__error_text = $ERROR_MESSAGE;
  88. }
  89. else {
  90. $__error_text = sprintf('Error No. [%s]', $ERROR_CODE);
  91. }
  92. }
  93. // inform plugins
  94. if ($rcmail && $rcmail->plugins) {
  95. $plugin = $rcmail->plugins->exec_hook('error_page', array(
  96. 'code' => $ERROR_CODE,
  97. 'title' => $__error_title,
  98. 'text' => $__error_text,
  99. ));
  100. if (!empty($plugin['title']))
  101. $__error_title = $plugin['title'];
  102. if (!empty($plugin['text']))
  103. $__error_text = $plugin['text'];
  104. }
  105. $HTTP_ERR_CODE = $ERROR_CODE && $ERROR_CODE < 600 ? $ERROR_CODE : 500;
  106. // Ajax request
  107. if ($rcmail->output && $rcmail->output->type == 'js') {
  108. header("HTTP/1.0 $HTTP_ERR_CODE $__error_title");
  109. die;
  110. }
  111. // compose page content
  112. $__page_content = <<<EOF
  113. <div>
  114. <h3 class="error-title">$__error_title</h3>
  115. <div class="error-text">$__error_text</div>
  116. </div>
  117. EOF;
  118. if ($rcmail->output && $rcmail->output->template_exists('error')) {
  119. $rcmail->output->reset();
  120. $rcmail->output->set_env('server_error', $ERROR_CODE);
  121. $rcmail->output->set_env('comm_path', $rcmail->comm_path);
  122. $rcmail->output->send('error');
  123. }
  124. $__skin = $rcmail->config->get('skin', 'default');
  125. $__productname = $rcmail->config->get('product_name', 'Roundcube Webmail');
  126. // print system error page
  127. print <<<EOF
  128. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  129. <html xmlns="http://www.w3.org/1999/xhtml"><head>
  130. <title>$__productname :: ERROR</title>
  131. <link rel="stylesheet" type="text/css" href="skins/$__skin/common.css" />
  132. </head>
  133. <body>
  134. <table border="0" cellsapcing="0" cellpadding="0" width="100%" height="80%"><tr><td align="center">
  135. $__page_content
  136. </td></tr></table>
  137. </body>
  138. </html>
  139. EOF;
  140. exit;