Client IP Address function conversion IP Address function _ Application techniques under ASP

Source: Internet
Author: User
Tags servervariables
<%
'******************************
' Function: Userip ()
' Parameters: None
' Author: Arisisi
' Date: 2007/7/12
' Description: Get client IP Address
' Example: <%=userip ()%>
'******************************
Function Userip ()
Dim Getclientip
' If the client uses a proxy server, you should use the ServerVariables (' Http_x_forwarded_for ') method
Getclientip = Request.ServerVariables ("Http_x_forwarded_for")
If Getclientip = "" or IsNull (Getclientip) or IsEmpty (Getclientip) Then
' If the client does not use an agent, you should use the Request.ServerVariables (' remote_addr ') method
Getclientip = Request.ServerVariables ("REMOTE_ADDR")
End If
Userip = Getclientip
End Function
%>
Converting IP address functions
Copy Code code as follows:

<%
' ******************************
Function: CIP (SIP)
' parameter: sip,i P Address
' Author: Arisisi
' Date: 2007/7/12
Description: Convert IP address function
' Example: <%=cip ("219.16.73.120")%>
' ***************
Function cip (SIP)
Tip=cstr (SIP)
Sip1=left (Tip,cint (InStr (Tip, ".") -1)
Tip=mid (Tip,cint (InStr (Tip, ".") +1)
Sip2=left (Tip,cint) (InStr (Tip, ".") -1)
Tip=mid (Tip,cint (InStr (Tip, ".") +1)
Sip3=left (Tip,cint) (InStr (Tip, ".") -1)
Sip4=mid (Tip,cint (InStr (Tip, ".") +1)
Cip=cint (SIP1) *256*256*256+cint (SIP2) *256*256+cint (SIP3) *256+cint (SIP4)
End function
%> br>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.