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.
07-28-2012, 12:34 (This post was last modified: 07-28-2012, 12:38 by narkos.)
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':
[code=php]
<?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();
?>
[/code]
Source code 'Parser.class.php':
[code=php]
<?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(array_key_exists($player_info[1], $this->players))
{
// 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
if (!feof($file)) {
echo "Error: fgets() failed\n";
}
// Close the file
fclose($file);
}
}
public function show()
{
// Loop the players array
foreach($this->players as $key => $value)
{
// Print the XUID key
echo '<strong>'.$key.'</strong><br />';
// Loop the names linked to the XUID
foreach($this->players[$key] as $name)
{
// Print Names
echo ' - '.$name.'<br />';
}
echo '<br />';
}
}
public function __destruct()
{
}
}
?>
[/code]
[Edit]
In the second block of code, at the line 59 the are interpreted... why????? it is between [kode=php] [/kode]