Help Converting Please
 

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

Help Converting Please

Started by Jelf, 22 March, 2005, 13:06:21

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Jelf

Hi all, been trying to convert a script and am stuck with this part,
It returns the error
Quoteattempt to call method `CheckIP' (a nil value)
Script cut just for help purpose..
["geoipinfo"] = function(curUser,data)
		local _,_,sip = string.find(data,"^%b<>%s+%+%S+%s+(%d+%.%d+%.%d+%.%d+)")
		if sip then
			-- Check GeoIP
			local ip1,ip2,ipcountry,ipcountrycode = "N/A","N/A","N/A","N/A"
			local ret = GeoIPRange:CheckIP(sip)
			if ret then
				ip1 = DeComputeIP(ret[1])
				ip2 = DeComputeIP(ret[2])
				ipcountry = ret[3]["C"]
				ipcountrycode = ret[3]["CC"]
			end
			SendToUser(curUser,"IP: "..sip..", From: "..ipcountry.." ("..ipcountrycode.."), Range: "..ip1.."-"..ip2,SecuLite.Bot)
		else
			SendToUser(curUser,"Syntax: "..SecuLite.Prefix.."geoipinfo ",SecuLite.Bot)
		end
	end,		
}
function CheckIP(self,ip)
	local cip = ComputeIP(ip)
	local iStart,iEnd,iMid = 1,self:Getn(),0
	while (iStart <= iEnd) do
		iMid = math.floor((iStart+iEnd)/2)
		local table = self:GetIndex(iMid)
		if (table[1] <= cip) and (table[2] >= cip) then
			return table
		elseif (table[1] > cip) then
			iEnd = iMid - 1
		elseif (table[1] < cip) then
			iStart = iMid + 1
		end
	end
end

I know that GeoIPRange is loaded so it must be something to do with how its trying to read the table
Any help appreciated, thanks

SMF spam blocked by CleanTalk