示例#1
0
 public static function oGetCoords($sAddress)
 {
     $sAddress = trim($sAddress);
     $sAddressHash = Utilitu::sConditionalHash($sAddress);
     $oAddress = DirectDB::oSelectOne(self::$sTable, array('address_hash' => $sAddressHash));
     if (!$oAddress) {
         $sResponse = Curl::sGet('http://maps.google.com/maps/api/geocode/json?address=' . urlencode($sAddress) . '&sensor=false');
         $oResponse = json_decode($sResponse);
         $oFirstResult = $oResponse->results[0];
         $oFRC = $oFirstResult->geometry->location;
         DirectDB::iInsert(self::$sTable, array('address_hash' => $sAddressHash, 'address_stub' => substr($sAddress, 0, 64), 'fetched' => date('Y-m-d H:i:s'), 'x' => '' . $oFRC->lng . '', 'y' => '' . $oFRC->lat . '', 'response' => $sResponse));
         $oAddress = DirectDB::oSelectOne(self::$sTable, array('address_hash' => $sAddressHash));
     }
     $oCoords = new StdClass();
     $oCoords->nX = $oAddress->x;
     $oCoords->nY = $oAddress->y;
     return $oCoords;
 }
示例#2
0
 public static function oGetEarliestHtmlForUrl($sUrl)
 {
     $sExtra = 'ORDER BY fetched ASC LIMIT 1';
     $sWhere = array('url_hash' => Utilitu::sConditionalHash($sUrl));
     $oReturn = DirectDB::oSelectOne('ads_htmls', $sWhere, '*', $sExtra);
     return $oReturn;
 }