Guest User

Untitled

a guest
Jan 22nd, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.13 KB | None | 0 0
  1. <?php
  2. $commandList = array(
  3. 'Broadcast' => array(
  4. script => 'post.sh',
  5. command => 'broadcast',
  6. label => array ('Message'),
  7. message => 'Executed: /{cmd} {value}',
  8. ),
  9. 'Say' => array(
  10. script => 'post.sh',
  11. command => 'say',
  12. label => array ('Message'),
  13. message => 'Executed: /{cmd} {value}',
  14. ),
  15. 'AdminChat' => array(
  16. script => 'post.sh',
  17. command => 'a',
  18. label => array ('Message'),
  19. message => 'Executed: /{cmd} {value}',
  20. ),
  21. 'Msg' => array(
  22. script => 'post.sh',
  23. command => 'msg',
  24. label => array ('Player', 'Message'),
  25. message => 'Executed: /{cmd} {value}',
  26. ),
  27. 'Give' => array(
  28. script => 'post.sh',
  29. command => 'give',
  30. label => array ('Player', 'Item', 'Amount'),
  31. message => 'Executed: /{cmd} {value}',
  32. ),
  33. 'Time' => array(
  34. script => 'post.sh',
  35. command => 'time',
  36. label => array ('Time', 'World/All'),
  37. message => 'Executed: /{cmd} {value}',
  38. ),
  39. 'TP' => array(
  40. script => 'post.sh',
  41. command => 'tp',
  42. label => array ('Player', 'ToPlayer'),
  43. message => 'Executed: /{cmd} {value}',
  44. ),
  45. 'Kick' => array(
  46. script => 'post.sh',
  47. command => 'kick',
  48. label => array ('Player', 'Reason'),
  49. message => 'Executed: /{cmd} {value}',
  50. ),
  51. 'Ban' => array(
  52. script => 'post.sh',
  53. command => 'ban',
  54. label => array ('Player', 'Reason'),
  55. message => 'Executed: /{cmd} {value}',
  56. ),
  57. 'Unban' => array(
  58. script => 'post.sh',
  59. command => 'unban',
  60. label => array ('Player'),
  61. message => 'Executed: /{cmd} {value}',
  62. ),
  63. 'OP' => array(
  64. script => 'post.sh',
  65. command => 'op',
  66. label => array ('Player'),
  67. message => 'Executed: /{cmd} {value}',
  68. ),
  69. 'DeOP' => array(
  70. script => 'post.sh',
  71. command => 'deop',
  72. label => array ('Player'),
  73. message => 'Executed: /{cmd} {value}',
  74. ),
  75. 'GC' => array(
  76. script => 'post.sh',
  77. command => 'gc',
  78. label => array (),
  79. message => 'Executed: /{cmd} {value}',
  80. ),
  81. 'StopLag' => array(
  82. script => 'post.sh',
  83. command => 'stoplag',
  84. label => array (),
  85. message => 'Executed: /{cmd} {value}',
  86. ),
  87. 'UnStopLag' => array(
  88. script => 'post.sh',
  89. command => 'stoplag -c',
  90. label => array (),
  91. message => 'Executed: /{cmd} {value}',
  92. ),
  93. 'List' => array(
  94. script => 'post.sh',
  95. command => 'list',
  96. label => array (),
  97. message => 'Executed: /{cmd} {value}',
  98. ),
  99. 'SelectWorld' => array(
  100. script => 'post.sh',
  101. command => 'manselect',
  102. label => array ('World'),
  103. message => 'Executed: /{cmd} {value}',
  104. ),
  105. 'ListGroups' => array(
  106. script => 'post.sh',
  107. command => 'listgroups',
  108. label => array (),
  109. message => 'Executed: /{cmd} {value}',
  110. ),
  111. 'ManUAdd' => array(
  112. script => 'post.sh',
  113. command => 'manuadd',
  114. label => array ('Player', 'Group'),
  115. message => 'Executed: /{cmd} {value}',
  116. ),
  117. 'Restart' => array(
  118. script => 'restart.sh',
  119. command => '',
  120. label => array (),
  121. message => 'Triggered soft restart, 15 second warning.',
  122. ),
  123. 'FullRestart' => array(
  124. script => 'fullrestart.sh',
  125. command => '',
  126. label => array (),
  127. message => 'Triggered hard restart. May cause rollback! Allow 60 seconds before connecting.',
  128. ),
  129. );
  130.  
  131. $cmd = escapeshellcmd($_GET['cmd']);
  132. $selectedCmd = escapeshellcmd($_GET['selectedcmd']);
  133. $inputBoxes = "";
  134. $message = '<span class="ok">Select a command from the box below</span>';
  135. $commandOptions = "";
  136. foreach ($commandList as $command => $data) {
  137. $commandOptions .= '<option value="' . $command . '"' . ($command == $cmd ? " selected" : ""). '>' . $command . '</option>';
  138. }
  139. //Was a valid command selected
  140. if (isset($commandList[$cmd])) {
  141. if ($selectedCmd == $cmd) {
  142. $continue = 1;
  143. $message = "";
  144. foreach ($commandList[$cmd]['label'] as $index => $label) {
  145. if ((!isset($_GET['value'][$index])) || ($_GET['value'][$index] == "")) {
  146. $message .= '<span class="error">You need to give a value for ' . $label . '</span><br />';
  147. $continue = 0;
  148. }
  149. }
  150. if ($continue) {
  151. $value = implode(' ',$_GET['value']);
  152. $script = $commandList[$cmd]['script'];
  153. $command = $commandList[$cmd]['command'];
  154. $exec = 'sudo -u mco /home/mco/mc/scripts/'. $script . ' "' . $command . ' ' . escapeshellcmd($value) . '"';
  155.  
  156. shell_exec($exec);
  157. $message = '<span class="ok">' . $commandList[$cmd]['message'] . '</span>';
  158. $message = str_replace(array('{cmd}','{value}'),array($command,$value),$message);
  159. }
  160. } else {
  161. $message = '<span class="warn">Complete the required fields, or choose a different command. Don\'t forget to hit submit!</span>';
  162. }
  163. foreach ($commandList[$cmd]['label'] as $index => $label) {
  164. $inputBoxes .= '<span class="label">'.$label . ': </span> <input name="value[]" '.($index == 0 ? 'autofocus' : '').' /><br />';
  165. }
  166. } elseif ($cmd) {
  167. $message = '<span class="error">Invalid Command</span>';
  168. }
  169. ?>
  170. <html>
  171. <head>
  172. <title>Command me!</title>
  173. <style>
  174. span.label{display:inline-block;width:100px;}
  175. span.error{color:red}
  176. span.warn{color:orange}
  177. span.ok{color:green}
  178. input,select{display:inline-block;width:150px;}
  179. </style>
  180. </head>
  181. <body>
  182. <h1>Perform a command on the server...</h1>
  183. <div style="height:250px; padding: 5px">
  184. <div style="height:70px; width:50%; padding-left: 5px; border: 1px dashed gray">
  185. <p><?php print $message; ?></p>
  186. </div><br />
  187. <form style="height:140px; width:50%; padding-left: 5px; border: 1px dashed gray">
  188. <input type="hidden" name="selectedcmd" value="<?php echo $cmd; ?>" />
  189. <span class="label">Command:</span>
  190. <select name="cmd">
  191. <?php print $commandOptions; ?>
  192. </select><br />
  193. <?php print $inputBoxes; ?>
  194. <input type="submit"/>
  195. </form>
  196. </div>
  197. <iframe src="tail.php?tail=25" width="95%" height="550px"/>
  198. </body>
  199. </html>
Add Comment
Please, Sign In to add comment