X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/051998dd80b0def50058266b7adbdf2e971032eb..e842d8793c1c416a75bbae39c004184f1ed66289:/lib/lib.php diff --git a/lib/lib.php b/lib/lib.php index 897db8e7..ec5b9b1f 100644 --- a/lib/lib.php +++ b/lib/lib.php @@ -1,51 +1,5 @@

Internal Server Error

"; - echo '

Nominatim has encountered an internal error while processing your request. This is most likely because of a bug in the software.

'; - echo "

Details: ".$sError,"

"; - echo '

Feel free to report the bug in the OSM bug database. Please include the error message above and the URL you used.

'; - if (CONST_Debug) - { - echo "

Debugging Information


"; - if ($sSQL) - { - echo "

SQL query

".$sSQL.""; - } - if ($vDumpVar) - { - echo "

Result

"; - var_dump($vDumpVar); - echo ""; - } - } - echo "\n\n"; - exit; - } - - - function userError($sError) - { - header('HTTP/1.0 400 Bad Request'); - header('Content-type: text/html; charset=utf-8'); - echo "

Bad Request

"; - echo '

Nominatim has encountered an error with your request.

'; - echo "

Details: ".$sError,"

"; - echo '

If you feel this error is incorrect feel free to report the bug in the OSM bug database. Please include the error message above and the URL you used.

'; - echo "\n\n"; - exit; - } - - function getParamBool($name, $default=false) - { - if (!isset($_GET[$name])) return $default; - - return (bool) $_GET[$name]; - } - function fail($sError, $sUserError = false) { if (!$sUserError) $sUserError = $sError; @@ -223,12 +177,7 @@ { // Try an exact match on the gb_postcode table $sSQL = 'select \'AA\', ST_X(ST_Centroid(geometry)) as lon,ST_Y(ST_Centroid(geometry)) as lat from gb_postcode where postcode = \''.$sPostcode.'\''; - $aNearPostcodes = $oDB->getAll($sSQL); - if (PEAR::IsError($aNearPostcodes)) - { - var_dump($sSQL, $aNearPostcodes); - exit; - } + $aNearPostcodes = chksql($oDB->getAll($sSQL)); if (sizeof($aNearPostcodes)) { @@ -701,12 +650,7 @@ if (!$bRaw) $sSQL .= " WHERE isaddress OR type = 'country_code'"; $sSQL .= " order by rank_address desc,isaddress desc"; - $aAddressLines = $oDB->getAll($sSQL); - if (PEAR::IsError($aAddressLines)) - { - var_dump($aAddressLines); - exit; - } + $aAddressLines = chksql($oDB->getAll($sSQL)); if ($bRaw) return $aAddressLines; //echo "
";
 		//var_dump($aAddressLines);
@@ -804,12 +748,7 @@
 			$sSQL .= ' OR ST_DWithin('.$sPointSQL.', ST_Centroid(geometry), '.$fSearchDiam.'))';
 			$sSQL .= ' ORDER BY ST_distance('.$sPointSQL.', geometry) ASC limit 1';
 			//var_dump($sSQL);
-			$aPlace = $oDB->getRow($sSQL);
-			if (PEAR::IsError($aPlace))
-			{
-				var_Dump($sSQL, $aPlace);
-				exit;
-			}
+			$aPlace = chksql($oDB->getRow($sSQL));
 			$iPlaceID = $aPlace['place_id'];
 		}
 
@@ -817,22 +756,12 @@
 		if ($iPlaceID)
 		{
 			$sSQL = "select address_place_id from place_addressline where cached_rank_address <= $iMaxRank and place_id = $iPlaceID order by cached_rank_address desc,isaddress desc,distance desc limit 1";
-			$iPlaceID = $oDB->getOne($sSQL);
-			if (PEAR::IsError($iPlaceID))
-			{
-				var_Dump($sSQL, $iPlaceID);
-				exit;
-			}
+			$iPlaceID = chksql($oDB->getOne($sSQL));
 
 			if ($iPlaceID && $aPlace['place_id'] && $iMaxRank < 28)
 			{
 				$sSQL = "select address_place_id from place_addressline where cached_rank_address <= $iMaxRank and place_id = ".$aPlace['place_id']." order by cached_rank_address desc,isaddress desc,distance desc";
-				$iPlaceID = $oDB->getOne($sSQL);
-				if (PEAR::IsError($iPlaceID))
-				{
-					var_Dump($sSQL, $iPlaceID);
-					exit;
-				}
+				$iPlaceID = chksql($oDB->getOne($sSQL));
 			}
 			if (!$iPlaceID)
 			{