------------------------------------------------------------------------------- -- THoR:RiP:ClientChecker:v.1.1 / By: NightLitch ------------------------------------------------------------------------------- BotName = "-THoR-CltChk-" ------------------------------------------------------------------------------- KB = 1024 MB = KB*KB GB = KB*KB*KB TB = KB*KB*KB*KB ------------------------------------------------------------------------------- --// User Settings ------------------------------------------------------------------------------- USER_MINSLOTS = 3 USER_MAXSLOTS = 15 USER_MAXHUBS = 5 USER_RATIO = 1 USER_BANDWIDTH = 500 USER_BLOCK_BANDWIDTH = 0 USER_CHECK_CLIENT = 1 USER_CHECK_TAG = 1 USER_MINSHARE = 0 USER_MINUNIT = GB USER_MAXSHARE = 1 USER_MAXUNIT = TB USER_CHECK_SHARE = 1 ------------------------------------------------------------------------------- --// Registered User Settings ------------------------------------------------------------------------------- REG_MINSLOTS = 3 REG_MAXSLOTS = 20 REG_MAXHUBS = 5 REG_RATIO = 1 REG_BANDWIDTH = 0 REG_BLOCK_BANDWIDTH = 1 REG_CHECK_CLIENT = 1 REG_CHECK_TAG = 1 REG_MINSHARE = 1 REG_MINUNIT = GB REG_MAXSHARE = 2 REG_MAXUNIT = TB REG_CHECK_SHARE = 1 ------------------------------------------------------------------------------- --// VIP User Settings ------------------------------------------------------------------------------- VIP_MINSLOTS = 2 VIP_MAXSLOTS = 25 VIP_MAXHUBS = 7 VIP_RATIO = 0 VIP_BANDWIDTH = 0 VIP_BLOCK_BANDWIDTH = 1 VIP_CHECK_CLIENT = 1 VIP_CHECK_TAG = 1 VIP_MINSHARE = 500 VIP_MINUNIT = MB VIP_MAXSHARE = 3 VIP_MAXUNIT = TB VIP_CHECK_SHARE = 1 ------------------------------------------------------------------------------- --// Operator Settings ------------------------------------------------------------------------------- OPR_MINSLOTS = 1 OPR_MAXSLOTS = 35 OPR_MAXHUBS = 10 OPR_RATIO = 1 OPR_BANDWIDTH = 0 OPR_BLOCK_BANDWIDTH = 1 OPR_CHECK_CLIENT = 1 OPR_CHECK_TAG = 1 OPR_MINSHARE = 0 OPR_MINUNIT = MB OPR_MAXSHARE = 5 OPR_MAXUNIT = TB OPR_CHECK_SHARE = 1 ------------------------------------------------------------------------------- --// Administrator Settings ------------------------------------------------------------------------------- ADM_MINSLOTS = 0 ADM_MAXSLOTS = 50 ADM_MAXHUBS = 15 ADM_RATIO = 0 ADM_BANDWIDTH = 0 ADM_BLOCK_BANDWIDTH = 1 ADM_CHECK_CLIENT = 1 ADM_CHECK_TAG = 0 ADM_MINSHARE = 0 ADM_MINUNIT = MB ADM_MAXSHARE = 10 ADM_MAXUNIT = TB ADM_CHECK_SHARE = 0 ------------------------------------------------- -- Connection Speed Check -- ------------------------------------------------- Allow_28 = 0 Allow_33 = 0 Allow_56 = 0 Allow_ISDN = 0 Allow_DSL = 1 Allow_Cable = 1 Allow_LANT1 = 1 Allow_LANT3 = 1 Allow_Sat = 0 ------------------------------------------------- -- Allow Client -- ------------------------------------------------- -- DC++ AllowDCPP = 1 VerDCPP = "0.301" -- ODC AllowODC = 1 VerODC = "5.0" -- DC:PRO AllowDCPRO = 1 VerDCPRO = "0.2.2.10" -- DCGUI AllowDCGUI = 1 VerDCGUI = "0.2.20" --DCTC AllowDCTC = 1 VerDCTC = "0" -- NMDC2 AllowNMDC2 = 1 VerNMDC2 = "2.02" -- Strong DC++ AllowSDC = 1 VERSDC = "1.00" -- iDC++ AllowIDC = 1 VerIDC = "1.03" -- MS++ AllowMSPP = 1 VerMSPP = "0" -- DCDM++ AllowDCDM = 1 VerDCDM = "2.8" -- Phantom DC++ AllowPHMDC = 1 VerPHMDC = "0.301" --BCDC++ AllowBCDC = 1 VerBCDC = "0.305" -- CZDC++ AllowCZDC = 1 VerCZDC = "0.303" -- RMDC++ AllowRMDC = 1 VerRMDC = "0.305" -- DC@fe++ AllowDCAFE = 1 VerDCAFE = "0.400" -- DC++ DCDM AllowDCDCDM = 1 VerDCDCDM = "0.030" -- zY++ AllowZYPP = 1 VerZYPP = "1.00" -- xR++ AllowXRPP = 1 VerXRPP = "0.10" ------------------------------------------------- -- Profile Setup -- ------------------------------------------------- Profiles = { [-1] = 1, -- regular user [3] = 2, -- registered user [2] = 3, -- vip user [1] = 4, -- operator [0] = 5, -- master/admin } -- Setting up the profile checkings numbers is the number from the SET table, then just add your profile Slot, Hub... here Checks = { [1] = {[1] = USER_MINSLOTS, [2] = USER_MAXSLOTS, [3] = USER_MAXHUBS, [4] = USER_RATIO, [5] = USER_BANDWIDTH, [6] = USER_BLOCK_BANDWIDTH, [7] = USER_CHECK_CLIENT, [8] = USER_CHECK_TAG, [9] = USER_MINSHARE, [10] = USER_MINUNIT, [11] = USER_MAXSHARE, [12] = USER_MAXUNIT, [13] = USER_CHECK_SHARE }, [2] = {[1] = REG_MINSLOTS, [2] = REG_MAXSLOTS, [3] = REG_MAXHUBS, [4] = REG_RATIO, [5] = REG_BANDWIDTH, [6] = REG_BLOCK_BANDWIDTH, [7] = REG_CHECK_CLIENT, [8] = REG_CHECK_TAG, [9] = REG_MINSHARE, [10] = REG_MINUNIT, [11] = REG_MAXSHARE, [12] = REG_MAXUNIT, [13] = REG_CHECK_SHARE }, [3] = {[1] = VIP_MINSLOTS, [2] = VIP_MAXSLOTS, [3] = VIP_MAXHUBS, [4] = VIP_RATIO, [5] = VIP_BANDWIDTH, [6] = VIP_BLOCK_BANDWIDTH, [7] = VIP_CHECK_CLIENT, [8] = VIP_CHECK_TAG, [9] = VIP_MINSHARE, [10] = VIP_MINUNIT, [11] = VIP_MAXSHARE, [12] = VIP_MAXUNIT, [13] = VIP_CHECK_SHARE }, [4] = {[1] = OPR_MINSLOTS, [2] = OPR_MAXSLOTS, [3] = OPR_MAXHUBS, [4] = OPR_RATIO, [5] = OPR_BANDWIDTH, [6] = OPR_BLOCK_BANDWIDTH, [7] = OPR_CHECK_CLIENT, [8] = OPR_CHECK_TAG, [9] = OPR_MINSHARE, [10] = OPR_MINUNIT, [11] = OPR_MAXSHARE, [12] = OPR_MAXUNIT, [13] = OPR_CHECK_SHARE }, [5] = {[1] = ADM_MINSLOTS, [2] = ADM_MAXSLOTS, [3] = ADM_MAXHUBS, [4] = ADM_RATIO, [5] = ADM_BANDWIDTH, [6] = ADM_BLOCK_BANDWIDTH, [7] = ADM_CHECK_CLIENT, [8] = ADM_CHECK_TAG, [9] = ADM_MINSHARE, [10] = ADM_MINUNIT, [11] = ADM_MAXSHARE, [12] = ADM_MAXUNIT, [13] = ADM_CHECK_SHARE }, } ------------------------------------------------- ------------------------------------------------- -- SCRIPT STARTS HERE -- ------------------------------------------------- ------------------------------------------------- UNIT = {[KB] = "Kb",[MB] = "Mb",[GB] = "Gb",[TB] = "Tb"} Client = { {"<++",AllowDCPP,VerDCPP, "DC++"}, {"",AllowODC, VerODC, "oDC"}, {"",AllowPHMDC, VerPHMDC, "Phantom DC++"}, {")%$ $([^$]*)[^$]%$[^$]*%$%s*(%d*)%$") Tag = Tag or "" Descr = Descr or "" if Speed==nil or Share==nil then _,_,Speed,Share = strfind(MyINFO, "%$ $([^$]*)[^$]%$[^$]*%$%s*(%d*)%$") end local _,_,xTag = strfind(Descr, "(%b<>)") xTag = xTag or "" Descr = gsub(Descr, xTag, "") local Tag = xTag..Tag local _,_,xC,xV,C,V,M,H,S,B = strfind(Tag, "<*(%S*)%s*([%.%d]*)>*<(%S*) V:([%.%d]*)%s*%S*,M:([5SAP]),H:([%d%/]*),S:([%d%*]*),*[BLUF]*:*([%.%d*]*)%S*>$") if S=="" then S = 0 C = "Tag Error" end if tonumber(H) == nil then gsub(H, "(%d+)", function (num) hubs = hubs +tonumber(num) end) else hubs = tonumber(H) end local ClientCheck, ClientMinVer = 0,"0" sClt,sChk,sMiV = cTag(C) if sClt == nil then C = "Fake Client" else C = sClt ClientCheck = sChk ClientMinVer = sMiV end if xC~="" then dClt,dChk,dMiV = cTag(xC) if dClt~=nil and C ~= "Fake Client" then C = dClt if xV=="" then V = xV end ClientCheck = dChk ClientMinVer = dMiV else C = "Invalid Double Tag" end end if strfind(Tag, "V:%a+") then C = "Fake Clients / NoTag Clients" V = "0" ClientCheck, ClientMinVer = 0,"0" end if C=="DCGUI" and tonumber(B) then B = B * S end if strfind(Tag, "L:") then if C~="Strong DC++" then C = "CZDC++" ClientCheck = OtherClients[C][1] ClientMinVer = OtherClients[C][2] end elseif strfind(Tag, "B:") then if C ~= "rmDC++" and C~="Phantom DC++" then C = "Bear Claw DC++" ClientCheck = OtherClients[C][1] ClientMinVer = OtherClients[C][2] end end if B =="" then B = "Unlimited" end MODE = {["5"] = "Socket5", ["A"] = "Active", ["P"] = "Passive",["S"] = "Socket"} _TAG = {["C"] = {C,ClientCheck,ClientMinVer},["V"] = V, ["M"] = tostring(MODE[M]), ["H"] = hubs, ["S"] = S, ["B"] = B,["T"] = Tag,["D"] = Descr} return _TAG,Speed,Share end function cTag(tag) local clt,chk,minv = nil,nil,nil,nil for i=1,getn(Client) do Client[i][1] = gsub(Client[i][1], "<" , "") if tag == Client[i][1] then chk = Client[i][2] minv = Client[i][3] clt = Client[i][4] end end return clt,chk,minv end function ClientCheck(Client,Version,sUser) if Checks[ProfileCheck(sUser)][7]==1 then if Client[2] == 1 then if Version < Client[3] then SendPmToNick(sUser.sName,BotName, "You are using "..Client[1].." version ( "..Version.." )") SendPmToNick(sUser.sName,BotName, "The oldest "..Client[1].." version allowed is ( "..Client[3].." ), you may download the latest "..Client[1].." at http://www.dslreports.com/faq/6513") sUser:Disconnect() return 0 end return 1 else SendPmToNick(sUser.sName,BotName, Client[1].." is not allowed here!!") sUser:Disconnect() return 0 end end return 1 end function TagCheck(Tag,Speed,Share,sUser) if ClientCheck(Tag["C"],Tag["V"],sUser) == 1 and Checks[ProfileCheck(sUser)][8] then if Tag["M"]==nil or Tag["H"]==nil or Tag["S"]==nil or Speed==nil or Share==nil then SendPmToNick(sUser.sName,BotName,"Your MyInfoString is invalid or corupted!!") sUser:Disconnect() elseif tonumber(Tag["S"]) < tonumber(Checks[ProfileCheck(sUser)][1]) and tonumber(Checks[ProfileCheck(sUser)][7])==1 then SendPmToNick(sUser.sName,BotName,"You have to few slots open, minimum is "..Checks[ProfileCheck(sUser)][1].." slot(s) open.") sUser:Disconnect() elseif tonumber(Tag["S"]) > tonumber(Checks[ProfileCheck(sUser)][2]) and tonumber(Checks[ProfileCheck(sUser)][7])==1 then SendPmToNick(sUser.sName,BotName,"You have to many slots open, maximum is "..Checks[ProfileCheck(sUser)][2].." slot(s) spen.") sUser:Disconnect() elseif tonumber(Tag["H"]) > tonumber(Checks[ProfileCheck(sUser)][3]) and tonumber(Checks[ProfileCheck(sUser)][7])==1 then SendPmToNick(sUser.sName,BotName,"You are in to many hubs, maximum is "..Checks[ProfileCheck(sUser)][3].." hub(s).") sUser:Disconnect() elseif tonumber(Checks[ProfileCheck(sUser)][4]) and tonumber(Tag["S"]) < tonumber(Tag["H"])*tonumber(Checks[ProfileCheck(sUser)][4]) and tonumber(Checks[ProfileCheck(sUser)][7])==1 then SendPmToNick(sUser.sName,BotName,"You have to few slots open per hubs, minimum is "..Checks[ProfileCheck(sUser)][4].." slot(s) per hub(s) open.") sUser:Disconnect() elseif Tag["B"]~="Unlimited" and tonumber(Tag["B"]) < tonumber(Checks[ProfileCheck(sUser)][5]) and tonumber(Checks[ProfileCheck(sUser)][7])==1 then if tonumber(Checks[ProfileCheck(sUser)][6])==0 then SendPmToNick(sUser.sName,BotName,"You have limit your bandwidh to "..Tag["B"].." kB/s, minimum is "..Checks[ProfileCheck(sUser)][5].." kB/s.") sUser:Disconnect() else SendPmToNick(sUser.sName,BotName,"Bandwidth limiters is not allowed here.") sUser:Disconnect() end elseif SPEED[Speed]~=1 then SendPmToNick(sUser.sName,BotName,Speed.." connection is not allowed here.") sUser:Disconnect() elseif tonumber(Share) < tonumber(Checks[ProfileCheck(sUser)][9]) * Checks[ProfileCheck(sUser)][10] and Checks[ProfileCheck(sUser)][13]==1 then SendPmToNick(sUser.sName,BotName,"You have not met the requirements for minimum share "..Checks[ProfileCheck(sUser)][9].." "..UNIT[Checks[ProfileCheck(sUser)][10]]) sUser:Disconnect() elseif tonumber(Share) > tonumber(Checks[ProfileCheck(sUser)][11]) * Checks[ProfileCheck(sUser)][12] and Checks[ProfileCheck(sUser)][13]==1 then SendPmToNick(sUser.sName,BotName,"You have not met the requirements for maximum share "..Checks[ProfileCheck(sUser)][11].." "..UNIT[Checks[ProfileCheck(sUser)][12]]) sUser:Disconnect() end end end