News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

geoIP (IP to Location)

Started by Spuds, November 06, 2011, 02:26:09 PM

Previous topic - Next topic

Spuds

Link to Mod



geoIP Location Mod
By Spuds



Introduction
This modification adds the ability to determine the latitude & longitude of a member given their IP address. This is commonly referred to as geolocation.  The mod makes use of the GeoLite data created by MaxMind, available from http://www.maxmind.com/ 

In some instances the IP address will not be found in the installed database, or will have incomplete data.  In this case the mod will make use of the hostip.info site as a secondary source to gather its information.

A note on accuracy: 
Maxmind shows that this database (which is updated on a monthly basis) is over 99.5% accurate on a country level making it a viable source for registration blocking.

When it comes to the city level accuracy this number is and 79% for the US (within a 25 mile radius).  That is the best accuracy, and other countries city/region location accuracy tapper off from that.  Even with that it still makes for an entertaining online member map.

Features
o Adds the ability to block or allow member registrations on a per country basis
o Adds an on-line member map which will show a map pin for each IP currently on your forum (needs the Country & City database)
o Adds in the geoIP information under the track IP sections, allows you to see city / region (state) / country of the IP address
o Currently only for IP4 addresses

There are admin settings available with this mod, go to admin - configuration - modification settings - geoIP.

Installation
IMPORTANT NOTES:
o The package will install on all systems, however to have the mod install the maxmind geoIP databases you need to be running MYSQL.
o If you do not have the zip module installed (the mod will inform you of this) then you may run into an out of memory issue when unzipping the large database. Without the zip module the memory requirements are 272M which may be a problem on some systems.  If you get an out of memory error or white screen your options are to use the country only database or to use the manual install option which requires that you upload the unzipped CSV files and then mod will install them.
o Often the maxmind download site is very slow, as such some sites may timeout when downloading the database files.  The mod does request more time but some hosts still do not allow this.  If you time out, simply try again at another time.
o The mySQL database size for the full country city database table will be approximately 80M, if storage space is an issue on your host / server please keep this in mind.

This mod is compatible with SMF 2.0 Only.

Support
Please use the geoIP modification thread for support with this modification.

Changelog
1.1.2 - 26 Apr 2013
! fixed problem due to  maxmind moving the csv download location for the city/county csv  only !
! fixed issue with large query on some sites thanks Joker
! minor format and unnecessarily global removal
! you can update by simply copying the geoIP.php and geoIPAdmin.php files to your sources directory

1.1.1 - 23 Jan 2012
! fixed error with county only database and Invalid Value Sent to Database error
! fixed issue with external lookups parsing

1.1 - 08 Dec 2011
+ Country flags next to member names in whos online list
+ Membergroup permissions for IDing member pin on online map (was on/off for all)
+ Improved logic for geoIP lookups
+ Released under BSD license
+ Stores geo data as part of the online table when the user lands instead of as on-demand data.

1.0 - 07 Sep 2011
+ Initial Release

Bugo

Well, I just started to translate this mod but found a hardcoded text in geoIP.template.php:
Last Update Status:
Did you left it specially for translators? :)

Spuds

Quote from: Bugo on November 07, 2011, 11:39:52 AM
Well, I just started to translate this mod but found a hardcoded text in geoIP.template.php:
Last Update Status:
Did you left it specially for translators? :)
Doh! .... thanks for finding that, I hope its the only one you find!  Good old hard coded text always seems to find its way in .... I put a new package with that changed to a txt string on the site :)

vbgamer45

Very nice mod glad it was made. Helpful to see what IP a country is from and "Adds the ability to block or allow member registrations on a per country basis"
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

4Kstore

I need something like this !
Thanks!

¡¡NEW MOD: Sparkles User Names!!!

Adrek

Interesting, this mod shows that I'm somewhere in middle of the Atlantic :D

anyway, nice mod ;)
Polskie wsparcie SMF na simplemachines.org

the simplest solution is most likely the right one

Manu.G

Great mod, exactly what I was searching for.

Only one question.
Is it possible to hide the online map for guests?
Version SMF 2.0.8
SimplePortal 2.3.5

Spuds

Quote from: Manu.G on November 08, 2011, 12:52:33 PM
Great mod, exactly what I was searching for.

Only one question.
Is it possible to hide the online map for guests?
You should be able to go to admin -> members -> permissions -> general permissions and select guest ... then under guest make sure that View Who's Online Map is not checked

Manu.G

