function minecraftBackupWorld($service_id, $label) { global $config; $label = stripAlphaNumeric($label); if (empty($label) || strlen($label) > 32) { $label = uid(5); } //get the identifier $id = stripAlphaNumeric(getServiceParam($service_id, "id")); if ($id === false) { return "Error: the identifier for this service is not set."; } //make sure didn't exceed limit on backups $backupLimit = getServiceParam($service_id, "blimit"); if ($backupLimit === false) { $backupLimit = 12; } $num_backups = count(minecraftServerList($service_id, "backups")); if ($num_backups > $backupLimit) { return "You have exceeded the limit on the number of backups. Please contact support."; } //try to turn off saving and do a save of the current world state // don't worry if this fails; if it fails the server probably isn't running... $result = minecraftCommand($service_id, array("save-off", "save-all")); sleep(2); //wait for anything to finish //copy the world directory to temporary directory $jail = jailEnabled($service_id); if ($jail) { jailFileMove($service_id, "world", "world_tmp", "cp -r"); } else { recursiveCopy($config['minecraft_path'] . $id . "/world", $config['minecraft_path'] . $id . "/world_tmp"); } //zip the directory simply, delete the temporary directory if ($jail) { jailExecute($service_id, "cd " . escapeshellarg(jailPath($service_id)) . " && zip -r " . escapeshellarg(jailPath($service_id) . $label . ".uxbakzip") . " world_tmp"); jailExecute($service_id, "rm -r " . escapeshellarg(jailPath($service_id) . "world_tmp")); } else { exec("cd " . escapeshellarg($config['minecraft_path'] . $id) . " && zip -r " . escapeshellarg($config['minecraft_path'] . $id . "/" . $label . ".uxbakzip") . " world_tmp"); delete_directory($config['minecraft_path'] . $id . "/world_tmp"); } minecraftCommand($service_id, "save-on"); }
<?php include "../include/common.php"; include "../config.php"; include "../include/session.php"; include "../include/dbconnect.php"; include "../include/account.php"; include "../include/minecraft.php"; if (isset($_SESSION['account_id']) && isset($_REQUEST['id']) && is_numeric($_REQUEST['id']) && isset($_SESSION['is_' . $_REQUEST['id'] . '_minecraft'])) { $message = ""; if (isset($_POST['command'])) { $result = minecraftCommand($_REQUEST['id'], $_POST['command']); if ($result !== true) { $message = $result; } else { $message = "Command sent successfully!"; } } $log = minecraftGetLog($_REQUEST['id']); get_page("log", "minecraft", array('service_id' => $_REQUEST['id'], 'log' => $log, 'message' => $message)); } else { header("Location: ../panel/"); }