3 require_once('init.php');
4 require_once('ParameterParser.php');
6 /***************************************************************************
8 * Error handling functions
12 function chksql($oSql, $sMsg = "Database request failed")
14 if (!PEAR::isError($oSql)) return $oSql;
16 header('HTTP/1.0 500 Internal Server Error');
17 header('Content-type: text/html; charset=utf-8');
19 $sSqlError = $oSql->getMessage();
23 <head><title>Internal Server Error</title></head>
25 <h1>Internal Server Error</h1>
26 <p>Nominatim has encountered an internal error while accessing the database.
27 This may happen because the database is broken or because of a bug in
28 the software. If you think it is a bug, feel free to report
29 it over on <a href="https://github.com/twain47/Nominatim/issues">
30 Github</a>. Please include the URL that caused the problem and the
31 complete error details below.</p>
32 <p><b>Message:</b> $sMsg</p>
33 <p><b>SQL Error:</b> $sSqlError</p>
34 <p><b>Details:</b> <pre>
43 echo "<pre>\n".$oSql->getUserInfo()."</pre>";
46 echo "</pre></p></body></html>";
50 function failInternalError($sError, $sSQL = false, $vDumpVar = false)
52 header('HTTP/1.0 500 Internal Server Error');
53 header('Content-type: text/html; charset=utf-8');
54 echo "<html><body><h1>Internal Server Error</h1>";
55 echo '<p>Nominatim has encountered an internal error while processing your request. This is most likely because of a bug in the software.</p>';
56 echo "<p><b>Details:</b> ".$sError,"</p>";
57 echo '<p>Feel free to file an issue on <a href="https://github.com/twain47/Nominatim/issues">Github</a>. Please include the error message above and the URL you used.</p>';
60 echo "<hr><h2>Debugging Information</h2><br>";
63 echo "<h3>SQL query</h3><code>".$sSQL."</code>";
67 echo "<h3>Result</h3> <code>";
72 echo "\n</body></html>\n";
77 function userError($sError)
79 header('HTTP/1.0 400 Bad Request');
80 header('Content-type: text/html; charset=utf-8');
81 echo "<html><body><h1>Bad Request</h1>";
82 echo '<p>Nominatim has encountered an error with your request.</p>';
83 echo "<p><b>Details:</b> ".$sError."</p>";
84 echo '<p>If you feel this error is incorrect feel file an issue on <a href="https://github.com/twain47/Nominatim/issues">Github</a>. Please include the error message above and the URL you used.</p>';
85 echo "\n</body></html>\n";
90 /***************************************************************************
91 * HTTP Reply header setup
94 if (CONST_NoAccessControl)
96 header("Access-Control-Allow-Origin: *");
97 header("Access-Control-Allow-Methods: OPTIONS,GET");
98 if (!empty($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']))
100 header("Access-Control-Allow-Headers: ".$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']);
103 if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') exit;
105 if (CONST_Debug) header('Content-type: text/html; charset=utf-8');