ASP調(diào)用純真IP庫(kù)實(shí)例(4)_ASP教程

      編輯Tag賺U幣
      教程Tag:暫無(wú)Tag,歡迎添加,賺取U幣!

      推薦:ASP實(shí)例:ASP實(shí)現(xiàn)空間的最近訪客
      由于工作關(guān)系,在做一個(gè)用戶空間。要用到空間的最近訪客,見(jiàn)ASP代碼: % username=request.QueryString(username) '地欄中的username,就是自己的用戶名了 if trim(request.Cookies(user_name)) Then '首頁(yè)要判斷該訪問(wèn)是否登陸,只有登陸的訪問(wèn)才能記


      ' ============================================
      ' 獲取字串信息
      ' ============================================
      Private Function GetStr()
      Dim c
      GetStr = ""
      Do While (True)
      c = AscB(Stream.Read(1))
      If (c = 0) Then Exit Do

      '如果是雙字節(jié),就進(jìn)行高字節(jié)在結(jié)合低字節(jié)合成一個(gè)字符
      If c > 127 Then
      If Stream.EOS Then Exit Do
      GetStr = GetStr & Chr(AscW(ChrB(AscB(Stream.Read(1))) & ChrB(C)))
      Else
      GetStr = GetStr & Chr(c)
      End If
      Loop
      End Function
      ' ============================================
      ' 核心函數(shù),執(zhí)行IP搜索
      ' ============================================
      Public Function QQWry(DotIP)
      Dim IP, nRet
      Dim RangB, RangE, RecNo

      IP = IPToInt (DotIP)

      Set Stream = CreateObject("ADodb.Stream")
      Stream.Mode = 3
      Stream.Type = 1
      Stream.Open
      Stream.LoadFromFile QQWryFile
      Stream.Position = 0
      Buf = Stream.Read(8)

      FirstStartIP = AscB(MidB(Buf, 1, 1)) + (AscB(MidB(Buf, 2, 1))*256) + (AscB(MidB(Buf, 3, 1))*256*256) + (AscB(MidB(Buf, 4, 1))*256*256*256)
      LastStartIP = AscB(MidB(Buf, 5, 1)) + (AscB(MidB(Buf, 6, 1))*256) + (AscB(MidB(Buf, 7, 1))*256*256) + (AscB(MidB(Buf, 8, 1))*256*256*256)
      RecordCount = Int((LastStartIP - FirstStartIP)/7)
      ' 在數(shù)據(jù)庫(kù)中找不到任何IP地址
      If (RecordCount <= 1) Then
      Country = "未知"
      QQWry = 2
      Exit Function
      End If

      RangB = 0
      RangE = RecordCount

      Do While (RangB < (RangE - 1))
      RecNo = Int((RangB + RangE)/2)
      Call GetStartIP (RecNo)
      If (IP = StartIP) Then
      RangB = RecNo
      Exit Do
      End If
      If (IP > StartIP) Then
      RangB = RecNo
      Else
      RangE = RecNo
      End If
      Loop

      Call GetStartIP(RangB)
      Call GetEndIP()

      If (StartIP <= IP) And ( EndIP >= IP) Then
      ' 沒(méi)有找到
      nRet = 0
      Else
      ' 正常
      nRet = 3
      End If
      Call GetCountry(IP)

      QQWry = nRet
      End Function
      ' ============================================
      ' 類終結(jié)
      ' ============================================
      Private Sub Class_Terminate
      On ErrOr Resume Next
      Stream.Close
      If Err Then Err.Clear
      Set Stream = Nothing
      End Sub
      End Class
      %>

      希望能對(duì)大家有所幫助

      分享:ASP防止GET,Post注入和防止服務(wù)器攻擊,并記錄IP
      % '防止GET,Post注入和防止服務(wù)器攻擊 '使用方法把本文件包含到需要防注的文件就OK了,說(shuō)明下,這里的post攻擊和Get攻擊不一定是攻擊,在英文版本的時(shí)候請(qǐng)注意使用 '馮旭修改 session.Abandon() Dim fxjt111_Attack_post,fxjt111_Attack_Get,fxjt111_Attack_Sys

      共4頁(yè)上一頁(yè)1234下一頁(yè)
      來(lái)源:模板無(wú)憂//所屬分類:ASP教程/更新時(shí)間:2010-06-02
      相關(guān)ASP教程