26283 total geeks with 3498 solutions
Recent challengers:
 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
MaxMouse
It's Friday... That's good enough for me!
CodeX
non stop lolz here but thats soon to end thanks to uni, surely the rest of the world is going good?
stabat
how things are going guys? Here... boring...
CodeX
I must be going wrong on the password lengths then, as long as it was done on ECB
MaxMouse
lol... the key is in hex (MD5: of the string "doit" without the "'s) and is in lower case. Maybe i should have submitted this as a challenge!

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


News Feeds
The Register
Private equity firm
coughs for £1bn for
Websense
Violin welcomes new
grand master flash
flogger
Outsourcing
transfer "rumour"
O2 brushed off?
It"s happening ...
to THOUSANDS
David Cameron asks
UK biz to pay their
low, low taxes
Syrian hacktivists
hijack
Telegraph"
s Facebook, Twitter
accounts
Review: Sony Xperia
SP
BT Tower is just a
relic? Wrong: It
relays 18,000hrs of
telly daily
Curiosity
plunges its drill
into Mars AGAIN,
seeks life-giving
sample
Our new 1.5TB
lappie drive isn"t
thick, it"s just
the densest - HGST
A backdoor into
Skype for the Feds?
You"re joking...
Slashdot
Inside the
Microsoft Digital
Crimes Unit
Working Handgun
Printed On a
Sub-$2,000 3D
Printer
Goodbye, Lotus
1-2-3
Australia Makes
Asian Language
Learning a Priority
Web of Tax Shelters
Saved Apple
Billions, Inquiry
Finds
German Researchers
Hit 40 Gbps On
Wireless Link
The Hunt For
LulzSec"s Missing
Sixth Member
Latvian Police Raid
Teacher"s Home for
Uploading $4.00
Textbook
EFF Resumes
Accepting Bitcoin
Donations After Two
Year Hiatus
Google Drops XMPP
Support
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 5454 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