*** Standalone Userinfo Database
 

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

*** Standalone Userinfo Database

Started by NightLitch, 14 May, 2005, 16:20:49

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

NightLitch

here is a little something from me to you all that want to use it:

--###------------------------------------------------------###--
--       Standalone Userinfo Database
--       Created by NightLitch (2005)
--###------------------------------------------------------###--
tSet = {}
tSet.BotName = "-Database-"
tSet.Weeks = 2
--###------------------------------------------------------###--
sMyINFO = {}
sTIME = {}
sIP = {}

tFunc = {}
tFunc.LoadFile = function(filename,table)
	local file,err = io.open(filename, "r")
	if err then tFunc.SaveFile(filename, table) return 1 end
	for line in file:lines() do
		local s,e,nick,value = string.find(line, "(%S+)%|(.*)")
		if nick and value ~= "" then
			table[nick] = value
		end
	end
	file:close()
end
tFunc.SaveFile = function(filename,table)
	local file,err = io.open(filename, "w")
	for nick, value in table do
		file:write(nick.."|"..value.."\n")
	end
	file:close()
end
tFunc.Add = function(nick,value,table) 
	table[nick] = value 
end
tFunc.Remove = function(nick,value,table) 
	table[nick] = nil 
end
tFunc.GetTime = function()
	local T = {}
	for a,b in os.date("*t") do T[a] = b end
	local time = os.time({year = T.year,month = T.month,day = (T.day+(tSet.Weeks*7)),hour = T.hour,min = T.min,sec = T.sec,isdst = T.isdst})
	return time
end
tFunc.Cleaner = function()
	local t,c = 0,0
	for sNick,sTime in sTIME do
		t = t + 1
		if os.time() > tonumber(sTime) then
			c = c + 1
			sTIME[sNick] = nil
			sMyINFO[sNick] = nil
			sIP[sNick] = nil
		end
	end
	OnExit()
	return "*** "..c.." / "..t.." users have been deleted from database ***"
end
tFunc.List = function()
	local line = "\r\n"
	line = line .. "\r\n -----###-----------------------------------------------------------------------------------------------------------------------------------------------------------------###-----"
	line = line .. "\r\n                    # Current Clean List #       "
	line = line .. "\r\n -----###-----------------------------------------------------------------------------------------------------------------------------------------------------------------###-----"
	for sNick,sTime in sTIME do
		if os.time() > tonumber(sTime) then
			line = line .. "\r\n\t "..sNick.." is last seen "..os.date("%A %d %B %Y (%H:%M:%S)", tonumber(sTime))
		end
	end
	line = line .. "\r\n -----###-----------------------------------------------------------------------------------------------------------------------------------------------------------------###-----"
	return line
end
tFunc.Online = function(nick)
	if GetItemByName(nick) then return "Online" else return "Offline" end
end
tFunc.Find = function(value)
	if string.find(value, "%d+%.%d+%.%d+%.%d+") then
		local line = "*** Users found on IP: "..value..": \r\n\r\n"
		for nick,ip in sIP do
			if ip == value then
				line = line .. "\t "..nick.."  ("..tFunc.Online(nick)..")\r\n"
			end
		end
		return line
	else
		local tUser = GetItemByName(value)
		if tUser then
			return tUser
		else
			for nick,ip in sIP do
				if string.lower(value) == string.lower(nick) then
					return {sName = nick, sIP = sIP[nick], sMyInfoString = sMyINFO[nick]}
				end
			end
		end
	end
	return
