getPathToGeoIpDatabase() public static method

Returns the path of an existing GeoIP database or false if none can be found.
public static getPathToGeoIpDatabase ( array $possibleFileNames ) : string | false
$possibleFileNames array The list of possible file names for the GeoIP database.
return string | false
示例#1
0
 private function setLocationProvider($file)
 {
     GeoIp::$dbNames['loc'] = array($file);
     GeoIp::$geoIPDatabaseDir = 'tests/lib/geoip-files';
     LocationProvider::$providers = null;
     LocationProvider::setCurrentProvider(self::GEOIP_IMPL_TO_TEST);
     if (LocationProvider::getCurrentProviderId() !== self::GEOIP_IMPL_TO_TEST) {
         throw new Exception("Failed to set the current location provider to '" . self::GEOIP_IMPL_TO_TEST . "'.");
     }
     $possibleFiles = GeoIp::$dbNames['loc'];
     if (GeoIp::getPathToGeoIpDatabase($possibleFiles) === false) {
         throw new Exception("The GeoIP location provider cannot find the '{$file}' file! Tests will fail.");
     }
 }
 private function isAtLeastOneGeoIpDbOutOfDate($rescheduledTime)
 {
     $previousScheduledRuntime = $this->getPreviousScheduledTime($rescheduledTime)->setTime("00:00:00")->getTimestamp();
     foreach (GeoIp::$dbNames as $type => $dbNames) {
         $dbUrl = Option::get(self::$urlOptions[$type]);
         $dbPath = GeoIp::getPathToGeoIpDatabase($dbNames);
         // if there is a URL for this DB type and the GeoIP DB file's last modified time is before
         // the time the updater should have been previously run, then **the file is out of date**
         if (!empty($dbUrl) && filemtime($dbPath) < $previousScheduledRuntime) {
             return true;
         }
     }
     return false;
 }