log users sharesize to file
 

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

log users sharesize to file

Started by sander815, 27 April, 2004, 08:43:45

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

sander815

i am running a private hub, and we don't want people to 1st share like 50 gb for a week, and then the next week share only 5 gb
We like to see a scripts so w can check a users share size from its last 10 logins ot whatever, last month

Is there a script that logs user sharesize when they login?
something like
{user}logged in at 4-4-04-20:11: sharesize 50.11gb
{user}logged in at 4-4-04-22:45: sharesize 53.11gb
{user}logged in at 5-4-04-21:11: sharesize 5.42gb
user}logged in at 6-4-04-21:11: sharesize 11.21gb

sander815

now, theres already this from the temp forum, but i am gettin no reactions there anymore:
BOT = "Share_Logger";
SHAREFILE = "share_log.txt";

TSHARE = {};

function DataArrival(user, data)
	if strsub(data,1,1)=="<" then
		data=strsub(data,1,strlen(data)-1)
		s,e,cmd = strfind(data,"%b<>%s+(%S+)")
		if (cmd=="+s") then
			s,e,name = strfind(data,"%b<>%s+%S+%s+(%S+)")
			GetFromFile(SHAREFILE,TSHARE)
			for ind,val in TSHARE do
				local s,e,Name,Info = strfind(val,"(%S+)-(.*)")
				if strlower(name) == strlower(Name) then
					user:SendData(BOT,Info)
				else
					user:SendData(BOT,"That user has not been in this hub.") return 1
				end
			end
			TSHARE = nil;
			TSHARE = {};
			return 1
		end
	end
	if strsub(data,1,7)=="$MyINFO" then
		local s,e,Share = strfind(data,"%$%s*(%d+)%$")
		local curTIME = date()
		Share = Share / 1024 / 1024 / 1024
		Share = format("%0.2f",Share)
		SaveToFile(SHAREFILE,user.sName,user.sIP.." Connected at "..curTIME..", Share : "..Share.." GB")
	end
end

function SaveToFile(File,sUser,data)
	local sFile = openfile(File,"a+")
	write(sFile,sUser.."#"..data.."\n")
	closefile(sFile)
end

function GetFromFile(File,IntoTable)
	iCon = 0
	readfrom(File)
		while 1 do
		local line = read()
		if line == nil then
			break
		else
			local _,_,Usr,Data = strfind(line,"(.*)%#(.*)")
			rawset(IntoTable,iCon,Usr.."-"..Data)
			iCon = iCon + 1
		end
	end
	readfrom()
end

this seems to work, only the script only reads the 1 ruke in the generated txt file:

this is in the logfile now:
user1#154.5.xxx.xxx Connected at 04/20/04 18:02:49, Share : 5.87 GB
user2#206.116.xxx.xxx Connected at 04/20/04 18:03:27, Share : 15.63 GB

+s user1
user1#154.5.x.xx Connected at 04/20/04 18:02:49, Share : 5.87 GB

+s user2
That user has not been in this hub.

it is in the log, so he has been in the hub
i copied and pasted username, to be 100% sure

now there are 25 logs, but it only reads the 1st log it made, the rest it can't read or so

chill

haven"t really played with the rawset function, but I don't think that it will actually insert the data from the file into the passed table more int ot he local table InfoTable of the function Get...()

so i just exchanged the tables

function GetFromFile(File,TSHARE)

        iCon = 0

        readfrom(File)

                while 1 do

                local line = read()

                if line == nil then

                        break

                else

                        local _,_,Usr,Data = strfind(line,"(.*)%#(.*)")

                        rawset(TSHARE,iCon,Usr.."-"..Data)

                        iCon = iCon + 1

                end

        end

        readfrom()

end

else check out the script SL  it does quite  some more but else
it does what you want in a better way i must say

SL

sander815

result is the same, it only read the 1st entry in the log

ill try your other script

kepp

Sorry, will look into this matter as soon as possible
Guarding    

SMF spam blocked by CleanTalk