Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include_once('mcraftrcon.class.php');
- /*
- Mineсraft RCON v1.0b (c) NC22
- + mcraft.class.php by xPaw
- и проверку входа под пользователем не забудьте добавить ;)
- */
- $server = "127.0.0.1";
- $rconPort = 25578;
- $rconPass = "thlsaphozaspapiro8in";
- function GetUserListHTML($result) {
- global $rcon;
- $str = trim($result);
- $str = str_replace(array("\r\n", "\n", "\r"),'', $str);
- $names = explode(', ',substr($str, 19));
- if (!empty($names)) for($i=0;$i<sizeof($names);$i++) trim($names[$i]);
- if ($names[0]=='') unset($names);
- if (empty($names)) return array('<p>Сервер пуст</p>','');
- $html = '';
- $script = '';
- for($i=0;$i<sizeof($names);$i++) {
- $script .= 'parent.addNickButton("'.$names[$i].'",'.$i.');';
- $html .= '<p><a href="#" id="nickButton'.$i.'">'.$names[$i].'</a></p>';
- }
- return array($html,$script);
- }
- if (empty($_POST['command']) and empty($_POST['userlist'])) exit('<script>parent.showResult("command is empty");</script>');
- try
- {
- $rcon = new MinecraftRcon;
- $rcon->Connect( $server, $rconPort, $rconPass);
- if (!empty($_POST['userlist'])) {
- $page = GetUserListHTML($rcon->Command('list'));
- exit("<script>parent.document.getElementById('users_online').innerHTML = '".$page[0]."'; ".$page[1]."</script>");
- }
- $command = trim($_POST['command']);
- $command = str_replace(array("\r\n", "\n", "\r"),'', $command);
- $command = preg_replace('| +|', ' ', $command);
- $str = trim(htmlspecialchars($rcon->Command($command), ENT_QUOTES ));
- $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>parent.showResult("'.$str.'");</script>';
- }
- catch( MinecraftRconException $e )
- {
- echo '<script>parent.showResult("'.$e->getMessage( ).'");</script>';
- }
- $rcon->Disconnect( );
- ?>
Advertisement
Add Comment
Please, Sign In to add comment