1

PHP mod logger

Lurvik's Avatar Lurvik12/14/13 10:01 pm
1 emeralds 213 2
12/14/2013 10:37 pm
Lurvik's Avatar Lurvik
So, I was bored and I've wanted to do something like this for quite some time now. So I did it.

What is it?

Well in the current community I often play in we have a feature called "mod logs" where people can look up a name and it'll fetch results from the logs where the name is mentioned. Like if I enter "kiipa" I would get "kiipa banned Y for Z" or "Z kicked kiipa for Y". But that script isn't very efficient.

So I wanted to make my own, but in PHP. So I did.

How does it work?

It requires the server to restart once per day, preferably at 00:00 (because vanilla Minecraft doesn't log dates, only time the script adds today's date to the timestamp, and that the script runs. The script will go trough the latest.log for anything interesting (anything matching "ban", "unban", "kick" and so on), if it find something it'll parse the time, issuer, command, victim and additional arguments. The script will then insert everything it finds of interest into a MySQL table.

Then you have a front-end module that looks up names from the table. So far it's been super fast in the whole process (a few milliseconds).

Is it safe?

It uses PDO and prepared statement to void any and all attempt at SQLi.

What will the added

I will fix it up a little, possibly make or get someone to make a plugin that will stop the server, execute the script and then start the server.

A plugin is needed to restart the server at 00:00 and run the insert script. And a plugin to log victims full name. For example if I do "/ban fred" on a bukkit server that uses something like essentials it will ban "fredrick" and "1337fredrick", but log as "/ban fred" and not "/ban fredrick".

How can I get it?
PM me and I'll send of the scripts and help you set it up. All of the code is well commented and it's easy to set up the MySQL details (which so far is the only thing that's customize able).

If you don't like the design feel free to make it prettier and personalized to your own preference. Currently the results are displayed in a table. So it's easy to write up some CSS to style it.
A preview:
Posted by Lurvik's Avatar
Lurvik
Level 1 : New Miner
0

Create an account or sign in to comment.

2

1
12/14/2013 10:37 pm
Level 1 : New Miner
Lurvik
Lurvik's Avatar
I'm up to suggestions.

Currently you can search for "iipa" and it'll find issuers and victims called "kiipa", for example.

I can add some features that you have to log in to see them and ability to add and remove commands to search for in a web interface. Right now I'm gonna sleep though. Been writing on this script since 16:00 and now it's almost 04:40.

---

So, now I worked on the script. Made it customizable and noob-friendly.



  • The script reads the mainConfig.json file (the little black box) for commands. It saves the values.

  • The script reads trough the whole latest.log file for any line that contains any of the commands. I spent a lot of time making a method that would read the config file, save all of the contents as an array and then call a method that takes a haystack and a needle. The needle can be a string or an array (or multidimensional array). The recursion was the thing that has taken me the longest so far.

  • After that the script has the lines that are of interest (displayed in the background).

  • The script removes irrelevant data ("[Server thread/INFO]: " and "issued server command :/")

  • Now the script has the time, issuer, victim and additional parameters. It splits the string and fixes the timestamp (removes brackets and add today's date).

  • The data is inserted into the MySQL table (the details for the MySQL server, including table, is easy to set (the conf.json you see behind the little black window)).

  • The script exists.


When searching it just check if the inserted username isn't too long or short, then with a simple query selects relevant data. It uses LIKE statements to find victim and issuer, so you can search for "kiip" to find any commands "kiipa" has used OR any commands where "kiipa" has been the victim.

I will try to upload this project to github soon.
1
12/14/2013 10:34 pm
Level 35 : Artisan Architect
xer0
xer0's Avatar
Very nice, hope to see this get even better.
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome