From ebb7c52084aeaca9fd0e7d63752b77be454b27fe Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Feb 2026 00:47:39 +0000 Subject: [PATCH 01/10] Initial plan From d8a7f6803474a1d4084b3b149923435c95a39c95 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Feb 2026 00:51:24 +0000 Subject: [PATCH 02/10] Fix RCON player data field mapping issue Co-authored-by: Stage4000 <46226385+Stage4000@users.noreply.github.com> --- rcon_manager.php | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/rcon_manager.php b/rcon_manager.php index 7cb5373..acbad25 100644 --- a/rcon_manager.php +++ b/rcon_manager.php @@ -171,12 +171,33 @@ public function testConnection() { /** * Get list of online players - * @return array Array of players + * @return array Array of players with normalized field names */ public function getPlayers() { try { $this->connect(); - return $this->rcon->getPlayersArray(); + $rawPlayers = $this->rcon->getPlayersArray(); + + // Normalize field names to match expected structure + // RCON library returns: id, name, GUID, ping, ip + // Code expects: num, name, guid, ping, time + $normalizedPlayers = []; + foreach ($rawPlayers as $player) { + $name = isset($player['name']) && trim($player['name']) !== '' + ? $player['name'] + : 'Unknown'; + + $normalizedPlayers[] = [ + 'num' => $player['id'] ?? null, + 'name' => $name, + 'guid' => $player['GUID'] ?? $player['guid'] ?? null, + 'ping' => $player['ping'] ?? 'N/A', + 'time' => 'N/A', // RCON doesn't provide playtime + 'ip' => $player['ip'] ?? null + ]; + } + + return $normalizedPlayers; } catch (Exception $e) { throw new Exception("Failed to get player list: " . $e->getMessage()); } From b27708c667e32df7e05939486d3ff23823fdea82 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Feb 2026 00:52:13 +0000 Subject: [PATCH 03/10] Fix kickPlayer and banPlayer to use correct RCON field names Co-authored-by: Stage4000 <46226385+Stage4000@users.noreply.github.com> --- rcon_manager.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/rcon_manager.php b/rcon_manager.php index acbad25..254e3de 100644 --- a/rcon_manager.php +++ b/rcon_manager.php @@ -217,8 +217,10 @@ public function kickPlayer($identifier, $reason = '') { if (preg_match('/^\d{' . self::STEAM_ID64_LENGTH . '}$/', $identifier)) { $players = $this->rcon->getPlayersArray(); foreach ($players as $player) { - if (isset($player['guid']) && $player['guid'] === $identifier) { - $identifier = $player['num']; + // RCON library uses 'GUID' (uppercase), not 'guid' + if (isset($player['GUID']) && $player['GUID'] === $identifier) { + // RCON library uses 'id', not 'num' + $identifier = $player['id']; break; } } @@ -255,10 +257,12 @@ public function banPlayer($identifier, $reason = '', $duration = 0) { $guid = null; foreach ($players as $player) { - if ($player['num'] == $identifier || + // RCON library uses 'id', not 'num' + if ($player['id'] == $identifier || stripos($player['name'], $identifier) !== false) { - $guid = isset($player['guid']) ? $player['guid'] : null; - $identifier = $player['num']; + // RCON library uses 'GUID' (uppercase), not 'guid' + $guid = isset($player['GUID']) ? $player['GUID'] : null; + $identifier = $player['id']; break; } } From 1dbadbaa0eac901fa1ca73e7482f5fcf0a47cd02 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Feb 2026 00:53:02 +0000 Subject: [PATCH 04/10] Address code review feedback: improve error handling and remove unnecessary fallbacks Co-authored-by: Stage4000 <46226385+Stage4000@users.noreply.github.com> --- rcon_manager.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/rcon_manager.php b/rcon_manager.php index 254e3de..4b6b7fd 100644 --- a/rcon_manager.php +++ b/rcon_manager.php @@ -183,14 +183,21 @@ public function getPlayers() { // Code expects: num, name, guid, ping, time $normalizedPlayers = []; foreach ($rawPlayers as $player) { + // Handle missing or empty player name $name = isset($player['name']) && trim($player['name']) !== '' ? $player['name'] : 'Unknown'; + + // Validate that required fields exist + if (!isset($player['id']) || !isset($player['GUID'])) { + error_log("RCON: Incomplete player data received - missing id or GUID"); + continue; // Skip this player if critical data is missing + } $normalizedPlayers[] = [ - 'num' => $player['id'] ?? null, + 'num' => $player['id'], 'name' => $name, - 'guid' => $player['GUID'] ?? $player['guid'] ?? null, + 'guid' => $player['GUID'], 'ping' => $player['ping'] ?? 'N/A', 'time' => 'N/A', // RCON doesn't provide playtime 'ip' => $player['ip'] ?? null From c12900dd5622564fea80538536b06f65e7ef6719 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Feb 2026 00:54:25 +0000 Subject: [PATCH 05/10] Improve code readability and error logging Co-authored-by: Stage4000 <46226385+Stage4000@users.noreply.github.com> --- rcon_manager.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/rcon_manager.php b/rcon_manager.php index 4b6b7fd..af11ee9 100644 --- a/rcon_manager.php +++ b/rcon_manager.php @@ -183,16 +183,15 @@ public function getPlayers() { // Code expects: num, name, guid, ping, time $normalizedPlayers = []; foreach ($rawPlayers as $player) { - // Handle missing or empty player name - $name = isset($player['name']) && trim($player['name']) !== '' - ? $player['name'] - : 'Unknown'; - // Validate that required fields exist if (!isset($player['id']) || !isset($player['GUID'])) { - error_log("RCON: Incomplete player data received - missing id or GUID"); + $playerName = $player['name'] ?? 'unknown'; + error_log("RCON: Incomplete player data received - missing id or GUID for player: {$playerName}"); continue; // Skip this player if critical data is missing } + + // Handle missing or empty player name + $name = (!empty($player['name']) && trim($player['name']) !== '') ? $player['name'] : 'Unknown'; $normalizedPlayers[] = [ 'num' => $player['id'], From f9002ac6658250bed728c5e87b564a0faa8869c7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Feb 2026 01:01:04 +0000 Subject: [PATCH 06/10] Revert incorrect field mapping and use actual RCON library structure Co-authored-by: Stage4000 <46226385+Stage4000@users.noreply.github.com> --- rcon_manager.php | 47 +++++++++++++---------------------------------- 1 file changed, 13 insertions(+), 34 deletions(-) diff --git a/rcon_manager.php b/rcon_manager.php index af11ee9..1672163 100644 --- a/rcon_manager.php +++ b/rcon_manager.php @@ -171,39 +171,22 @@ public function testConnection() { /** * Get list of online players - * @return array Array of players with normalized field names + * @return array Array of players with enhanced fields */ public function getPlayers() { try { $this->connect(); - $rawPlayers = $this->rcon->getPlayersArray(); + $players = $this->rcon->getPlayersArray(); - // Normalize field names to match expected structure - // RCON library returns: id, name, GUID, ping, ip - // Code expects: num, name, guid, ping, time - $normalizedPlayers = []; - foreach ($rawPlayers as $player) { - // Validate that required fields exist - if (!isset($player['id']) || !isset($player['GUID'])) { - $playerName = $player['name'] ?? 'unknown'; - error_log("RCON: Incomplete player data received - missing id or GUID for player: {$playerName}"); - continue; // Skip this player if critical data is missing + // Add missing 'time' field that RCON doesn't provide + // RCON library already returns: num, name, id, ip, ipport, ping, guid + foreach ($players as &$player) { + if (!isset($player['time'])) { + $player['time'] = 'N/A'; // RCON doesn't track session time } - - // Handle missing or empty player name - $name = (!empty($player['name']) && trim($player['name']) !== '') ? $player['name'] : 'Unknown'; - - $normalizedPlayers[] = [ - 'num' => $player['id'], - 'name' => $name, - 'guid' => $player['GUID'], - 'ping' => $player['ping'] ?? 'N/A', - 'time' => 'N/A', // RCON doesn't provide playtime - 'ip' => $player['ip'] ?? null - ]; } - return $normalizedPlayers; + return $players; } catch (Exception $e) { throw new Exception("Failed to get player list: " . $e->getMessage()); } @@ -223,10 +206,8 @@ public function kickPlayer($identifier, $reason = '') { if (preg_match('/^\d{' . self::STEAM_ID64_LENGTH . '}$/', $identifier)) { $players = $this->rcon->getPlayersArray(); foreach ($players as $player) { - // RCON library uses 'GUID' (uppercase), not 'guid' - if (isset($player['GUID']) && $player['GUID'] === $identifier) { - // RCON library uses 'id', not 'num' - $identifier = $player['id']; + if (isset($player['guid']) && $player['guid'] === $identifier) { + $identifier = $player['num']; break; } } @@ -263,12 +244,10 @@ public function banPlayer($identifier, $reason = '', $duration = 0) { $guid = null; foreach ($players as $player) { - // RCON library uses 'id', not 'num' - if ($player['id'] == $identifier || + if ($player['num'] == $identifier || stripos($player['name'], $identifier) !== false) { - // RCON library uses 'GUID' (uppercase), not 'guid' - $guid = isset($player['GUID']) ? $player['GUID'] : null; - $identifier = $player['id']; + $guid = isset($player['guid']) ? $player['guid'] : null; + $identifier = $player['num']; break; } } From f9d0e66d5831740015ade174b6da5552282a4f4a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Feb 2026 01:02:40 +0000 Subject: [PATCH 07/10] Add unset after foreach with reference to prevent bugs Co-authored-by: Stage4000 <46226385+Stage4000@users.noreply.github.com> --- rcon_manager.php | 1 + 1 file changed, 1 insertion(+) diff --git a/rcon_manager.php b/rcon_manager.php index 1672163..ebd3d2a 100644 --- a/rcon_manager.php +++ b/rcon_manager.php @@ -185,6 +185,7 @@ public function getPlayers() { $player['time'] = 'N/A'; // RCON doesn't track session time } } + unset($player); // Break the reference to avoid unexpected behavior return $players; } catch (Exception $e) { From e2f1567f15a74c0213cc8ed105cfb3695f667c48 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Feb 2026 01:09:13 +0000 Subject: [PATCH 08/10] Add comprehensive RCON debug logging for troubleshooting Co-authored-by: Stage4000 <46226385+Stage4000@users.noreply.github.com> --- rcon_debug_log.php | 246 +++++++++++++++++++++++++++++++++++++++++++++ rcon_manager.php | 104 +++++++++++++++++++ 2 files changed, 350 insertions(+) create mode 100644 rcon_debug_log.php diff --git a/rcon_debug_log.php b/rcon_debug_log.php new file mode 100644 index 0000000..595e872 --- /dev/null +++ b/rcon_debug_log.php @@ -0,0 +1,246 @@ + + + +
+ + +View detailed RCON communication logs for debugging
+Visit the Active Players page to generate RCON traffic
+