end
tFunc.SplitMyInfoString = function(MyINFO,table)
    local _,_,Descr,Speed,Mail,Share = string.find(MyINFO, "%$MyINFO %$ALL %S+ (.*)%$ %$(.*)%$(%S*)%$%s*(%-*%d*)%$%|$")
    local _,_,Tag = string.find(Descr, "(%b<>)$")
    Tag = Tag or ""
    Descr = string.sub(Descr, 1,string.len(Descr) - string.len(Tag))
    Speed = string.sub(Speed, 1,string.len(Speed) - 1)
    table["sDescription"] = Descr table["sTag"] = Tag table["sConnection"] = Speed table["sEmail"] = Mail table["iShareSize"] = tFunc.ShareUnit(tonumber(Share))
	if Tag == "" then return table end
	local Limiter = {["B"] = "(%d+)",["L"] = "(%d+)",["F"] = "%d+%/(%d+)"}
	local Mode = {["A"] = "Active",["P"] = "Passive", ["5"] = "Socket"}
	local TagString, TagTable = Tag, {}
	TagString = string.sub(TagString,1,string.len(TagString)-1) 
	TagString = TagString..","
	string.gsub( TagString, "(.):([^,]+),", function( letter, value ) if letter == "O" then return "" end if Limiter[letter] then _,_,value = string.find(value, Limiter[letter]) end TagTable[letter] = value end)
	local _,_,sClient = string.find(TagString, "^(<%S+)%s+")
	hubs = 0
	if tonumber(TagTable["H"]) == nil then string.gsub(TagTable["H"], "(%d+)", function (num) hubs = hubs +tonumber(num) end) else hubs = tonumber(TagTable["H"]) end
	table["sClient"] = sClient
	table["sClientVersion"] = TagTable["V"]
	table["sMode"] = Mode[TagTable["M"]]
	table["iBlimit"] = TagTable["B"] or TagTable["L"] or TagTable["F"] or "unlimited"
	table["iSlots"] = TagTable["S"]
	table["iHubs"] = hubs
	return table
end
tFunc.ShareUnit = function(intSize)
	if tonumber(intSize) ~= 0 then
		local tUnits = { "Bytes", "KB", "MB", "GB", "TB" }
		intSize = tonumber(intSize);
		local sUnits;
		for index = 1, table.getn(tUnits) do
			if(intSize < 1024) then
				sUnits = tUnits[index];
				break;
			else 
				intSize = intSize / 1024;
			end
		end
		return string.format("%0.1f %s",intSize, sUnits);
	else 
		return "0 Bytes"
	end
end

function NewUserConnected(sUser)
	tFunc.Add(sUser.sName,sUser.sIP, sIP)
	tFunc.Add(sUser.sName,sUser.sMyInfoString, sMyINFO)
	tFunc.Add(sUser.sName,tFunc.GetTime(), sTIME)
end

function UserDisconnected(sUser)
	tFunc.Add(sUser.sName,sUser.sIP, sIP)
	tFunc.Add(sUser.sName,sUser.sMyInfoString, sMyINFO)
	tFunc.Add(sUser.sName,tFunc.GetTime(), sTIME)
end

OpConnected = NewUserConnected
OpDisconnected = UserDisconnected

function Main()
	tFunc.LoadFile("sMyINFO.dat", sMyINFO)
	tFunc.LoadFile("sIP.dat", sIP)
	tFunc.LoadFile("sTIME.dat", sTIME)
end

function OnExit()
	tFunc.SaveFile("sMyINFO.dat", sMyINFO)
	tFunc.SaveFile("sIP.dat", sIP)
	tFunc.SaveFile("sTIME.dat", sTIME)
end

function ChatArrival(sUser,sData)
	local _,_,Cmd,Arg = string.find(sData, "%b<>%s*(%S+)%s*(.*)%|")
	if Cmd == "!cleanlist" and sUser.bOperator then
		sUser:SendData(tSet.BotName, tFunc.List() )
		return 1
	elseif Cmd == "!clean" and sUser.bOperator then
		local msg = tFunc.Cleaner()
		SendToAll(tSet.BotName, msg)
	elseif Cmd == "!getinfo" and sUser.bOperator then
		local s,e,value = string.find(Arg, "(%S+)")
		if value == nil then sUser:SendData(tSet.BotName, "*** Syntax: !getinfo ") return 1 end
		local usr = tFunc.Find(value)
		if usr == nil then sUser:SendData(tSet.BotName, "*** Nothing found on "..value) return 1
		elseif type(usr) == "string" then sUser:SendData(tSet.BotName, usr) return 1
		elseif type(usr) == "table" then
			usr = tFunc.SplitMyInfoString(usr.sMyInfoString,usr)
			local line = ""
			line = line .. "\r\n -----###-----------------------------------------------------------------------------------------------------------------------------------------------------------------###-----"
			line = line .. "\r\n                    # Information on: "..value.." #       "
			line = line .. "\r\n -----###-----------------------------------------------------------------------------------------------------------------------------------------------------------------###-----"
			line = line .. "\r\n                              Nickname: "..usr.sName
			line = line .. "\r\n                              IP: "..usr.sIP
			line = line .. "\r\n                              Client: "..usr.sClient.." v."..usr.sClientVersion
			line = line .. "\r\n                              Share: "..usr.iShareSize
			line = line .. "\r\n                              Mode: "..usr.sMode
			line = line .. "\r\n                              Slots: "..usr.iSlots
			line = line .. "\r\n                              Hubs: "..usr.iHubs
			line = line .. "\r\n                              Bandwidth: "..usr.iBlimit
			line = line .. "\r\n                              Description: "..usr.sDescription
			line = line .. "\r\n                              Tag: "..usr.sTag
			line = line .. "\r\n                              Connection Speed: "..usr.sConnection
			line = line .. "\r\n                              Email: "..usr.sEmail
			line = line .. "\r\n                              Status: "..tFunc.Online(usr.sName)
			line = line .. "\r\n                              Last Login: "..os.date("%A %d %B %Y (%H:%M:%S)", tonumber(sTIME[usr.sName]) )
			line = line .. "\r\n -----###-----------------------------------------------------------------------------------------------------------------------------------------------------------------###-----"
			sUser:SendData(tSet.BotName, line)
			return 1
		end
	end
