<?php
function get_client_ip_server() {
$ipaddress = '';
if ($_SERVER['HTTP_CLIENT_IP'])
$ipaddress = $_SERVER['HTTP_CLIENT_IP'];
else if($_SERVER['HTTP_X_FORWARDED_FOR'])
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
else if($_SERVER['HTTP_X_FORWARDED'])
$ipaddress = $_SERVER['HTTP_X_FORWARDED'];
else if($_SERVER['HTTP_FORWARDED_FOR'])
$ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
else if($_SERVER['HTTP_FORWARDED'])
$ipaddress = $_SERVER['HTTP_FORWARDED'];
else if($_SERVER['REMOTE_ADDR'])
$ipaddress = $_SERVER['REMOTE_ADDR'];
else
$ipaddress = 'UNKNOWN';
return $ipaddress;
}
$ip_addr=get_client_ip_server();
//echo $ip_addr= '103.36.125.146';
?>
<?php
$url = "http://www.geoplugin.net/json.gp?ip='".$ip_addr."'";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$contents = curl_exec($ch);
if (curl_errno($ch)) {
echo curl_error($ch);
echo "\n<br />";
$contents = '';
} else {
curl_close($ch);
}
if (!is_string($contents) || !strlen($contents)) {
echo "Failed to get contents.";
$contents = '';
}
$contents;
$result=json_decode($contents);
//print_r($result);
?>
<?php
//echo $result->geoplugin_countryCode;
if( $result->geoplugin_countryCode == "IN" ) {
//do something here, like load a specific static block...
echo $this->getLayout()->createBlock('cms/block')->setBlockId('indiareturnpolicy')->toHtml();
}
else
{
echo $this->getLayout()->createBlock('cms/block')->setBlockId('international-return-policy')->toHtml();
}
echo $ip = $_SERVER["HTTP_CLIENT_IP"];
?>
function get_client_ip_server() {
$ipaddress = '';
if ($_SERVER['HTTP_CLIENT_IP'])
$ipaddress = $_SERVER['HTTP_CLIENT_IP'];
else if($_SERVER['HTTP_X_FORWARDED_FOR'])
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
else if($_SERVER['HTTP_X_FORWARDED'])
$ipaddress = $_SERVER['HTTP_X_FORWARDED'];
else if($_SERVER['HTTP_FORWARDED_FOR'])
$ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
else if($_SERVER['HTTP_FORWARDED'])
$ipaddress = $_SERVER['HTTP_FORWARDED'];
else if($_SERVER['REMOTE_ADDR'])
$ipaddress = $_SERVER['REMOTE_ADDR'];
else
$ipaddress = 'UNKNOWN';
return $ipaddress;
}
$ip_addr=get_client_ip_server();
//echo $ip_addr= '103.36.125.146';
?>
<?php
$url = "http://www.geoplugin.net/json.gp?ip='".$ip_addr."'";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$contents = curl_exec($ch);
if (curl_errno($ch)) {
echo curl_error($ch);
echo "\n<br />";
$contents = '';
} else {
curl_close($ch);
}
if (!is_string($contents) || !strlen($contents)) {
echo "Failed to get contents.";
$contents = '';
}
$contents;
$result=json_decode($contents);
//print_r($result);
?>
<?php
//echo $result->geoplugin_countryCode;
if( $result->geoplugin_countryCode == "IN" ) {
//do something here, like load a specific static block...
echo $this->getLayout()->createBlock('cms/block')->setBlockId('indiareturnpolicy')->toHtml();
}
else
{
echo $this->getLayout()->createBlock('cms/block')->setBlockId('international-return-policy')->toHtml();
}
echo $ip = $_SERVER["HTTP_CLIENT_IP"];
?>
EmoticonEmoticon