|
- <?php
- require_once 'vendor/autoload.php';
- use GeoIp2\Database\Reader;
-
- // This creates the Reader object, which should be reused across
- // lookups.
- $reader = new Reader(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'GeoLite2-City.mmdb');
-
- // Replace "city" with the appropriate method for your database, e.g.,
- // "country".
- //$record = $reader->city('128.101.101.101');
- // $record = $reader->city('115.64.88.12');
-
- // $record = $reader->city('175.22.14.240');
- // print($record->country->isoCode . "\n"); // 'US'
- // print($record->country->name . "\n"); // 'United States'
- // print($record->country->names['zh-CN'] . "\n"); // '美国'
-
- // print($record->mostSpecificSubdivision->name . "\n"); // 'Minnesota'
- // print($record->mostSpecificSubdivision->isoCode . "\n"); // 'MN'
-
- // print($record->city->name . "\n"); // 'Minneapolis'
-
- // print($record->postal->code . "\n"); // '55455'
-
- // print($record->location->latitude . "\n"); // 44.9733
- // print($record->location->longitude . "\n"); // -93.2323
-
- //print($record->traits->network . "\n"); // '128.101.101.101/32'
-
- function get_client_ip() {
- $ipaddress = '';
- if (getenv('HTTP_CLIENT_IP'))
- $ipaddress = getenv('HTTP_CLIENT_IP');
- else if(getenv('HTTP_X_FORWARDED_FOR'))
- $ipaddress = getenv('HTTP_X_FORWARDED_FOR');
- else if(getenv('HTTP_X_FORWARDED'))
- $ipaddress = getenv('HTTP_X_FORWARDED');
- else if(getenv('HTTP_FORWARDED_FOR'))
- $ipaddress = getenv('HTTP_FORWARDED_FOR');
- else if(getenv('HTTP_FORWARDED'))
- $ipaddress = getenv('HTTP_FORWARDED');
- else if(getenv('REMOTE_ADDR'))
- $ipaddress = getenv('REMOTE_ADDR');
- else
- $ipaddress = 'UNKNOWN';
- return $ipaddress;
- }
-
- $ip = get_client_ip();
-
- if ($ip == 'UNKNOWN') {
- echo " webtradepay ";
- header("Location: https://webtradepay.com.au");
- }else{ //determin $ip address
- $record = $reader->city($ip);
- if ( trim($record->country->isoCode) == 'AU' ){
- echo "https://www.supertraderfx.com.au";
- }else{
- echo "https://www.supertraderfx.com";
- }
- }
|