ASP based on IP address to automatically determine the direction of substation code _ Application techniques

Source: Internet
Author: User
Function getipvalue (ClientIP) ' Gets the IP conversion growth integer of the client, the return value 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" [IPAddress] where "&IpValue&"
Between Ip1 and Ip2 "
Set Rsip=conn.execute (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 down one back

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.