3 require_once('init.php');
 
   4 require_once('ParameterParser.php');
 
   5 require_once(CONST_Debug ? 'DebugHtml.php' : 'DebugNone.php');
 
   7 /***************************************************************************
 
   9  * Error handling functions
 
  14 function chksql($oSql, $sMsg = 'Database request failed')
 
  16     if (!PEAR::isError($oSql)) return $oSql;
 
  18     header('HTTP/1.0 500 Internal Server Error');
 
  19     header('Content-type: text/html; charset=utf-8');
 
  21     $sSqlError = $oSql->getMessage();
 
  25   <head><title>Internal Server Error</title></head>
 
  27     <h1>Internal Server Error</h1>
 
  28     <p>Nominatim has encountered an internal error while accessing the database.
 
  29        This may happen because the database is broken or because of a bug in
 
  30        the software. If you think it is a bug, feel free to report
 
  31        it over on <a href="https://github.com/openstreetmap/Nominatim/issues">
 
  32        Github</a>. Please include the URL that caused the problem and the
 
  33        complete error details below.</p>
 
  34     <p><b>Message:</b> $sMsg</p>
 
  35     <p><b>SQL Error:</b> $sSqlError</p>
 
  36     <p><b>Details:</b> <pre>
 
  42         echo "<pre>\n".$oSql->getUserInfo().'</pre>';
 
  45     echo '</pre></p></body></html>';
 
  49 function failInternalError($sError, $sSQL = false, $vDumpVar = false)
 
  51     header('HTTP/1.0 500 Internal Server Error');
 
  52     header('Content-type: text/html; charset=utf-8');
 
  53     echo '<html><body><h1>Internal Server Error</h1>';
 
  54     echo '<p>Nominatim has encountered an internal error while processing your request. This is most likely because of a bug in the software.</p>';
 
  55     echo '<p><b>Details:</b> '.$sError,'</p>';
 
  56     echo '<p>Feel free to file an issue on <a href="https://github.com/openstreetmap/Nominatim/issues">Github</a>. ';
 
  57     echo 'Please include the error message above and the URL you used.</p>';
 
  59         echo '<hr><h2>Debugging Information</h2><br>';
 
  61             echo '<h3>SQL query</h3><code>'.$sSQL.'</code>';
 
  64             echo '<h3>Result</h3> <code>';
 
  69     echo "\n</body></html>\n";
 
  74 function userError($sError)
 
  76     header('HTTP/1.0 400 Bad Request');
 
  77     header('Content-type: text/html; charset=utf-8');
 
  78     echo '<html><body><h1>Bad Request</h1>';
 
  79     echo '<p>Nominatim has encountered an error with your request.</p>';
 
  80     echo '<p><b>Details:</b> '.$sError.'</p>';
 
  81     echo '<p>If you feel this error is incorrect feel file an issue on <a href="https://github.com/openstreetmap/Nominatim/issues">Github</a>. ';
 
  82     echo 'Please include the error message above and the URL you used.</p>';
 
  83     echo "\n</body></html>\n";
 
  88 /***************************************************************************
 
  89  * HTTP Reply header setup
 
  92 if (CONST_NoAccessControl) {
 
  93     header('Access-Control-Allow-Origin: *');
 
  94     header('Access-Control-Allow-Methods: OPTIONS,GET');
 
  95     if (!empty($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'])) {
 
  96         header('Access-Control-Allow-Headers: '.$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']);
 
  99 if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') exit;
 
 101 if (CONST_Debug) header('Content-type: text/html; charset=utf-8');