Reply
Country from IP
Old 10-05-2006, 06:13 AM Country from IP
kreoton's Avatar
Extreme Talker

Posts: 194
The problem is that function gethostbyaddr() dosn't gives any results and my function is unuseful:

PHP Code:
if ($hostname gethostbyaddr($_SERVER['REMOTE_ADDR'])){
    if (
substr($hostname,-2)!="lt"){
        
header("Location:/en/");
        die();
    } else {
        
header("Location:/lt/");
        die();
    }
} else {
    
header("Location:/lt/");
    die();

Any ideas?
kreoton is offline
Reply With Quote
View Public Profile Visit kreoton's homepage!
 
When You Register, These Ads Go Away!
Old 10-05-2006, 06:33 AM Re: Country from IP
jito's Avatar
MY LIFE IS 'i' LIFE

Posts: 551
Name: surajit ray
Location: inside the heart of my friends
i can find a logical error:
if ($hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']))

i think u need "=="
__________________
Think+, work +, but not HIV + :)
jito is offline
Reply With Quote
View Public Profile
 
Old 10-05-2006, 07:29 AM Re: Country from IP
kreoton's Avatar
Extreme Talker

Posts: 194
Quote:
Originally Posted by jito View Post
i can find a logical error:
if ($hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']))

i think u need "=="
no = is ok the function gethostbyaddr() returns IP not host
kreoton is offline
Reply With Quote
View Public Profile Visit kreoton's homepage!
 
Old 10-05-2006, 07:35 AM Re: Country from IP
vectorialpx's Avatar
Super Talker

Posts: 128
Name: irimia octavian
Location: Romania
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR'])

= will make
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']), like you say
== is for conditions!

you conditioned if
gethostbyaddr($_SERVER['REMOTE_ADDR']) can give to $hostname the value.
__________________
my photos, my website, creation lab
vectorial pixel web services :: and, sorry for my English !
vectorialpx is offline
Reply With Quote
View Public Profile Visit vectorialpx's homepage!
 
Old 10-05-2006, 08:09 AM Re: Country from IP
jito's Avatar
MY LIFE IS 'i' LIFE

Posts: 551
Name: surajit ray
Location: inside the heart of my friends
really srry kreoton, i interprete ur code wrongly. thought u want to compare two values.
gethostbyadd() returns a string containing the unmodified_ip on failure.
__________________
Think+, work +, but not HIV + :)
jito is offline
Reply With Quote
View Public Profile
 
Old 10-05-2006, 08:25 AM Re: Country from IP
vectorialpx's Avatar
Super Talker

Posts: 128
Name: irimia octavian
Location: Romania
oh yes...

so... there's no need for if...

problem: not any IP has a dns... so... is not well
__________________
my photos, my website, creation lab
vectorial pixel web services :: and, sorry for my English !
vectorialpx is offline
Reply With Quote
View Public Profile Visit vectorialpx's homepage!
 
Old 10-05-2006, 09:28 AM Re: Country from IP
kreoton's Avatar
Extreme Talker

Posts: 194
is it posible to find out country from part of ip?
kreoton is offline
Reply With Quote
View Public Profile Visit kreoton's homepage!
 
Old 10-05-2006, 10:00 AM Re: Country from IP
jito's Avatar
MY LIFE IS 'i' LIFE

Posts: 551
Name: surajit ray
Location: inside the heart of my friends
yes, and that's what u need.
http://ip-to-country.webhosting.info/
search google for more.
__________________
Think+, work +, but not HIV + :)
jito is offline
Reply With Quote
View Public Profile
 
Old 10-06-2006, 08:45 AM Re: Country from IP
kreoton's Avatar
Extreme Talker

Posts: 194
i found many scripts with big text data, but i dont think it is nessary to use them just to see if visitor is from one country (in my case lithuania).
kreoton is offline
Reply With Quote
View Public Profile Visit kreoton's homepage!
 
Old 10-07-2006, 02:29 AM Re: Country from IP
jito's Avatar
MY LIFE IS 'i' LIFE

Posts: 551
Name: surajit ray
Location: inside the heart of my friends
then find out the ip-database of LT and it's over. don't forget to update the database on monthly basis
__________________
Think+, work +, but not HIV + :)
jito is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Country from IP
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.17701 seconds with 12 queries