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.

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

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 :

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: ",".) 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", ", unknown", and "unknown,", 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.


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.

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


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

$key string
$default mixed
mixed $var if defined, otherwise $default

Definition at line 212 of file HTTP.php.

fbHTTP::redirect url,
append_sid = true

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

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

$time int
$file string

Definition at line 262 of file HTTP.php.

fbHTTP::sendNoCacheHeaders  )  [static]


Definition at line 244 of file HTTP.php.

fbHTTP::sendStatusHeader status_code  )  [static]

$status_code int

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