Author Topic: please help me in this routine  (Read 1500 times)

0 Members and 1 Guest are viewing this topic.

Offline Chibok

  • Junior Member
  • **
  • Posts: 11
  • Karma: +0/-0
please help me in this routine
« on: 31 August, 2005, 00:05:31 »
in Portugal the politica of the ISP'S is to limit passes through it of InterNet, more serious still is to divide in passes through national and international, recently a problem was identified that inside of proprio ISP some of you creak them are counted as I pass through international. In the remaining portion I did not find problems of greater only in the routine of comparison of which I do not obtain to leave. The logical one is the following one: When the command will be received to bind to compare if the IP of who intends to unload this in a database and it will be to verify if the IP of where to unload this in one another database and will be to block unloading.

Quote
----------------------------------------------------------
-- IP-Filtro e Blokeio de Dll de Sapo a Cabovisao    --
-- Versao: 1.0                  --
-- By: Chibok                  --            
-- 2005-08                  --
-- Agradecimentos:               --
-- Zero-Cool, pela ajuda dada na resulu??o de diversos   --
-- problemas e erros               --   
-- Xico, pela ajuda dada            --
----------------------------------------------------------
-- Example to add a range:
-- !addrange 192.168.0.1-192.168.0.255 RangeName RangeTag
----------------------------------------------------------

-------------------------------------------------------------------------------------------
BotName = "-IP-Shield-"
Prefix = "!"
-------------------------------------------------------------------------------------------
AllowRange = {}
NacionaisRange = {}
InternacionaisRange = {}

AllowFile = "Ranges/Ranges.dat"       -- ranges file ke podem entrar    = NACIONAIS
NacionalFile = "Ranges/Nacional.dat"      -- ranges file ke consideram outras internacionais = SAPO
InternacionalFile = "Ranges/Internacional.dat"   -- ranges file consideradas internacionais = CABOVISAO
-------------------------------------------------------------------------------------------
function Main()
   frmHub:RegBot(BotName)
   frmHub:EnableFullData(1)

   LoadFromFile(AllowFile)
   LoadFromFile(NacionalFile)
   LoadFromFile(InternacionalFile)
end
-------------------------------------------------------------------------------------------
function ComputeIP(curIP)
   local _,_,a,b,c,d = strfind(curIP, "(%d+).(%d+).(%d+).(%d+)")
   return a*16777216 + b*65536 + c*256 + d
end
-------------------------------------------------------------------------------------------
function GetRange(ip,table)
   local _,_,a,b,c,d = strfind(ip, "(%d*).(%d*).(%d*).(%d*)")
   if ( tonumber(a) and tonumber(b) and tonumber(c) and tonumber(d) ) then
      local uip = ComputeIP(ip)
      if uip then
         local c = ""
         for r,i in table do
            local _,_,range1,range2 = strfind(r, "(.*)-(.*)")
            range1 = ComputeIP(range1)
            range2 = ComputeIP(range2)
            if uip>=range1 and uip<=range2 then
               c = "1"
               return 1,r
            end
         end
      end
   end
end
-------------------------------------------------------------------------------------------
function NewUserConnected(curUser,data)

   -- mensagem de entrada

   curUser:SendData(BotName,"Running and testing  IP-Shield 1.0 By: Chibok")
   local Int = "N?o"
   local Nac = "N?o"
   local RangeInt = "1"
   --local Int,RangeInt = GetRange(curUser.sIP,InternacionaisRange)
   local Nac,RangeNac = GetRange(curUser.sIP,NacionaisRange)
   local Allow,Range = GetRange(curUser.sIP,AllowRange)
   local Network = ""
   if Allow==1 then
      curUser:SendData(BotName,"*** Verify Your IP here...")
      curUser:SendData(BotName,"Your IP is Allowed here...")
      curUser:SendData(BotName,"IP "..curUser.sIP.." permitido")
      curUser:SendData(BotName,"Gama de IP "..Range.." permitida")
      curUser:SendData(BotName,"Gama de IP "..RangeNac.." SAPO permitida+")
      curUser:SendData(BotName,"Gama de IP "..RangeInt.."  Cabovisao Permitida")
      return 1
   else
      curUser:SendData(BotName,"Your IP is not Allowed here...")
      --curUser:Disconnect()
      return 1
   end
end

----------------------------------------------------------------------------------
--//    OpConnected
----------------------------------------------------------------------------------

OpConnected = NewUserConnected

-------------------------------------------------------------------------------------------
function DataArrival(curUser, data)
------------------------------------------------------------ iniciar tratamento de comandos   
   if strsub(data, 1, 4) == "$To:" then
      local s,e,to,from,text = strfind(data, "%$To:%s(%S+)%sFrom:%s(%S+)%s$(.*)$")
      if to == BotName then
         data = text
         data = strsub(data,1,strlen(data)-1)
         if (GetCom(curUser,data) == 1) then
            return 0
         else
            return 0
         end
      end
   
----------

BlockTriggs = {
   ["$Rev"] = 1,
   ["$Con"] = 2,
}

   function DataArrival(curUser,data)
   if strsub(data,1,1) == "$" then
      local str1 = strsub(data,1,4)
      if BlockTriggs[str1] then
         if NacionaisRange[NacionaisRange(curUser.sIP)] then
            curUser:SendData("*** You are not authorized to download.")
            return 1
         elseif BlockTriggs[str1] == 1 then
            local _,_,NacionaisRange = strfind(data,"(%S+)|$")
            if NacionaisRange[strlower(curUser.sIP)] then
               curUser:SendData("*** The user you are trying to download is not authorized to upload.")
               return 1
            end
         elseif BlockTriggs[str1] == 2 then

            curUser:SendData("*** ????The user you are trying to download is not authorized to upload.")
            --local _,_,curUser.sIP = strfind(strsub(data,14,strlen(data)),"^(%S+)")
            if NacionaisRange[strlower(InternacionaisRange)] then
               curUser:SendData("*** The user you are trying to download is not authorized to upload.")
               return 1
            end
         end
      end                        
   end
end
end
end


PtokaX forum

please help me in this routine
« on: 31 August, 2005, 00:05:31 »