Existent "IpLog" .. few things need changed . please help
 

Existent "IpLog" .. few things need changed . please help

Started by davnis, 03 June, 2005, 13:26:53

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

davnis

I find this script usefull but need some part to be changed that i think will make it god enough for many people.


1.
The log script record the people when connect and disconect. I think is ok only the connected people.
In this way the txt file will be increased on large hubs.

Example :

"[ June 02 23:49:17 ] - Log In > [RO]chit30, profile Unregistered, from: 81.196.155.160, using: oDC5.31, in: Passive mode, shares: 40.18 Gb., on: 1 slots, is in: 1 hubs as a user, regged in: 0, Ops in 0, total: 1",

"[ June 02 23:49:23 ] - Log Out > [RO][GL][ASTRAL]Soviet, profile Unregistered, from: 83.103.199.31, using: DC++0.4032, in: Passive mode, shares: 20.62 Gb., on: 6 slots, is in: 8 hubs as a user, regged in: 0, Ops in 0, total: 8",


2.
The command +log can be modifyed to not return 200 records but an Nick or an Ip ??

Something like :

+log
+log

And the script to return all the records from that nick or ip

Any help will be apreciated !

thank you,
davnis






--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.txt" --Log file
LogCmd = "+log" --View log Command
Maxlog = 200 --Number of entries to cache
Bot = frmHub:GetHubBotName() -- Bot name pulled from hub
--End User Settings--------------------------------------------
function Main()
local f,e = io.open( LogFile, "r" )
if f then
dofile(LogFile)
else
Log = {}
SaveLog()
end
end

function OnExit()
SaveLog()
end

function ChatArrival(user, data)
if string.sub(data, 1, 1) ~= "<" then end
data = string.sub(data,1,string.len(data)-1)
local s,e,cmd = string.find(data, "^%b<>%s+(%S+)")
local s,e,lines = string.find(data, "^%b<>%s+%S+%s+(%d+)")
if cmd and cmd == LogCmd then
if lines ~= nil then
GetLog(user, lines)
return 1
else
user:SendData("Please specify how may log entries to show, you can display available entries up to "..Maxlog.." lines.")
return 1
end
return 1
end
end

function GetLog(user, linecount)
local n1 = table.getn(Log)
local n2 = linecount
local n3 = n1 - n2
local n4
local str
if tonumber(n2) > n1 then
n3 = 1
n4 = n1 - n3
str = "<"..string.rep("-",45).."-[ There are only ( "..n4.." ) Connection Log Entries ]----------->\r\n"
else
n4 = n2
str = "<"..string.rep("-",50).."-[ Last ( "..n4.." ) Connection Log Entries ]----------->\r\n"
end
for i=n3+1,n1 do str = str.."\r\n"..Log end
user:SendPM(Bot,str.."\r\n")
user:SendPM(Bot,"<"..string.rep("-",60).."-[ End of Connection Log ]--------------->")
end

function NewUserConnected(user,data)
if string.find(string.lower(user.sName), "ping") then return end
local prof = ""
if GetProfileName(user.iProfile) == nil then
prof = "Unregistered"
else
prof = GetProfileName(user.iProfile)
end
local when = os.date("[ %B %d %X ] ")
local userinfo = "- Log In > "..user.sName..", profile "..prof..", from: "..user.sIP..
", using: "..user.sClient..user.sClientVersion..", in: "..GetMode(user.sMode).." mode, shares: "..string.format("%.2f Gb.",user.iShareSize/(1024 * 1024 * 1024))..
", on: "..user.iSlots.." slots, is in: "..GetStatus(user.iNormalHubs).." hubs as a user, regged in: "..GetStatus(user.iRegHubs)..
", Ops in "..GetStatus(user.iOpHubs)..", total: "..GetStatus(user.iHubs)
table.insert(Log, when..userinfo)
if table.getn(Log) > Maxlog then
table.remove(Log, 1)
end
SaveLog()
end

OpConnected = NewUserConnected

function UserDisconnected(user,data)
if string.find(string.lower(user.sName), "ping") then return end
local prof = ""
if GetProfileName(user.iProfile) == nil then
prof = "Unregistered"
else
prof = GetProfileName(user.iProfile)
end
local when = os.date("[ %B %d %X ] ")
local userinfo = "- Log Out > "..user.sName..", profile "..prof..", from: "..user.sIP..
", using: "..user.sClient..user.sClientVersion..", in: "..GetMode(user.sMode).." mode, shares: "..string.format("%.2f Gb.",user.iShareSize/(1024 * 1024 * 1024))..
", on: "..user.iSlots.." slots, is in: "..GetStatus(user.iNormalHubs).." hubs as a user, regged in: "..GetStatus(user.iRegHubs)..
", Ops in "..GetStatus(user.iOpHubs)..", total: "..GetStatus(user.iHubs)
table.insert(Log, when..userinfo)
if table.getn(Log) > Maxlog then
table.remove(Log, 1)
end
SaveLog()
end

OpDisconnected = UserDisconnected

function SaveLog()
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)..",\r\n" )
end
f:write( "}" )
f:close()
return 1
else
return nil, user:SendData("Save Log failed: "..e)
end
end

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

function GetStatus(status)
if not status or status == nil or status == "" then
status = 0
end
return status
end





Ajax

Please specify how may log entries to show, you can display available entries up to 200 lines.
 ?(  ?(  ?(  ?(
:evil:

davnis

#2
I don't whant to get a numbers of lines of log !!
i whant the script to be modifyed to return one nick log, or one ip log

+log

or

+log


and the script to return me only information about that IP or Nick. I tihnk is useful in this way in sted of using 200 lines of log..

thanks

sander815


jiten

QuoteOriginally posted by sander815
would like that also....

or a modified one that keeps track of users info

see http://board.univ-angers.fr/thread.php?threadid=2359&boardid=12&styleid=1&sid=2f3be16aeeb3237d39da8bde443c80ec
Search the forum for "Connection Logger". Maybe you'll find it useful.

Best regards,

jiten

SMF spam blocked by CleanTalk