Advertisement
Guest User

cjf panel api

a guest
May 18th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.18 KB | None | 0 0
  1. ```PHP
  2. <?php
  3. include '../inc/config.php';
  4. include '../inc/functions.php';
  5. //include '../inc/sessions.php';
  6.  
  7. if ($GLOBALS['API_ENABLED'] != true) {
  8.     die('API Is Disabled');
  9. }
  10.  
  11. if (!isset($_GET['key'])) {
  12.     die ('You have not entered the API key - Use ?key=xxx');
  13. }
  14.  
  15. if ($_GET['key'] != $GLOBALS['API_KEY']) {
  16.     die ('Incorrect API Key');
  17. }
  18.  
  19. if(!isset($_GET['action'])) {
  20.     die('Incorrect parameters');
  21. }
  22.  
  23. $action = $_GET['action'];
  24. $ssh = initSSH();
  25.  
  26. switch ($action) {
  27.     case "resetmap":
  28.         $ssh->exec('nohup ' . $config['SCRIPTS_FOLDER'] . 'server_resetmap.sh ' . escapeshellarg($_GET['mapname']) . ' &');
  29.         echo "Map is resetting - This may take a few moments";
  30.         logAction("Map Reset to " . $_GET['mapname']);
  31.         break;
  32.     case "wipeflatlands":
  33.         $ssh->exec('nohup ' . $config['SCRIPTS_FOLDER'] . 'server_wipeflatlands.sh &');
  34.         echo "The flatlands are being wiped - Please wait a few moments";
  35.         logAction('Flatlands Wiped');
  36.         break;
  37.     case "start":
  38.         $ssh->exec('nohup ' . $config['SCRIPTS_FOLDER'] . 'server_start.sh &');
  39.         echo "Server start has been attempted";
  40.         logAction("Server Started");
  41.         break;
  42.     case "restart":
  43.         $ssh->exec('nohup ' . $config['SCRIPTS_FOLDER'] . 'server_restart.sh &');
  44.         logAction("Server Restarted");
  45.         break;
  46.     case "stop":
  47.         $ssh->exec('nohup ' . $config['SCRIPTS_FOLDER'] . 'server_stop.sh &');
  48.         echo "Server Restarted";
  49.         logAction("Server Stopped");
  50.         echo "Server stopped";
  51.         break;
  52.     case "cmd":
  53.         $ssh->exec('nohup ' . $config['SCRIPTS_FOLDER'] . 'server_cmd.sh ' . escapeshellarg($_GET['cmd']) . ' &');
  54.         echo "Command: " . $_GET['cmd'] . " Sent.";
  55.         logAction("Command: " . $_GET['cmd']);
  56.         break;
  57.     case "chat":
  58.         $chatmessage = $_GET['message'];
  59.         $username = $_SESSION['user']['username'];
  60.         $chatWithUsername = str_replace("{username}", $username, $config['CHAT_INTERFACE_OPTIONS']);
  61.         $chatComplete = str_replace("{chatmessage}", $chatmessage, $chatWithUsername);
  62.         $ssh->exec('nohup ' . $config['SCRIPTS_FOLDER'] . 'server_cmd.sh rawsay ' . $chatComplete . ' &');
  63.         echo "Sent message: " . $chatmessage;
  64.         logAction("Chat: " . $_GET['message']);
  65.         break;
  66.     case "adminchat":
  67.         $chatmessage = $_GET['message'];
  68.         $chatwithusername = str_replace("{username}", $_SESSION['user']['username'], $config['ADMIN_CHAT_INTERFACE_OPTIONS']);
  69.         $chatcomplete = str_replace("{chatmessage}", $chatmessage, $chatwithusername);
  70.         $ssh->exec('nohup ' . $config['SCRIPTS_FOLDER'] . 'server_cmd.sh consoleo ' . $chatcomplete . ' &');
  71.         echo "Sent message" . $chatmessage;
  72.         logAction("Adminchat: " . $_GET['message']);
  73.         break;
  74.     case "createuser":
  75.         $username = $_POST['username'];
  76.         $password = $_POST['password'];
  77.         $rank = $_POST['rank'];
  78.         addUser($username, $password, $rank);
  79.         logAction('User Added: ' . $username);
  80.         die('User has been added.');
  81.         break;
  82.     default:
  83.        die('Incorrect Parameters - If this is not expected please contact thecjgcjg.');
  84.        break;
  85. }
  86.  
  87. ?>```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement