home *** CD-ROM | disk | FTP | other *** search
/ 221.214.14.186 / 221.214.14.186.tar / 221.214.14.186 / zb / Notepad-1 / connIP.asp < prev    next >
Text File  |  2004-12-09  |  972b  |  36 lines

  1. <%
  2. dim connIP,connIPstr
  3.  
  4. Set ConnIP=Server.CreateObject("ADODB.Connection")   
  5. 'Connstr="DBQ="+server.mappath("public/ly.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};DriverId=25;FIL=MS Access;ImplicitCommitSync=Yes;MaxBufferSize=512;MaxScanRows=8;PageTimeout=5;SafeTransactions=0;Threads=3;UserCommitSync=Yes;"   
  6. connIPstr ="Provider = Microsoft.Jet.OLEDB.4.0; Data Source ="&_
  7.     Server.MapPath("db/address.mdb")
  8. ConnIP.Open connIPstr
  9.  
  10. 'response.write getFrom("134.130.35.51")
  11.  
  12. 'connipclose()
  13.  
  14. sub connIPclose
  15.     connIP.close
  16.     set conn=nothing
  17. end sub
  18.  
  19. function getFrom(ip)
  20.     dim arr,num, sql, rs
  21.     arr=split(ip,".")
  22.     if ip="" or ubound(arr)<>3 then
  23.         getFrom=""
  24.         exit function
  25.     end if
  26.     num=int(arr(0))*16777216+int(arr(1))*65536+int(arr(2))*256+int(arr(3))-1
  27.     sql="select top 1 country,city from address where ip1<="&num&" and ip2>="&num
  28.     set rs=connip.execute(sql)
  29.     if not rs.eof then
  30.         getFrom=rs(0)&rs(1)
  31.     end if
  32.     rs.close
  33.     set rs=nothing
  34. end function
  35. %>
  36.