22858 total geeks with 3297 solutions
Recent challengers:
sharepoint how to
 Welcome, you are an anonymous user! [register] [login] Get a yourname@osix.net email address 

Articles

GEEK

User's box
Username:
Password:

Forgot password?
New account

Shoutbox
innocentius
I win at OSIX, I guess. Onward to the other challenges!
sefo
anilg, new comments are deleted automaticall y because of some abuse recently
anilg
this is plain wierd. I submitted comments twice to article 950, and they dont seem to be there. Something wrong with the comment code?
CodeX
shout-boxes in general are old + the staff thing happened to everyone after an issue 2 months ago
anilg
/me is no longer staff :(

Donate
Donate and help us fund new challenges
Donate!
Due Date: Sep 30
September Goal: $40.00
Gross: $0.00
Net Balance: $0.00
Left to go: $40.00
Contributors


News Feeds
The Register
Google Instant
blacklists the
Slutskys
Jailbreak hole in
iOS 4.1 will be
hard to close
Google Instant
? more searches,
less thought
Amazon buys (some
of) digital music
site Amie Street
Microsoft wins
court order
crushing mighty
spam botnet
Appro sells another
flash-happy HPC
cluster
NoSQL CouchDB
founder turns to
phone and cloud
services
Netezza, Symantec
jump on takeover
rumors
Adobe Reader 0day
under active attack
Hurd to take
$950,000 salary
after Oracle pay
cut
Slashdot
Film Industry Hires
Cyber Hitmen To
Take Down Pirates
The Real "Stuff
White People Like"
Biometric IDs For
All India"s
Citizens
Big Brother In the
School Cafeteria?
Viking Landers
Might Have Missed
Martian Organics
Online Ads, Privacy
Remain In FTC
Crosshairs
Anti-Product
Placement For
Negative Branding
Solar Cells Made
From Bioluminescent
Jellyfish
How 6 Memorable
Tech Companies Got
Their Names
School Swaps Math
Textbooks For iPads
Article viewer

Getting a System IP Address



Written by:irah
Published by:Codybob90
Published on:2009-05-13 05:28:55
Topic:PHP
Search OSI about PHP.More articles by irah.
 viewed 3053 times send this article printer friendly

Digg this!
    Rate this article :
This article is for PHP programmers.

The following user-defined function is used to get the client system IP address. In case of tracking purpose, we can use the following function in order to get the client system IP address.

For example, you are working in a network and you have a web page and you plan to add more security to that page. If you want to track what system the web page was seen from, you can use the following function.

function getRealIpAddr() {
        if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
                $ip=$_SERVER['HTTP_CLIENT_IP'];
        } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
                $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
        } else {
                $ip=$_SERVER['REMOTE_ADDR'];
        }
        return $ip;
}


Take this function and experiment with it.

Did you like this article? There are hundreds more.

Comments:
sarvesh_osix
2009-08-15 10:51:48
function getRealIpAddr() {
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
$ip=$_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$ip=$_SERVER['REMOTE_ADDR'];
}
return $ip;
}
Anonymously add a comment: (or register here)
(registration is really fast and we send you no spam)
BB Code is enabled.
Captcha Number:


Blogs: (People who have posted blogs on this subject..)
elasolova
My PHP Projects on Sat 26th Sep 10am
I have been developing PHP applications for almost a year now. I have developed three projects. One is a simple trivia game. The other is a question-answer based community at http://www.javaist.com/quans . The last one is a programming challenge site just
countll
Blog entry for Thu 25th Oct 7am on Thu 25th Oct 7am
soo nu on this wicked world of NET. just decided to dive in today..hope friend aroun here can help

Test Yourself: (why not try testing your skill on this subject? Clicking the link will start the test.)
Test of experience (hopefully) by AcidIce

Things you're only likely to know if you've actually written a lot of PHP before :)


     
Your Ad Here
 
Copyright Open Source Institute, 2006