<?php define('MQ_SERVER_ADDR', 'localhost'); define('MQ_SERVER_PORT', 25575); define('MQ_SERVER_PASS', 'lolrcontest'); define('MQ_TIMEOUT', 2); require __DIR__ . '/MinecraftRcon.class.php'; echo "<pre>"; try { $Rcon = new MinecraftRcon(); $Rcon->Connect(MQ_SERVER_ADDR, MQ_SERVER_PORT, MQ_SERVER_PASS, MQ_TIMEOUT); $Data = $Rcon->Command("say Hello from xPaw's minecraft rcon implementation."); if ($Data === false) { throw new MinecraftRconException("Failed to get command result."); } else { if (StrLen($Data) == 0) { throw new MinecraftRconException("Got command result, but it's empty."); } } echo HTMLSpecialChars($Data); } catch (MinecraftRconException $e) { echo $e->getMessage(); } $Rcon->Disconnect();
if (Filter::input('save', 'post', 'bool')) { sqlConfigSet('rcon-serv', $game_server); sqlConfigSet('rcon-pass', $rcon_pass); sqlConfigSet('rcon-port', $rcon_port); } else { sqlConfigSet('rcon-serv', 0); } try { $rcon = new MinecraftRcon(); $rcon->Connect($game_server, $rcon_port, $rcon_pass); if ($userlist) { $page = GetUserListHTML($rcon->Command('list')); exit("<script>'.{$token}.'parent.GetById('users_online').innerHTML = '" . $page[0] . "'; " . $page[1] . "</script>"); } $command = str_replace(array("\r\n", "\n", "\r"), '', $command); $command = preg_replace('| +|', ' ', $command); $str = trim(TextBase::HTMLDestruct($rcon->Command($command))); $str = str_replace(array("\r\n", "\n", "\r"), '', $str); if (!strncmp($command, 'say', 3) and strlen($str) > 2) { $str = substr($str, 2); } if (!strncmp(substr($str, 2), 'Usage', 5)) { $str = substr($str, 2); } $str = str_replace(array(chr(167)), '', $str); echo '<script>' . $token . 'parent.showResult("' . $str . '");</script>'; } catch (MinecraftRconException $e) { echo '<script>' . $token . 'parent.showResult("' . $e->getMessage() . '");</script>'; } $rcon->Disconnect();