[PHP] getting ip address of the user.

2002-09-24 Thread Anil Garg

hi,

Can i get the ip-address of the machines who accessed my website??
Plz give the pointer that on what lines shall i start for doing so.

thanx and regards
anil



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] getting ip address of the user.

2002-09-24 Thread Jesse Cablek

Anil Garg mailto:[EMAIL PROTECTED] scribbled;
 
 Can i get the ip-address of the machines who accessed my website??
 Plz give the pointer that on what lines shall i start for doing so.
 

print $_SERVER['REMOTE_ADDR'];

-jesse


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] getting ip address of the user.

2002-09-24 Thread Bill Farrell

Hi, Y'all,
Here's another suggestion FWIW.  I prep a few
variables in the htmlhead.php routine, $RemoteHost
being one of them.  Having some simple names for
associated values is kinda handy.  One of the biggest
strengths of PHP is that there's more than one way to
go about solving problems.  Here goes:

?php
/* Identify the request, request headers, and the
requestor */
$HTTP_Headers = getallheaders();
$Method = getenv( REQUEST_METHOD );
$Referer = getenv( HTTP_REFERER );
$RemoteHost = getenv( REMOTE_HOST );

if ( $HTTP_X_FORWARDED_FOR ) {
$RemoteAddr = $HTTP_X_FORWARDED_FOR;
} elseif ( $HTTP_VIA) {
   $RemoteAddr = $HTTP_VIA;
} elseif ( $REMOTE_ADDR ) {
   $RemoteAddr = $REMOTE_ADDR;
}

?


--- Jesse Cablek [EMAIL PROTECTED] wrote:
 Anil Garg mailto:[EMAIL PROTECTED] scribbled;
  
  Can i get the ip-address of the machines who
 accessed my website??
  Plz give the pointer that on what lines shall i
 start for doing so.
  
 
 print $_SERVER['REMOTE_ADDR'];
 
 -jesse
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 



=
Bill Farrell
Multivalue and *nix Support Specialist

Phone: (828) 667-2245
Fax:   (928) 563-5189
Web:   http://www.jwfarrell.com

__
Do you Yahoo!?
New DSL Internet Access from SBC  Yahoo!
http://sbc.yahoo.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] getting ip address of the user.

2002-09-24 Thread Bill Farrell

Hi, Tony...
Here's a script I pilfered from online a coupla years
back and have modified (over and over).  The code
would be online, except my ISP is having heartburns
lately...
Bill

?php

$MetaTitle = WhoAmI;
$MetaDescription = Utility to demonstrate PHP;
include( style/htmlhead.php );

$OnLoad = ;
include( style/bodytemplate_top.php );

// seed with microseconds
function make_seed() {
list($usec,$sec) = explode( , microtime());
return ((float)$sec+(float)$usec) * 10;
}

$Agent = getenv( HTTP_USER_AGENT );
$Authorities = array( 'whois.arin.net',
'whois.ripe.net', 'whois.apnic.net' );
$date = date(r);

if ( $HTTP_X_FORWARDED_FOR ) {
$ip = $HTTP_X_FORWARDED_FOR;
} elseif( $HTTP_VIA ) {
$ip = $HTTP_VIA;
} elseif( $REMOTE_ADDR ) {
$ip = $REMOTE_ADDR;
} else {
die();
}

$TheDate = rtrim( `date +%Y%m%d-%H%M` );
srand(make_seed());
$randval = rand();
$LogID = $ThisWebServer.:.$TheDate.:.microtime();
  
$host = gethostbyaddr($ip);
if ( $host == $ip ) {
$host = possibly spoofed;
}

$headers = getallheaders();
$HeaderLog = array();
while (list ($header, $value) = each ($headers)) {
array_push( $HeaderLog, $header=$value );
}


$GotResponse = false;

// ARIN makes a messy output.  To get what we want we
have to requery using the NIC 
// handle to get the email address for the contact. 
First, replace this skimpy output
// with the output that has the required data in it

