This is a simplified version of my GeoIP modification. The simplification is that it now depends on the web server (Nginx or Apache) providing the GeoIP data. This means that your web server must having this capability enabled and that it also provides the environment data to PHP. My original modification created a mysql database from the maxmind files, this proved to be a support issue. Now it depends on the server, so if your web server does not have this, don't install this addon. Also note I've only tested this with Nginx since thats what I use,
geoIP Location
IntroductionThis modification adds the ability to use the latitude & longitude of a member given their IP address. This is commonly referred to as geolocation. The mod makes use of the geoip capabilities in Nginx or Apache web servers.
You must have this capability enabled in your web server and they must make the following enviroment variables available to PHP ('GEOIP_LATITUDE', 'GEOIP_LONGITUDE' 'GEOIP_CITY_COUNTRY_NAME', 'GEOIP_CITY', 'GEOIP_CITY_COUNTRY_CODE')
Licenseo This modification is released under a MPL V1.1 license, a copy of it with its provisions is included with the package.
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 level of accuracy, it still makes for an entertaining online member map.
In some instances the IP address will not be found, or will have incomplete data. In this case the mod will make use of secondary sources to gather information.
Featureso Adds an on-line member map which will show a map pin for each IP currently on your forum
o Adds the ability to block or allow member registrations on a per country basis
o Adds in the geoIP information under the track IP sections, allows you to see city / region (state) / country of the IP address
o No source edits
o @todo add country flag to online member list
There are admin settings available with this mod, go to admin - configuration - addon settings - geoIP.
InstallationIMPORTANT NOTES:o The package will install on all systems, however you
must have geoip capabilities enabled in the web server and the environment variables made available to PHP. If you are on shared hosting, check with your host, or if you are on a VPS you can read how to do it, for example with Nginx : http://www.howtoforge.com/using-geoip-with-nginx-on-ubuntu-12.04
Repohttps://bitbucket.org/spuds_/elk_geoip
Sourcehttps://bitbucket.org/spuds_/elk_geoip/src
Downloadhttp://addons.elkarte.net/feature/geoIP-Location.html
Cool stuff! :D
And that makes me think that a very cool feature for our beloved PacMan could be a dependencies check of sort... well, in the end it would just be a "during-install-checks-run-this-function" kind of thing.
/me loves how easy things look like when you write them compared to how difficult the darn b**stards are when you have to actually code them. xD
Not a bad idea ... we do have <requires> in pacman , but thats a package dependency check. Could add a server based one, like min level of php, mysql, or some extension installed. I think this could be done if I add in a <code> section and do the checks as well.
Updated package to support ElkArte 1.1
Fantastic addon! Many thanks for your work on this
@Spuds 8) One question: would it be possible for the popups on the Online Member map to show the corresponding IP?
I have checked with my host and they have enabled GeoIP in my shared hosting plan. I installed this add-on in a clean install of ElkArte 1.1.1. I got my Google API key and put it in the admin settings for GeoIP. My host told me to add
GeoIPEnable On
to my .htaccess file.
I'm using PHP 7.1.
But when I try to go to the map I see a map flash in the box and then it immediately goes gray with the message:
Oops! Something went wrong.
This page didn't load Google Maps correctly. See the JavaScript console for technical details.
Looking at the Javascript Console it says:
Google Maps API error: MissingKeyMapError https://developers.google.com/maps/documentation/javascript/error-messages#missing-key-map-error
ElkArte error log shows this error (see atttached)
Is this addon compatible with ElkArte 1.1.1? If so any idea what could be going on
Tell me please, can I put CMS on the server with version 5.1
Or what is the minimum requirement?
hmm... I'm not expert on this one, but it may be a little mistake in the template, can you try changing:
$key = !empty($modSettings['googleMap_Key']) ? $modSettings['googleMap_Key'] : '';
to:
$key = !empty($modSettings['geoIP_Key']) ? $modSettings['geoIP_Key'] : '';
in the file geoIP.template.php?
This seems unrelated, it may be some functionality removed?
You can just change:
if ($modSettings['googleMap_Sidebar'] !== 'none')
to:
if (!empty($modSettings['googleMap_Sidebar']) && $modSettings['googleMap_Sidebar'] !== 'none')
in GeoIP.controller.php.
Thanks for the replies Emanuele. I am using the default ElkArte template. I will try these two things this weekend and see if I can get it working.
Changing those settings in geoIP.template.php does give me a map now but there are no locations shown and the sidebar doesn't show any users online even though there are users logged in and online.
Changing the setting in GeoIP.controller.php does get rid of the error messages but the map is no longer visible when you make that change.
hmm...
No error in the javascript console?
Or in the error log?
With the edits to geoIP.template.php I still get this error in the error log. (see attachment #1)
And in the javascript console I get this. (see attachment #2)
I reverted back to the original files geoIP.template.php and GeoIP.controller.php and made the edits again. I do get the map now but still no users listed in the sidebar and no locations shown on the map and I am no longer getting the errors in the error log and I am not seeing any errors in the javascript console. So no errors, I get the map but no users and no locations on the map.
Are you using nginx? I ran into some issues between the latest nginx 1.13.8 and the maxminds geoip database. For some reason it was super slow with lookups, like 10 seconds for each reference I reverted back to 1.13.7, problem solved. Or so I thought. After updating the geoip database files, things were sluggish with some unexpected behaviors. One of which the map took a while to populate after restarting nginx. So reverting the geoip files was in order as well. Didn't try the two latest versions together. Thought it wise to let them settle out the bugs first. Anyway, just throwing that out there. ;)
I think I have to install the mod to understand what is going on... Today is finished, I'll see if I can tomorrow. :-\
I am on shared hosting. Not sure what OS they use.
You can check php info in server config to check the OS. Mine is something like this:
$_SERVER['SERVER_SOFTWARE'] nginx/1.13.8
Mine shows this:
$_SERVER['SERVER_SOFTWARE'] LiteSpeed
I'm having issues getting this to work with geoip2 on nginx. How should the fastcgi_param be passed? It's probably just a variable naming issue.... ::)
here is what I use. This is on nginx version: nginx/1.14.1 with ngx_geoip2_module-3.2 ... this is for the GeoLite2 databases.
# GEOIP Variables
fastcgi_param GEOIP_COUNTRY_CODE $geoip2_country_code;
fastcgi_param GEOIP_COUNTRY_NAME $geoip2_country;
fastcgi_param GEOIP_CITY_COUNTRY_CODE $geoip2_country_code;
fastcgi_param GEOIP_CITY_COUNTRY_NAME $geoip2_country;
fastcgi_param GEOIP_REGION $geoip2_region_code;
fastcgi_param GEOIP_REGION_NAME $geoip2_region;
fastcgi_param GEOIP_CITY $geoip2_city;
fastcgi_param GEOIP_POSTAL_CODE $geoip2_postal_code;
fastcgi_param GEOIP_CITY_CONTINENT_CODE $geoip2_continent_code;
fastcgi_param GEOIP_LATITUDE $geoip2_latitude;
fastcgi_param GEOIP_LONGITUDE $geoip2_longitude;