PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: Jokken on 05 September, 2004, 19:08:41

Title: Isp check(swe)
Post by: Jokken on 05 September, 2004, 19:08:41
I wonder if someone could make me a isp check script so that only swedish users can join the hub. very greatfull if someone could. Don?t have to be advanced.
THX
Title:
Post by: nErBoS on 05 September, 2004, 20:58:39
Hi,

There is already one script for that, try to search in the Finished Scripts area.

Best regards, nErBoS
Title:
Post by: IceCoder on 05 September, 2004, 21:04:49
Hi there, you could always use my own script
but you have to find the ip ranges by your self






---------------------------------------------
-- ISP/IP checker
-- Written by IceCoder
--  Make an text file called ipranges.txt
    and put the ips and isp's like this
    213.214.;[BBB]
---------------------------------------------


sBotName = "-Infection-"
sScriptVersion = "1.0"
Owner = "IceCoder"
bIPCheck = 1
bISPCheck = 1

botemail = "admin@swedish-hub.se"
botspeed = "LAN(T3)"
botdescr = "This Script is written by IceCoder v"..sScriptVersion -- DON'T CHANGE IT
botinfostring = "$MyINFO $ALL "..sBotName.." "..botdescr.."$ $"..botspeed.."$"..botemail.."$"

sRejectMessage = "Sorry, This hub is for Swedish users only. If you are using a swedish isp and still can't enter add this ICQ# XXXXXXXX."
sPrefixMessage = "You must use your own prefix like $prefix and it will look like $prefixKarl  //"..Owner
AllowArray = {}

function Main()
   getIpList()
   frmHub:RegBot(sBotName)
        SendToAll(botinfostring)
end

function getIpList()
   readfrom("ipranges.txt")
   while 1 do
      local line = read()
      if line == nil then
         break
      else
         ip,prefix = splittext(line, ";")
         AllowArray[ip]=prefix
      end
   end
   readfrom()
end

function NewUserConnected(User)
SendToAll(botinfostring)
if User.iProfile ~= 2 then
 if (bIPCheck == 1) then
  local sIP, sIPa, sIPb, sIPc, sPrefix
  sIP = User.sIP

  _,_,sIPc = strfind(sIP, "((%d+).(%d+).(%d+))",1)
  _,_,sIPb = strfind(sIP, "((%d+).(%d+))",1)
  _,_,sIPa = strfind(sIP, "(%d+)",1)

    sIPa = sIPa..".*"
    sIPb = sIPb..".*"
    sIPc = sIPc..".*"

  if (AllowArray[sIP] ~= nil) then
   sPrefix = AllowArray[sIP]
  elseif (AllowArray[sIPc] ~= nil) then
   sPrefix = AllowArray[sIPa]
  elseif (AllowArray[sIPb] ~= nil) then
   sPrefix = AllowArray[sIPb]
  elseif (AllowArray[sIPa] ~= nil) then
   sPrefix = AllowArray[sIPc]
  end

   if (sPrefix == nil) then
        User:SendData(sBotName, "Infection Powered by: IceCoder")
   User:SendData(sBotName, sRejectMessage)
   User:SendData("$ForceMove "..frmHub:GetRedirectAddress())
   else
    if (bISPCheck == 1) then
     if (strsub(strlower(User.sName), 1, strlen(sPrefix)) == strlower(sPrefix) or strlower(sPrefix) == "ignore") then
   User:SendData(sBotName, "Welcome to "..frmHub:GetHubName().."..!")
     else
   sPrefixMessage = gsub(sPrefixMessage, "$prefix", sPrefix)
        User:SendData(sBotName, "Infection Powered by: IceCoder")
   User:SendData(sBotName, sPrefixMessage)
   User:Disconnect()
     end
    end
   end


 end
end
end

function OpConnectet(user)
        SendToAll(botinfostring)
end

function splittext(input, splitsyntax)
 if strfind(input, splitsyntax) then
  part1 = strsub(input,1,strfind(input, splitsyntax)-strlen(splitsyntax))
  part2 = strsub(input,strfind(input, splitsyntax)+strlen(splitsyntax), -1)
 end
return part1, part2
end