Пример #1
0
 public function getGeoLookUpServices()
 {
     $arrReturn = array();
     $arrFile = scan(TL_ROOT . "/system/modules/geolocation");
     foreach ($arrFile as $value) {
         if (preg_match("/GeoLookUp.*\\.php/", $value) && !preg_match("/.*(Factory|Interface).*/", $value)) {
             $objService = GeoLookUpFactory::getEngine($value);
             if ($objService->getType() == GeoLookUpInterface::GEO || $objService->getType() == GeoLookUpInterface::BOTH) {
                 $arrReturn[$value] = $objService->getName();
             }
         }
     }
     return $arrReturn;
 }
Пример #2
0
 /**
  * User lookup service to get informations about a ip adress
  * 
  * @param GeolocationContainer $objGeolocation
  * @return boolean|GeolocationContainer Fales if no result else a GeolocationContainer
  */
 public function doIPLookUp(GeolocationContainer $objGeolocation)
 {
     // No values found, so try to get the country
     $arrLookUpServices = deserialize($GLOBALS['TL_CONFIG']['geo_IPlookUpSettings']);
     $objGeolocationResult = FALSE;
     foreach ($arrLookUpServices as $value) {
         $objLookUpService = GeoLookUpFactory::getEngine($value["lookUpClass"]);
         $objGeolocationResult = $objLookUpService->getLocation($value["lookUpConfig"], $objGeolocation);
         if ($objGeolocationResult !== FALSE) {
             $objGeolocation = $objGeolocationResult;
             break;
         }
     }
     if ($objGeolocationResult === FALSE) {
         return false;
     } else {
         // Set information for geolocation
         $objGeolocation->setIP(preg_replace("/\\.\\d?\\d?\\d?\$/", ".0", $objGeolocation->getIP()));
         $objGeolocation->setTracked(true);
         $objGeolocation->setTrackType(GeolocationContainer::LOCATION_IP);
         $objGeolocation->addTrackFinished(GeolocationContainer::LOCATION_IP);
         $objGeolocation->setTrackRunning(GeolocationContainer::LOCATION_NONE);
         $objGeolocation->setFailed(false);
         $objGeolocation->setError("");
         $objGeolocation->setErrorID(GeolocationContainer::ERROR_NONE);
     }
     return $objGeolocation;
 }