CDN Accelerated ASP Web site to obtain user real IP program _ Application Skills

Source: Internet
Author: User
Copy Code code as follows:

function Checkip (checkstring) ' uses regular to determine whether IP is legal
Dim Re1
Set Re1=new REGEXP
Re1.pattern= "^[0-9]{1,3}. [0-9] {1,3}. [0-9] {1,3}. [0-9] {1,3}$ "
Re1.global=false
Re1. Ignorecase=false
Checkip=re1.test (checkstring)
Set re1=nothing
End Function

Copy Code code as follows:
Function Get_cli_ip () "Take the real IP function, http_client_ip before http_x_forwarded_for again Remote_addr
Dim client_ip
If Checkip (Request.ServerVariables ("Http_client_ip")) =true then
Get_cli_ip = C Heckip (Request.ServerVariables ("Http_client_ip"))
Else
MyArray = Split (Request.ServerVariables ("Http_x_ Forwarded_for "),", ")
If UBound (myarray) >=0 then
Client_ip = Trim (myarray (0))
if Checkip (CLIENT_IP) =tr UE then
Get_cli_ip = client_ip
Exit Function
End If
End If
Get_cli_ip = Request.servervariab Les ("remote_addr")
End If
End Function

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.