Пример #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 iSaveHtml($sList, $sUrl, $sContent, $sFetched = null)
 {
     if (!$sFetched) {
         $sFetched = date('Y-m-d H:i:s');
     }
     $sDomain = Utilitu::sUrlToDomain($sUrl);
     $aInsert = array('list' => Utilitu::sConditionalHash($sList), 'domain_hash' => Utilitu::sConditionalHash($sDomain), 'url_hash' => Utilitu::sConditionalHash($sUrl), 'html_hash' => md5($sContent), 'html' => $sContent, 'fetched' => $sFetched, 'parsed' => 0, 'url' => $sUrl);
     $iHtmlID = DirectDB::iInsert('ads_htmls', $aInsert);
     return $iHtmlID;
 }