You are here

function _ip2country_update in IP-based Determination of a Visitor's Country 6

Same name and namespace in other branches
  1. 5 uc_ip2country.module \_ip2country_update()
  2. 7 ip2country.admin.inc \_ip2country_update()

AJAX callback to update the IP to Country database.

Parameters

$rir: String with name of IP registry. One of 'afrinic', 'arin', 'lacnic', 'ripe'. Not case sensitive.

Return value

JSON object for display by jQuery script.

1 string reference to '_ip2country_update'
ip2country_menu in ./ip2country.module
Implements hook_menu().

File

./ip2country.admin.inc, line 51
Determination of user's Country based on IP address.

Code

function _ip2country_update($rir) {

  // Update DB from RIR.
  ip2country_update_database($rir);
  if (variable_get('ip2country_watchdog', TRUE)) {
    watchdog('ip2country', 'Manual database update from @registry server.', array(
      '@registry' => drupal_strtoupper($rir),
    ), WATCHDOG_NOTICE);
  }
  print drupal_to_js(array(
    'count' => t('@rows rows affected.', array(
      '@rows' => ip2country_get_count(),
    )),
    'server' => $rir,
    'message' => t('The IP to Country database has been updated from @server.', array(
      '@server' => drupal_strtoupper($rir),
    )),
  ));
  exit;
}