Evie Addon Details

Watch - Add Favorite

IPToCountry - Version 2

posted on 2008-01-17 10:47:55
by SuperDave
30
w00ts
w00t!
Requires: Tags: addon css dods fun hl2dm info internet library utility

Description

Resolves IP addresses to name of the originating country. Requires only ES 2.0+

Documentation (included in library):
To use this library, you must first import it:
 
import iptocountry
 
 
The following functions are available:
 
iptocountry.get_country(ip)
- Returns full country name, three-letter country abbreviation of IP
ip = IP address to resolve to country name
 
 
iptocountry.get_location_data(ip):
- Returns a dictionary of location data of IP
ip = IP address to resolve to location data
 
 
iptocountry.update_data(url=None):
- Syncs server database with internet data--VERY SLOW
url = URL to download IPToCountry database
 
 
iptocountry.get_last_update():
- Returns the time of the last database update (in seconds since epoch)
 
 
The following instance of CountryResolve is publicly exposed:
 
iptocountry.service
 
 
The database for this library is provided by http://Software77.net. For more information, please see:
 
http://software77.net/cgi-bin/ip-country/geo-ip.pl
 
NO CLAIMS ARE MADE REGARDING THE ACCURACY OF THIS DATABASE. Please use this library with that in mind.


This library comes with an example addon with the following options:
// IPToCountry Example options
// ./addons/eventscripts/iptocountry_example/iptocountry_example.cfg
// http://addons.eventscripts.com/addons/view/iptocountry
 
// Load this addon with: es_load iptocountry_example
 
// To configure language settings for IPToCountry Example please see iptocountry_example_languages.ini
 
// This example addon:
// - Shows example interaction with IPToCountry
// - Automatically updates the IPToCountry database
// - Announces the country of joining players
// - Provides server commands for interaction with ESS scripts
// - Loads IPToCountry for quicker database access for other addons
// Due to the large size of the database, it is _HIGHLY_ recommended this addon be loaded during server start or map change.
 
// The database for the IPToCountry library is provided by: http://Software77.net
 
// NO CLAIMS ARE MADE REGARDING THE ACCURACY OF THIS DATABASE. Please use the IPToCountry library with that in mind.
 
// More information can be found here: http://software77.net/cgi-bin/ip-country/geo-ip.pl
 
 
// ***** Update options *****
// THis exaple addon will only update the database when no players are connected due to conenctivity concerns.
 
iptocountry_example_update_days 14
// Number of days between database updates--set to 0 to eliminate [default 14]
 
iptocountry_example_update_load 0
// 0 = no change, 1 = update database every time ipcountry_example is loaded (NOT RECOMMENDED) [default 0]
 
 
// ***** Announcement options *****
 
iptocountry_example_announce_chat 2
// 0 = no change, 1 = announce on the console the country each player joins from,
// 2 = annoucne in chat area the country each player joins from [default 2]
 
iptocountry_example_announce_center 1
// 0 = no change, 1 = announce in center text the country each player joins from [default 1]
 
iptocountry_example_announce_hud 0
// 0 = no change, 1 = announce in a HUD message the country each player joins from [default 0]
 
 
// ***** Command documentation *****
 
// This addon provides the following server commands:
 
// iptocountry_getcountry -country var- -abbr var- -"ip"-
// - Returns country name and three-letter abbreviation info for the specified IP
// country var - Variable name to receive country name
// abbr var - Variable name to receive country three-letter abbreviation
// ip - IP address to resolve to country information
 
// iptocountry_getinfo -var- -info type- -"ip"-
// - Returns location info for the specified IP
// var - Variable name to receive location inforation
// info type - Type of information to receive (ip_from/ip_to/registry/assigned/country_2/country_3/country_long)
// ip - IP address to resolve to country information
 
// iptocountry_getlastupdate -var-
// - Returns the time of the last database update (in seconds since epoch)
// var - Variable name to receive time of last update
 
// iptocountry_updatedata ["url"]
// - Syncs the database with an internet database
// THIS COMMAND SHOULD NOT BE USED WHILE PLAYERS ARE CONNECTED!
// url - (Optional) URL of database to download


Please see the forum link below for more translations or if you have a translation to add. Please also post general questions or comments.

Version Notes For 2 (Announce this update)

Updated on: 2008-04-19 02:47:58 EST
- Eliminated need for temporary files while downloading database
- Further optimized code
( Previous Versions )