Example #1
0
 public static function maxmindValidateFilename($filename)
 {
     if (file_exists(ABSPATH . $filename)) {
         $filename = ABSPATH . $filename;
     }
     if (!is_readable($filename)) {
         return '';
     }
     try {
         $reader = new \GeoIp2\Database\Reader($filename);
         $metadata = $reader->metadata();
         $reader->close();
     } catch (\Exception $e) {
         if (WP_DEBUG) {
             echo 'Error while creating reader for "' . $filename . '": ' . $e->getMessage();
         }
         return '';
     }
     return $filename;
 }
 public static function maxmindValidateFilename($filename)
 {
     // Maybe make path absolute
     if (file_exists(ABSPATH . $filename)) {
         $filename = ABSPATH . $filename;
     }
     if (!is_readable($filename)) {
         return '';
     }
     try {
         $reader = new \GeoIp2\Database\Reader($filename);
         $metadata = $reader->metadata();
         $reader->close();
     } catch (\Exception $e) {
         if (WP_DEBUG) {
             echo printf(__('Error while creating reader for "%s": %s', 'geoip-detect'), $filename, $e->getMessage());
         }
         return '';
     }
     return $filename;
 }