JS脚本数据库代码 复制代码 代码如下: "版权所有 <% 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 "数据库正在更新中,请稍后再试!""注释,需要把这几个字翻译成英文。 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" "是网通的话则跳转到网通的网址去,自己修改为自己的网站 Else response.redirect "http://www.****.com" "不是网通的则跳转到的网址,自己修改,不废话了 end if rs1.close set rs1=nothing conn.close set conn=nothing end if%>
另一实例: 复制代码 代码如下: <% "------------------------------------------------------------------------------------------------- Function GetUserIPInfo "根据当前用户使用线路信息 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) "根据用户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() "得到用户IP地址 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) "内部函数调用 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() %> <br> <% Response.write RemoteGetIPInfo("202.108.9.16") %> <br> <% Response.write GetUserIPInfo %>