end

report errors and other things...

Cheers // NightLitch
//NL

Dessamator

hmmm, looks a lot cleaner than ur other code, and more optimized as well, well done !
Ignorance is Bliss.

NightLitch

QuoteOriginally posted by Dessamator
hmmm, looks a lot cleaner than ur other code, and more optimized as well, well done !

Question is does it work OK that is what I need to know...

The cleaner part that is...

Other then that it could be some minior bugs, but what doesn't have bugs.  ;)
//NL

Dessamator

yah sure ill test it, but dont worry there's gonna be a lot of testers soon, and bugs will arise as always, :)
Ignorance is Bliss.

Oz

can u add this function and for registered users?

thx

GeceBekcisi

Having an IP history of the queried nick would also be very good...

Thanks..
Do you need an advanced user handling script? Download UserBekcisi today (Latest Edit)
Features: User + ISP + GeoIP database, user info + share checking and many more...

GeceBekcisi

#6
Getting "Saturday 20 August 2005" like Last login query results for queries made in "Saturday 23 August 2005".. Date is buggy..

I tried to correct but couldnt succeed due to being unable where this error happens from. Anyone can correct that?
Do you need an advanced user handling script? Download UserBekcisi today (Latest Edit)
Features: User + ISP + GeoIP database, user info + share checking and many more...

GeceBekcisi

