#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 1999
    Location
    Seixal, Portugal
    Posts
    19
    Rep Power
    0
    Hi,

    Some times when someone comes to our site we couldnīt get a DNS counterpart for their IP number . But we need it to give them country related news first and global news latter on our home page . There's a place or a way to know from IP numbers where is the server contacting us located .

    ------------------
    Projecto EINet
  2. #2
  3. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    ## host should give the value of $ENV{'REMOTE_HOST'}, otherwise, it will use $ENV{'REMOTE_ADDR'}
    ## so in this example, $host is the host while $ip is for $ENV{'REMOTE_ADDR'} in short form
    $ip = $ENV{'REMOTE_ADDR'};
    $n = `nslookup $ip | grep Name`; chop($n);
    $host = substr($n, rindex($n, " ")+1);

    if ($host eq "") {
    $host=$ENV{'REMOTE_ADDR'};
    }
    >>But we need it to give them country related news first and global news latter on our home page
    There are two ways you should do. You can download and install this http://www.perl.com/CPAN-local/modul...try-0.1.tar.gz
    If your site is hosted at someone's server, you can simply place this Country.pm under any subdirectory of your account. For example: /html/your_account/libdata/Net/Country.pm
    Next, put the following line in your script:
    use lib "/html/your_account/libdata";
    use Net::Country;
    If you will install Net-Country on your own server, the lib path should be in your path, so you don't need to use the "use lib..." line.

    The other way is to use http://www.apache.org/docs/mod/mod_m...ml#addlanguage . Also take a look at ENV{'ACCEPT_LANGUAGE'}, but it might not give you a value.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 1999
    Location
    Seixal, Portugal
    Posts
    19
    Rep Power
    0
    Thanks. Thanks. And thanks again.

    ------------------
    Projecto EINet
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 1999
    Location
    Seixal, Portugal
    Posts
    19
    Rep Power
    0
    Another quest yet.

    Does the IP number mean anything or is in any way related with the country where the server is? There's a place where I can get more info about the logic of IP numbers are created.

    Thanks

    ------------------
    Projecto EINet

    [This message has been edited by Projecto EINet (edited April 29, 2000).]
  8. #5
  9. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    No, you are on your own. You need to create a huge db to keep track of that. Country.pm helps you determine the country of a $ENV{'REMOTE_HOST'} based on the right-most prefix delimited by a decimal.
    For example, 'somehost.foo.bar.it' -> from Italy.
    Luckily, there probably aren't any international ISP or your result will be meaningless.

    You should combine the $ENV{'ACCPET_LANGUAGE'} and http://www.apache.org/docs/mod/mod_n...nguagepriority plus Country.pm to get a better handle to your case.

IMN logo majestic logo threadwatch logo seochat tools logo