The permission settings I haven't seen, sorry.
I checked it and for guests the permission isn't given, but when I'm as guest on my forum
I can still enter the map :-?

I think something went wrong when I installed it. I got an error-message it was for the Who.template.php,
could it be because of this the mod wasn't installed correct?
Version SMF 2.0.8
SimplePortal 2.3.5

Spuds

#9
Quote from: Manu.G on November 08, 2011, 04:53:42 PM
The permission settings I haven't seen, sorry.
I checked it and for guests the permission isn't given, but when I'm as guest on my forum
I can still enter the map :-?

I think something went wrong when I installed it. I got an error-message it was for the Who.template.php,
could it be because of this the mod wasn't installed correct?
Probably means you had guests allowed to view who's online enabled as well.  I had the mod set up based on either permissions which is confusing so I've changed it to behave more in line with the permissions and not as a hierarchy of them, they will now need both now to view the map.  Permissions are confusing enough without my help  :P

You can just copy the below file over the one in your sources directory instead of uninstalling and reinstalling the mod.

regarding the who online template error, that would just prevent the view the online map link from showing on the whos online page, nothing to worry about really.

Manu.G

Thanks a lot! It works!

Ah now I got it :)
Yes, guest have the permission to see "Who's online". Now my English is leaving me, but I think I got
what the problem is. :)
Version SMF 2.0.8
SimplePortal 2.3.5

Manu.G

Me again  :-[


In the forum I'm running we used the last years the Location Mod by Gobalopper
http://custom.simplemachines.org/mods/index.php?mod=56
With this mod was it possible to show in the "Who's Online" list a little flag in front of
the name of the member and guest. It was a nice extra feature.


Is it possible to add this to the who's online list? Just the flag of the country nothing more.
It won't be a problem when guests can see from which country a member/visitor is coming,
without telling the city as it is in the the GeoIp online map.


Only when it isn't for need to make some huge changes :)
Version SMF 2.0.8
SimplePortal 2.3.5

Spuds

#12
Here is an early preview of version 1.1

It adds the flags next to the member names in the online map and fixes/improves various other things in the mod.  This one is for testing and feedback  ;)

Manu.G

Hey, that's great! Thanks!


I installed it on my test forum and here is what happen :)


I marked in the GeIP settings "Enable the GeoIP Who's online flags:" but after I saved the settings,
it's unchecked. It only appears as marked when all boxes are checked. So I marked all 4 boxes, saved and
removed 2 marks "Enable the GeoIP Registration Filter:" and "Enable the GeoIP Pin identification:" saved and
after this "Enable the GeoIP Who's online flags:" was also unchecked.


The flags in the "Who's online" working perfect for members I think, but not for guests.
In front of my member name the little flag appears, the correct flag, but not by guests.
In front of a guest is a little field to see, but no flag, because it should be this flag
".../Themes/default/images/ISO_3166_Flags/.gif"


Could be something went wrong during the install but the only test failed message I got was the Who.template.php, the
code for it I installed manual


But despite everything, it's great to get the little flags back in the "Who's online" :D
Version SMF 2.0.8
SimplePortal 2.3.5

Spuds

QuoteI marked in the GeIP settings "Enable the GeoIP Who's online flags:" but after I saved the settings,
it's unchecked.
That was a typo on my part ... I updated the package in the above post so that should be fixed.

I was not able to reproduce the guest item you were describing.   Its important to note that if members or guests were online when the mod was installed, it will not update them right away (it will for anyone who logs in after its installed but may take sometime to refresh for those that were on-line already) It really only checks when a user first goes to the site to minimize overhead.

In those cases you would just get the [*] symbol for the flag.  I've changed that to be a pirate flag instead :P


Manu.G

Quote from: Spuds on November 16, 2011, 01:27:29 PM
QuoteI marked in the GeIP settings "Enable the GeoIP Who's online flags:" but after I saved the settings,
it's unchecked.
That was a typo on my part ... I updated the package in the above post so that should be fixed.

I was not able to reproduce the guest item you were describing.   Its important to note that if members or guests were online when the mod was installed, it will not update them right away (it will for anyone who logs in after its installed but may take sometime to refresh for those that were on-line already) It really only checks when a user first goes to the site to minimize overhead.

In those cases you would just get the [*] symbol for the flag.  I've changed that to be a pirate flag instead :P

Works like a charm! You are GREAT!!!
The pirate flag is a great idea!!!  O:)


Found an entry in the error-log, but I saw it few days ago in the actual forum, but forget to tell you  :-[


Quote8: Undefined index: cannot_geoIP_view
File: .../.../www/.../.../Sources/Security.php
Line: 894
The error was caused by a guest :)
Version SMF 2.0.8
SimplePortal 2.3.5

