[Include] GeoIP (ISP, Country, City)
#1

GeoIP (ISP, Country, City)

I have been working on a geo IP that doesn't require a plugin and that can detect more than country, at a fast speed that doesn't freeze the server. The result is this.

The INC uses SQLite this product includes GeoLite data created by MaxMind, available from
http://maxmind.com/

http://geolite.maxmind.com/download/...se/LICENSE.txt

The Country and ISP database is 15 MB, the City database alone is 100 MB, City is in a seperate SQLite database incase you decide not to upload city. (compressed, both databases together are 40 mb)

Speed test

Code:
[07:54:06] took 1 ms - GetPlayerCountry
[07:54:06] took 0 ms - GetPlayerCity
[07:54:06] took 17 ms - GetPlayerISP
If you are an SQL guru and can understand how the include works and have a faster solution to get the info even faster, please post or pm me. The point of this include is a quick SQL query that hang pause the server!

Functions
Code:
GetPlayerCountry(playerid, string[], const len = sizeof(string));
GetPlayerISP(playerid, string[], const len = sizeof(string));
GetPlayerCity(playerid, string[], const len = sizeof(string));
GetPlayerGMT(playerid);

GetIPCountry(ip[], dest[], len = sizeof(dest));
GetIPISP(ip[], dest[], len = sizeof(dest));
GetIPCity(ip[], dest[], len = sizeof(dest));
GetIPGMT(ip[]);
If you want to edit the functions or add to them looking at the databases, you can actually get thing such as Area code, Metro code, Region, Postal code, city latitude and city longitude.

Accuracy

http://www.maxmind.com/en/city_accuracy - City accuracy
Country accuracy - 99.5%

Updates

I will try to update the database files monthly when Maxmind updates their databases on their website

Download

GitHub
Download (Database files) (place in /scriptfiles/)
Example

New include will not work with old database files! you must update the database files AND the include for it to work!

Credits
- Whitetiger
- RaekwonDaChef
- ******
- Andreas Gohr
Reply
#2

Nice post White
Reply
#3

Nice include! Will be pretty useful for country banning :3
Reply
#4

You a have database GeoIP for MySQL? or how to convert
Reply
#5

i wrote it originally in mysql but but it caused some problems with phpmyadmin and i figured most server hosts wouldnt allow you to import 275 MB of sql information (at least, everyone i tried wouldnt let me import even 100 mb!), so its SQLite to save people time from importing large files into their databases, and the queries where slower and would freeze the server when it was doing the look up even with threaded queries
Reply
#6

Quote:
Originally Posted by whitetigerswt
View Post
where slower and would freeze the server when it was doing the look up even with threaded queries
Freeze SA:MP or MySQL server?
Reply
#7

the sa-mp server would freeze
Reply
#8

Nice post man Really
Reply
#9

Very nice script!

Quote:
Originally Posted by CrunkBankS
View Post
Freeze SA:MP or MySQL server?
The other filterscript that's released is poorly coded and hangs the server if it doesn't find the result.
Reply
#10

Quote:
Originally Posted by Norn
View Post
Very nice script!



The other filterscript that's released is poorly coded and hangs the server if it doesn't find the result.
I hope you're not referring to mine.
Reply
#11

what name i give in filterscripts
Reply
#12

Quote:
Originally Posted by Slice
View Post
I hope you're not referring to mine.
No no yours using http which is fine it was some indian guy haha.
Reply
#13

I get: Country, ISP, City = unknown.
When i check my IP @ maxmind site all info shows, why?
Reply
#14

as far as i know, MaxMind has costs on certain IP services. Is this the free version, or the paid version?

also, could this be imported so i can import it into a mysql database? (or create a new one)
Reply
#15

it is the GeoLite free databases


Quote:
Originally Posted by Richie
View Post
I get: Country, ISP, City = unknown.
When i check my IP @ maxmind site all info shows, why?
pm me your ip and ill see if i can get it to work

EDIT: if people really want use in mysql ill post the last mysql version i have, but i can't promise that it will even work, you're welcome to edit it

What you need:
- SQL db tables: http://pastebin.com/9H2Pj1zS
- MaxMind Country database, City database, and GeoASN In .CSV format (its all on there site)
- mysql database

when importing the files you should do them like this:



with the corresponding tables

GeoIPASNum2.csv -> geo_isp
GeoIPCountryWhois.csv -> ip_country
GeoLiteCity-Blocks.csv -> ip_city
GeoLiteCity-Location.csv -> ip_city_locations

Download (mysql FS usage example)
Download (mysql FS usage example, pastebin)

I highly recommend you dont use mysql!

edit 2: there was a problem with the original .inc, please update it will save you time in the long run
Reply
#16

Interesting
Reply
#17

Nice work, whitetigerswt! (:
Reply
#18

NICE NIGA!
Reply
#19

< Removed >
Reply
#20

Where did you found the .db files on Maxmind's download site? (http://geolite.maxmind.com/download/geoip/database/)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)