Created
May 7, 2011 21:12
-
-
Save axiixc/960843 to your computer and use it in GitHub Desktop.
Quick and dirty, but it works. Scans your minecraft's server.log file and pulls out some stats.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php # axiixc.com | |
$file = 'server.log'; | |
$contents = file($file); | |
$regexp_arr = array( | |
'message' => '/] <([A-Za-z0-9]+)>/', | |
'login' => '/] ([A-Za-z0-9]+) \[/', | |
'give' => '/] [A-Za-z0-9]+: Giving ([A-Za-z0-9]+) some/' | |
); | |
foreach ($regexp_arr as $argname => $regexp) { | |
$mMatches = array(); | |
foreach ($contents as $line) { | |
if (preg_match($regexp, $line, $matches)) { | |
$mMatches[$matches[1]]++; | |
} | |
} | |
printf("-- %s --\n", $argname); | |
arsort($mMatches); | |
foreach ($mMatches as $userName => $count) { | |
printf("%5d\t%s\n", $count, $userName); | |
} | |
print("\n\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment