Stat-Logger v1.0
 

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

Stat-Logger v1.0

Started by Dessamator, 12 June, 2005, 17:54:27

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Dessamator

----> Stat-Logger v1.1 By Dessamator
-- added client and client version (request by [NL]Koromo) 
-- changed everything to tables & optimized the code -- request by penguin
-- Added !clearlogs 
----> Stat-Logger 0.4a By Dessamator
-- Added Search Log(!searchlog)
-- Added SendTo (request by Penguin )
----> Stat-logger 0.3b
-- fixed error in saving logs(report by TTB)
----> Stat-logger 0.3a 
-- Added !lastips(request by Penguin)
-- Lua 5 by Dessamator
----> Stat-logger 0.3 by Troubadour 
-- created a seperated config file + gui
----> Stat-logger 0.2 by Troubadour 
-- to write all info to a file with the date of that day when users log in (name, e-mail, ip and share)
-- command for viewing the files is !
-- for example !280704 is the command to view the file of 28 juli 2004
----> Stat-logger 0.1 by Troubadour 
-- to write all info to a file when a user logs in (name, e-mail, ip and share)
-- command to view the file is !statlog


a={}
LoginInfo ={}
fLoginInfo = "logininfo.dat"
--
MaxLogins = 15
SendTo = 1 -- (1 =>MainChat 2=>PM, 3=>Main and pvt (request by Penguin)

function Main() 
	if io.open("Stat-logger03.cfg","r") then   -- is used for the settings
		dofile("Stat-logger03.cfg")
	else
		BOTName = "Stat-logger"
		Version = "Stat-logger V.1"
	end
		frmHub:RegBot(BOTName)
	SendToAll("( >>>>  "..Version.." Started"..os.date(" the %d/%m-%Y at %X ").."  <<<< )")
	if io.open(fLoginInfo,"r") then
		dofile(fLoginInfo)
	end	
end 

function OnExit()
	SaveToFile(fLoginInfo,LoginInfo,"LoginInfo")
end

function ChatArrival(user,data) 
data=string.sub(data,1,-2) 
s,e,cmd = string.find(data,"%b<>%s+(%S+)") 
local n,temp,usrinfo=0,"The last "..MaxLogins.." logged users\r\n","This is the log you Requested:\r\n"

local function loadinfo(cmd,insert)
	if not cmd then 
		usrinfo=""
		cmd=os.date("%d%m%y")
	end

	for i,v in LoginInfo[cmd] do
		usrinfo= usrinfo.."Date : "..LoginInfo[cmd][i].Date.." , Nick : "..i..
		" , Profile : "..LoginInfo[cmd][i]["Profile"]..
		" , Time :"..LoginInfo[cmd][i].Time..
		" , E-mail :  "..LoginInfo[cmd][i]["email"]..
		" , Description : "..LoginInfo[cmd][i]["description"]..
		" , IP :"..LoginInfo[cmd][i]["IP"].. 
		" , Share: "..LoginInfo[cmd][i]["share"].."Gb"..
		" , Client : "..LoginInfo[cmd][i]["Client"]..
		" "..LoginInfo[cmd][i]["Clientver"]..
		" , Login(s) : "..LoginInfo[cmd][i]["Times"].." \r\n"

		
	end
	if insert then
		table.insert(a, usrinfo)
	end
	return usrinfo
end
	if cmd=="!lastips" then
		loadinfo(blah,"insert")
		for i=table.getn(a),1, -1 do
			if n%s+%S+%s+%S+%s+(.+)")
		s,e,item = string.find(data,"%b<>%s+%S+%s+(%S+)") 
		findlog(user,item, date)
		return 1
	elseif cmd=="!clearlogs" then 
		LoginInfo = {}
		user:SendData(BOTName, "All Logs Have Been removed")
		return 1
	end
	cmd = string.sub(cmd, 2,string.len(cmd)) 
	if LoginInfo[cmd] then 
		SendWhere(user,loadinfo(cmd))
		return 1 
	end 
end

function ToArrival(user,data)
s,e,to = string.find(data,"$To:%s+(%S+)%s+From:%s+%S+%s+$%b<>%s+%S+") 
	if to==BOTName then
		ChatArrival(user,data)
	end 
	
end 

function SendWhere(user,msg)
	if	SendTo == 1 then user:SendData(BOTName,msg)
	elseif	SendTo == 2 then user:SendPM(BOTName,msg)
	elseif	SendTo == 3 then SendToAll(BOTName,msg) user:SendPM(BOTName,msg)
	end
end

function OpConnected(user)
	local share = string.format("%0.2f",(user.iShareSize / (1024*1024*1024)))
	if not  LoginInfo[os.date("%d%m%y")] then
		LoginInfo[os.date("%d%m%y")] = {}
	end
	if not  LoginInfo[os.date("%d%m%y")][user.sName] then
		LoginInfo[os.date("%d%m%y")][user.sName]= {}
		LoginInfo[os.date("%d%m%y")][user.sName]["description"]=user.sDescription
		LoginInfo[os.date("%d%m%y")][user.sName]["email"]=user.sEmail
		LoginInfo[os.date("%d%m%y")][user.sName]["share"]=share
		LoginInfo[os.date("%d%m%y")][user.sName]["Date"]=os.date("%x")
		LoginInfo[os.date("%d%m%y")][user.sName]["Time"]=os.date("%X")
		LoginInfo[os.date("%d%m%y")][user.sName]["IP"]=user.sIP
		LoginInfo[os.date("%d%m%y")][user.sName]["Client"]=user.sClient
		LoginInfo[os.date("%d%m%y")][user.sName]["Clientver"]=user.sClientVersion
		LoginInfo[os.date("%d%m%y")][user.sName]["Profile"]=GetProfileName(user.iProfile) or "User"
		LoginInfo[os.date("%d%m%y")][user.sName]["Times"]=0
	end
	if LoginInfo[os.date("%d%m%y")][user.sName]["Times"] then
		LoginInfo[os.date("%d%m%y")][user.sName]["Times"]=LoginInfo[os.date("%d%m%y")][user.sName]["Times"] + 1
	end
end

NewUserConnected = OpConnected

function findlog(user,item,date)
local found,date ="\r\n\t\t\The Results of your search:\r\n\t\t"..string.rep("??",12).."\r\n",date or os.date("%d%m%y")
	if item and LoginInfo[date] then
		for i,v in LoginInfo[date] do
			if LoginInfo[date][i]["IP"] == item or LoginInfo[date][item] then
				found= found.."On the "..LoginInfo[date][i].Date.." - "..i.." - made 1st login @ :"..LoginInfo[date][i].Time..
				" with e-mail :"..LoginInfo[date][i]["email"]..", IP :"..LoginInfo[date][i]["IP"].. 
				", logged in "..LoginInfo[date][i]["Times"].." more times,"..
				" and with share: "..LoginInfo[date][i]["share"].."Gb connected:\r\n"	
			elseif not (LoginInfo[date][i]["IP"] == item) or not (LoginInfo[date][item] ) then found =nil
			end
		end
	elseif not item then SendWhere(user,"Syntax Error. Correct Syntax is : !searchlog   eg.: !searchlog 127.0.0.1 060505") found=nil
	elseif not LoginInfo[date] then	SendWhere(user,"There is no log to search in !!!")
	end
	if found then
		SendWhere(user,found)
	elseif not found and item  then
		SendWhere(user,"That ip or nick wasnt found in the logs!!")
	end
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 string.format("[%q]",key) or string.format("[%d]",key);

                if(type(value) == "table") then
                        sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
                else
                        local sValue = (type(value) == "string") and string.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)
	local handle = io.open(file,"w+")
        handle:write(Serialize(table, tablename))
	handle:flush()
        handle:close()
end


P.S. if ur upgrading from the previous version do the following.
1. Stop the Script
2. Remove the logininfo.dat (or whatever name u changed it too"
3. Start the Script
Ignorance is Bliss.

amenay

All chat and commands result in " That Log doesnt exist !"  for me.  The logininfo.dat file is writing fine..haven't really given the chatarrival a good lookover.  Just copied in straight from the board (no errors) and edited botname^^'  Hope I'm not alone on this one.  Peace

Dessamator

#2
you are probably using an incorrect syntax, try switching on the script logging in, and typing !160605

P.S. The correct syntax is !DDMMYY(day month year)

--
oops,  my error there indeed there was a bug in the script , post edited (thnx for the report ) :)
Ignorance is Bliss.

oldman

I installed the stat-loggerv1.0  and  FreshStuff 4.xx by bastya_elvtars and what do I see? When I send the <+albums> command (or any other) to look for the albums in the freshstuff I got a PM from Stat-logger that  it is not in the log file or something like that. I changed back to stat-loggerv0.4 and everything is OK.  What can be the problem?

Dessamator

yep there was an error on the script, ive solved it already, the post was edited, copy the script again !
Ignorance is Bliss.

amenay

Thanks for that fix, glad to help.  Still having problems with the commands, though.  Searchlog just gives: [00:16:53]
      The Results of your search:
      ????????????????????????

