IP to Nation Module

The IP to Nation module enables you to determine which country an IP address is associated with. You can do two things with this information:

  1. Ban entire countries. When a country is banned, someone with an IP address from that country is not permitted to submit comments, trackbacks, referrer data, or use the email/tell-a-friend forms.
  2. Show a flag icon within your comments or entries to indicate the country of the person who submitted the entry.

NOTE: When updating your IP to Nation module, make sure that you also update your /system/lib/countries.php file so that newly added or changed nations display properly.

Database Updates

Periodically, the IP address database for the IP to Nation module is updated from ip2nation.com's database. When this occurs, a note will be made in the Change Log. To update your installation, simply make sure that you are running the latest version and build of ExpressionEngine, and visit the Modules > IP to Nation page in your Control Panel. The update may take a few seconds; do not click any links or refresh the page while the auto-update is taking place.

Banning Counties

To look up the country associated with an IP address, or to ban a country you'll to to the Modules > IP to Nation page in your Control Panel.

World Flags Tag

In order to use the world flag feature, please first visit the Modules page of the control panel and make sure your IP to Nation module is installed.

Note:  Please download the flag icons from ExpressionEngine.com. Once downloaded, unzip the archive, then upload the "world_flags" folder to your server. The folder can go anywhere since you'll set the URL in the tag as described below.


The "world flags" tag can be used within your {exp:comment:entries} or {exp:weblog:entries} like this:

{exp:ip_to_nation:world_flags   image_url="http://example.com/images/world_flags/"}
{ip_address}
{/exp:ip_to_nation:world_flags}

Parameters

The world flags tag has two parameters:

image_url=

This URL to your "world_flags" folder.

Make sure you include the folder name in the URL and include a trailing slash:

http://www.example.com/images/world_flags/

type="text"

You can optional set the tag to output the name of the country as text by using the type="text" parameter.

Top of Page

User Contributed Notes

Posted by: Sean C. Smith on 28 June 2008 10:46pm
Sean C. Smith's avatar

some ip’s are turning up as gb rather than uk - there is no flag for this. The solution is to copy flag_uk and rename it to flag_gb and upload to server.

Posted by: medic119 on 18 July 2007 1:10pm
medic119's avatar

Within the context of the exp:comment:entries tag, you can also grab Trackback IPs to display the image.

Example:

{exp:ip_to_nation:world_flags image_url="http://example.com/images/world_flags/"}
{trackback_ip}
{
/exp:ip_to_nation:world_flags}

You must have an ExpressionEngine license and have attained a forum rank of "Lab Assistant" (100 posts) to contribute notes to the User Guide