Hi guys,
I am wondering if someone can help me out. I am after a MW3 console log parser that will extract players GUIDs / XUIDs and their alias.
I would prefer for it to be web based where I can either upload or point to FTP location to the log file and then parser it.
In additon a search feature to allow searches of player names.
eg Cyanide,
Would punch out my GUID and a list of aliases I have used.
Any help is more than appreciated.
Cheers
Hello,
I made a little parser, i hope this is what you want...
It uses the lines of player connection, disconnection and spawn, if you need other modify the code or ask me...
Source code 'index.php':
PHP Code
<?php
// Include the parser class
include_once('Parser.class.php');
// Instantiate the parser with the logfile location
$Parser = new Parser('logs/console.log');
// Show the final results
$Parser->show();
?>
Source code 'Parser.class.php':
PHP Code
<?php
class Parser {
// Store the players // The keys are the XUID and the value is an array that contains the names
private $players = array();
public function __construct($log_file)
{
// Open the log file
$file = @fopen($log_file, "r"); // If fopen returned true
if ($file) {
// Loop the file
while (($line = fgets($file, 4096)) !== false) { // If the line is a Player connection, spawn or disconnect
if (preg_match("#\[[0-9]{2}:[0-9]{2}:[0-9]{2}\] Connect#", $line) || preg_match("#\[[0-9]{2}:[0-9]{2}:[0-9]{2}\] Spawn#", $line) || preg_match("#\[[0-9]{2}:[0-9]{2}:[0-9]{2}\] Disconnect#", $line)) {
// Explode the line to get the infos
$player_info = explode(';', $line); // If the player array contains the xuid
{
// If the name is not already stored
if (!in_array($player_info[3] ,$this->players[$player_info[1]])) {
// Store the name
$this->players[$player_info[1]][] = $player_info[3];
}
}
else
{
// Add the XUID key
$this->players[$player_info[1]] = array(); // Store the name
$this->players[$player_info[1]][] = $player_info[3];
}
}
}
// If failed
echo "Error: fgets() failed\n"; }
// Close the file
}
}
public function show()
{
// Loop the players array
foreach($this->players as $key => $value)
{
// Print the XUID key
echo '<strong>'.$key.'</strong>'; // Loop the names linked to the XUID
foreach($this->players[$key] as $name)
{
// Print Names
}
}
}
public function __destruct()
{
}
}
?>
[Edit]
In the second block of code, at the line 59 the are interpreted... why????? it is between [kode=php] [/kode]
Narkos,
This is just fantastic,
I appreciate this so much. Cheers.