ip range-description
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

ip range-description

Started by gia, 09 April, 2007, 14:15:21

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

gia

hello.
this script changes description of the user on "Net_1, Net_2, Net_3" depending on range IP

-- BotName -- 
HubBot = frmHub:GetHubBotName()
--time after user connect to overwrite the description
TimeOverWrite = 1 -- time in second
-- range ip overwrite ="begin ip range-end ip range-description" 
-- not teste whit space in description
RangeDesc = {[1]="10.0.0.0-10.255.255.255-Net_1", [2]="89.105.0.0-89.105.255.254-Net_2", [3]="172.20.0.0-172.20.255.255-Net_3"}

-- Info Path --
InfoLog = "UserInfo/" -- Create this folder before starting the script

function Main()
   SetTimer(TimeOverWrite*1000)
end
   
-- New User Connect Info Arrival
function MyINFOArrival(curUser,data)
if GetTimer() == nil then StartTimer() end
end

function OnTimer()
   OverWrite(HubBot)
   StopTimer()
end

function rebuilmyinfo(curUser)
   local descript,userip = nil,calcip(curUser.sIP)
   if userip ~= 0 then
         for index,descIP in pairs(RangeDesc) do
            local _,_,startRange,endRange,RangeDescript = string.find(descIP, "(.*)-(.*)-(.*)")
            startRange = calcip(startRange)
            endRange = calcip(endRange)
            if userip>=startRange and userip<=endRange then
               descript = RangeDescript
            end
         end
      if descript == nil then descript = "Extern" end
      local _,_,nick,orgdescr,rest = string.find(curUser.sMyInfoString, "$MyINFO $ALL (%S+)%s+([^$]*)<(.*)")
      SendToAll("$MyINFO $ALL "..nick.." "..descript.."<"..rest)
      end
end

function calcip(ipcalc)
   local _,_,a,b,c,d = string.find(ipcalc, "(%d+).(%d+).(%d+).(%d+)")
   local calc = 0
   if (tonumber(a) and tonumber(b) and tonumber(c) and tonumber(d)) then
      calc = a*16777216 + b*65536 + c*256 + d   
      return calc
      else return 0
   end
end

function OverWrite(curUser)
   local tableover = frmHub:GetOnlineUsers()
   for i, Userover in pairs(tableover) do
      rebuilmyinfo(Userover)
   end
end


possible do so "Net_1...etc." was added to description, rather then changed it?
thank.

bastya_elvtars

Moved to Finished, thanks for the submission.
Everything could have been anything else and it would have just as much meaning.

Naithif

#2
Quote from: gia on 09 April, 2007, 14:15:21
possible do so "Net_1...etc." was added to description, rather then changed it?
thank.

Maybe trying

      SendToAll("$MyINFO $ALL "..nick.." "..orgdescr.." "..descript.."<"..rest)


instead of

      SendToAll("$MyINFO $ALL "..nick.." "..descript.."<"..rest)


As line 39

gia

Quote from: Naithif on 10 April, 2007, 09:19:19
Maybe trying

      SendToAll("$MyINFO $ALL "..nick.." "..orgdescr.." "..descript.."<"..rest)


instead of

      SendToAll("$MyINFO $ALL "..nick.." "..descript.."<"..rest)


As line 39

thank you, Naithif !
This works.

sphinx_spb

This scripts results error:
[05:12] Syntax C:\ptokax\scripts\iprange.lua:39: attempt to concatenate global 'rest' (a nil value)

What can I do about it? ???

sphinx_spb

Thanks, Mutor! Now it works great.
But, with this script Ptokax starts lag very hard... ???
Even chat is lagged, so I forced to switch the script off  :'(

wlfdark

#6
crash attempt to call global 'GetTimer' (a nil value), , can you help?


???????? ?????????? PtokaX LUA API ????????? v0.9. ??????? ?????? 08/29/09 21:09:22
	-- BotName -- 
HubBot = SetMan.GetString(21)
--time after user connect to overwrite the description
TimeOverWrite = 10 -- time in second
-- range  ip  overwrite ="begin ip range-end ip range-description" 
-- not teste whit space in description
RangeDesc = {
[1]="10.202.0.0-10.202.255.255-[???????]", -- ???????? ????? ???? ???????? ? ???????? ???? (??? ???????), ????? ?????????? ??? ?? ??? ????????? ??????? , ?????????? ? ?????????
[2]="172.20.0.0-172.20.255.255-[???????]", -- ? ??? ????? , ?????? ??????? ????? ????????? ?? ???????????? )) , ? ???? ?????? ????? 130 ?????????? 
[3]="192.168.0.0-192.168.255.255-[???????]",
[4]="10.239.0.0-10.239.255.255-[??????????]",
}

-- Info Path -- 
InfoLog = "UserInfo/" -- Create this folder before starting the script

function OnStartup()

end

-- New User Connect Info Arrival
function MyINFOArrival(curUser,data)
	Core.GetUserAllData(curUser)
if GetTimer() == nil then StartTimer() end
end

function OnTimer(tmr)
OverWrite(HubBot)
TmrMan.RemoveTimer(tmr)
end

function rebuilmyinfo(curUser)
local descript,userip = nil,calcip(curUser.sIP)
if userip ~= 0 then
for index,descIP in pairs(RangeDesc) do
local _,_,startRange,endRange,RangeDescript = string.find(descIP, "(.*)-(.*)-(.*)")
startRange = calcip(startRange)
endRange = calcip(endRange)
if userip>=startRange and userip<=endRange then
descript = RangeDescript
end
end
if descript == nil then descript = "[??]" end -- ? ??????? ???????? ??? ??????????? ???? (????? ???? , ?????? ??? ???????)
local s,e,nick,desc,speed,email,share = string.find(curUser.sMyInfoString, "$MyINFO $ALL (%S+)%s+([^$]*)$ $([^$]*)$([^$]*)$([^$]+)")
local addtag = tProfileTag[curUser.iProfile].." "..descript
Core.SendToAll("$MyINFO $ALL "..nick.." "..addtag.." "..desc.."$ $"..speed.."$"..email.."$"..share.."$")
end
end


function calcip(ipcalc)
local _,_,a,b,c,d = string.find(ipcalc, "(%d+).(%d+).(%d+).(%d+)")
local calc = 0
if (tonumber(a) and tonumber(b) and tonumber(c) and tonumber(d)) then
calc = a*16777216 + b*65536 + c*256 + d 
return calc
else return 0
end
end

function OverWrite(curUser)
local tableover = Core.GetOnlineUsers(true)
for i, Userover in pairs(tableover) do
rebuilmyinfo(Userover)
end
end



Edit: Please use Code Tags when posting Code ;)

SMF spam blocked by CleanTalk