Yet Another IP 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

Yet Another IP Logger

Started by Jaras, 28 May, 2004, 01:17:27

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Jaras

BotName = "IP/Nick DataBase"

IPNicksFile = "IPNicksFile.txt"

function Is2ndIPHigher( IP1, IP2 )
	local _,_,dec1 = strfind( IP1, "^(%d+)%.?" )
	local _,_,dec2 = strfind( IP2, "^(%d+)%.?" )
	if not( strfind( IP1, ".", 1, 1 ) ) or not( strfind( IP2, ".", 1, 1 ) ) or ( dec1 ~= dec2 ) then
		return tonumber( dec1 ) < tonumber( dec2 )
	else
		IP1 = strsub( IP1, strlen( dec1 ) + 2 )
		IP2 = strsub( IP2, strlen( dec2 ) + 2 )
		return Is2ndIPHigher( IP1, IP2 )
	end
end

function FoundNick( nick, searchIn )
	local _,_,tmpNick = strfind( searchIn, "^(%S+)%s?" )
	if ( tmpNick == nick ) or ( not( strfind( searchIn, " ", 1, 1 ) ) ) then 
		return tmpNick == nick
	else
		searchIn = strsub( searchIn, strlen( tmpNick ) + 2 )
		return FoundNick( nick, searchIn )
	end
end

function SavedIPNick( curUser )
	local found = nil
	local lines = ""
	readfrom( IPNicksFile )
	while 1 do
		local line = read()
		if ( line ~= nil ) and ( line ~= "" ) then
			if not found then
				local _,_,nextIP = strfind( line, "^(%S+)%s" )
				if Is2ndIPHigher( curUser.sIP, nextIP ) then
					line = curUser.sIP.." = "..curUser.sName.."\n"..line
					found = 0
				else
					if strsub( line, 1, strlen( curUser.sIP ) ) == curUser.sIP then
						local nicks = strsub( line, strlen( curUser.sIP ) + 4 )
						if FoundNick( curUser.sName, nicks ) then
							readfrom()
							return 0
						else
							line = line.." "..curUser.sName
							found = 1
						end
					end
				end
			end
			lines = lines..line.."\n"
		else
			if ( lines == "" ) or ( not found ) then
				lines = lines..curUser.sIP.." = "..curUser.sName.."\n"
				found = 0
			end
			readfrom()
			writeto( IPNicksFile )
			write( lines )
			writeto()
			return 2 - found
		end
	end
end

function OpConnected( curUser )
	SavedIPNick( curUser )
end

function NewUserConnected( curUser )
	SavedIPNick( curUser )
end

function Main()
	frmHub:UnregBot( BotName )
end

lil' script building some kind of DataBase, which lookes like that:
IP1 = Nick11 Nick12 Nick13 .. Nick1n
IP2 = Nick21 .. Nick2k
:
:
IPm = Nickm1 .. Nickmn

where IPs are sorted from the "lowest" at the begining to the "highest" at the end of file. so when i login from IP 666.666.666.666 as Jaras, next i'll logout and f.e. after 2 hours i'll login again but as Pussy line will look like that:
666.666.666.666 = Jaras Pussy

so u'll know, that i'm "acting suspicious" =]. i dont have time for adding commands, but using plop's texter or setting output file to unused file from other script (like "txt/network.txt" i my case - using RC 8.0) will make it. i'll also add cmd for searching database for IP or Nick (strfind will do the job) and when found returning whole line, but as i said, don't have time now (exams). hope someone will find this script useful.
for some yet unknown purposes function returns:
0 - when no data were written to file (user already exists)
1 - when added another Nick to existing IP
2 - added new entry (IP and Nick)
don't forget to make empty file specified in IPNicksFile variable and do not modify it (the file itself) ever unless u know what u're doin'=].

P.S. anyone can tell me what should i do to prevent typed commands from showing on main chat?

SMF spam blocked by CleanTalk