Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-02-2002, 12:20 AM   PM User | #1
mouse
Regular Coder


 
Join Date: Jun 2002
Location: North East England
Posts: 853
Thanks: 0
Thanked 0 Times in 0 Posts
mouse is an unknown quantity at this point
Question How do I get the user's IP?

^^^as titled
__________________
[+] Computer/PC issues [+] Silverpaw3D
------------------------------------------------
Never buy a dwarf with learning disabilities...

...it's not big, and it's not clever.
mouse is offline   Reply With Quote
Old 08-02-2002, 12:37 AM   PM User | #2
HormonX
New Coder

 
Join Date: Aug 2002
Location: Toronto, Canada
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
HormonX is an unknown quantity at this point
...

this should be the easiest way of doing that ...

<? echo $HTTP_SERVER_VARS["REMOTE_ADDR"] ?>

HormonX
HormonX is offline   Reply With Quote
Old 08-02-2002, 12:45 AM   PM User | #3
mouse
Regular Coder


 
Join Date: Jun 2002
Location: North East England
Posts: 853
Thanks: 0
Thanked 0 Times in 0 Posts
mouse is an unknown quantity at this point
$REMOTE_ADDR

is quite easy too, cheers anyhoo
__________________
[+] Computer/PC issues [+] Silverpaw3D
------------------------------------------------
Never buy a dwarf with learning disabilities...

...it's not big, and it's not clever.
mouse is offline   Reply With Quote
Old 08-02-2002, 01:22 PM   PM User | #4
bcarl314
Mega-ultimate member


 
Join Date: Jun 2002
Location: Winona, MN - The land of 10,000 lakes
Posts: 1,855
Thanks: 1
Thanked 45 Times in 42 Posts
bcarl314 will become famous soon enough
Can you get the IP address of a computer behind a proxy server?
bcarl314 is offline   Reply With Quote
Old 08-02-2002, 03:26 PM   PM User | #5
SYP}{ER
Regular Coder

 
Join Date: Jun 2002
Location: Ontario, Canada
Posts: 183
Thanks: 0
Thanked 0 Times in 0 Posts
SYP}{ER is an unknown quantity at this point
Not sure about the proxy thing, but a few other ways to get the IP

getenv ("REMOTE_ADDR");

or

$_SERVER["REMOTE_ADDR"];

__________________
Offtone.com - In the works...
SYP}{ER is offline   Reply With Quote
Old 08-02-2002, 03:44 PM   PM User | #6
Ökii
Regular Coder

 
Join Date: Jun 2002
Location: UK
Posts: 577
Thanks: 0
Thanked 0 Times in 0 Posts
Ökii is an unknown quantity at this point
PHP Code:
function getip() {
    if (isSet(
$_SERVER)) {
        if (isSet(
$_SERVER["HTTP_X_FORWARDED_FOR"])) {
            
$realip $_SERVER["HTTP_X_FORWARDED_FOR"];
        } elseif (isSet(
$_SERVER["HTTP_CLIENT_IP"])) {
            
$realip $_SERVER["HTTP_CLIENT_IP"];
        } else {
            
$realip $_SERVER["REMOTE_ADDR"];
        }
    
    } else {
        if ( 
getenv'HTTP_X_FORWARDED_FOR' ) ) {
            
$realip getenv'HTTP_X_FORWARDED_FOR' );
        } elseif ( 
getenv'HTTP_CLIENT_IP' ) ) {
            
$realip getenv'HTTP_CLIENT_IP' );
        } else {
            
$realip getenv'REMOTE_ADDR' );
        }
    }
    return 
$realip;    

You might need to amend the $_SERVER calls to $HTTP_SERVER_VARS (note: I'm pretty sure I copied that from php.net somepage so don't blame me if it works properly )
__________________
Ökii - formerly pootergeist
teckis - take your time and it'll save you time.
Ökii is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:57 PM.


Advertisement
Log in to turn off these ads.