ASP automatically determines the code of the substation based on the IP address

Source: Internet
Author: User

Function getipvalue (clientip) 'obtains the client's IP address conversion and growth integer. The returned value is getipvalue.
On Error resume next
Dim strip, array_ip
Strip = 0
Array_ip = Split (clientip ,".")
If ubound (array_ip) <> 3 then
Getipvalue = 0
Exit Function
End if
For I = 0 to 3
Strip = strip + (CINT (array_ip (I) * (256 ^ (3-I )))
Next
Getipvalue = strip
If err then getipvalue = 0
End Function
Clientip = request. servervariables ("remote_host ")
Ipvalue = getipvalue (clientip)
Strsql = "select top 1 city from [IPaddress] Where" & ipvalue &"
Between IP1 and ip2"
Set rsip1_conn.exe cute (strsql)
If rsip. bof and rsip. EOF then
Urlcity = "unknown"
Else
Urlcity = rsip. Fields. Item ("city"). Value
End if
If instr (urlcity, "Guangzhou") <> 0 then
Response. Redirect ("http://www.jb51.net ")
End if
If instr (urlcity, "Shenzhen") <> 0 then
Response. Redirect ("http://img.jb51.net ")
End if
If instr (urlcity, "Shanghai") <> 0 then
Response. Redirect ("http://xiazai.jb51.net ")
End if
The IP database used can go online to get down one
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.