For every user/IP, regardless of if being in the logininfo.dat file or not.

!lastips is working well, but the !DDMMYY is doing nothing at ([00:19:26] !150605) all, and this error comes out:

[00:19] Syntax ...:\PtokaX 3.3.0 beta 16.06\scripts\001-StatLogger.lua:130: attempt to concatenate field `description' (a nil value

Hope this helps more, I tried it without any other scripts running, and recopied it a few times to no avail, so I'm thinking it's not me..

Dessamator

#6
wierd , that error never happens with me, did u edit something in the script,
 could u copy the line with the error ?
--

meanwhile u can try this :
stop the script, erase the logininfo.dat, and start the script !

or just
change this :
", Description : "..LoginInfo[cmd][i]["description"]..


to this :
--", Description : "..LoginInfo[cmd][i]["description"]..

and use the !clearlogs command !


Ignorance is Bliss.

amenay

#7
I hadn't edited anything except that I comment the scripts restart message.  So that it looked like this.

--SendToAll("( >>>>  "..Version.." Started"..os.date(" the %d/%m-%Y at %X ").."  <<<< )")


Of course, there's really no way that could be causing it, but I tried it without that too with no change.  I was getting the error whenever I copied the script and didn't even change anything but the botname.  And before I posted yesterday I tried !clearlogs then restarting the script, the command worked after restarting it, but it didn't help the bug then at all.  Hadn't tried deleting the log file completely, though.

So anyways, after trying what you suggested; stopping, deleting, starting again, first with the line you mentioned commented (had read it wrong it as "and just change this:" not or) the !date command worked perfectly, so I tried uncommenting it, and it worked still after that.  Well, I've poked around at it for a bit.. haven't been able to recreate the error at all... so yeah, weird sounds about right.

As for the line with the error:

124 ", Description : "..LoginInfo[cmd][i]["description"]..
125
126 ", IP :"..LoginInfo[cmd][i]["IP"]..
127
128 ", logged in "..LoginInfo[cmd][i]["Times"].." more times,"..
129
130 " and with share: "..LoginInfo[cmd][i]["share"].."Gb connected:\r\n"


Also, the !searchlog command still gives no results, and with no error.  Everything else is looking fine, will definitely give word if I figure out how or why I was getting that error.  Running PX 3.3.0 build 17.09 on WS2k3, by the way.

Dessamator

QuoteOriginally posted by amenay
Also, the !searchlog command still gives no results, and with no error.  Everything else is looking fine, will definitely give word if I figure out how or why I was getting that error.  Running PX 3.3.0 build 17.09 on WS2k3, by the way.

fixed, post edited !
Ignorance is Bliss.

[NL]Koromo

#9
This script is getting better all the time.
Could you also implent which client was used by the user?
(for instance : DC++, DCpro, BlackDC ect and the version of it?)
Also wich tag was used!
Would be very usefull i think.

Keep up the good work!

Dessamator

QuoteOriginally posted by [NL]Koromo
This script is getting better all the time.
Could you also implent which client was used by the user?
(for instance : DC++, DCpro, BlackDC ect and the version of it?)
Also wich tag was used!
Would be very usefull i think.

Keep up the good work!

Done !
P.S. Some dc's fake their tag, so it wont be 100% accurate !
Ignorance is Bliss.

[NL]Koromo

Once again you did a great job.
Thanks.

kunal

-- to write all info to a file when a user logs in (name, e-mail, ip and share)
-- command to view the file is !statlog

the !statlog cmd doesnt work.

Dessamator

QuoteOriginally posted by Dessamator
you are probably using an incorrect syntax, try switching on the script logging in, and typing !160605

P.S. The correct syntax is !DDMMYY(day month year)

--
oops,  my error there indeed there was a bug in the script , post edited (thnx for the report ) :)
Ignorance is Bliss.


Dessamator

Seemingly you didnt get my point, that command was removed in the earlier versions, trobadour removed it.
Ignorance is Bliss.

Troubadour

any new improvements added m8 or have you stopped expanding this script?

Regards,
Troubadour
Regards,

Troubadour

** Guardian Forum **

hubaddy:   nederfun.no-ip.com

Dessamator

QuoteOriginally posted by Troubadour
any new improvements added m8 or have you stopped expanding this script?

Regards,
Troubadour
No new improvements m8, I planned on expanding  it and adding a cleaner for old posts, but i guess i forgot, maybe you could add it  ;) , and any other features/improvements you wish to add.
Ignorance is Bliss.

SMF spam blocked by CleanTalk