]> git.openstreetmap.org Git - nominatim.git/commitdiff
more isset checks for PHP variables
authorSarah Hoffmann <lonvia@denofr.de>
Sun, 9 Dec 2012 08:35:34 +0000 (09:35 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Wed, 12 Dec 2012 17:49:21 +0000 (18:49 +0100)
lib/lib.php
lib/template/address-json.php
lib/template/address-jsonv2.php
lib/template/address-xml.php
lib/template/search-jsonv2.php
website/search.php

index 547b10833d12e592c06b3024c0d579d1512ffe90..f0f7ecebfae64ca3187c8bbc920a4084a770841a 100644 (file)
                }
 
                $aLanguages = array();
                }
 
                $aLanguages = array();
-               if (preg_match_all('/(([a-z]{1,8})(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $aLanguagesParse, PREG_SET_ORDER))
-               {
-                       foreach($aLanguagesParse as $iLang => $aLanguage)
+               if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) {
+                       if (preg_match_all('/(([a-z]{1,8})(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $aLanguagesParse, PREG_SET_ORDER))
                        {
                        {
-                               $aLanguages[$aLanguage[1]] = isset($aLanguage[5])?(float)$aLanguage[5]:1 - ($iLang/100);
-                               if (!isset($aLanguages[$aLanguage[2]])) $aLanguages[$aLanguage[2]] = $aLanguages[$aLanguage[1]]/10;
+                               foreach($aLanguagesParse as $iLang => $aLanguage)
+                               {
+                                       $aLanguages[$aLanguage[1]] = isset($aLanguage[5])?(float)$aLanguage[5]:1 - ($iLang/100);
+                                       if (!isset($aLanguages[$aLanguage[2]])) $aLanguages[$aLanguage[2]] = $aLanguages[$aLanguage[1]]/10;
+                               }
+                               arsort($aLanguages);
                        }
                        }
-                       arsort($aLanguages);
-               }
+        }
                if (!sizeof($aLanguages)) $aLanguages = array(CONST_Default_Language=>1);
                foreach($aLanguages as $sLangauge => $fLangauagePref)
                {
                if (!sizeof($aLanguages)) $aLanguages = array(CONST_Default_Language=>1);
                foreach($aLanguages as $sLangauge => $fLangauagePref)
                {
index c05bce294e1837279815fd04ca69bf8c43787f30..0a1d074a3540e8f68aa0d323fbeff98307e1e0f0 100644 (file)
@@ -3,7 +3,7 @@
 
        if (!sizeof($aPlace))
        {
 
        if (!sizeof($aPlace))
        {
-               if ($sError)
+               if (isset($sError))
                        $aFilteredPlaces['error'] = $sError;
                else
                        $aFilteredPlaces['error'] = 'Unable to geocode';
                        $aFilteredPlaces['error'] = $sError;
                else
                        $aFilteredPlaces['error'] = 'Unable to geocode';
index 4e751a0d4b458ba4f7cff9fbe7fe592863c92276..00f8750db3f97430f4975707a1ec6421762be796 100644 (file)
@@ -3,7 +3,7 @@
 
        if (!sizeof($aPlace))
        {
 
        if (!sizeof($aPlace))
        {
-               if ($sError)
+               if (isset($sError))
                        $aFilteredPlaces['error'] = $sError;
                else
                        $aFilteredPlaces['error'] = 'Unable to geocode';
                        $aFilteredPlaces['error'] = $sError;
                else
                        $aFilteredPlaces['error'] = 'Unable to geocode';
index 75f69e1563c2a96cc8d27dddfb205a226680dcf8..fcd90b85e63cc6b9ea55c2accde01763244bebfa 100644 (file)
@@ -14,7 +14,7 @@
 
        if (!sizeof($aPlace))
        {
 
        if (!sizeof($aPlace))
        {
-               if ($sError)
+               if (isset($sError))
                        echo "<error>$sError</error>";
                else
                        echo "<error>Unable to geocode</error>";
                        echo "<error>$sError</error>";
                else
                        echo "<error>Unable to geocode</error>";
index 671edde4b8fcaafcbf4e3f7bb53fa9fed32bb028..e1552a155ad53ec489791c78a9daa2927820be62 100644 (file)
@@ -40,7 +40,7 @@
 
                $aPlace['category'] = $aPointDetails['class'];
                $aPlace['type'] = $aPointDetails['type'];
 
                $aPlace['category'] = $aPointDetails['class'];
                $aPlace['type'] = $aPointDetails['type'];
-               if ($aPointDetails['icon'])
+               if (isset($aPointDetails['icon']))
                {
                        $aPlace['icon'] = $aPointDetails['icon'];
                }
                {
                        $aPlace['icon'] = $aPointDetails['icon'];
                }
index a619ed7805db9b3ffd0b8bbca2f224ecc8072c76..5ba2571bb5a221236db542b92312abd6e3d2951d 100755 (executable)
                logEnd($oDB, $hLog, sizeof($aToFilter));
        }
        $sMoreURL = CONST_Website_BaseURL.'search?format='.urlencode($sOutputFormat).'&exclude_place_ids='.join(',',$aExcludePlaceIDs);
                logEnd($oDB, $hLog, sizeof($aToFilter));
        }
        $sMoreURL = CONST_Website_BaseURL.'search?format='.urlencode($sOutputFormat).'&exclude_place_ids='.join(',',$aExcludePlaceIDs);
-       $sMoreURL .= '&accept-language='.$_SERVER["HTTP_ACCEPT_LANGUAGE"];
+       if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) $sMoreURL .= '&accept-language='.$_SERVER["HTTP_ACCEPT_LANGUAGE"];
        if ($bShowPolygons) $sMoreURL .= '&polygon=1';
        if ($bShowAddressDetails) $sMoreURL .= '&addressdetails=1';
        if (isset($_GET['viewbox']) && $_GET['viewbox']) $sMoreURL .= '&viewbox='.urlencode($_GET['viewbox']);
        if ($bShowPolygons) $sMoreURL .= '&polygon=1';
        if ($bShowAddressDetails) $sMoreURL .= '&addressdetails=1';
        if (isset($_GET['viewbox']) && $_GET['viewbox']) $sMoreURL .= '&viewbox='.urlencode($_GET['viewbox']);