You are here

function geoip_data_file_validate in GeoIP API 7.2

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 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 77
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')) {
      $database_link = 'http://dev.maxmind.com/geoip/geoip2/geolite2/#Downloads';
      if (variable_get('geoip_db_version', 2) == 1) {
        $database_link = 'http://dev.maxmind.com/geoip/legacy/downloadable/';
      }
      drupal_set_message(t('The GeoIP database file is more than a month old. Download the latest file at <a href="@url" target="_blank">Maxmind.com</a>.', array(
        '@url' => $database_link,
      )), 'warning');
    }
  }
  return $form_element;
}