user and ip log
 

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

user and ip log

Started by dragos_sto, 20 September, 2006, 12:45:32

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

dragos_sto

i bild a script ho make log whit user ip
not finish yet
i have one little problem
log ip dont work like i expected
if user have a nik whitout [] work ok
but if fave a nik like [dsl]dief
in this section :
      if string.find(line,usernam) then
         local _,_,des = string.find(line,"%b==(%d+)")
         des = des + 1
         count = 1
         ma = ma..""..usernam.."=="..des.."\r\n"
      else
         ma = ma..line.."\r\n"
      end
string.find not detect the to be this string in the line (user.sname)

some one whit some ideea

like usually i`m not a good writer .. sorry , and hope some one understand

final script posted at
http://forum.ptokax.org/index.php?topic=6421.0

Herodes

#1
%b== shouldn't work....
cause it needs <>, (), [] or {}

please give the format of the logs...
what is an example line that the string.find(line,"%b==(%d+)") should match ?

Something noticable in the script of yours is this:
if io.open(pathIp.."/"..userip..ext) == nil then io.open(pathIp.."/"..userip..ext,"w") end

nice thinking ;) I'll do some testing but I think it should be ok,... have you checked that this behaves as expected ?

dragos_sto

the ideea work it to count the number o how many time
a user from ip x.x.x.x log on the hub and
and see what nick it used most

in theat section of script string.find
dont match the line ho it read ok
for example :
read value of line it - [dsl]dief==1
when make if string.find(line,usernam) then
where usernam = [dsl]dief
string.find return nil :(

dragos_sto

in rest the script work ok
and the log are ok beside that little problem above
no error return from the hub

Herodes

then try changing
local s,e, des= string.find(line,"%b==(%d+)")

to
local s,e, des = string.find( line, "%=%=(%d+)$" )

if you are on lua 5.1 then try changing string.find with string.match since it saves you from using the s,e variables..
local des = string.match( line, "%=%=(%d+)$")


dragos_sto

i whil ...
and post the result after testing

dragos_sto

no change ,
but ho i wrote above the problem it not at
local s,e, des= string.find(line,"%b==(%d+)")
i change the line but the problem it not gone
the problem persist
and like i write above it if user have thei nickname letter like []

read value of line it - [dsl]dief==1
when make if string.find(line,usernam) then
where usernam = [dsl]dief
string.find return nil
if i change whit string.match
no change :((

dragos_sto

modify the first post

it at most final version
after i solve the above problem :( :'(

Herodes

This is what you posted
      if string.find(line,usernam) then
         local _,_,des = string.find(line,"%b==(%d+)")
         des = des + 1
         count = 1
         ma = ma..""..usernam.."=="..des.."\r\n"
      else
         ma = ma..line.."\r\n"
      end


Try this one, read the comments,... ;)

--- use this function for making the usernam variable (a string) pure since the regular expression in the string.find is a string too
local function Purify( s )
    local t, r = { ['['] = 1, [']'] = 1, ['?'] = 1, ['+'] = 1, ['*'] = 1, ['.'] = 1, ['-'] = 1, ['%'] = 1, ['$'] = 1, ['^'] = 1, ['('] = 1, [')'] = 1, ['{'] = 1, ['}'] =1  }, ''
    for char in string.gmatch( s, '(.)' ) do
        local esc = ''
        if t[char] then esc = '%' end
        r = r..esc..char
    end
    return r
end
--- now your piece of script looks like this ... string.match applied..
      if string.find(line, Purify(usernam) ) then
         local des = string.match( line, "%S+==(%d+)" )
         des = des + 1
         count = 1
         ma = ma..usernam.."=="..des.."\r\n"
      else
         ma = ma..line.."\r\n"
      end

also you could do the following,...
if ( string.sub(line,  1, string.len(usernam) ) == usernam ) then
    local des = string.match ( line, "%S+%=%=(%d+)$" )
    des = des + 1
    count = 1
    ma = ma..usernam.."=="..des.."\r\n"
else
    ma = ma..line.."\r\n"
end

dragos_sto

i will test first
Code: lua
if ( string.sub(line,  1, string.len(usernam) ) == usernam ) then
    local des = string.match ( line, "%S+%=%=(%d+)$" )
    des = des + 1
    count = 1
    ma = ma..usernam.."=="..des.."\r\n"
else
    ma = ma..line.."\r\n"
end


and post the result after

dragos_sto

now work ok
but i have one question
why string.find or string.match return nil ...  ???

10x a lot for help

Herodes

Quote from: dragos_sto on 22 September, 2006, 12:11:01
now work ok
but i have one question
why string.find or string.match return nil ...  ???

10x a lot for help
because they don't find anything that matches the regular expression we provide it with...

- check what the 'line' var is just before it goes into the string.find/match
- check the regular expression with a sample target string,... in this case do a
local line = "nick==4"

dragos_sto

the file log look the same like for other ip
when sendtoall the line to se what value return
in front of the nick appear "-" from nowhere

Herodes

Maybe trying "(%d+)$" instead of "%S+%=%=(%d+)$" will help,... it means : the number(s) at the end of the string

sourabhiitm

I have a problem ..
This script is startng and working fine only for some time with ptokex 0.3.6.  after some time (approx 1 min) ,
It is giving an error

UserInfo.lua:103: bad argument #1 to 'lines' (UserInfo/skamslast.log: No such file or directory)
and it is not working anymore.. ???
Some body help!!!!!!
By skamlast I mean.. It is a user.. wvrytime some diferent name is coming , which is basicaly name of any user..

dragos_sto

skamslast.log exist in userinfo folder ?
delete the file and see if the error ocure

sourabhiitm

I m using Rincefield IP log now .. SO i havnt tried. :)

SMF spam blocked by CleanTalk