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.

134 lines
5.8 KiB

  1. <?php
  2. // turn on warnings and notice during developement
  3. include('initialize/PhpErrorSettings.inc.php');
  4. // Project: Web Reference Database (refbase) <http://www.refbase.net>
  5. // Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's
  6. // original author(s).
  7. //
  8. // This code is distributed in the hope that it will be useful,
  9. // but WITHOUT ANY WARRANTY. Please see the GNU General Public
  10. // License for more details.
  11. //
  12. // File: ./error.php
  13. // Repository: $HeadURL: file:///svn/p/refbase/code/branches/bleeding-edge/error.php $
  14. // Author(s): Matthias Steffens <mailto:refbase@extracts.de>
  15. //
  16. // Created: 05-Jan-03, 16:35
  17. // Modified: $Date: 2018-02-23 04:16:36 +0000 (Fri, 23 Feb 2018) $
  18. // $Author: karnesky $
  19. // $Revision: 1422 $
  20. // This php script will display an error page
  21. // showing any error that did occur. It will display
  22. // a link to the previous search results page (if any)
  23. // Incorporate some include files:
  24. include 'initialize/db.inc.php'; // 'db.inc.php' is included to hide username and password
  25. include 'includes/header.inc.php'; // include header
  26. include 'includes/footer.inc.php'; // include footer
  27. include 'includes/include.inc.php'; // include common functions
  28. include 'initialize/ini.inc.php'; // include common variables
  29. // --------------------------------------------------------------------
  30. // START A SESSION:
  31. // call the 'start_session()' function (from 'include.inc.php') which will also read out available session variables:
  32. start_session(false);
  33. // --------------------------------------------------------------------
  34. // Initialize preferred display language:
  35. // (note that 'locales.inc.php' has to be included *after* the call to the 'start_session()' function)
  36. include 'includes/locales.inc.php'; // include the locales
  37. // --------------------------------------------------------------------
  38. // [ Extract form variables sent through POST/GET by use of the '$_REQUEST' variable ]
  39. // [ !! NOTE !!: for details see <http://www.php.net/release_4_2_1.php> & <http://www.php.net/manual/en/language.variables.predefined.php> ]
  40. // Check if any error occurred while processing the database UPDATE/INSERT/DELETE
  41. // /referr
  42. if(!preg_match("/error.php/", $referer) && (strtolower(parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST)) == strtolower($_SERVER['HTTP_HOST']))){
  43. $errorNo = $_REQUEST['errorNo'];
  44. $errorMsg = $_REQUEST['errorMsg'];
  45. $errorMsg = stripSlashesIfMagicQuotes($errorMsg); // function 'stripSlashesIfMagicQuotes()' is defined in 'include.inc.php'
  46. // Extract the header message that was returned by originating script:
  47. $HeaderString = $_REQUEST['headerMsg'];
  48. $HeaderString = stripSlashesIfMagicQuotes($HeaderString);
  49. }
  50. else{
  51. $errorMsg = "Unexpected Error.";
  52. $referer="/";
  53. }
  54. // Extract the view type requested by the user (either 'Mobile', 'Print', 'Web' or ''):
  55. // ('' will produce the default 'Web' output style)
  56. if (isset($_REQUEST['viewType']))
  57. $viewType = $_REQUEST['viewType'];
  58. else
  59. $viewType = "";
  60. // Extract generic variables from the request:
  61. if (isset($_SESSION['oldQuery']))
  62. $oldQuery = $_SESSION['oldQuery']; // get the query URL of the formerly displayed results page
  63. else
  64. $oldQuery = array();
  65. // --------------------------------------------------------------------
  66. // (4) DISPLAY HEADER & RESULTS
  67. // (NOTE: Since there's no need to query the database here, we won't perform any of the following: (1) OPEN CONNECTION, (2) SELECT DATABASE, (3) RUN QUERY, (5) CLOSE CONNECTION)
  68. // Show the login status:
  69. showLogin(); // (function 'showLogin()' is defined in 'include.inc.php')
  70. // (4a) DISPLAY header:
  71. // call the 'displayHTMLhead()' and 'showPageHeader()' functions (which are defined in 'header.inc.php'):
  72. displayHTMLhead(encodeHTML($officialDatabaseName) . " -- Error", "noindex,nofollow", "Feedback page that shows any error that occurred while using the " . encodeHTML($officialDatabaseName), "", false, "", $viewType, array());
  73. showPageHeader($HeaderString);
  74. // Generate a 'search.php' URL that points to the formerly displayed results page:
  75. if (!empty($oldQuery))
  76. $oldQueryURL = generateURL("search.php", "html", $oldQuery, true); // function 'generateURL()' is defined in 'include.inc.php'
  77. // Build appropriate links:
  78. $links = "\n<tr>"
  79. . "\n\t<td>"
  80. . "\n\t\tChoose how to proceed:&nbsp;&nbsp;";
  81. // - provide a 'go back' link (the following would only work with javascript: <a href=\"javascript:history.back()\">Go Back</a>")
  82. $links .= "\n\t\t<a href=\"" . encodeHTML($referer) . "\">Go Back</a>"; // variable '$referer' is globally defined in function 'start_session()' in 'include.inc.php'
  83. // - provide a link to any previous search results:
  84. if (!empty($oldQuery))
  85. $links .= "\n\t\t&nbsp;&nbsp;-OR-&nbsp;&nbsp;"
  86. . "\n\t\t<a href=\"" . $oldQueryURL . "\">Display previous search results</a>";
  87. // - we also include a link to the home page here:
  88. $links .= "\n\t\t&nbsp;&nbsp;-OR-&nbsp;&nbsp;"
  89. . "\n\t\t<a href=\"index.php\">Goto " . encodeHTML($officialDatabaseName) . " Home</a>"
  90. . "\n\t</td>"
  91. . "\n</tr>";
  92. // SHOW ERROR MESSAGE:
  93. echo "\n<table class=\"error\" align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"10\" width=\"95%\">\n<tr>\n\t<td valign=\"top\"> Error "
  94. . encodeHTML($errorNo) . " : <b>" . encodeHTML($errorMsg) . "</b>" // function 'encodeHTML()' is defined in 'include.inc.php'
  95. . "</td>\n</tr>"
  96. . $links
  97. . "\n</table>";
  98. // --------------------------------------------------------------------
  99. // DISPLAY THE HTML FOOTER:
  100. // call the 'showPageFooter()' and 'displayHTMLfoot()' functions (which are defined in 'footer.inc.php')
  101. showPageFooter($HeaderString);
  102. displayHTMLfoot();
  103. // --------------------------------------------------------------------
  104. exit; // die
  105. ?>