• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
    • 軟件測試技術
    • 軟件測試博客
    • 軟件測試視頻
    • 開源軟件測試技術
    • 軟件測試論壇
    • 軟件測試沙龍
    • 軟件測試資料下載
    • 軟件測試雜志
    • 軟件測試人才招聘
      暫時沒有公告

    字號: | 推薦給好友 上一篇 | 下一篇

    ip限制函數

    發布: 2007-7-14 19:37 | 作者: 佚名    | 來源: 網絡轉載     | 查看: 9次 | 進入軟件測試論壇討論

    領測軟件測試網 大家如果還有好的建議算法,就聯系我。。海

    '******************************
    'Function CheckIp(cInput_Ip,cBound_Ip)
    'Created by qqdao, qqdao@263.net 2001/11/28
    '說明:首先需要根據;號循環,然后判斷是否含有"-",如果有則進行拆分處理,最后判斷是否在范圍內
    '參數: cInput_Ip,代檢查的ip
    ' cBound_Ip,給定的范圍格式為,單個ip,和范圍ip,范圍ip最后使用”-“分割,如果是“*”則必須放到最后一位
    ' 每個范圍后添加":ALLOW"表示允許登陸,添加":REFUSE"表示拒絕登陸。多個范圍用”;“隔開
    ' 例如192.168.1*.*:ALLOW;192.168.1.1:ALLOW;192.168.1.1-10:REFUSE"
    '返回值: true/false
    '更新:2001/12/05 支持ALLOW,REFUSE支持’*‘,不想對?支持,因為和*差不多
    '******************************
    function CheckIp(cInput_Ip,cBound_Ip)
    dim cSingle_Ip,cTemp_IP,cStart_IP,cEnd_Ip
    CheckIp = false
    cSingle_Ip=split(cBound_Ip,";")

    for i=0 to ubound(cSingle_Ip)
    if Instr(cSingle_Ip(i),"REFUSE") <> 0 then '就是拒絕了
    cTemp_IP = left(cSingle_Ip(i),instr(cSingle_Ip(i),":")-1)

    if Instr(cTemp_IP,"*") <> 0 then '是寬范圍
    cStart_IP = left(cTemp_IP,instr(cTemp_IP,"*")-1)
    if left(cInput_Ip,len(cStart_IP))=cStart_IP then
    CheckIp = false
    exit function
    end if
    end if

    if Instr(cTemp_IP,"-") = 0 then
    cStart_IP = cTemp_IP
    cEnd_Ip = cTemp_IP
    else
    cStart_IP = left(cTemp_IP,instr(cTemp_IP,"-")-1)
    cEnd_Ip = left(cStart_IP,InStrRev(cStart_IP,".")-1)+"."+mid(cTemp_IP,instr(cTemp_IP,"-")+1)
    end if

    if Ip2Str(cInput_Ip)>=Ip2Str(cStart_IP) and Ip2Str(cInput_Ip)<=Ip2Str(cEnd_Ip) then
    CheckIp = false
    exit function
    end if

    elseif Instr(cSingle_Ip(i),"ALLOW") <> 0 then '允許

    cTemp_IP = left(cSingle_Ip(i),instr(cSingle_Ip(i),":")-1)

    if Instr(cTemp_IP,"*") <> 0 then '是寬范圍
    cStart_IP = left(cTemp_IP,instr(cTemp_IP,"*")-1)
    if left(cInput_Ip,len(cStart_IP))=cStart_IP then
    CheckIp = true
    end if
    end if

    if Instr(cTemp_IP,"-") = 0 then
    cStart_IP = cTemp_IP
    cEnd_Ip = cTemp_IP
    else
    cStart_IP = left(cTemp_IP,instr(cTemp_IP,"-")-1)
    cEnd_Ip = left(cStart_IP,InStrRev(cStart_IP,".")-1)+"."+mid(cTemp_IP,instr(cTemp_IP,"-")+1)
    end if

    if Ip2Str(cInput_Ip)>=Ip2Str(cStart_IP) and Ip2Str(cInput_Ip)<=Ip2Str(cEnd_Ip) then
    CheckIp =true
    else
    CheckIp =false
    end if
    end if
    next

    end function


    '******************************
    'Function Ip2Str(cIp)
    'Created by qqdao, qqdao@263.net 2001/11/28
    '參考動網ip算法
    '參數:cIp ip地址
    '返回值: 轉換后數值
    '******************************
    function Ip2Str(cIp)
    Dim str1,str2,str3,str4
    Dim cIp_Temp
    if cIp="127.0.0.1" then cIp="192.168.0.1"
    str1=left(cIp,instr(cIp,".")-1)
    cIp_Temp=mid(cIp,instr(cIp,".")+1)
    str2=left(cIp_Temp,instr(cIp_Temp,".")-1)
    cIp_Temp=mid(cIp_Temp,instr(cIp_Temp,".")+1)
    str3=left(cIp_Temp,instr(cIp_Temp,".")-1)
    str4=mid(cIp_Temp,instr(cIp_Temp,".")+1)

    if isNumeric(str1)=0 or isNumeric(str2)=0 or isNumeric(str3)=0 or isNumeric(str4)=0 then

    else
    Ip2Str=cint(str1)*256*256*256+cint(str2)*256*256+cint(str3)*256+cint(str4)-1
    end if

    end function


    延伸閱讀

    文章來源于領測軟件測試網 http://www.kjueaiud.com/


    關于領測軟件測試網 | 領測軟件測試網合作伙伴 | 廣告服務 | 投稿指南 | 聯系我們 | 網站地圖 | 友情鏈接
    版權所有(C) 2003-2010 TestAge(領測軟件測試網)|領測國際科技(北京)有限公司|軟件測試工程師培訓網 All Rights Reserved
    北京市海淀區中關村南大街9號北京理工科技大廈1402室 京ICP備2023014753號-2
    技術支持和業務聯系:info@testage.com.cn 電話:010-51297073

    軟件測試 | 領測國際ISTQBISTQB官網TMMiTMMi認證國際軟件測試工程師認證領測軟件測試網

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>