note 22750 added to function.getenv

From: Date: Fri, 28 Jun 2002 12:23:56 +0000
Subject: note 22750 added to function.getenv
Groups: php.notes 
Request: Send a blank email to php-notes+get-32365@lists.php.net to get a copy of this message
Here's an improvement on Klemens Karssen excellent script : <?php # ascertain the user's ip address # # """"""""""""""""""""""""""""""" # $a = getenv("HTTP_X_FORWARDED_FOR"); $b = getenv("REMOTE_ADDR"); if ($a <> "") { ### [ip proxied] ### $posn=0; do { $posn++; # increment $POSN. if ($a{$posn} == ',') { # if inside the $A string, at the $POSN character -- there is a "," character break; # .. exit the do/while loop. } } while ($posn < strlen($a)); # do until the end of the $A string has been reached. $login_ip = substr($a,0,$posn); # $LOGIN_IP = from 0 to $POSN characters of $A string # $A = "nigger", [0=>4] === {nigg} } else { ### [ip standard] ### $login_ip = $b; } # ........./......... # $login_ip = $login_ip; $login_host = gethostbyaddr($login_ip); echo "<font face=courier size=-1>"; echo "&nbsp; Your IP Address is [<b>".$login_ip."</b>]<br>"; echo "Your Host Address is [<b>".$login_host."</b>]<br><br>"; echo "</font>"; ?> -- http://www.php.net/manual/en/function.getenv.php http://master.php.net/manage/user-notes.php?action=edit+22750 http://master.php.net/manage/user-notes.php?action=delete+22750 http://master.php.net/manage/user-notes.php?action=reject+22750

« previous php.notes (#32365) next »