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.

132 lines
5.7 KiB

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