Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $commandList = array(
- 'Broadcast' => array(
- script => 'post.sh',
- command => 'broadcast',
- label => array ('Message'),
- message => 'Executed: /{cmd} {value}',
- ),
- 'Say' => array(
- script => 'post.sh',
- command => 'say',
- label => array ('Message'),
- message => 'Executed: /{cmd} {value}',
- ),
- 'AdminChat' => array(
- script => 'post.sh',
- command => 'a',
- label => array ('Message'),
- message => 'Executed: /{cmd} {value}',
- ),
- 'Msg' => array(
- script => 'post.sh',
- command => 'msg',
- label => array ('Player', 'Message'),
- message => 'Executed: /{cmd} {value}',
- ),
- 'Give' => array(
- script => 'post.sh',
- command => 'give',
- label => array ('Player', 'Item', 'Amount'),
- message => 'Executed: /{cmd} {value}',
- ),
- 'Time' => array(
- script => 'post.sh',
- command => 'time',
- label => array ('Time', 'World/All'),
- message => 'Executed: /{cmd} {value}',
- ),
- 'TP' => array(
- script => 'post.sh',
- command => 'tp',
- label => array ('Player', 'ToPlayer'),
- message => 'Executed: /{cmd} {value}',
- ),
- 'Kick' => array(
- script => 'post.sh',
- command => 'kick',
- label => array ('Player', 'Reason'),
- message => 'Executed: /{cmd} {value}',
- ),
- 'Ban' => array(
- script => 'post.sh',
- command => 'ban',
- label => array ('Player', 'Reason'),
- message => 'Executed: /{cmd} {value}',
- ),
- 'Unban' => array(
- script => 'post.sh',
- command => 'unban',
- label => array ('Player'),
- message => 'Executed: /{cmd} {value}',
- ),
- 'OP' => array(
- script => 'post.sh',
- command => 'op',
- label => array ('Player'),
- message => 'Executed: /{cmd} {value}',
- ),
- 'DeOP' => array(
- script => 'post.sh',
- command => 'deop',
- label => array ('Player'),
- message => 'Executed: /{cmd} {value}',
- ),
- 'GC' => array(
- script => 'post.sh',
- command => 'gc',
- label => array (),
- message => 'Executed: /{cmd} {value}',
- ),
- 'StopLag' => array(
- script => 'post.sh',
- command => 'stoplag',
- label => array (),
- message => 'Executed: /{cmd} {value}',
- ),
- 'UnStopLag' => array(
- script => 'post.sh',
- command => 'stoplag -c',
- label => array (),
- message => 'Executed: /{cmd} {value}',
- ),
- 'List' => array(
- script => 'post.sh',
- command => 'list',
- label => array (),
- message => 'Executed: /{cmd} {value}',
- ),
- 'SelectWorld' => array(
- script => 'post.sh',
- command => 'manselect',
- label => array ('World'),
- message => 'Executed: /{cmd} {value}',
- ),
- 'ListGroups' => array(
- script => 'post.sh',
- command => 'listgroups',
- label => array (),
- message => 'Executed: /{cmd} {value}',
- ),
- 'ManUAdd' => array(
- script => 'post.sh',
- command => 'manuadd',
- label => array ('Player', 'Group'),
- message => 'Executed: /{cmd} {value}',
- ),
- 'Restart' => array(
- script => 'restart.sh',
- command => '',
- label => array (),
- message => 'Triggered soft restart, 15 second warning.',
- ),
- 'FullRestart' => array(
- script => 'fullrestart.sh',
- command => '',
- label => array (),
- message => 'Triggered hard restart. May cause rollback! Allow 60 seconds before connecting.',
- ),
- );
- $cmd = escapeshellcmd($_GET['cmd']);
- $selectedCmd = escapeshellcmd($_GET['selectedcmd']);
- $inputBoxes = "";
- $message = '<span class="ok">Select a command from the box below</span>';
- $commandOptions = "";
- foreach ($commandList as $command => $data) {
- $commandOptions .= '<option value="' . $command . '"' . ($command == $cmd ? " selected" : ""). '>' . $command . '</option>';
- }
- //Was a valid command selected
- if (isset($commandList[$cmd])) {
- if ($selectedCmd == $cmd) {
- $continue = 1;
- $message = "";
- foreach ($commandList[$cmd]['label'] as $index => $label) {
- if ((!isset($_GET['value'][$index])) || ($_GET['value'][$index] == "")) {
- $message .= '<span class="error">You need to give a value for ' . $label . '</span><br />';
- $continue = 0;
- }
- }
- if ($continue) {
- $value = implode(' ',$_GET['value']);
- $script = $commandList[$cmd]['script'];
- $command = $commandList[$cmd]['command'];
- $exec = 'sudo -u mco /home/mco/mc/scripts/'. $script . ' "' . $command . ' ' . escapeshellcmd($value) . '"';
- shell_exec($exec);
- $message = '<span class="ok">' . $commandList[$cmd]['message'] . '</span>';
- $message = str_replace(array('{cmd}','{value}'),array($command,$value),$message);
- }
- } else {
- $message = '<span class="warn">Complete the required fields, or choose a different command. Don\'t forget to hit submit!</span>';
- }
- foreach ($commandList[$cmd]['label'] as $index => $label) {
- $inputBoxes .= '<span class="label">'.$label . ': </span> <input name="value[]" '.($index == 0 ? 'autofocus' : '').' /><br />';
- }
- } elseif ($cmd) {
- $message = '<span class="error">Invalid Command</span>';
- }
- ?>
- <html>
- <head>
- <title>Command me!</title>
- <style>
- span.label{display:inline-block;width:100px;}
- span.error{color:red}
- span.warn{color:orange}
- span.ok{color:green}
- input,select{display:inline-block;width:150px;}
- </style>
- </head>
- <body>
- <h1>Perform a command on the server...</h1>
- <div style="height:250px; padding: 5px">
- <div style="height:70px; width:50%; padding-left: 5px; border: 1px dashed gray">
- <p><?php print $message; ?></p>
- </div><br />
- <form style="height:140px; width:50%; padding-left: 5px; border: 1px dashed gray">
- <input type="hidden" name="selectedcmd" value="<?php echo $cmd; ?>" />
- <span class="label">Command:</span>
- <select name="cmd">
- <?php print $commandOptions; ?>
- </select><br />
- <?php print $inputBoxes; ?>
- <input type="submit"/>
- </form>
- </div>
- <iframe src="tail.php?tail=25" width="95%" height="550px"/>
- </body>
- </html>
Add Comment
Please, Sign In to add comment