Fed Drago

Hello I love this Mod but when I try to Backup my database using the back up section in Smf I get a white screen and nothing happens. I uninstalled this mod and ran the back up database again and everything worked?

Is this a bug or Have I missed something?

Cheers

Spuds

I'll check on that but my initial guess is that since the database is large (the full geoip table is about 80m) that you are simply running out of memory during the SMF database backup which results in a white screen.  If you have access to phpmyadmin you can backup from there and just not select that table when you export.   

FYI thats not normally going to be the largest table in SMF but if the forum is new or does not have a lot of messages yet then it could be.  On my site the message and search tables dominate in the size race.

Fed Drago

Quote from: Spuds on December 14, 2011, 09:42:29 AM
I'll check on that but my initial guess is that since the database is large (the full geoip table is about 80m) that you are simply running out of memory during the SMF database backup which results in a white screen.  If you have access to phpmyadmin you can backup from there and just not select that table when you export.   

FYI thats not normally going to be the largest table in SMF but if the forum is new or does not have a lot of messages yet then it could be.  On my site the message and search tables dominate in the size race.

Yes I figured as much, I do not have any problem backing up my database from my server at all. Its only why I back up the data base from the forums maintenance in the Admin section. It's just convenient to use instead of logging into my server.

If you find anything please let me know. 

Also yes I only have around 200 messages on my forums so it is very small.

Thank you  :) 

Jeff B

I was looking forward to giving this a try, and it installed, according to the package manager without error.  I can not find any sign of the configuration link in the admin section, so I decided to try to uninstall, and the following is what I see. Does this mean it did not actually install?

1.    Execute Code    add_remove_hooks.php    
   2.    Delete File    ./Sources/geoIPIntegration.php    
   3.    Delete File    ./Sources/geoIP.php    
   4.    Delete File    ./Sources/geoIPAdmin.php    
   5.    Delete File    ./Themes/default/css/geoIP.css    
   6.    Delete File    ./Themes/default/scripts/geoIP_database.js    
   7.    Delete File    ./Themes/default/geoIP.template.php    
   8.    Delete File    ./Themes/default/languages/geoIP.english.php    
   9.    Delete File    ./Themes/default/languages/geoIP.english-utf8.php    
   10.    Delete File    ./Themes/default/images/admin/geoip.gif    
   11.    Delete Tree    ./Themes/default/images/ISO_3166_Flags    
   12.    Delete Tree    ./Sources/geoIP    
*    13.    Execute Modification    ./Sources/Register.php    Test failed
      1.    Replace    ./Sources/Register.php    Test failed
*    14.    Execute Modification    ./Themes/default/BoardIndex.template.php    Test successful
*    15.    Execute Modification    ./Sources/Who.php    Test failed
      1.    Replace    ./Sources/Who.php    Test failed
      2.    Replace    ./Sources/Who.php    Test failed
*    16.    Execute Modification    ./Themes/default/Who.template.php    Test failed
      1.    Replace    ./Themes/default/Who.template.php    Test failed
      2.    Replace    ./Themes/default/Who.template.php    Test failed
      3.    Replace    ./Themes/default/Who.template.php    Test failed
*    17.    Execute Modification    ./Sources/Profile-View.php    Test failed
      1.    Replace    ./Sources/Profile-View.php    Test failed
*    18.    Execute Modification    ./Themes/default/Profile.template.php    Test failed
      1.    Replace    ./Themes/default/Profile.template.php    Test failed
*    19.    Execute Modification    ./Sources/ScheduledTasks.php    Test failed
      1.    Add Before    ./Sources/ScheduledTasks.php    Test failed
*    20.    Execute Modification    ./Sources/Subs.php    Test failed
      1.    Replace    ./Sources/Subs.php    Test failed
*    21.    Execute Modification    ./Themes/default/languages/Modifications.english.php    Test failed
      1.    Add Before    ./Themes/default/languages/Modifications.english.php    Test failed
*    22.    Execute Modification    ./Themes/default/languages/Who.english.php    Test failed
      1.    Replace    ./Themes/default/languages/Who.english.php    Test failed
   23.    Execute Modification    ./Themes/default/languages/Modifications.english-utf8.php    Skipping file
   24.    Execute Modification    ./Themes/default/languages/Who.english-utf8.php    Skipping file
   25.    Adapt Database    remove_settings.php    

Advertisement: