Home > Web Front-end > JS Tutorial > Line diversion automatically jumps code intelligently, automatically selects the fastest mirror website (js)_javascript skills

Line diversion automatically jumps code intelligently, automatically selects the fastest mirror website (js)_javascript skills

WBOY
Release: 2016-05-16 17:59:56
Original
1443 people have browsed it

JS script without database code

Copy code The code is as follows:



JS script database code
Copy code The code is as follows :

'Copyright
<%
On Error Resume next
dim conn,dbpath,UserIP
set conn=server.createobject("adodb.connection" )
DBPath = Server.MapPath("IP.mdb")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & DBPath
If Err Then
err. Clear
Set Conn = Nothing
Response.Write "The database is being updated, please try again later!"' Note, these words need to be translated into English.
Response.End
End If
myip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If myip = "" Then myip = Request.ServerVariables("REMOTE_ADDR")
tempip=myip
myip = Split(myip,".")
if Ubound(myip)=3 then
For i=0 To Ubound(myip)
myip(i)=left(myip(i), 3)
if isnumeric(myip(i)) then
myip(i)=cint(myip(i))
else
myip(i)=0
end if
next
myipnumeber=myip(0)*256*256*256 myip(1)*256*256 myip(2)*256 myip(3)
sql="select addr from ip where ip1<="&myipnumeber& " and ip2>="&myipnumeber
set rs1=conn.execute(sql)
if not rs1.eof then
response.redirect "http://www.***.com" 'It's Netcom If it is, jump to the URL of China Netcom and modify it to your own website
Else
response.redirect "http://www.****.com" 'If it is not Netcom, jump to the URL , modify it yourself, no more nonsense
end if
rs1.close
set rs1=nothing
conn.close
set conn=nothing
end if%>

For example:
Copy code The code is as follows:



title






< tr>


Dear Visitors
Hello! Automatically selecting the fastest route for you
Title



Speed ​​test Center...




<script> <br>i=1 <br>var autourl=new Array() <br>autourl[1]="Telecom address" //Modify to Telecom access address<br>autourl[2]= "Netcom address" //Modify to Netcom access address <br>function auto(url) <br>{ <br>if(i) <br>{ <br>i=0; <br>top.location=url <br>}} <br>function run() <br>{ <br>for(var i=1;i<autourl.length;i ) <BR>document.write("<img src='" autourl[ i] "' width=1 height=1 onerror=auto('" autourl[i] "')>") <br>} <br>run() <br></script>
< /div>




Also An example:
Copy code The code is as follows:

<%
'--------------------------------------------- -------------------------------------------------- ----------
Function GetUserIPInfo 'According to the current user's line information
Set XMLHTTP = Server.CreateObject("MSXML2.XMLHTTP")
'XMLHTTP.Open "Get"," http://www.dns7.cn/ip/?ip="&GetUserIP(),false
XMLHTTP.Open "Get","http://www.dns7.cn/ip/?ip=60.12.1.2 ",false
XMLHTTP.Send
strResult= bytes2BSTR(XMLHTTP.ResponseBody)
GetUserIPInfo=strResult
End Function
'------------- -------------------------------------------------- --------------------------------
Function RemoteGetIPInfo(IP) 'Get the line information based on the user's IP
Set XMLHTTP = Server.CreateObject("MSXML2.XMLHTTP")
XMLHTTP.Open "Get","http://www.dns7.cn/ip/?ip="&IP,false
XMLHTTP. Send
strResult= bytes2BSTR(XMLHTTP.ResponseBody)
RemoteGetIPInfo=strResult
End Function
'-------------------------- -------------------------------------------------- --------------------------
Function GetUserIP() 'Get the user IP address
Dim userip,userip2
userip = Request. ServerVariables("HTTP_X_FORWARDED_FOR")
userip2 = Request.ServerVariables("REMOTE_ADDR")
If userip = "" Then
GetUserIP=userip2
Else
GetUserIP=userip
End If
End Function
'--------------------------------------------- -------------------------------------------------- -----
Function bytes2BSTR(vIn) 'Internal function call
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1 ))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i 1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 CInt(NextCharCode))
i = i 1
End If
Next
bytes2BSTR = strReturn
End Function
'------ -------------------------------------------------- -------------------------------------
%>
<%
'Response.write GetUserIP()
%>


<%
Response.write RemoteGetIPInfo("202.108.9.16")
% >


<%
Response.write GetUserIPInfo
%> The principle is very simple. No matter which server the user enters, as long as you use this code on the default page, he will jump to the server with the fastest access speed. This can realize server offloading and is suitable for those with large traffic and multiple servers. Lines with multiple servers!
I have tested it and it is very easy to use
Code 1:
Write on the page you want to jump to:
Copy code



Copy code The code is as follows:
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template