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"); }
$message = $_REQUEST['message']; } if (isset($_POST['action'])) { if ($_POST['action'] == "link" && isset($_POST['filename'])) { $result = minecraftServerLink($_REQUEST['id'], $_POST['filename'], "version", ""); if ($result === true) { $message = "Server version linked successfully with repository."; } else { $message = $result; } } else { if ($_POST['action'] == "upload" && isset($_POST['upload'])) { $result = minecraftServerUpload($_REQUEST['id'], $_FILES, "version"); if ($result === true) { $message = "Server version uploaded successfully."; } else { $message = $result; } } } if (!isset($_SESSION['noredirect'])) { header("Location: version.php?id=" . $_REQUEST['id'] . "&message=" . urlencode($message)); return; } } # get the versions in repository $versions = minecraftServerList($_REQUEST['id'], "versions"); get_page("version", "minecraft", array('service_id' => $_REQUEST['id'], 'versions' => $versions, 'message' => $message)); } else { header("Location: ../panel/"); }
if ($result === true) { $message = "World backed up successfully."; } else { $message = $result; } } else { if ($_POST['action'] == "remove" && isset($_POST['filename'])) { minecraftServerDelete($_REQUEST['id'], $_POST['filename'], "."); $message = "Backup deleted."; } else { if ($_POST['action'] == "restore" && isset($_POST['filename'])) { $result = minecraftRestoreWorld($_REQUEST['id'], removeExtension($_POST['filename'])); if ($result === true) { $message = "The world has been restored based on the backup successfully."; } else { $message = $result; } } } } if (!isset($_SESSION['noredirect'])) { header("Location: backup.php?id=" . $_REQUEST['id'] . "&message=" . urlencode($message)); return; } } //list backups to show which ones can be deleted or restored $backups = minecraftServerList($_REQUEST['id'], "backups"); get_page("backup", "minecraft", array('service_id' => $_REQUEST['id'], 'backups' => $backups, 'message' => $message)); } else { header("Location: ../panel/"); }
$message = "Plugin linked successfully with repository."; } else { $message = $result; } } else { if ($_POST['action'] == "upload" && isset($_POST['upload'])) { $result = minecraftServerUpload($_REQUEST['id'], $_FILES); if ($result === true) { $message = "Plugin uploaded successfully."; } else { $message = $result; } } else { if ($_POST['action'] == "remove" && isset($_POST['filename'])) { minecraftServerDelete($_REQUEST['id'], $_POST['filename']); $message = "Plugin deleted."; } } } if (!isset($_SESSION['noredirect'])) { header("Location: plugin.php?id=" . $_REQUEST['id'] . "&message=" . urlencode($message)); return; } } # get the current repository and user files $repositoryPlugins = minecraftServerList($_REQUEST['id'], "repository"); $userPlugins = minecraftServerList($_REQUEST['id'], "plugins"); get_page("plugin", "minecraft", array('service_id' => $_REQUEST['id'], 'repositoryPlugins' => $repositoryPlugins, 'userPlugins' => $userPlugins, 'message' => $message)); } else { header("Location: ../panel/"); }