foreach ( $Authorities as $Authority ) {
if ( $GotResponse ) { break; }
$RespondingAuthority = $Authority;
@exec(/usr/bin/whois $ip@$Authority,
$WholeResponse, $status );
$UWholeResponse = strtoupper( join(  ,
$WholeResponse) );
if ( ( strpos( $UWholeResponse, NO ENTRIES )
=== false )  ( strpos( $UWholeResponse, NO MATCH )
=== false ) ) {
$GotResponse = true;
$Keepgoing = true;
foreach ( $WholeResponse as $Line ) {
if ( ( $Authority == whois.arin.net
)  ( $Keepgoing ) ) {
$StartPos = strpos(
$Line, chr(40) );
if ( !( $StartPos ===
false ) ) {
$StartPos++;
$RightSide =
strpos( $Line, chr(41) );
$RightSide =
$RightSide - $StartPos;
$Query =
substr( $Line, $StartPos, $RightSide );
$Query .=
@whois.arin.net;
unset(
$WholeResponse );
@exec(
/usr/bin/whois !$Query, $WholeResponse, $status );
$Keepgoing =
false;
break;  
}   
}   
}   
}   
}

// APNIC and RIPE produce similar reports.  ARIN on
the other hand makes
// you work twice as hard to find an email address. 
With ARIN, one must
// perform a double-query (as above) to get the
information associated
// with a network's NIC handle.  APNIC and RIPE just
hand it to you 
// straightaway.

