PtokaX forum

Archive => Archived 5.0 boards => Request for scripts => Topic started by: badtrip on 18 June, 2005, 04:34:16

Title: IP?S rages BLOCK ??????
Post by: badtrip on 18 June, 2005, 04:34:16
hello ppl,


I?m nead a script like that :

if you are in  this IP rage 123.0.0.1-123.255.255.0

you can not dowload from the ip rages :

190.0.0.1-190.255.255.0
etc....

but if you use the comand !freeIP you can download
anyway ...

help-me plz, i?m nead this script , in my country some ISP?s  are internacional to Others ISP?s in the country and i wont to block some rages of ip?s to some ISP?s users...
Title:
Post by: jiten on 18 June, 2005, 11:35:40
Found this one that may help you:
-- modded by jiten

sBot = "-=Brainu=-"

sOpChatName = "-=OpChat=-"


--## Configuration ##--

-- Put in this table the Prefixes you want the users to have
 
sPrefix = { "[CV]" , "(CV)" ,}

-- Put in this table the IP-Range or IP you want to be checked for

arrIP = {
   ["10.6.0.0"] = "10.6.0.30",
   ["84.90.0.0"] = "84.91.255.255",      --  Cabovisao,SA
   ["213.228.128.0"] = "213.228.191.255",   --  Cabovisao,SA
   ["217.129.0.0"] = "217.129.255.255",      --  Cabovisao,SA
}
--## END ##--

function Main()
frmHub:RegBot(sBot)
end

function NewUserConnected(user)
if (CheckUserPrefix(user) == nil) and not (isGoodIP(user.sIP) == nil) then
user:SendPM(sBot, "Inclui o prefixo [CV] ou (CV) no teu nick, isto porque o Sapo Adsl conta como internacional o trafego de ti")
user:SendPM(sBot, "Se precisares de ajuda, ou tiveres d?vidas contacta um Operador")
SendPmToOps(sOpChatName, "O utilizador "..user.sName.." foi requisitado para usar o prefixo [CV]")
end
end

OpConnected = NewUserConnected

function ConnectToMeArrival(user,data)
if (CheckUserPrefix(user) == nil) and not (isGoodIP(user.sIP) == nil) then
user:SendData(sBot, "N?o podes fazer downloads/uploads at? mudares o teu prefixo para [CV] ou (CV)")
return 1
end
end

RevConnectToMeArrival = ConnectToMeArrival

function CheckUserPrefix(user)
for key,pre in sPrefix do
if string.find(string.lower(user.sName), string.lower(pre),1,1) then
return 1
end
end
end

function isGoodIP(sIP)
sIP = ipToNumber(sIP)
local iFirst,iLast
for iFirst, iLast in arrIP do
if (sIP >= ipToNumber(iFirst) and sIP <= ipToNumber(iLast)) then
return 1
end
end
return nil
end

function ipToNumber(sIP)
iAux = ""
string.gsub(sIP,"(%d+)", function(w)
w = tonumber(w)
if (w < 10) then
iAux = iAux.."00"..w
elseif (w < 100) then
iAux = iAux.."0"..w
else
iAux = iAux..w
end
end)
return tonumber(iAux)
end

Cheers
Title:
Post by: badtrip on 18 June, 2005, 20:37:07
hello


tk?s  my friend   ;)