Connection Logger
 

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

Connection Logger

Started by jiten, 05 June, 2005, 21:48:47

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jiten

-- Heavily optimized by jiten (6/4/2005)
-- Added: Nick/IP Search
-- Removed: Logout logging

-- Connection Log 1.0 LUA 5 by Mutor The Ugly
--
-- Log connections to hub in an external file
-- Hublist pingers are excluded by nick, add IP's if needed

--User Settings------------------------------------------------
LogFile = "Log.tbl"		-- Log file
LogCmd = "+log"			-- View log Command
Maxlog = 200			-- Number of entries to cache
MaxShow = 30			-- Number of entries to show
sBot = frmHub:GetHubBotName()	-- Bot name pulled from hub
--End User Settings--------------------------------------------

Main = function()
	if loadfile(LogFile) then dofile(LogFile) else Log = {} OnExit() end
end

OnExit = function()
	local f,e = io.open( LogFile, "w+" )
	if f then
		f:write("Log = {\n") 
		for i = 1, table.getn(Log) do f:write( "  "..string.format("%q", Log[i])..",\n" )  end
		f:write("}") f:close()
	end
end

ChatArrival = function(user, data)
	local data = string.sub(data,1,-2)
	local s,e,cmd = string.find(data, "^%b<>%s+(%S+)")
	if cmd and string.lower(cmd) == LogCmd and user.bOperator then
		local s,e,IP = string.find(data,"%b<>%s+%S+%s+(%S+)")
		if IP then
			local _,_,a,b,c,d = string.find(IP,"(%d*).(%d*).(%d*).(%d*)")
			local Message = function(user,data)
				local msg, Exists = "", nil
				for i, value in Log do if string.find(value,IP) then msg = msg..value.."\r\n" Exists = 1 end end
				if Exists == 1 then
					local Structure = "\r\n<"..string.rep("-",45).."-[ Search Results of: ( "..IP.." ) ] ----------->\r\n\r\n"
					Structure = Structure..msg
					Structure = Structure.."\r\n<"..string.rep("-",60).."-[ End of Connection Log ]--------------->"
					user:SendPM(sBot,Structure)
				else
					user:SendData(sBot,"*** Error: There's no User/IP: "..IP.." in the Connection Logs.")
				end
			end
			if not (a == "" or b == "" or c == "" or d == "") or not tonumber(a) and b == "" and c == "" and d == "" then
				Message(user,data)
			else
				user:SendData(sBot, "*** Syntax Error: Type "..LogCmd.." ")
			end
		else
			local Structure = "\r\n<"..string.rep("-",45).."-[ Last ( "..table.getn(Log).." ) Connection Log Entries ] ----------->\r\n\r\n"
			for i = 1, table.getn(Log) do Structure = Structure..Log[i].."\r\n" end
			Structure = Structure.."\r\n<"..string.rep("-",60).."-[ End of Connection Log ]--------------->"
			user:SendPM(sBot,Structure)
		end
		return 1
	end
end

NewUserConnected = function(user,data)
	local GetMode = function(mode) if mode == "A" then mode = "Active" elseif mode == "P" then mode = "Passive" else mode = Socks5 end return mode end
	if string.find(string.lower(user.sName), "ping") then return end
	local userinfo = "- Log In > "..user.sName..", Profile: "..(GetProfileName(user.iProfile) or "Not Registered")..", IP: "..user.sIP..
	", Client/Version: "..user.sClient.."/"..user.sClientVersion..", Mode: "..GetMode(user.sMode).." , Share: "..string.format("%.2f GB.",user.iShareSize/(1024 * 1024 * 1024))..
	", Slots: "..user.iSlots..", User: "..(user.iNormalHubs or 0)..", Registered: "..(user.iRegHubs or 0)..
	", Operator: "..(user.iOpHubs or 0)..", Total Hubs: "..(user.iHubs or 0)
	table.insert(Log, os.date("[ %B %d %X ] ")..userinfo)
	if table.getn(Log) > Maxlog then table.remove(Log, 1) end OnExit()
end

OpConnected = NewUserConnected

sander815

if i would like some info stripped, is this correct

NewUserConnected = function(user,data)

	local GetMode = function(mode) if mode == "A" then mode = "Active" elseif mode == "P" then mode = "Passive" else mode = Socks5 end return mode end

	if string.find(string.lower(user.sName), "ping") then return end

	local userinfo = "- Log In > "..user.sName..", IP: "..user.sIP..

	", Client/Version: "..user.sClient.."/"..user.sClientVersion.." , Share: "..string.format("%.2f GB.",user.iShareSize/(1024 * 1024 * 1024))..

	", Slots: "..user.iSlots..", User: "..(user.iNormalHubs or 0)..", Registered: "..(user.iRegHubs or 0)..

	", Operator: "..(user.iOpHubs or 0)..", Total Hubs: "..(user.iHubs or 0)

	table.insert(Log, os.date("[ %B %d %X ] ")..userinfo)

	if table.getn(Log) > Maxlog then table.remove(Log, 1) end OnExit()

end

i stripped out profile and user mode

jiten

QuoteOriginally posted by sander815
if i would like some info stripped, is this correct

NewUserConnected = function(user,data)

	local GetMode = function(mode) if mode == "A" then mode = "Active" elseif mode == "P" then mode = "Passive" else mode = Socks5 end return mode end

	if string.find(string.lower(user.sName), "ping") then return end

	local userinfo = "- Log In > "..user.sName..", IP: "..user.sIP..

	", Client/Version: "..user.sClient.."/"..user.sClientVersion.." , Share: "..string.format("%.2f GB.",user.iShareSize/(1024 * 1024 * 1024))..

	", Slots: "..user.iSlots..", User: "..(user.iNormalHubs or 0)..", Registered: "..(user.iRegHubs or 0)..

	", Operator: "..(user.iOpHubs or 0)..", Total Hubs: "..(user.iHubs or 0)

	table.insert(Log, os.date("[ %B %d %X ] ")..userinfo)

	if table.getn(Log) > Maxlog then table.remove(Log, 1) end OnExit()

end

i stripped out profile and user mode
Yes, it's correct. You may also want to remove this line as it isn't needed anymore:
local GetMode = function(mode) if mode == "A" then mode = "Active" elseif mode == "P" then mode = "Passive" else mode = Socks5 end return mode end
Cheers

Skippy84

I have translated the Script into german you can found it here


http://skippy.dyndns.ws/Forum/viewtopic.php?p=56#56

sander815

i had a nice logfile from around 1 meg, unfortunately the next day it was gone, and the script overwrote the logfile with a new one.
If the max entries is reached, will the script erase everything, and then start over?

Dessamator

QuoteOriginally posted by sander815
i had a nice logfile from around 1 meg, unfortunately the next day it was gone, and the script overwrote the logfile with a new one.
If the max entries is reached, will the script erase everything, and then start over?

yep, thats what max log is for !
Ignorance is Bliss.

sander815

hmm, can it be edited so that when max log file is reached it only deletes entries at the beginning of the file, and not completely delete the file?

SMF spam blocked by CleanTalk