You are here

function geoip_data_file_validate in GeoIP API 7

Same name and namespace in other branches
  1. 5 geoip.module \geoip_data_file_validate()
  2. 6 geoip.admin.inc \geoip_data_file_validate()
  3. 7.2 geoip.admin.inc \geoip_data_file_validate()

Validate that the geoip_data_file exists.

1 string reference to 'geoip_data_file_validate'
geoip_admin_settings in ./geoip.admin.inc
Menu callback and form builder for admin/settings/geoip.

File

./geoip.admin.inc, line 32
Admin functions for geoip module.

Code

function geoip_data_file_validate($form_element) {
  $file = $form_element['#value'];
  if (!file_exists($file)) {
    form_error($form_element, t('The GeoIP data file could not be located at the specified location.'));
  }
  else {
    $mtime = filemtime($file);
    if ($mtime < strtotime('1 months ago')) {
      drupal_set_message(t('The GeoIP database file is more than a month old. Download the latest <a href="@country-url">country</a> or <a href="@city-url">city</a> databases from <a href="http://maxmind.com">MaxMind.com</a>.', array(
        '@country-url' => 'http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz',
        '@city-url' => 'http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz',
        '@home-url' => 'http://www.maxmind.com/app/ip-location',
      )), 'warning');
    }
  }
  return $form_element;
}