Jump to content

Berserk

New Members
  • Posts

    3
  • Joined

  • Last visited

Berserk's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. ... the server details that are retrieve using the code above I want to display them into the description of a forum
  2. that code gives this result In phpbb every forum allows you to put a description to it basically in want that in the description to be displayed the result of the code presented above
  3. I'm not sure if i post this in the wrong section i have this php code which retrives the server information and display them within a website <?php error_reporting(E_ALL); ini_set('display_errors', 1); require_once __DIR__ . '/vendor/autoload.php'; // Include Composer autoloader use Knik\GRcon\GRcon; use Knik\GRcon\Protocols\GoldSourceAdapter; // Server details $serverHost = '54.36.237.158'; $serverPort = '27015'; $rconPassword = 'test'; // Replace with your actual RCON password // Retry parameters $maxRetries = 3; // Maximum number of retry attempts $retryDelay = 2; // Delay in seconds between retry attempts for ($retry = 0; $retry < $maxRetries; $retry++) { try { // Create GoldSource RCON adapter $adapter = new GoldSourceAdapter([ 'host' => $serverHost, 'port' => $serverPort, 'password' => $rconPassword, ]); // Initialize RCON connection $rcon = new GRcon($adapter); // Attempt to execute RCON command to get server info $response = $rcon->execute('status'); // Parse server response to extract information $serverInfo = []; preg_match('/hostname:\s+(.+)/', $response, $matches); if (isset($matches[1])) { $serverInfo['hostname'] = $matches[1]; } preg_match('/map\s+:\s+(.+)/', $response, $matches); if (isset($matches[1])) { // Remove the "at: 0 x, 0 y, 0 z" part $serverInfo['map'] = preg_replace('/\sat:\s[0-9]+ x,\s[0-9]+ y,\s[0-9]+ z/', '', $matches[1]); } preg_match('/players\s+:\s+(\d+)/', $response, $matches); if (isset($matches[1])) { $serverInfo['playerCount'] = intval($matches[1]); } // Display server information echo "<h2>Server Name: " . $serverInfo['hostname'] . "</h2>"; echo "<h3>Current Map: " . $serverInfo['map'] . "</h3>"; echo "<h3>Player Count: " . $serverInfo['playerCount'] . "</h3>"; break; // Connection and query were successful, exit retry loop } catch (Throwable $e) { echo "Error: " . $e->getMessage() . "<br>"; if ($retry < $maxRetries - 1) { sleep($retryDelay); // Wait before retrying } else { echo "Unable to connect after $maxRetries retries."; } } } ?> the code is working fine , however i want to include this script in a phpbb forum description something i can't figure out at all
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.