Old 24-06-2007   #1 (permalink)
Honorary Member
 
Join Date: Jun 2006
Age: 32
Posts: 1,039
Rep Power: 4
Default PHP Script - Retrieving Log Output

HI,

Can anyone show me or provide me with a script to be able get log output from a css server via php?, i think from there i can send it straight into the database.

I want to have a look if its possible to integrate into my stats program.

At the moment im thinking it wont provide much benefit over me manually importing the logfiles (5 min job per match, provided all playes have correct steam id's).

There are a number of reasons why grabbing the logs from the server through UDP might not provide much benefit

- match starting times can be different
- who playes who
- which event to choose
- registered vs unregistered players
- server crashes

Please bear in mind im not a coder by profession or make out to be one , have an understanding of arrays and functions, but no object orientated php.

Thanks in advance.

Happy to work with someone on this.
billy baxter is offline   Reply With Quote
Old 24-06-2007   #2 (permalink)
Participating Member
 
KeyDecoder's Avatar
 
Join Date: Jan 2007
Location: Brisbane
Age: 26
Posts: 346
Rep Power: 3
Default

Your best bet is to look at PHP KBot written by Khaless (http://sourceforge.net/projects/kbot-irc/).

That has logComms.class.php, logParser.class.php which appear to provide code which handles recieving log information from the server.

css_rconpugbot.php appears to have code which should show how to use it, although you'll need the RCon code to send the rcon command to tell the server your listening.

css_defines.inc.php seems to have the information that the log can process, I think.

Your other option is to look at automating the process that you currently do manually.
__________________
KeyDecoder
This is where I say something witty and original, like this.
KeyDecoder is offline   Reply With Quote
Old 24-06-2007   #3 (permalink)
Honorary Member
 
Join Date: Jun 2006
Age: 32
Posts: 1,039
Rep Power: 4
Default

Cheers Key, will look and see it can work.

All do manually atm is

- dload the logfile via FTP to me local desktop
- using my upload script i upload to www.euro26.com.au and the rest is automated
billy baxter is offline   Reply With Quote
Old 24-06-2007   #4 (permalink)
Honorary Member
 
Join Date: Jun 2006
Age: 32
Posts: 1,039
Rep Power: 4
Default

Umm classes etc is way over my head, will keep doing what im doing unless someone wants to do it!
billy baxter is offline   Reply With Quote
Old 25-06-2007   #5 (permalink)
Contributing Member
 
Join Date: Jun 2006
Posts: 607
Rep Power: 3
Default

Here's some help.

Instantiate the log parser (http://kbot-irc.svn.sourceforge.net/...74&view=markup)

$logParser = new logParser;
then you can use an event driven model. Register events like so

$logParser->registerHandler(PATTERN, $object, 'methodNameToCall');

Please note, I define a few patterns in http://kbot-irc.svn.sourceforge.net/...21&view=markup
so one can say:
$logParser->registerHandler(KILLS, $object, 'kill');

Once you have this setup you can then either
a) pipe the file into the log handler or
b) pipe UDP data to the log handler (buffering on lines)
__________________
92% of teens have moved on to rap. If you are part of the 8% who still listen to real music, copy and paste this into your signature.
Khaless is offline   Reply With Quote
Old 25-06-2007   #6 (permalink)
Honorary Member
 
Join Date: Jun 2006
Age: 32
Posts: 1,039
Rep Power: 4
Default

Khaless,

Still looks advanced for me will have to read more about classes, i will have to read and understand how the code works, just too busy atm with RL stuff.
billy baxter is offline   Reply With Quote
Old 27-06-2007   #7 (permalink)
Contributing Member
 
Petro's Avatar
 
Join Date: Aug 2006
Location: Sydney
Posts: 718
Rep Power: 3
Default

From memory to retrieve log information, and general server information, you need to analyse the packets that get sent, i think they get sent in Hex format. Correct me if i'm wrong.
__________________
STEAM_0:1:113146


Petro's VAC Ban Detector: http://www.landypro.com/vac
Petro is offline   Reply With Quote
Old 27-06-2007   #8 (permalink)
Contributing Member
 
Join Date: Jun 2006
Posts: 607
Rep Power: 3
Default

Quote:
Originally Posted by Petro View Post
From memory to retrieve log information, and general server information, you need to analyse the packets that get sent, i think they get sent in Hex format. Correct me if i'm wrong.
Hex format is just a representation, unless you are really silly and encode a byte stream into ASCII HEX before you send it (I have seen this done interestingly enough, its completely pointless).

The log format is plain text sent in upd packets (remote logging) or written to a local file.
__________________
92% of teens have moved on to rap. If you are part of the 8% who still listen to real music, copy and paste this into your signature.
Khaless is offline   Reply With Quote
Old 07-07-2007   #9 (permalink)
Honorary Member
 
Join Date: Jun 2006
Age: 32
Posts: 1,039
Rep Power: 4
Default

Quote:
Originally Posted by Khaless View Post
Here's some help.

Instantiate the log parser (http://kbot-irc.svn.sourceforge.net/...74&view=markup)

$logParser = new logParser;
then you can use an event driven model. Register events like so

$logParser->registerHandler(PATTERN, $object, 'methodNameToCall');

Please note, I define a few patterns in http://kbot-irc.svn.sourceforge.net/...21&view=markup
so one can say:
$logParser->registerHandler(KILLS, $object, 'kill');

Once you have this setup you can then either
a) pipe the file into the log handler or
b) pipe UDP data to the log handler (buffering on lines)
thanks for the info, im going to start re-coding my current logparser using classes, once i have worked that out i will look at using UDP.