unset( $SendTo ); // just for effect
if ( $RespondingAuthority != whois.arin.net ) {
foreach ( $WholeResponse as $Line ) {
list( $Key, $Value ) = explode( :,
$Line );
if ( strtoupper( $Key ) == E-MAIL )
{ 
if ( eregi( @dsl.net, $Value ) ) {
$SendTo = [EMAIL PROTECTED];
} elseif ( eregi( ripe.net, $Value ) ) {
$SendTo = [EMAIL PROTECTED];
} elseif ( eregi( bellsouth.net, $Value ) ) {
$SendTo = [EMAIL PROTECTED];
} else {
$SendTo = trim( $Value );
}
break;  
}   
}
} else {
foreach ( $WholeResponse as $Line ) {
$Words = explode(  , trim( $Line )
);
foreach ( $Words as $Word ) {
if
(eregi(^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*$,$Word))
{
if ( eregi( @dsl.net, $Word ) ) {
$SendTo = [EMAIL PROTECTED];
} elseif ( eregi( ripe.net,
$Value ) ) {
$SendTo =
[EMAIL PROTECTED];
} elseif ( eregi(
bellsouth.net, $Value ) ) {
$SendTo =
[EMAIL PROTECTED];
} else {
$SendTo = $Word;
}
break;
}
}
if ( isset( 

RE: [PHP] getting ip address of the user.

2002-09-24 Thread Mark Charette

This comes up so very often ...

The answer is - you may be able to get _an_ IP number for a machine that
accesssed your site. It is meaningless as a means of identification:

Proxies use 1 IP for a number of users.

-Original Message-
From: Anil Garg [mailto:[EMAIL PROTECTED]]

hi,

Can i get the ip-address of the machines who accessed my website??
Plz give the pointer that on what lines shall i start for doing so.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Getting IP address

2001-09-19 Thread Andrew Semark

Can anybody tell me how to get the IP address of the remote machine looking
at the web page.  I have two versions of PHP 4 On the box with version 4.0.1
I can use $HTTP_SERVER_VARS[REMOTE_ADDR], but on the other server running
4.0.0 this don't work. Is there another way of doing this as it's not
possible to upgrade this server.

Thank

Andy



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Getting IP address

2001-09-19 Thread Aniceto Lopez

this is working for me $REMOTE_ADDR


Aniceto Lopez
www.laMundial.net
download and spread our music


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Getting IP address

2001-09-19 Thread Andreas Gietl

On Wednesday 19 September 2001 11:37, Andrew Semark wrote:

$addr = getenv('REMOTE_ADDR');

 Can anybody tell me how to get the IP address of the remote machine looking
 at the web page.  I have two versions of PHP 4 On the box with version
 4.0.1 I can use $HTTP_SERVER_VARS[REMOTE_ADDR], but on the other server
 running 4.0.0 this don't work. Is there another way of doing this as it's
 not possible to upgrade this server.

 Thank

 Andy

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Getting IP address

2001-09-19 Thread Jon Haworth

A better version would be:

if (getenv(HTTP_X_FORWARDED_FOR)) {

$ip=getenv(HTTP_X_FORWARDED_FOR); 
} else { 
$ip=getenv(REMOTE_ADDR); 
}   

This checks for proxy forwarding as well, if you just use REMOTE_ADDR you
might end up with a proxy, not the real IP.

Cheers
Jon


-Original Message-
From: Andreas Gietl [mailto:[EMAIL PROTECTED]]
Sent: 19 September 2001 11:15
To: Andrew Semark; [EMAIL PROTECTED]
Subject: Re: [PHP] Getting IP address


On Wednesday 19 September 2001 11:37, Andrew Semark wrote:

$addr = getenv('REMOTE_ADDR');

 Can anybody tell me how to get the IP address of the remote machine
looking
 at the web page.  I have two versions of PHP 4 On the box with version
 4.0.1 I can use $HTTP_SERVER_VARS[REMOTE_ADDR], but on the other server
 running 4.0.0 this don't work. Is there another way of doing this as it's
 not possible to upgrade this server.


**
'The information included in this Email is of a confidential nature and is 
intended only for the addressee. If you are not the intended addressee, 
any disclosure, copying or distribution by you is prohibited and may be 
unlawful. Disclosure to any party other than the addressee, whether 
inadvertent or otherwise is not intended to waive privilege or confidentiality'

**

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Getting IP address

2001-09-19 Thread Tamas Arpad

On Wednesday 19 September 2001 13:13, Jon Haworth wrote:
 A better version would be:

 if (getenv(HTTP_X_FORWARDED_FOR)) {

   $ip=getenv(HTTP_X_FORWARDED_FOR);
 } else {
   $ip=getenv(REMOTE_ADDR);
 }

 This checks for proxy forwarding as well, if you just use
 REMOTE_ADDR you might end up with a proxy, not the real IP.

As I know HTTP_X_FORWARDED_FOR can contain more than one ip address, 
it depends on how many proxies have forwarded the http answer.
Arpi


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Getting IP address

2001-09-19 Thread Jon Haworth

Well, presumably you could split $ip into an array based on whatever the
delimiter is. I just use this snippet for our intranet where everything
comes through exactly one proxy.

Cheers
Jon


-Original Message-
From: Tamas Arpad [mailto:[EMAIL PROTECTED]]
Sent: 19 September 2001 12:54
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Getting IP address


On Wednesday 19 September 2001 13:13, Jon Haworth wrote:
 A better version would be:

 if (getenv(HTTP_X_FORWARDED_FOR)) {

   $ip=getenv(HTTP_X_FORWARDED_FOR);
 } else {
   $ip=getenv(REMOTE_ADDR);
 }

 This checks for proxy forwarding as well, if you just use
 REMOTE_ADDR you might end up with a proxy, not the real IP.

As I know HTTP_X_FORWARDED_FOR can contain more than one ip address, 
it depends on how many proxies have forwarded the http answer.
Arpi



**
'The information included in this Email is of a confidential nature and is 
intended only for the addressee. If you are not the intended addressee, 
any disclosure, copying or distribution by you is prohibited and may be 
unlawful. Disclosure to any party other than the addressee, whether 
inadvertent or otherwise is not intended to waive privilege or confidentiality'

**

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Getting ip address of client and displaying a number in decimal format.

2001-09-13 Thread Troy Lynch

I'm trying to find out how to do 2 things one. I'd like to get the ip
address of the client machine so I can write it to a database. And then I'd
like to convert a number to show 2 decmials to the right like for money
etc


Thanks

Troy



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Getting ip address of client and displaying a number in decimal format.

2001-09-13 Thread Kelly Barrett

Troy,
$REMOTE_ADDR gives you the client IP.

To convert a number to show 2 decimals use sprintf:

$money = 5;

$money_string = sprintf(%.2f, $money); // $money_string will be 5.00

Cheers,
Kelly.

 -Original Message-
 From: Troy Lynch [mailto:[EMAIL PROTECTED]]
 Sent: Friday, 14 September 2001 8:49 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Getting ip address of client and displaying a number in
 decimal format.
 
 
 I'm trying to find out how to do 2 things one. I'd like to get the ip
 address of the client machine so I can write it to a database. 
 And then I'd
 like to convert a number to show 2 decmials to the right like for money
 etc
 
 
 Thanks
 
 Troy
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Getting ip address of client and displaying a number in decimal format.

2001-09-13 Thread Alexander Skwar

So sprach »Troy Lynch« am 2001-09-13 um 17:48:55 -0500 :
 I'm trying to find out how to do 2 things one. I'd like to get the ip
 address of the client machine so I can write it to a database. And then I'd

- php.net/ip2long

 like to convert a number to show 2 decmials to the right like for money
 etc

- php.net/number_format

Alexander Skwar
-- 
How to quote:   http://learn.to/quote (german) http://quote.6x.to (english)
Homepage:   http://www.digitalprojects.com   |   http://www.iso-top.de
   iso-top.de - Die günstige Art an Linux Distributionen zu kommen
Uptime: 23 hours 59 minutes

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]