You are here

ip2country_test.module in IP-based Determination of a Visitor's Country 8

Determination of user's Country based on IP.

This module uses the IP Address that a user is connected from to deduce the Country where the user is located. This method is not foolproof, because a user may connect through an anonymizing proxy, or may be in an unusual case, such as getting service from a neighboring country, or using an IP block leased from a company in another country. Additionally, users accessing a server on a local network may be using an IP that is not assigned to any country (e.g. 192.168.x.x).

@author Tim Rohaly. <http://drupal.org/user/202830>

File

tests/modules/ip2country_test/ip2country_test.module
View source
<?php

/**
 * @file
 * Determination of user's Country based on IP.
 *
 * This module uses the IP Address that a user is connected from to deduce
 * the Country where the user is located. This method is not foolproof,
 * because a user may connect through an anonymizing proxy, or may be in
 * an unusual case, such as getting service from a neighboring country,
 * or using an IP block leased from a company in another country.
 * Additionally, users accessing a server on a local network may be using
 * an IP that is not assigned to any country (e.g. 192.168.x.x).
 *
 * @author Tim Rohaly.    <http://drupal.org/user/202830>
 */

/**
 * Implements hook_ip2country_alter().
 */
function ip2country_test_ip2country_alter($path, $arg) {
  \Drupal::messenger()
    ->addMessage('hook_ip2country_alter() executed.');

  // @todo Actually do something here!
  // Should have a little testing database of IP addresses,
  // replace the array in ip2country.test,
  // mini DB can be used in place of real DB for testing, plus
  // it validates hook.
}

Functions

Namesort descending Description
ip2country_test_ip2country_alter Implements hook_ip2country_alter().