Some one can correct that date bug? Please :(
Do you need an advanced user handling script? Download UserBekcisi today (Latest Edit)
Features: User + ISP + GeoIP database, user info + share checking and many more...

bastya_elvtars

Maybe some of you would like to try this, as many requests are covered.
Everything could have been anything else and it would have just as much meaning.

GeceBekcisi

bastya_elvtars, your script is really good and nearly what I need but;
    [*] iprange info command locks computer, i couldnt find why
    [*] Instead of
    local v,u=bytestoh(Share)
    msg=msg.."Shared: "..sUsersShare.." "..u.."\r\n"..
    
    this
    local v,u=bytestoh(Share)
    local sUsersShare = string.format( "%.2f",v)
    msg=msg.."Shared: "..sUsersShare.." "..u.."\r\n"..
    
    kinda things would be much useful
    [/list]

    BTW thanks for the script..
    Do you need an advanced user handling script? Download UserBekcisi today (Latest Edit)
    Features: User + ISP + GeoIP database, user info + share checking and many more...

    bastya_elvtars

    #10
    QuoteOriginally posted by GeceBekcisi
    iprange info command locks computer, i couldnt find why

    Yeah, I saw it, and frankly, I don't know the reason at the moment, but already inspecting.

    -- // EDIT

    It crashed PtokaX here. I think it is weird, because it worked fine with the previous version. Gonna build a coroutine for the range info, maybe that helps, because this shouldnt't happen.


    QuoteOriginally posted by GeceBekcisi
    Instead of
    local v,u=bytestoh(Share)
    msg=msg.."Shared: "..sUsersShare.." "..u.."\r\n"..
    
    this
    local v,u=bytestoh(Share)
    local sUsersShare = string.format( "%.2f",v)
    msg=msg.."Shared: "..sUsersShare.." "..u.."\r\n"..
    
    kinda things would be much useful

    Oh, yes, I way lowe loooooooong decimal numbers. The bytestoh function does not format the string it returns, you have to do it yourself, feel free to edit my scripts.
    Everything could have been anything else and it would have just as much meaning.

    bastya_elvtars

    Found and eliminated the bug. Please update.
    Everything could have been anything else and it would have just as much meaning.

    Jaakko

    Two requests.
    1. Option to disable inbuilt right click commands. It looks kind of stupid now when at my hub I have all mouse commands translated in finnish. All but dabase's.
    2. Profile names aren't same in every hub. In my case all my op's are vip's at userinfo and so on.

    Herman

    Bastya? Im having a problem with the script. Im using robocop as security software, and im having a netfounder profile, which im using....and the script wont recognize me as operator so i cant use it....you have a quick fix for this problem?
    Owner of PcGamers4Ever

    bastya_elvtars

    QuoteOriginally posted by Herman
    Bastya? Im having a problem with the script. Im using robocop as security software, and im having a netfounder profile, which im using....and the script wont recognize me as operator so i cant use it....you have a quick fix for this problem?

    It is not designed to use nonstandard profiles, it can be changed to support it, but I cannot do it for you now.
    Everything could have been anything else and it would have just as much meaning.

    Psycho_Chihuahua

    #15
    my guess would be to edit the line
    local proftable={[0]="Superoperator",[1]="Operator",[2]="VIP",[3]="Registered User"}
    
    to match your Profile settings


    but then on the other hand i'm still a bit of a noob in scripting myself  :D
    PtokaxWiki ?PtokaX Mirror + latest Libs

    01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

    Herman

    QuoteOriginally posted by Psycho_Chihuahua
    my guess would be to edit the line
    local proftable={[0]="Superoperator",[1]="Operator",[2]="VIP",[3]="Registered User"}
    
    to match your Profile settings


    but then on the other hand i'm still a bit of a noob in scripting myself  :D




    Well, i tried adding netfounder to that line...but it didnt work. When i use the !getinfo command on a netfounder, it says he is a "user"
    Owner of PcGamers4Ever

    GrinSlaW

    hello

    how can i change the rightclick name in your userinfo script bastya_elvtars ? i whant to change the name from Userinfo to -=] UserInfo [=- but i dont see where to do it in the script  ?(


    cheers
    .:: AcExtreme ::. | .:: AcPro ::.

    Herman

    QuoteOriginally posted by GrinSlaW
    hello

    how can i change the rightclick name in your userinfo script bastya_elvtars ? i whant to change the name from Userinfo to -=] UserInfo [=- but i dont see where to do it in the script  ?(


    cheers

    In the lua file at the top you see this:

    -- Bot's data

    Bot={
    name="-UserInfo-"


    Change -UserInfo- to the name you want your bot to be called
    Owner of PcGamers4Ever

    GrinSlaW

    umh thats where i change the bot name i know that. The questions was where i change the rightclick name

    tnx anyway  :)

    cheers
    .:: AcExtreme ::. | .:: AcPro ::.

    Herman

    #20
    QuoteOriginally posted by GrinSlaW
    umh thats where i change the bot name i know that. The questions was where i change the rightclick name

    tnx anyway  :)

    cheers

    Think you have to change the names in the rigstration commands at the bottom of the file.

    Dunno what tho, if not helped by bastya, you could just use the trial and error way
    Owner of PcGamers4Ever

    GrinSlaW

    #21
    i have tried that just get syntax error when i change there

    yes hope bastya will post some help  :)

    *EDIT* found out where it was it was not so hard if you read the script properly then i found it :)

    cheers
    .:: AcExtreme ::. | .:: AcPro ::.

    bastya_elvtars

    QuoteOriginally posted by GrinSlaW
    i have tried that just get syntax error when i change there

    yes hope bastya will post some help  :)

    *EDIT* found out where it was it was not so hard if you read the script properly then i found it :)

    cheers

    Sorry for not posting the solution, I could not use my HDDs for a while, otherwise I would post a fix. Gotta create a lecture now... later...
    Everything could have been anything else and it would have just as much meaning.

    gander

    well i had a look trough the script and it looks like the whole script is based on the botname ... so i guess its not possible to change rightclick without rewriting the script... or?

    gander

    #24
    guess i found it


    here you go

     if not PM then
        rightclick["$UserCommand "..context.." Userinfo\\"..name.."$<%[mynick]> "..command.."|"]=level
      else
        rightclick["$UserCommand "..context.." Userinfo\\"..name.."$$To: "..Bot.name.." From: %[mynick] $<%[mynick]> "..command.."|"]=level
      end

    just change where it says "userinfo\\"  to what ever...like ex "]userinfo[\\"

    worked here

    SMF spam blocked by CleanTalk