indiantown
Technical User
Hello All,
I am using the below script to create redirection of my page visitors as per their ip address,
<?php
$v=0;$f=0;$n=array();
if(isset($HTTP_GET_VARS['ip'])){
$ip=$HTTP_GET_VARS['ip'];}
else{$ip='10.1.1.10';}
$ip=sprintf("%u",ip2long($ip));
while(strlen($ip)<10){$ip='0'.$ip;}
$h=opendir($crdr);
while($e=readdir($h)){
$o=(int)$e;if(strlen($o)>5){
$n[$f]=$e;$f++;}}closedir($h);
sort($n);
$o=count($n)-1;$d=$n[$o];
for($j=0;$j<$o;$j++){if($ip>=$n[$j]&&$ip<$n[$j+1]){$d=$n[$j];break;}}
$d=$crdr.'/'.$d;$q=fopen($d,"r");
while(!feof($q)){$r=fgets($q,32);
$a=substr($r,0,9);$b=substr($r,10,19);$c=substr($r,20);
if($ip>=$a&&$ip<=$b){$v=1;break;}}
fclose($q);
if($v==0){print "window.location='$default'";}
else{$cc=strtolower($c);$cc=str_replace("\n","",$cc);
if($cc=='gb'){$cc='uk';}
if($cc=='in'){$cc='in';}
if($cc=='fr'){$cc='fr';}
if($cc=='de'){$cc='de';}
$path=set_path($cc);
if(is_file($path)||is_dir($path)){print "window.location='$path'";}
else{print "window.location='$default'";}}
?></script>
means if a person signs from UK they would get redirected to UK page instead of US page.
What I need help is that how I can use one page and call the script in this way: page.php?c=en or page.php?c=cn etc otherwise I would have to keep on creating pages for each country.
Appreciate some help and direction.
regards
I am using the below script to create redirection of my page visitors as per their ip address,
<?php
$v=0;$f=0;$n=array();
if(isset($HTTP_GET_VARS['ip'])){
$ip=$HTTP_GET_VARS['ip'];}
else{$ip='10.1.1.10';}
$ip=sprintf("%u",ip2long($ip));
while(strlen($ip)<10){$ip='0'.$ip;}
$h=opendir($crdr);
while($e=readdir($h)){
$o=(int)$e;if(strlen($o)>5){
$n[$f]=$e;$f++;}}closedir($h);
sort($n);
$o=count($n)-1;$d=$n[$o];
for($j=0;$j<$o;$j++){if($ip>=$n[$j]&&$ip<$n[$j+1]){$d=$n[$j];break;}}
$d=$crdr.'/'.$d;$q=fopen($d,"r");
while(!feof($q)){$r=fgets($q,32);
$a=substr($r,0,9);$b=substr($r,10,19);$c=substr($r,20);
if($ip>=$a&&$ip<=$b){$v=1;break;}}
fclose($q);
if($v==0){print "window.location='$default'";}
else{$cc=strtolower($c);$cc=str_replace("\n","",$cc);
if($cc=='gb'){$cc='uk';}
if($cc=='in'){$cc='in';}
if($cc=='fr'){$cc='fr';}
if($cc=='de'){$cc='de';}
$path=set_path($cc);
if(is_file($path)||is_dir($path)){print "window.location='$path'";}
else{print "window.location='$default'";}}
?></script>
means if a person signs from UK they would get redirected to UK page instead of US page.
What I need help is that how I can use one page and call the script in this way: page.php?c=en or page.php?c=cn etc otherwise I would have to keep on creating pages for each country.
Appreciate some help and direction.
regards