TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   Http_x_forwarded_for (http://www.talkphp.com/general/5132-http_x_forwarded_for.html)

delayedinsanity 11-25-2009 01:15 AM

Http_x_forwarded_for
 
Has anybody ever seen an Apache/PHP formatted HTTP_X_FORWARDED_FOR string? According to the RFC the following function should work, but I've never trapped a hit from a proxy server to be sure.

In addition, I've seen some people write their functions to grab the last ip in the set, but according to the RFC it should be the first.

php Code:
function kstats_trap_ip() {

    // This one *should* be trustworthy if found
    if ( getenv( 'HTTP_CLIENT_IP' ) )
        return $_SERVER['HTTP_CLIENT_IP'];

    // Otherwise we'll check if there's a proxy present
    if ( getenv( 'HTTP_X_FORWARDED_FOR' ) ) {

        $ip = explode( ',', $_SERVER['HTTP_X_FORWARDED_FOR'] );
        return trim( $ip[0] );

    }

    // Nothing else found
    return $_SERVER['REMOTE_ADDR'];

}

Rainman 02-19-2013 05:23 AM

Welcome to mmoggg website to buy RS Gold, offer a lot, of course, Diablo 3 Gold and Cheap RS Gold, to be purchased at any time, at any time shipment, and Diablo 3 Gold Kaufen look forward to your visit!


All times are GMT. The time now is 06:42 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0