Response to some questions from users

>Hi,
>
>If I use your code in PHP, how much of a delay will that be as compared to using a database?
>
>Please let me know.
>Thank you !
>Rickson.

The system used for country identification will work very fast in most cases.

Lets consider an ip like this: AAA.BBB.CCC.DDD (AAA is a number, etc).

When IP addresses starting with AAA may belong to many different contries (file AAA.php is big), finding corresponding country will require more time. Fortunately, in most cases, the file searched is very small (
212 files from 255 are <5.000 bites). In those cases, this system will be faster than usage of a database.

>i manage 2 stores one is targeted towards UK and the other toward the rest of the world.
>
>i want a visitor from uk to be taken directly to the uk store
>and the others to be taken to the second store
>
>how would i be able to do that?
>
>thanks

Try this way:

<?
$IPaddress=$_SERVER['REMOTE_ADDR'];
$two_letter_country_code=iptocountry($IPaddress);

if ($two_letter_country_code=="UK"){
     include("This_file_for_UK.html");
      die();
    }else{
     include("This_file_for_others.html");
      die();
    }

function iptocountry($ip) {   
    $numbers = preg_split( "/\./", $ip);   
    include("ip_files/".$numbers[0].".php");
    $code=($numbers[0] * 16777216) ($numbers[1] * 65536) ($numbers[2] * 256) ($numbers[3]);   
    foreach($ranges as $key => $value){
        if($key<=$code){
            if($ranges[$key][0]>=$code){$two_letter_country_code=$ranges[$key][1];break;}
            }
    }
    if ($two_letter_country_code==""){$two_letter_country_code="unkown";}
    return $two_letter_country_code;
}
?>

>But I cannot get the full name of the country.Which file do
>i have to edit?thanks in advance.
Try this two lines:

include("ip_files/countries.php");
print $countries[$country];




2010@ PhpTutorial.info. All rights reserved. Contact