public static function doUpstreamUpdate($aid, $branchId, $file, $version) { $dir = dirname(__DIR__) . "/../addons/upload/files/"; $addonObject = AddonManager::getFromID($aid); if (strpos($file, "http") !== 0) { $file = "http://" . $file; } $filename = "upstream_{$branchId}_" . $addonObject->getFilename(); $filepath = $dir . $filename; file_put_contents($filepath, fopen($file, 'r')); echo "\n\nDownloaded {$file} to {$filepath}\n\n"; AddonManager::submitUpdate($addonObject, $version, $branchId, realpath($filepath), "Imported from upstream."); }
$filename = "update_" . $addonObject->getId() . ".zip"; $tempLocation = dirname(dirname(__DIR__)) . "/addons/upload/files/" . $filename; if (!is_dir(dirname(dirname(__DIR__)) . "/addons/upload/files/")) { mkdir(dirname(dirname(__DIR__)) . "/addons/upload/files/"); } //to do: aws stuff instead of this $res = move_uploaded_file($tempPath, $tempLocation); if ($res) { chmod($tempLocation, 0777); } else { $response = ["message" => "Error moving uploaded file; please contact an administrator", "version" => $addonObject->getVersion()]; } } if (isset($_POST['changelog'])) { $uploadChangelog = $_POST['changelog']; } else { $uploadChangelog = ""; } if (isset($uploadVersion)) { //repeated but slightly different path from above? $tempLocation = realpath(dirname(__DIR__) . "/../addons/upload/files/" . $filename); if (!$betaUpload) { $res = AddonManager::submitUpdate($addonObject, $uploadVersion, $tempLocation, $uploadChangelog, $_REQUEST['restart']); return $res; } else { return $res = AddonManager::uploadBetaAddon($addonObject, $uploadVersion, $tempLocation, $_REQUEST['restart']); } $response = ["redirect" => "/addons/review/update.php?id=" . $addonObject->getId()]; return $response; } return $response;