You are here

function ip2country_update_database in IP-based Determination of a Visitor's Country 8

Same name and namespace in other branches
  1. 5 uc_ip2country.inc \ip2country_update_database()
  2. 6 ip2country.inc \ip2country_update_database()
  3. 7 ip2country.inc \ip2country_update_database()

Updates the database.

Truncates ip2country table then reloads from ftp servers.

Parameters

string $registry: Regional Internet Registry from which to get the data. Allowed values are afrinic, apnic, arin (default), lacnic, or ripe.

Return value

int|false FALSE if database update failed. Otherwise, returns the number of rows in the updated database.

Deprecated

in ip2country:8.x-1.9 and is removed from ip2country:8.x-2.0. Use the ip2country.manager service instead. For example, \Drupal::service('ip2country.manager')->updateDatabase($rir).

See also

https://www.drupal.org/node/3076484

File

./ip2country.inc, line 35
Utility routines to load the IP to Country database.

Code

function ip2country_update_database($registry = 'arin') {
  @trigger_error("ip2country_update_database() is deprecated in ip2country:8.x-1.9 and is removed from ip2country:8.x-2.0. Use \\Drupal::service('ip2country.manager')->updateDatabase() instead. See https://www.drupal.org/node/3076484", E_USER_DEPRECATED);
  $ip2country_config = \Drupal::config('ip2country.settings');
  $md5_checksum = $ip2country_config
    ->get('md5_checksum');
  $batch_size = $ip2country_config
    ->get('batch_size');
  return \Drupal::service('ip2country.manager')
    ->updateDatabase($registry, $md5_checksum, $batch_size);
}