<?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($_REQUEST['message'])) { $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; } } }
function minecraftServerUpload($service_id, $files, $type = "plugin") { global $config; if ($type != "plugin" && $type != "version") { return; } //get the identifier $id = stripAlphaNumeric(getServiceParam($service_id, "id")); if ($id === false) { return "Error: the identifier for this service is not set."; } //check if we're allowed to upload files $uploadable = getServiceParam($service_id, "uploadable"); if ($uploadable === false) { return "Uploads are not allowed for this service; instead, try using the linking form."; } //make sure didn't exceed limit on plugins if ($type == "plugin") { $pluginLimit = getServiceParam($service_id, "plimit"); if ($pluginLimit === false) { $pluginLimit = 1000; } $num_plugins = count(minecraftServerList($service_id)); if ($num_plugins > $pluginLimit) { return "You have exceeded the limit on the number of plugins. Please contact support."; } } if (!empty($files["uploaded_file"]) && $files['uploaded_file']['error'] == 0) { //Check if the file is a map and it's size is less than 20MB $filename = basename($files['uploaded_file']['name']); $ext = getExtension($filename); if ($ext == "jar" && $files["uploaded_file"]["size"] < 20000000) { //Determine the path to which we want to save this file if ($type == "plugin") { $newname = $config['minecraft_path'] . $id . "/plugins/" . escapeFile($filename); } else { if ($type == "version") { $newname = $config['minecraft_path'] . $id . "/minecraft.jar"; } } //Check if the file with the same name is already exists on the server if (!file_exists($newname)) { //Attempt to move the uploaded file to it's new place if (move_uploaded_file($files['uploaded_file']['tmp_name'], $newname)) { //update symlinks if needed $jail = jailEnabled($service_id); if ($jail) { if ($type == "plugin") { minecraftServerLink($service_id, $filename, $newname); } else { if ($type == "version") { minecraftServerLink($service_id, "minecraft.jar", $newname, ""); } } } return true; } else { return "Error: could not move the uploaded file."; } } else { return "Error: a map with the same filename already exists!"; } } else { return "Error: Only .jar plugin files under 20MB can be uploaded. Please contact support."; } } else { return "No file was uploaded, or there was an error during the upload."; } }
<?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($_REQUEST['message'])) { $message = $_REQUEST['message']; } if (isset($_POST['action'])) { if ($_POST['action'] == "link" && isset($_POST['filename'])) { $result = minecraftServerLink($_REQUEST['id'], $_POST['filename']); if ($result === true) { $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'])) {