Forum Articles
  Welcome back Join CF
You are here You are here: Home | Forum | php? detecting ip of NTL user?

You are currently viewing our boards as a guest which gives you limited access to view most of the discussions, articles and other free features. By joining our Virgin Media community you will have full access to all discussions, be able to view and post threads, communicate privately with other members (PM), respond to polls, upload your own images/photos, and access many other special features. Registration is fast, simple and absolutely free so please join our community today.


Welcome to Cable Forum
Go Back   Cable Forum > Computers & IT > Internet Discussion

php? detecting ip of NTL user?
Reply
 
Thread Tools
Old 12-07-2005, 07:32   #1
dragon
Inactive
 
Join Date: Jan 2004
Posts: 3,898
dragon has reached the bronze age
dragon has reached the bronze agedragon has reached the bronze agedragon has reached the bronze agedragon has reached the bronze agedragon has reached the bronze agedragon has reached the bronze agedragon has reached the bronze agedragon has reached the bronze agedragon has reached the bronze agedragon has reached the bronze age
php? detecting ip of NTL user?

My friend has a site portal on his site which features a shoutbox

, problem is the shoutbox is logging the visiting IP of an NTL user as the ip of the proxy cache, (it does this when you post a shout) obivously if someone ended up causing trouble and my friend was to ban the IP he'd end up banning the whole cache instead.


i was wandering if theres something he can add to his could add to his code so that the true ip was determaned rather than that of the proxy cache?
dragon is offline   Reply With Quote
Advertisement
Old 12-07-2005, 08:15   #2
Jon M
Inactive
 
Jon M's Avatar
 
Join Date: Oct 2003
Location: East Midlands
Age: 48
Services: Rural BB - Radio Link via Virgin Fibre
Posts: 2,947
Jon M has a bronze arrayJon M has a bronze arrayJon M has a bronze array
Jon M has a bronze arrayJon M has a bronze arrayJon M has a bronze arrayJon M has a bronze arrayJon M has a bronze arrayJon M has a bronze arrayJon M has a bronze arrayJon M has a bronze arrayJon M has a bronze arrayJon M has a bronze arrayJon M has a bronze arrayJon M has a bronze arrayJon M has a bronze arrayJon M has a bronze arrayJon M has a bronze arrayJon M has a bronze arrayJon M has a bronze array
Send a message via MSN to Jon M
Re: php? detecting ip of NTL user?

You're saying he coded this shoutbox himself?

If he did, then surely he can find this out for himself?
If not, who made it? and have you asked the question to them?

The php code for displaying the end user IP is:
Code:
<? echo getenv('REMOTE_ADDR'); ?>
__________________

This code will detect whether it is a forwarded (behind a proxy) address:
Code:
**Ignore this, it's useless ASP code**
Jon M is offline   Reply With Quote
Old 12-07-2005, 10:10   #3
philip.j.fry
Inactive
 
philip.j.fry's Avatar
 
Join Date: Jul 2003
Posts: 1,395
philip.j.fry has reached the bronze age
philip.j.fry has reached the bronze agephilip.j.fry has reached the bronze agephilip.j.fry has reached the bronze agephilip.j.fry has reached the bronze age
Re: php? detecting ip of NTL user?

Quote:
Originally Posted by Jon M
This code will detect whether it is a forwarded (behind a proxy) address:
Code:
Dim sIPAddress
sIPAddress = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If sIPAddress="" Then sIPAddress = Request.ServerVariables("REMOTE_ADDR")
EndIf
Isn't that VB rather than PHP?
philip.j.fry is offline   Reply With Quote
Old 12-07-2005, 10:16   #4
punky
Inactive
 
Join Date: Jun 2003
Age: 45
Posts: 14,750
punky has a golden aurapunky has a golden aura
punky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aurapunky has a golden aura
Re: php? detecting ip of NTL user?

Quote:
Originally Posted by philip.j.fry
Isn't that VB rather than PHP?
I thought it was ASP.
__________________

The most robust way of doing it that I have seen is this:

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;
} 
From here:

http://board.php-princess.net/index....=ST&f=10&t=14# second post down, by pootergeist. Haven't tried it, looks pretty good though.
punky is offline   Reply With Quote
Old 12-07-2005, 10:19   #5
Jon M
Inactive
 
Jon M's Avatar
 
Join Date: Oct 2003
Location: East Midlands
Age: 48
Services: Rural BB - Radio Link via Virgin Fibre
Posts: 2,947
Jon M has a bronze arrayJon M has a bronze arrayJon M has a bronze array
Jon M has a bronze arrayJon M has a bronze arrayJon M has a bronze arrayJon M has a bronze arrayJon M has a bronze arrayJon M has a bronze arrayJon M has a bronze arrayJon M has a bronze arrayJon M has a bronze arrayJon M has a bronze arrayJon M has a bronze arrayJon M has a bronze arrayJon M has a bronze arrayJon M has a bronze arrayJon M has a bronze arrayJon M has a bronze arrayJon M has a bronze array
Send a message via MSN to Jon M
Re: php? detecting ip of NTL user?

Lol, ASP, how did I not spot that
Trying to be too fast with google.
Jon M is offline   Reply With Quote
Old 12-07-2005, 10:25   #6
philip.j.fry
Inactive
 
philip.j.fry's Avatar
 
Join Date: Jul 2003
Posts: 1,395
philip.j.fry has reached the bronze age
philip.j.fry has reached the bronze agephilip.j.fry has reached the bronze agephilip.j.fry has reached the bronze agephilip.j.fry has reached the bronze age
Re: php? detecting ip of NTL user?

Quote:
Originally Posted by punky
I thought it was ASP.
Doh me never used ASP or VB before but I knew that Dim was the way to declare variables in VB (edit: unless it isn't and I'm completely wrong ).
philip.j.fry is offline   Reply With Quote
Old 12-07-2005, 12:42   #7
Gareth
cf.mega poster
 
Gareth's Avatar
 
Join Date: Dec 2003
Age: 51
Posts: 7,101
Gareth has a pair of shiny starsGareth has a pair of shiny starsGareth has a pair of shiny starsGareth has a pair of shiny starsGareth has a pair of shiny starsGareth has a pair of shiny stars
Gareth has a pair of shiny starsGareth has a pair of shiny starsGareth has a pair of shiny starsGareth has a pair of shiny starsGareth has a pair of shiny starsGareth has a pair of shiny starsGareth has a pair of shiny stars
Re: php? detecting ip of NTL user?

<pedantic>ASP just stands for Active Server Pages, which is a technology that uses VBScript and/or Javascript and/or perl and/or any other scripting language you like. ASP itself is not a language. </pedantic>

Just thought I'd clear that up.
Gareth is offline   Reply With Quote
Old 12-07-2005, 13:52   #8
philip.j.fry
Inactive
 
philip.j.fry's Avatar
 
Join Date: Jul 2003
Posts: 1,395
philip.j.fry has reached the bronze age
philip.j.fry has reached the bronze agephilip.j.fry has reached the bronze agephilip.j.fry has reached the bronze agephilip.j.fry has reached the bronze age
Re: php? detecting ip of NTL user?

Quote:
Originally Posted by Gareth
<pedantic>ASP just stands for Active Server Pages, which is a technology that uses VBScript and/or Javascript and/or perl and/or any other scripting language you like. ASP itself is not a language. </pedantic>
Woohoo, I was only partially wrong then
philip.j.fry is offline   Reply With Quote
Reply

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

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

Forum Jump


All times are GMT. The time now is 14:58.


Server: lithium.zmnt.uk
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
All Posts and Content are © Cable Forum