CooL Idea!
 

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

CooL Idea!

Started by D-J Valhala, 12 October, 2004, 14:41:12

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

D-J Valhala

i have an idea...
script that shows how many users connected  to the hub
every IP = 1 in the entery list
+entery
last 24 hoers: 2500 enterys
sins script start enterys: 5000
 :D
can it be made???
My PsyIsrael Network
==================
--=[PsyIsrael DC Hub]=--
--=[PsyIsrael Website]=--
==================

nErBoS

#1
Hi,

Here you go...

--## IP ENTRY BOT
--## Requested by D-J Valhala
--## Made by nErBoS
--## Commands: 
--##	+entry	- Shows all the entry status of IP

sBot = "IE-Bot"

arrIPEntry = {
	["TOTAL"] = 0,
}
fIPEntry = "ipentry.dat"

--## Configuration ##--

uLaterPtokax = 0	-- Choose 0 if you are using a Ptokax version 0.3.3.0 or higher
			-- Choose 1 if you are using a Ptokax version lower then 0.3.3.0

--## END ##--

function Main()
	frmHub:RegBot(sBot)
	LoadFromFile(fIPEntry)
end

function OnExit()
	SaveToFile(fIPEntry , arrIPEntry , "arrIPEntry")
end

function NewUserConnected(user)
	if (arrIPEntry[GetTime()] == nil) then
		CleanAndRefresh()
		arrIPEntry[GetTime()] = {}
		if (uLaterPtokax == 1) then
			OnExit()
		end
	end
	if (arrIPEntry[GetTime()][user.sIP] == nil) then
		arrIPEntry[GetTime()][user.sIP] = 1
		arrIPEntry["TOTAL"] = arrIPEntry["TOTAL"] + 1
		if (uLaterPtokax == 1) then
			OnExit()
		end
	end
end

OpConnected = NewUserConnected

function DataArrival(user, data)
	if (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot) then
		data = strsub(data,1,strlen(data)-1)
		s,e,cmd = strfind(data, "%b<>%s+(%S+)")
		if (cmd == "+entry") then
			local sTmp = "\r\n\r\n\t\t--## IP Entries of the HUB ##--\r\n\r\n"
			if (arrIPEntry[GetTime()] == nil) then
				CleanAndRefresh()
				arrIPEntry[GetTime()] = {}
			end
			sTmp = sTmp.."\t--## Today IP entries: "..GetCount(arrIPEntry[GetTime()]).."\r\n"
			sTmp = sTmp.."\t--## IP entries from all time: "..arrIPEntry["TOTAL"].."\r\n"
			user:SendPM(sBot, sTmp)
			return 1
		end
	end
end

function GetTime()
	local day,month,year = date("%d"),date("%m"),date("%y")
	return day.."/"..month.."/20"..year
end

function CleanAndRefresh()
	local aux,date
	for date, aux in arrIPEntry do
		if (date ~= "TOTAL") then
			arrIPEntry[date] = nil
		end
	end
end

function GetCount(table)
	local count,aux,index = 0 
	for index, aux in table do
		count = count + 1
	end
	return count
end

function Serialize(tTable, sTableName, sTab)
	assert(tTable, "tTable equals nil");
	assert(sTableName, "sTableName equals nil");

	assert(type(tTable) == "table", "tTable must be a table!");
	assert(type(sTableName) == "string", "sTableName must be a string!");

	sTab = sTab or "";
	sTmp = ""

	sTmp = sTmp..sTab..sTableName.." = {\n"

	for key, value in tTable do
		local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);

		if(type(value) == "table") then
			sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
		else
			local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
			sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
		end

		sTmp = sTmp..",\n"
	end

	sTmp = sTmp..sTab.."}"
	return sTmp
end

function SaveToFile(file , table , tablename)
	writeto(file)
	write(Serialize(table, tablename))
	writeto()
end

function LoadFromFile(file)
	if (readfrom(file) ~= nil) then
		readfrom(file)
		dostring(read("*all"))
		readfrom()
	end
end

I still have one script to do to you, will do it as soon as i can :D

Best regards, nErBoS
--## nErBoS Spot ##--

D-J Valhala

work good but whan i restart the scripts it wont save...
and about the other script... take your time m8 :D
My PsyIsrael Network
==================
--=[PsyIsrael DC Hub]=--
--=[PsyIsrael Website]=--
==================

nErBoS

Hi,

Yes i have forgot to put the configuration part to TD and older version of ptokax. Fixed in the script above.

Best regards, nErBoS
--## nErBoS Spot ##--

D-J Valhala

steel no save...

[11:51] +entry
[11:52] <-PsYiBot->
   ===============================
   U s e r s   E n t r i e s   o f   t h e   H u b:
   ===============================
    Total entries In Lest 24 Hours: 598
    Total entries: 991

[11:59] <-PsYiBot->
   ===============================
   U s e r s   E n t r i e s   o f   t h e   H u b:
   ===============================
    Total entries In Lest 24 Hours: 2
    Total entries: 2

[12:00] <-PsYiBot->
   ===============================
   U s e r s   E n t r i e s   o f   t h e   H u b:
   ===============================
    Total entries In Lest 24 Hours: 0
    Total entries: 0
My PsyIsrael Network
==================
--=[PsyIsrael DC Hub]=--
--=[PsyIsrael Website]=--
==================

SMF spam blocked by CleanTalk