Hack Forums
[PHP] Script that checks for geolocation IP and useragent - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Web Development (https://hackforums.net/forumdisplay.php?fid=183)
+---- Thread: [PHP] Script that checks for geolocation IP and useragent (/showthread.php?tid=5849953)



Script that checks for geolocation IP and useragent - 2073436 - Jun 15, 2018

It checks for geolocation and if it's location A, it'll redirect to the prefered link.

Basically a cloaker in php

I'd highly appreciate it if someone could share such script or assemble one if you've got the time for it


RE: Script that checks for geolocation IP and useragent - Have Faith - Jun 15, 2018

Here's a couple libraries that should do what you want:

http://geocoder-php.org/
https://github.com/geocoder-php/Geocoder

:)
Willing to help. Message me if you have any questions. That should start you off very well.


RE: Script that checks for geolocation IP and useragent - .kr. - Jun 15, 2018

You can download a free database and Php example here:
https://db-ip.com/db/#downloads

For user-agent you could use:
Code
$_SERVER['HTTP_USER_AGENT']

Maybe it's a good idea to use a cookie to buffer the database request


i think it's a interesting assignment and this is the way i solved it:

1. download the geoip database from:
https://db-ip.com/db/download/country

2. seperate the us ipv4 address range and the us ipv6 address range with python:


3. then check the ip location with this php script:



RE: Script that checks for geolocation IP and useragent - 2073436 - Jun 16, 2018

(Jun 15, 2018 06:28 PM)DaisyChains Wrote:  Here's a couple libraries that should do what you want:

http://geocoder-php.org/
https://github.com/geocoder-php/Geocoder

:)
Willing to help. Message me if you have any questions. That should start you off very well.

(Jun 15, 2018 10:40 PM).kr. Wrote:  You can download a free database and Php example here:
https://db-ip.com/db/#downloads

For user-agent you could use:
Code
$_SERVER['HTTP_USER_AGENT']

Maybe it's a good idea to use a cookie to buffer the database request


i think it's a interesting assignment and this is the way i solved it:

1. download the geoip database from:
https://db-ip.com/db/download/country

2. seperate the us ipv4 address range and the us ipv6 address range with python:


3. then check the ip location with this php script:

Thanks, I appreciate it!