Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

fbHTTP Class Reference

List of all members.

Detailed Description

HTTP protocol related functions.

Todo:
404 page to optionally email webmaster if 404 request has a referrer

Definition at line 21 of file HTTP.php.

Static Public Member Functions

 getRemoteAddress ()
 getIPAddressType ($ip)
 redirect ($url, $append_sid=true)
 getRequestVar ($key, $default=null)
 sendStatusHeader ($status_code)
 sendNoCacheHeaders ()
 sendLastModified ($time=null, $file=null)


Member Function Documentation

fbHTTP::getIPAddressType ip  )  [static]
 

Get the type of IP address

Todo:
use constants instead? FB_IP_ADDRESS_TYPE_LOOPBACK _INTERNAL _EXTERNAL _MULTICAST _RESERVED
Returns:
string 'loopback', 'internal', 'external', 'reserved', or false if address is invalid

Definition at line 139 of file HTTP.php.

Referenced by getRemoteAddress().

fbHTTP::getRemoteAddress  )  [static]
 

per http://forums.devshed.com/archive/6/2002/07/2/38967 :

Perl Forums

Thread: complications in determining *real* IP

Doucette REMOTE_ADDR gives you the IP, but a lot of the time these are proxies. I found out that I can (sometimes) get the 'real' IP from HTTP_X_FORWARDED_FOR and HTTP_CLIENT_IP.

Here are some interesting facts:

  • Out of a sample of ~7000 hits on my server, HTTP_X_FORWARDED_FOR was available 14% of the time, HTTP_CLIENT_IP 2%, (and REMOTE_ADDR 100%.)

  • There were instances in which HTTP_X_FORWARDED_FOR existed and HTTP_CLIENT_IP did not, vice-versa, and also instances in which they both existed.

  • Sometimes HTTP_X_FORWARDED_FOR has more than one IP listed (seperated by commas like this: "111.111.111.111, 222.222.222.222".) When this happened, somtimes HTTP_CLIENT_IP existed, and sometimes not, there was no correlation.

  • Sometimes HTTP_X_FORWARDED_FOR has values in these formats: "unknown", "unknown, unknown", "111.111.111.111, unknown", and "unknown, 111.111.111.111", which your script must check for.

The only thing I know is, when only REMOTE_ADDR exists, I use that as the IP... and I'm assuming that when only REMOTE_ADDR and only one of HTTP_X_FORWARDED_FOR and HTTP_CLIENT_IP exist, I have to use the one that exists as the IP.

LOTS OF QUESTIONS:

1) When both HTTP_X_FORWARDED_FOR and HTTP_CLIENT_IP exist, which do I use?

2) When only HTTP_X_FORWARDED_FOR exists, but it contains two IPs, which do I use?

3) When both HTTP_X_FORWARDED_FOR and HTTP_CLIENT_IP exist, but HTTP_X_FORWARDED_FOR contains two IPs, which do I use?

4) Some IPs returned in HTTP_X_FORWARDED_FOR start with "192.". Isn't this an internal IP which should be ignored as they are shared by many users? What other ranges of IPs are internal?

While I'm on the topic:

5) Does anyone know if HTTP_VIA or HTTP_FORWARDED can help me out? (They were respectively available 17% and 0.5% of the time in ~7000 hits to my server.)

If anyone knows these variables in detail, please explain them to me! I can not find any detailed information on them.

Returns:
The remote IP address of the user, if available, otherwise false.

Definition at line 77 of file HTTP.php.

References getIPAddressType().

Referenced by fbHMAC_Login_ADOdb::getChallenge().

fbHTTP::getRequestVar key,
default = null
[static]
 

Usage:

$varname = fbHTTP::getRequestVar('varname', 'default value');

Parameters:
$key string
$default mixed
Returns:
mixed $var if defined, otherwise $default

Definition at line 212 of file HTTP.php.

fbHTTP::redirect url,
append_sid = true
[static]
 

Redirect the client to the url $url Appends SID to url if session.use_trans_sid is true

Returns:
void (function exits, so it never returns)

Definition at line 184 of file HTTP.php.

Referenced by fbHTTPS::httpMe(), and fbHTTPS::httpsMe().

fbHTTP::sendLastModified time = null,
file = null
[static]
 

Parameters:
$time int
$file string
Returns:
bool

Definition at line 262 of file HTTP.php.

fbHTTP::sendNoCacheHeaders  )  [static]
 

Returns:
bool

Definition at line 244 of file HTTP.php.

fbHTTP::sendStatusHeader status_code  )  [static]
 

Parameters:
$status_code int
Returns:
bool

Definition at line 227 of file HTTP.php.

References fbHTTP_Status::getStatusName().


The documentation for this class was generated from the following file:
Generated on Fri Mar 19 12:52:32 2004 for Freebeer by doxygen 1.3.6-20040222