AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Retrieve data from log string (https://forums.alliedmods.net/showthread.php?t=131478)

Jack86 07-05-2010 15:15

Retrieve data from log string
 
I need help for a specific one time plugin. A buddy of mine gave me php script that reads bans from database and post them on our forum, and since i have a separate log for bans all i need is plugin that will read that logs once and store them into sql. Im stuck at part where it should read from line and take that info. Log line looks like this

L 05/11/2010 - 22:48:16: Ban: " dzoniJ<4490><STEAM_0:0:17887801><>" ban and kick " Dzivaldo<4587>< STEAM_0:1:23584114><>" (minutes " 90") (reason " Banovan si od dzoniJ") (IP " 109.92.183.155")

Now my idea is to somehow detect these border characters for required string like L data1 : "data2< "data3< etc, and get data between them, but i need a bit (a lot :mrgreen:) of help.

Arkshine 07-06-2010 17:30

Re: Retrieve data from log string
 
For the first 3 arguments, parse_loguser() can do the job.

Jack86 07-07-2010 03:51

Re: Retrieve data from log string
 
OK, i did it diferently than before and it works, but now i have " character in front of name gotten with parse_loguser and i dont know how to remove it (remove_quotes doesnt work)

PHP Code:

        while (!feof(File))
        {
            
fgets(File,line,sizeof(line)-1);
            
            
split(line,temp,sizeof (temp) -1,useless0": ")
            
split(temp,useless0timersizeof(timer)-1"L ")

            
split(line,useless0admnamesizeof(admname)-1"n: ")
            
split(admname,tempsizeof (temp)-1nameidsizeof(nameid)-1"kick ")
            
            
parse_logusertempnamesizeof(name)-1,userid,useless0)
            
parse_logusernameidname2sizeof(name)-1,userid,authidsizeof(authid)-1)
            
            
split(nameid,useless0tim3sizeof(tim3)-1"minutes")
            
parsetim3minutessizeof(minutes)-1)
                
            
split(tim3,useless0ip1sizeof(ip1)-1"IP")
            
parseip1ipsizeof(ip)-1



All times are GMT -4. The time now is 07:10.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.