I had no idea about define and constants (one of the issues of self teaching i guess with no structure), looks like they will be good to use.
billy baxter is offline   Reply With Quote
Old 08-07-2007   #10 (permalink)
Senior Member
 
peedee's Avatar
 
Join Date: Aug 2006
Location: The Internet
Age: 21
Posts: 966
Rep Power: 3
Default

Dont forget to include random ASCI art animals in your coding :>
peedee is offline   Reply With Quote
Old 08-07-2007   #11 (permalink)
Monster Member
 
jamiec's Avatar
 
Join Date: Sep 2006
Location: irc.gamesurge.net
Posts: 4,922
Rep Power: 7
Send a message via MSN to jamiec
Default

why would he want to do that
__________________
Man donates blood to save his Mrs. A year later they break up. He says "give me my blood back b**ch". She throws him a tampon and says "f**k you, I'll pay you back monthly".
- lividscott.
jamiec is offline   Reply With Quote
Old 08-07-2007   #12 (permalink)
Contributing Member
 
Join Date: Jun 2006
Posts: 607
Rep Power: 3
Default

Quote:
Originally Posted by peedee View Post
Dont forget to include random ASCI art animals in your coding :>
Please Dont.
__________________
92% of teens have moved on to rap. If you are part of the 8% who still listen to real music, copy and paste this into your signature.
Khaless is offline   Reply With Quote
Old 08-07-2007   #13 (permalink)
Pro Member
 
nuk3's Avatar
 
Join Date: May 2006
Location: Sydney, Australia
Posts: 6,539
Rep Power: 9
Default

Quote:
Originally Posted by Khaless View Post
Please Dont.
I wish your signature would stop flashbanging me Mr Khaless : (
__________________
OM NOM NOM
nuk3 is offline   Reply With Quote
Old 08-07-2007   #14 (permalink)
Monster Member
 
Join Date: Jan 2007
Location: Brisbane, Australia
Age: 19
Posts: 3,500
Rep Power: 6
Default

Quote:
Originally Posted by nuk3 View Post
I wish your signature would stop flashbanging me Mr Khaless : (
Hey, that just means you don't have to read it

EDIT: After actually reading it - i agree with it haha - Might copy that into mine
__________________
Jayson
Jayso is offline   Reply With Quote
Old 08-07-2007   #15 (permalink)
Contributing Member
 
Join Date: Jun 2006
Posts: 607
Rep Power: 3
Default

Quote:
Originally Posted by nuk3 View Post
I wish your signature would stop flashbanging me Mr Khaless : (
It worked when the design was darker.
__________________
92% of teens have moved on to rap. If you are part of the 8% who still listen to real music, copy and paste this into your signature.
Khaless is offline   Reply With Quote
Old 08-07-2007   #16 (permalink)
Honorary Member
 
Join Date: Jun 2006
Age: 32
Posts: 1,039
Rep Power: 4
Default

Could any of you professional programmers take a look and criticise my use of classes, if you want to, PM me your email and i will send the code through.

Thanks in advance.
billy baxter is offline   Reply With Quote
Old 08-07-2007   #17 (permalink)
Pro Member
 
nuk3's Avatar
 
Join Date: May 2006
Location: Sydney, Australia
Posts: 6,539
Rep Power: 9
Default

Quote:
Originally Posted by billy baxter View Post
Could any of you professional programmers take a look and criticise my use of classes, if you want to, PM me your email and i will send the code through.

Thanks in advance.
Hit me up on msn.
__________________
OM NOM NOM
nuk3 is offline   Reply With Quote
Old 09-07-2007   #18 (permalink)
Honorary Member
 
Join Date: Jun 2006
Age: 32
Posts: 1,039
Rep Power: 4
Default

Im liking this OOP, its good to be able to change the state of an object, e.g. for a match class, setting which half it is, max rounds etc. Far easier than using if :then, do:while statements.

I also like how the objects can hold arrays as well as other info and the inheritance side of things.

yes im a noob.
billy baxter is offline   Reply With Quote
Old 09-07-2007   #19 (permalink)
GotGames Ninja Admin
 
Twelve-60's Avatar
 
Join Date: May 2006
Location: NSW, Australia
Age: 20
Posts: 2,282
Rep Power: 5
Send a message via MSN to Twelve-60
Default

haha

Yeah classes are great, so handy for having multiple connections

- Twelve-60
__________________
Twelve-60 is offline   Reply With Quote
Old 09-07-2007   #20 (permalink)
Honorary Member
 
Join Date: Jun 2006
Age: 32
Posts: 1,039
Rep Power: 4
Default

Quote:
Originally Posted by Twelve-60 View Post
haha

Yeah classes are great, so handy for having multiple connections

- Twelve-60
yes i sensed this
billy baxter is offline   Reply With Quote
Old 09-07-2007   #21 (permalink)
Contributing Member
 
Join Date: Jun 2006
Posts: 607
Rep Power: 3
Default

Quote:
Originally Posted by billy baxter View Post
Could any of you professional programmers take a look and criticise my use of classes, if you want to, PM me your email and i will send the code through.

Thanks in advance.
OOP is actually quite an interesting road and many times (including by me) done completely incorrectly. Make sure (as well as practicing it!) to read up on the theory.
__________________
92% of teens have moved on to rap. If you are part of the 8% who still listen to real music, copy and paste this into your signature.
Khaless is offline   Reply With Quote