Guest User

mcraft.rcon.php

a guest
Mar 1st, 2021
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. <?php
  2. include_once('mcraftrcon.class.php');
  3.  
  4. /*
  5.  
  6. Mineсraft RCON v1.0b (c) NC22
  7.  
  8. + mcraft.class.php by xPaw
  9.  
  10. и проверку входа под пользователем не забудьте добавить ;)
  11.  
  12. */
  13.  
  14. $server = "127.0.0.1";
  15. $rconPort = 25578;
  16. $rconPass = "thlsaphozaspapiro8in";
  17.  
  18. function GetUserListHTML($result) {
  19. global $rcon;
  20.  
  21. $str = trim($result);
  22. $str = str_replace(array("\r\n", "\n", "\r"),'', $str);
  23.  
  24. $names = explode(', ',substr($str, 19));
  25.  
  26. if (!empty($names)) for($i=0;$i<sizeof($names);$i++) trim($names[$i]);
  27.  
  28. if ($names[0]=='') unset($names);
  29.  
  30. if (empty($names)) return array('<p>Сервер пуст</p>','');
  31.  
  32. $html = '';
  33. $script = '';
  34.  
  35. for($i=0;$i<sizeof($names);$i++) {
  36.  
  37. $script .= 'parent.addNickButton("'.$names[$i].'",'.$i.');';
  38. $html .= '<p><a href="#" id="nickButton'.$i.'">'.$names[$i].'</a></p>';
  39.  
  40. }
  41.  
  42.  
  43. return array($html,$script);
  44. }
  45.  
  46. if (empty($_POST['command']) and empty($_POST['userlist'])) exit('<script>parent.showResult("command is empty");</script>');
  47.  
  48. try
  49. {
  50. $rcon = new MinecraftRcon;
  51. $rcon->Connect( $server, $rconPort, $rconPass);
  52.  
  53. if (!empty($_POST['userlist'])) {
  54.  
  55. $page = GetUserListHTML($rcon->Command('list'));
  56. exit("<script>parent.document.getElementById('users_online').innerHTML = '".$page[0]."'; ".$page[1]."</script>");
  57.  
  58. }
  59.  
  60. $command = trim($_POST['command']);
  61. $command = str_replace(array("\r\n", "\n", "\r"),'', $command);
  62. $command = preg_replace('| +|', ' ', $command);
  63.  
  64.  
  65. $str = trim(htmlspecialchars($rcon->Command($command), ENT_QUOTES ));
  66.  
  67. $str = str_replace(array("\r\n", "\n", "\r"),'', $str);
  68.  
  69. if (!strncmp($command,'say',3) and strlen($str) > 2) $str = substr($str, 2);
  70. if (!strncmp(substr($str, 2),'Usage',5)) $str = substr($str, 2);
  71.  
  72. $str = str_replace(array(chr(167)), '', $str);
  73.  
  74. echo '<script>parent.showResult("'.$str.'");</script>';
  75.  
  76. }
  77. catch( MinecraftRconException $e )
  78. {
  79. echo '<script>parent.showResult("'.$e->getMessage( ).'");</script>';
  80. }
  81.  
  82. $rcon->Disconnect( );
  83.  
  84. ?>
Advertisement
Add Comment
Please, Sign In to add comment