$this->loadStructuredAddressElement($sPostalCode, 'postalcode', 5, 11, array(5, 11));
$this->loadStructuredAddressElement($sCountry, 'country', 4, 4, false);
- if (sizeof($this->aStructuredQuery) > 0) {
+ if (!empty($this->aStructuredQuery)) {
$this->sQuery = join(', ', $this->aStructuredQuery);
if ($this->iMaxAddressRank < 30) {
$this->sAllowedTypesSQLList = '(\'place\',\'boundary\')';
$aParams = $this->aStructuredQuery;
- if (sizeof($aParams) == 1) return false;
+ if (count($aParams) == 1) return false;
$aOrderToFallback = array('postalcode', 'street', 'city', 'county', 'state');
$sPhraseType,
$iToken == 0 && $iPhrase == 0,
$iPhrase == 0,
- $iToken + 1 == sizeof($aWordset)
- && $iPhrase + 1 == sizeof($aPhrases)
+ $iToken + 1 == count($aWordset)
+ && $iPhrase + 1 == count($aPhrases)
);
foreach ($aNewSearches as $oSearch) {
usort($aNewWordsetSearches, array('Nominatim\SearchDescription', 'bySearchRank'));
$aWordsetSearches = array_slice($aNewWordsetSearches, 0, 50);
}
- //var_Dump('<hr>',sizeof($aWordsetSearches)); exit;
+ //var_Dump('<hr>',count($aWordsetSearches)); exit;
$aNewPhraseSearches = array_merge($aNewPhraseSearches, $aNewWordsetSearches);
usort($aNewPhraseSearches, array('Nominatim\SearchDescription', 'bySearchRank'));
$iSearchCount = 0;
$aSearches = array();
foreach ($aGroupedSearches as $iScore => $aNewSearches) {
- $iSearchCount += sizeof($aNewSearches);
+ $iSearchCount += count($aNewSearches);
$aSearches = array_merge($aSearches, $aNewSearches);
if ($iSearchCount > 50) break;
}
}
}
- if (sizeof($aTokens)) {
+ if (!empty($aTokens)) {
// Check which tokens we have, get the ID numbers
$sSQL = 'SELECT word_id, word_token, word, class, type, country_code, operator, search_name_count';
$sSQL .= ' FROM word ';
// because order in the address doesn't matter.
$aPhrases = array_reverse($aPhrases);
$aPhrases[0]->invertWordSets();
- if (sizeof($aPhrases) > 1) {
- $aPhrases[sizeof($aPhrases)-1]->invertWordSets();
+ if (count($aPhrases) > 1) {
+ $aPhrases[count($aPhrases)-1]->invertWordSets();
}
$aReverseGroupedSearches = $this->getGroupedSearches($aSearches, $aPhrases, $aValidTokens, false);
$sHash = serialize($aSearch);
if (isset($aSearchHash[$sHash])) {
unset($aGroupedSearches[$iGroup][$iSearch]);
- if (sizeof($aGroupedSearches[$iGroup]) == 0) unset($aGroupedSearches[$iGroup]);
+ if (empty($aGroupedSearches[$iGroup])) unset($aGroupedSearches[$iGroup]);
} else {
$aSearchHash[$sHash] = 1;
}
if ($iQueryLoop > 20) break;
}
- if (sizeof($aResults) && ($this->iMinAddressRank != 0 || $this->iMaxAddressRank != 30)) {
+ if (!empty($aResults) && ($this->iMinAddressRank != 0 || $this->iMaxAddressRank != 30)) {
// Need to verify passes rank limits before dropping out of the loop (yuk!)
// reduces the number of place ids, like a filter
// rank_address is 30 for interpolated housenumbers
$aResults = $tempIDs;
}
- if (sizeof($aResults)) break;
+ if (!empty($aResults)) break;
if ($iGroupLoop > 4) break;
if ($iQueryLoop > 30) break;
}
}
// No results? Done
- if (!sizeof($aResults)) {
+ if (empty($aResults)) {
if ($this->bFallback) {
if ($this->fallbackStructuredQuery()) {
return $this->lookup();
}
// Absolute limit on number of results
- if (sizeof($aSearchResults) >= $this->iFinalLimit) break;
+ if (count($aSearchResults) >= $this->iFinalLimit) break;
}
if (CONST_Debug) var_dump($aSearchResults);
arsort($aLanguages);
}
}
- if (!sizeof($aLanguages) && CONST_Default_Language) {
+ if (empty($aLanguages) && CONST_Default_Language) {
$aLanguages[CONST_Default_Language] = 1;
}
$aResult = array(array(join(' ', $aWords)));
$sFirstToken = '';
if ($iDepth < Phrase::MAX_DEPTH) {
- while (sizeof($aWords) > 1) {
+ while (count($aWords) > 1) {
$sWord = array_shift($aWords);
$sFirstToken .= ($sFirstToken?' ':'').$sWord;
$aRest = $this->createWordSets($aWords, $iDepth + 1);
$aResult = array(array(join(' ', $aWords)));
$sFirstToken = '';
if ($iDepth < Phrase::MAX_DEPTH) {
- while (sizeof($aWords) > 1) {
+ while (count($aWords) > 1) {
$sWord = array_pop($aWords);
$sFirstToken = $sWord.($sFirstToken?' ':'').$sFirstToken;
$aRest = $this->createInverseWordSets($aWords, $iDepth + 1);
$aResults = $this->lookup(array($iPlaceID => new Result($iPlaceID)));
- return sizeof($aResults) ? reset($aResults) : null;
+ return empty($aResults) ? null : reset($aResults);
}
public function lookup($aResults, $iMinRank = 0, $iMaxRank = 30)
{
- if (!sizeof($aResults)) {
+ if (empty($aResults)) {
return array();
}
$aSubSelects = array();
if (CONST_Debug) var_dump($aSubSelects);
- if (!sizeof($aSubSelects)) {
+ if (empty($aSubSelects)) {
return array();
}
*/
public function looksLikeFullAddress()
{
- return sizeof($this->aName)
- && (sizeof($this->aAddress || $this->sCountryCode))
+ return (!empty($this->aName))
+ && (!empty($this->aAddress) || $this->sCountryCode)
&& preg_match('/[0-9]+/', $this->sHouseNumber);
}
*/
public function isValidSearch()
{
- if (!sizeof($this->aName)) {
+ if (empty($this->aName)) {
if ($this->sHouseNumber) {
return false;
}
// If we have a structured search or this is not the first term,
// add the postcode as an addendum.
if ($this->iOperator != Operator::POSTCODE
- && ($sPhraseType == 'postalcode' || sizeof($this->aName))
+ && ($sPhraseType == 'postalcode' || !empty($this->aName))
) {
$oSearch = clone $this;
$oSearch->iSearchRank++;
$oSearch->iSearchRank++;
}
// also must not appear in the middle of the address
- if (sizeof($this->aAddress)
- || sizeof($this->aAddressNonSearch)
+ if (!empty($this->aAddress)
+ || (!empty($this->aAddressNonSearch))
|| $this->sPostcode
) {
$oSearch->iSearchRank++;
$iOp = Operator::NEAR; // near == in for the moment
if ($aSearchTerm['operator'] == '') {
- if (sizeof($this->aName) || $this->oContext->isBoundedSearch()) {
+ if (!empty($this->aName) || $this->oContext->isBoundedSearch()) {
$iOp = Operator::NAME;
}
$oSearch->iSearchRank += 2;
// of the phrase. In structured search the name must forcably in
// the first phrase. In unstructured search it may be in a later
// phrase when the first phrase is a house number.
- if (sizeof($this->aName) || !($bFirstPhrase || $sPhraseType == '')) {
+ if (!empty($this->aName) || !($bFirstPhrase || $sPhraseType == '')) {
if (($sPhraseType == '' || !$bFirstPhrase) && !$bHasPartial) {
$oSearch = clone $this;
$oSearch->iSearchRank++;
$iWordID = $aSearchTerm['word_id'];
if ((!$bStructuredPhrases || $iPhrase > 0)
- && sizeof($this->aName)
+ && (!empty($this->aName))
&& strpos($aSearchTerm['word_token'], ' ') === false
) {
if ($aSearchTerm['search_name_count'] + 1 < CONST_Max_Word_Frequency) {
if (preg_match('#^[0-9]+$#', $aSearchTerm['word_token'])) {
$oSearch->iSearchRank += 2;
}
- if (sizeof($aFullTokens)) {
+ if (!empty($aFullTokens)) {
$oSearch->iSearchRank++;
}
$aNewSearches[] = $oSearch;
}
if ((!$this->sPostcode && !$this->aAddress && !$this->aAddressNonSearch)
- && (!sizeof($this->aName) || $this->iNamePhrase == $iPhrase)
+ && (empty($this->aName) || $this->iNamePhrase == $iPhrase)
) {
$oSearch = clone $this;
$oSearch->iSearchRank += 2;
- if (!sizeof($this->aName)) {
+ if (empty($this->aName)) {
$oSearch->iSearchRank += 1;
}
if (preg_match('#^[0-9]+$#', $aSearchTerm['word_token'])) {
$iHousenumber = -1;
if ($this->sCountryCode
- && !sizeof($this->aName)
+ && empty($this->aName)
&& !$this->iOperator
&& !$this->sClass
&& !$this->oContext->hasNearPoint()
if (4 >= $iMinRank && 4 <= $iMaxRank) {
$aResults = $this->queryCountry($oDB);
}
- } elseif (!sizeof($this->aName) && !sizeof($this->aAddress)) {
+ } elseif (empty($this->aName) && empty($this->aAddress)) {
// Neither name nor address? Then we must be
// looking for a POI in a geographic area.
if ($this->oContext->isBoundedSearch()) {
);
//now search for housenumber, if housenumber provided
- if ($this->sHouseNumber && sizeof($aResults)) {
+ if ($this->sHouseNumber && !empty($aResults)) {
$aNamedPlaceIDs = $aResults;
$aResults = $this->queryHouseNumber($oDB, $aNamedPlaceIDs, $iLimit);
- if (!sizeof($aResults) && $this->looksLikeFullAddress()) {
+ if (empty($aResults) && $this->looksLikeFullAddress()) {
$aResults = $aNamedPlaceIDs;
}
}
// finally get POIs if requested
- if ($this->sClass && sizeof($aResults)) {
+ if ($this->sClass && !empty($aResults)) {
$aResults = $this->queryPoiByOperator($oDB, $aResults, $iLimit);
}
}
var_dump(array_keys($aResults));
}
- if (sizeof($aResults) && $this->sPostcode) {
+ if (!empty($aResults) && $this->sPostcode) {
$sPlaceIds = Result::joinIdsByTable($aResults, Result::TABLE_PLACEX);
if ($sPlaceIds) {
$sSQL = 'SELECT place_id FROM placex';
{
$sSQL = 'SELECT p.place_id FROM location_postcode p ';
- if (sizeof($this->aAddress)) {
+ if (!empty($this->aAddress)) {
$sSQL .= ', search_name s ';
$sSQL .= 'WHERE s.place_id = p.parent_place_id ';
$sSQL .= 'AND array_cat(s.nameaddress_vector, s.name_vector)';
$aTerms = array();
$aOrder = array();
- if ($this->sHouseNumber && sizeof($this->aAddress)) {
+ if ($this->sHouseNumber && !empty($this->aAddress)) {
$sHouseNumberRegex = '\\\\m'.$this->sHouseNumber.'\\\\M';
$aOrder[] = ' (';
$aOrder[0] .= 'EXISTS(';
$aOrder[0] .= ') DESC';
}
- if (sizeof($this->aName)) {
+ if (!empty($this->aName)) {
$aTerms[] = 'name_vector @> '.getArraySQL($this->aName);
}
- if (sizeof($this->aAddress)) {
+ if (!empty($this->aAddress)) {
// For infrequent name terms disable index usage for address
if (CONST_Search_NameOnlySearchFrequencyThreshold
- && sizeof($this->aName) == 1
+ && count($this->aName) == 1
&& $aWordFrequencyScores[$this->aName[reset($this->aName)]]
< CONST_Search_NameOnlySearchFrequencyThreshold
) {
$aTerms[] = $this->oContext->withinSQL('centroid');
$aOrder[] = $this->oContext->distanceSQL('centroid');
} elseif ($this->sPostcode) {
- if (!sizeof($this->aAddress)) {
+ if (empty($this->aAddress)) {
$aTerms[] = "EXISTS(SELECT place_id FROM location_postcode p WHERE p.postcode = '".$this->sPostcode."' AND ST_DWithin(search_name.centroid, p.geometry, 0.1))";
} else {
$aOrder[] = "(SELECT min(ST_Distance(search_name.centroid, p.geometry)) FROM location_postcode p WHERE p.postcode = '".$this->sPostcode."')";
$sImportanceSQL .= $this->oContext->viewboxImportanceSQL('centroid');
$aOrder[] = "$sImportanceSQL DESC";
- if (sizeof($this->aFullNameAddress)) {
+ if (!empty($this->aFullNameAddress)) {
$sExactMatchSQL = ' ( ';
$sExactMatchSQL .= ' SELECT count(*) FROM ( ';
$sExactMatchSQL .= ' SELECT unnest('.getArraySQL($this->aFullNameAddress).')';
$aResults = array();
- if (sizeof($aTerms)) {
+ if (!empty($aTerms)) {
$sSQL = 'SELECT place_id,'.$sExactMatchSQL;
$sSQL .= ' FROM search_name';
$sSQL .= ' WHERE '.join(' and ', $aTerms);
$bIsIntHouseNumber= (bool) preg_match('/[0-9]+/', $this->sHouseNumber);
$iHousenumber = intval($this->sHouseNumber);
- if ($bIsIntHouseNumber && !sizeof($aResults)) {
+ if ($bIsIntHouseNumber && empty($aResults)) {
// if nothing found, search in the interpolation line table
$sSQL = 'SELECT distinct place_id FROM location_property_osmline';
$sSQL .= ' WHERE startnumber is not NULL';
}
// If nothing found try the aux fallback table
- if (CONST_Use_Aux_Location_data && !sizeof($aResults)) {
+ if (CONST_Use_Aux_Location_data && empty($aResults)) {
$sSQL = 'SELECT place_id FROM location_property_aux';
$sSQL .= ' WHERE parent_place_id in ('.$sPlaceIDs.')';
$sSQL .= " AND housenumber = '".$this->sHouseNumber."'";
}
// If nothing found then search in Tiger data (location_property_tiger)
- if (CONST_Use_US_Tiger_Data && $bIsIntHouseNumber && !sizeof($aResults)) {
+ if (CONST_Use_US_Tiger_Data && $bIsIntHouseNumber && empty($aResults)) {
$sSQL = 'SELECT place_id FROM location_property_tiger';
$sSQL .= ' WHERE parent_place_id in ('.$sPlaceIDs.') and (';
if ($iHousenumber % 2 == 0) {
$aResult = array();
$bUnknown = false;
- $iSize = sizeof($aArg);
+ $iSize = count($aArg);
for ($i = 1; $i < $iSize; $i++) {
if (isset($aQuick[$aArg[$i]])) {
$aLine = $aQuick[$aArg[$i]];
{
$sCPU = file_get_contents('/proc/cpuinfo');
preg_match_all('#processor\s+: [0-9]+#', $sCPU, $aMatches);
- return sizeof($aMatches[0]);
+ return count($aMatches[0]);
}
$aFilteredPlaces = array();
-if (!sizeof($aPlace)) {
+if (empty($aPlace)) {
if (isset($sError))
$aFilteredPlaces['error'] = $sError;
else $aFilteredPlaces['error'] = 'Unable to geocode';
echo " querystring='".htmlspecialchars($_SERVER['QUERY_STRING'], ENT_QUOTES)."'";
echo ">\n";
-if (!sizeof($aPlace)) {
+if (empty($aPlace)) {
if (isset($sError))
echo "<error>$sError</error>";
else echo '<error>Unable to geocode</error>';
}
}
- if (sizeof($aParentOfLines))
+ if (!empty($aParentOfLines))
{
headline('Parent Of');
_one_row($aAddressLine);
}
}
- if (sizeof($aParentOfLines) >= 500) {
+ if (count($aParentOfLines) >= 500) {
echo '<p>There are more child objects which are not shown.</p>';
}
}
$aPlace['icon'] = $aPointDetails['icon'];
}
- if (isset($aPointDetails['address']) && sizeof($aPointDetails['address'])>0) {
+ if (isset($aPointDetails['address']) && !empty($aPointDetails['address'])) {
$aPlace['address'] = $aPointDetails['address'];
}
echo '</div>';
$i = $i+1;
}
- if (sizeof($aSearchResults) && $sMoreURL)
+ if (!empty($aSearchResults) && $sMoreURL)
{
echo '<div class="more"><a class="btn btn-primary" href="'.htmlentities($sMoreURL).'">Search for more results</a></div>';
}
$aPlace['icon'] = $aPointDetails['icon'];
}
- if (isset($aPointDetails['address']) && sizeof($aPointDetails['address'])) {
+ if (isset($aPointDetails['address']) && !empty($aPointDetails['address'])) {
$aPlace['address'] = $aPointDetails['address'];
}
+ <!-- eval, system, etc -->
+ <rule ref="Generic.PHP.ForbiddenFunctions">
+ <properties>
+ <property name="forbiddenFunctions" type="array" value="sizeof=>count,delete=>unset,print=>echo,create_function=>null,eval=>null"/>
+ </properties>
+ </rule>
+
<!-- **************************************************************
DOCUMENTATION
************************************************************** -->
}
// Assume the first template with lots of params is the type (fallback for infobox)
- if (!isset($aPageProperties['sPossibleInfoboxType']) && sizeof($aParams) > 10) {
+ if (!isset($aPageProperties['sPossibleInfoboxType']) && count($aParams) > 10) {
$aPageProperties['sPossibleInfoboxType'] = trim($aTemplate[0]);
// $aPageProperties['aInfoboxParams'] = $aParams;
}
if (!isset($aNominatRecords[0])) {
$aNameParts = preg_split('#[(,]#', $aRecord['name']);
- if (sizeof($aNameParts) > 1) {
+ if (count($aNameParts) > 1) {
$sNameURL = $sURL.'&q='.urlencode(trim($aNameParts[0]));
var_Dump($sNameURL);
$sXML = file_get_contents($sNameURL);
}
// assume first is best/right
- for ($i = 0; $i < sizeof($aNominatRecords); $i++) {
+ for ($i = 0; $i < count($aNominatRecords); $i++) {
$fDiff = ($aRecord['lat']-$aNominatRecords[$i]['LAT']) * ($aRecord['lat']-$aNominatRecords[$i]['LAT']);
$fDiff += ($aRecord['lon']-$aNominatRecords[$i]['LON']) * ($aRecord['lon']-$aNominatRecords[$i]['LON']);
$fDiff = sqrt($fDiff);
$aPlaceAddress = array_reverse($oPlaceLookup->getAddressDetails($iPlaceID));
-if (!sizeof($aPlaceAddress)) userError('Unknown place id.');
+if (empty($aPlaceAddress)) userError('Unknown place id.');
$aBreadcrums = array();
foreach ($aPlaceAddress as $i => $aPlace) {
$sSQL .= ' order by rank_address asc,rank_search asc,localname,class, type,housenumber';
$aParentOfLines = chksql($oDB->getAll($sSQL));
-if (sizeof($aParentOfLines)) {
+if (!empty($aParentOfLines)) {
echo '<h2>Parent Of:</h2>';
$aClassType = getClassTypesWithImportance();
$aGroupedAddressLines = array();
echo '</div>';
}
}
- if (sizeof($aParentOfLines) >= 500) {
+ if (count($aParentOfLines) >= 500) {
echo '<p>There are more child objects which are not shown.</p>';
}
echo '</div>';
$iTotalBroken = (int) chksql($oDB->getOne('select count(*) from import_polygon_error'));
$aPolygons = array();
-while ($iTotalBroken && !sizeof($aPolygons)) {
+while ($iTotalBroken && empty($aPolygons)) {
$sSQL = 'select osm_type as "type",osm_id as "id",class as "key",type as "value",name->\'name\' as "name",';
$sSQL .= 'country_code as "country",errormessage as "error message",updated';
$sSQL .= ' from import_polygon_error';
if ($bReduced) $aWhere[] = "errormessage like 'Area reduced%'";
if ($sClass) $sWhere[] = "class = '".pg_escape_string($sClass)."'";
- if (sizeof($aWhere)) {
+ if (!empty($aWhere)) {
$sSQL .= ' where '.join(' and ', $aWhere);
}
if ($oLookup) {
$aPlaces = $oPlaceLookup->lookup(array($oLookup->iId => $oLookup));
- if (sizeof($aPlaces)) {
+ if (!empty($aPlaces)) {
$aPlace = reset($aPlaces);
}
}
if ($sOutputFormat=='html') {
$sDataDate = chksql($oDB->getOne("select TO_CHAR(lastimportdate,'YYYY/MM/DD HH24:MI')||' GMT' from import_status limit 1"));
}
-logEnd($oDB, $hLog, sizeof($aSearchResults));
+logEnd($oDB, $hLog, count($aSearchResults));
$sQuery = $oGeocode->getQueryString();