PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: blackwings on 15 January, 2005, 20:20:39

Title: Mod this IP-blocker to...
Post by: blackwings on 15 January, 2005, 20:20:39
Can anyone do this =

Change so that it doesn't do the block on users at connect, but instead have a command that will show all users in the hub that has a IP within the IP-Ranges in the .dat file.


--//RangeBlaster v2.05 by Phatty
--//20k Ip Keys Written by (uk-kingdom)John
--//The rest of keys by Phatty
--//Memory based, will be tweaking soon, to make faster ;)

Bot = "IPBlocker"

Ranges = {}

report = "IPBlocker-Report" -- Name for PM report
reportnick = "Mike" -- Nick to report too

function Main()
LoadIps()
end

function LoadIps()
local tmp = 0
local handle = openfile("RangeBlaster/Ranges.dat","r")
line = read(handle)
while line do
tmp = tmp + 1
local s,e,ipr1,ipr2 = strfind(line,"(%S+)|(%S+)")
if ipr2 == nil then
-- SendToAll(Bot,"Error on line "..line)
end
Ranges[ipr1] = ipr2
line = read(handle)
end
-- SendToAll(Bot,"Successfully loaded "..tmp)
end

function Blocked(userip)
local s,e,range1,range2,range3,range4 = strfind(userip,"(%d+).(%d+).(%d+).(%d+)")
for i,p in Ranges do
local s,e,ipa1,ipb1,ipc1,ipd1 = strfind(i, "(%d*).(%d*).(%d*).(%d*)")
local s,e,ipa2,ipb2,ipc2,ipd2 = strfind(p, "(%d*).(%d*).(%d*).(%d*)")
if range1 == ipa1 then
if range1 < ipa1 or range1 > ipa2 then
else
if range2 < ipb1 or range2 > ipb2 then
else
if range3 < ipc1 or range3 > ipc2 then
else
if range4 < ipd1 or range4 > ipd2 then
else
collectgarbage()
flush()
return 1
end
end
end
end
end
end
end

function DataArrival(user,data)
if strsub(data, 1, 13) == "$ValidateNick" then
if Blocked(user.sIP) == 1 then
SendPmToNick (reportnick,report, user.sName.." - "..user.sIP.." has been blocked by "..Bot.."!")
user:Disconnect()
end
end
end