View Single Post
Old 01-21-2019, 04:15 AM  
Brian mike
#Alberta51
 
Brian mike's Avatar
 
Industry Role:
Join Date: Oct 2014
Location: USA Territory (Alberta)
Posts: 8,128
Question about redirect visitors by country?

I have few countries i try to redirect to another offers so i find this website

"Are you looking for code snippet to redirect visitors by country?"
https://www.ip2location.com/free/visitor-redirection

Please note i have not really any knowledge on coding so bare with me
I need to know if using site like this can help us "webmaster with limited knowledge" or if it risky and that will create a backdoor for who ever use those code.

Thanks Grumpy


this is the code generate by this tools to redirect countries

PHP Code:
<?php
require 'IP2Location.php';
 
$loc = new IP2Location('databases/IP-COUNTRY.BIN'IP2Location::FILE_IO);
$record $loc->lookup($_SERVER['REMOTE_ADDR'], IP2Location::ALL);
 
if(
$record == 'CN') {
    
header('HTTP/1.1 301 Moved Permanently');
    
header('Location: https://xxxxxxxxxxxxxx.com/?p=3054&media_type=adult&pi=allsitesunwantedcountry');
    exit;
}
 
if(
$record == 'IN') {
    
header('HTTP/1.1 301 Moved Permanently');
    
header('Location: https://xxxxxxxxxxxxxxxx.com/?p=3054&media_type=adult&pi=allsitesunwantedcountry');
    exit;
}
 
if(
$record == 'RU') {
    
header('HTTP/1.1 301 Moved Permanently');
    
header('Location: https://xxxxxxxxxxxxxxxxx.com/?p=3054&media_type=adult&pi=allsitesunwantedcountry');
    exit;
}
 
if(
$record == 'UA') {
    
header('HTTP/1.1 301 Moved Permanently');
    
header('Location: https://xxxxxxxxxxxxxxxxxx.com/?p=3054&media_type=adult&pi=allsitesunwantedcountry');
    exit;
}
 
?>


I would have to install this IP2Location PHP Module first.

PHP Code:
<?php
require 'IP2Location.php';
 
/*
   Cache whole database into system memory and share among other scripts & websites
   WARNING: Please make sure your system have sufficient RAM to enable this feature
*/
// $db = new \IP2Location\Database('./database/IP-COUNTRY-SAMPLE.BIN', \IP2Location\Database::SHARED_MEMORY);
/*
   Cache the database into memory to accelerate lookup speed
   WARNING: Please make sure your system have sufficient RAM to enable this feature
*/
// $db = new \IP2Location\Database('./database/IP-COUNTRY-SAMPLE.BIN', \IP2Location\Database::MEMORY_CACHE);
 
 
/*
    Default file I/O lookup
*/
$db = new \IP2Location\Database('./database/IP-COUNTRY-SAMPLE.BIN', \IP2Location\Database::FILE_IO);
 
$records $db->lookup('8.8.8.8', \IP2Location\Database::ALL);
 
echo 
'<pre>';
echo 
'IP Number             : ' $records['ipNumber'] . "\n";
echo 
'IP Version            : ' $records['ipVersion'] . "\n";
echo 
'IP Address            : ' $records['ipAddress'] . "\n";
echo 
'Country Code          : ' $records['countryCode'] . "\n";
echo 
'Country Name          : ' $records['countryName'] . "\n";
echo 
'Region Name           : ' $records['regionName'] . "\n";
echo 
'City Name             : ' $records['cityName'] . "\n";
echo 
'Latitude              : ' $records['latitude'] . "\n";
echo 
'Longitude             : ' $records['longitude'] . "\n";
echo 
'Area Code             : ' $records['areaCode'] . "\n";
echo 
'IDD Code              : ' $records['iddCode'] . "\n";
echo 
'Weather Station Code  : ' $records['weatherStationCode'] . "\n";
echo 
'Weather Station Name  : ' $records['weatherStationName'] . "\n";
echo 
'MCC                   : ' $records['mcc'] . "\n";
echo 
'MNC                   : ' $records['mnc'] . "\n";
echo 
'Mobile Carrier        : ' $records['mobileCarrierName'] . "\n";
echo 
'Usage Type            : ' $records['usageType'] . "\n";
echo 
'Elevation             : ' $records['elevation'] . "\n";
echo 
'Net Speed             : ' $records['netSpeed'] . "\n";
echo 
'Time Zone             : ' $records['timeZone'] . "\n";
echo 
'ZIP Code              : ' $records['zipCode'] . "\n";
echo 
'Domain Name           : ' $records['domainName'] . "\n";
echo 
'ISP Name              : ' $records['isp'] . "\n";
echo 
'</pre>';
?>
__________________
Tube - Cam - Escorts - Top List
Menu Tab - Banner - Header Link - Blog Post
DM me
Brian mike is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote