ItsMods

Full Version: MW3 console log Parser
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
  1. <?php
  2. // Include the parser class
  3. include_once('Parser.class.php');
  4.  
  5. // Instantiate the parser with the logfile location
  6. $Parser = new Parser('logs/console.log');
  7.  
  8. // Show the final results
  9. $Parser->show();
  10. ?>


Source code 'Parser.class.php':
PHP Code
  1. <?php
  2. class Parser {
  3.  
  4. // Store the players // The keys are the XUID and the value is an array that contains the names
  5. private $players = array();
  6.  
  7. public function __construct($log_file)
  8. {
  9. // Open the log file
  10. $file = @fopen($log_file, "r");
  11. // If fopen returned true
  12. if ($file) {
  13. // Loop the file
  14. while (($line = fgets($file, 4096)) !== false) {
  15. // If the line is a Player connection, spawn or disconnect
  16. 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))
  17. {
  18. // Explode the line to get the infos
  19. $player_info = explode(';', $line);
  20. // If the player array contains the xuid
  21. if(array_key_exists($player_info[1], $this->players))
  22. {
  23. // If the name is not already stored
  24. if (!in_array($player_info[3] ,$this->players[$player_info[1]]))
  25. {
  26. // Store the name
  27. $this->players[$player_info[1]][] = $player_info[3];
  28. }
  29. }
  30. else
  31. {
  32. // Add the XUID key
  33. $this->players[$player_info[1]] = array();
  34. // Store the name
  35. $this->players[$player_info[1]][] = $player_info[3];
  36. }
  37. }
  38. }
  39. // If failed
  40. if (!feof($file)) {
  41. echo "Error: fgets() failed\n";
  42. }
  43. // Close the file
  44. fclose($file);
  45. }
  46. }
  47.  
  48. public function show()
  49. {
  50. // Loop the players array
  51. foreach($this->players as $key => $value)
  52. {
  53. // Print the XUID key
  54. echo '<strong>'.$key.'</strong>';
  55. // Loop the names linked to the XUID
  56. foreach($this->players[$key] as $name)
  57. {
  58. // Print Names
  59. echo '   - '.$name.'';
  60. }
  61. echo '';
  62. }
  63. }
  64.  
  65. public function __destruct()
  66. {
  67. }
  68. }
  69. ?>


[Edit]
In the second block of code, at the line 59 the &nbsp; are interpreted... why????? it is between [kode=php] [/kode]
Narkos,
This is just fantastic,
I appreciate this so much. Cheers.