The IP address is available from the web server variable "REMOTE_ADDR".
ASP without Proxy detection
ASP with Proxy detection
PHP without Proxy detection
PHP with Proxy detection
JSP without Proxy detection
JSP with Proxy detection
ColdFusion without Proxy detection
ColdFusion with Proxy detection
ASP.NET (C#) without Proxy detection
ASP.NET (C#) with Proxy detection
ASP.NET (VB.NET) without Proxy detection
ASP.NET (VB.NET) with Proxy detection
ASP without Proxy detection
<%
ipaddress = Request.ServerVariables("REMOTE_ADDR")
%>
ASP with Proxy detection
<%
ipaddress = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
if ipaddress = "" then
ipaddress = Request.ServerVariables("REMOTE_ADDR")
end if
%>
PHP without Proxy detection
<?
$ipaddress = getenv(REMOTE_ADDR);
?>
PHP with Proxy detection
<?
if (getenv(HTTP_X_FORWARDED_FOR)) {
$ipaddress = getenv(HTTP_X_FORWARDED_FOR);
} else {
$ipaddress = getenv(REMOTE_ADDR);
}
?>
JSP without Proxy detection
<%
String ipaddress = request.getRemoteAddr();
%>
JSP with Proxy detection
<%
if (request.getHeader("HTTP_X_FORWARDED_FOR") == null) {
String ipaddress = request.getRemoteAddr();
} else {
String ipaddress = request.getHeader("HTTP_X_FORWARDED_FOR");
}
%>
ColdFusion without Proxy detection
<CFCOMPONENT>
<CFSET ipaddress="#CGI.Remote_Addr#">
</CFCOMPONENT>
ColdFusion with Proxy detection
<CFCOMPONENT>
<CFIF #CGI.HTTP_X_Forwarded_For# EQ "">
<CFSET ipaddress="#CGI.Remote_Addr#">
<CFELSE>
<CFSET ipaddress="#CGI.HTTP_X_Forwarded_For#">
</CFIF>
</CFCOMPONENT>
ASP.NET (C#) without Proxy detection
public string IpAddress()
{
return Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
}
ASP.NET (C#) with Proxy detection
public string IpAddress()
{
string strIp;
strIp = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (strIp == null)
{
strIp = Request.ServerVariables["REMOTE_ADDR"];
}
return strIp;
}
ASP.NET (VB.NET) without Proxy detection
Public Function IpAddress()
IpAddress = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
End Function
ASP.NET (VB.NET) with Proxy detection
Public Function IpAddress()
Dim strIp As String
strIp = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If strIp = "" Then
strIp = Request.ServerVariables("REMOTE_ADDR")
End If
IpAddress = strIp
End Function
2 comments:
Unknown
April 18, 2007 5:05 PM
Anonymous
April 04, 2008 3:47 PM
Post a Comment Subscribe to Post Comments (Atom)