<?php require_once dirname(__FILE__) . "/../../root.php"; require_once __ROOT__ . "/settings.php"; require_once __ROOT__ . "/inc/api_users.php"; require_once __ROOT__ . "/inc/commons/url.php"; require_once __ROOT__ . "/inc/commons/http.php"; require_once __ROOT__ . "/inc/api_nuget.php"; require_once __ROOT__ . "/inc/api_nugetv3.php"; $api = new ApiNugetBaseV3(); $api->Initialize(dirname(__FILE__)); $api->Execute(); HttpUtils::ApiError(404, "Not found");
function _getupdates($action) { if ($action != "getupdates") { return; } HttpUtils::ApiError(404, "Not found"); }
require_once __ROOT__ . "/inc/commons/url.php"; require_once __ROOT__ . "/inc/commons/http.php"; require_once __ROOT__ . "/inc/api_nuget.php"; $id = UrlUtils::GetRequestParamOrDefault("id", null); $version = UrlUtils::GetRequestParamOrDefault("version", null); if ($id == null || $version == null) { HttpUtils::ApiError(500, "Wrong data. Missing param."); } if (strlen($id) == 0 || strlen($version) == 0) { HttpUtils::ApiError(500, "Wrong data. Empty id or version."); } $query = "Id eq '" . $id . "' and Version eq '" . $version . "'"; $db = new NuGetDb(); $os = new PhpNugetObjectSearch(); $os->Parse($query, $db->GetAllColumns()); $allRows = $db->GetAllRows(1, 0, $os); if (sizeof($allRows) == 0) { HttpUtils::ApiError(404, "Not found."); } $file = $allRows[0]->Id . "." . $allRows[0]->Version . ".nupkg"; $path = Path::Combine(Settings::$PackagesRoot, $file); if (!file_exists($path)) { HttpUtils::ApiError(404, "Not found " . $file); } header('Content-Type: application/zip'); header('Content-Disposition: attachment; filename=' . basename($path)); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize($path)); readfile($path);
<?php require_once dirname(__FILE__) . "/root.php"; require_once __ROOT__ . "/settings.php"; require_once __ROOT__ . "/inc/commons/uploadutils.php"; require_once __ROOT__ . "/inc/nugetreader.php"; require_once __ROOT__ . "/inc/commons/url.php"; if (!empty($_SERVER['HTTP_X_NUGET_APIKEY'])) { HttpUtils::ApiError('403', 'Invalid request'); die; } $message = ""; ?> <html><body> <script type="text/javascript"> <?php if (!$loginController->IsLoggedIn) { ?> parent.packagesUploadControllerCallback("fail-unathorized","none","none"); <?php } else { if (UploadUtils::IsUploadRequest()) { $uploader = new UploadUtils(Settings::$PackagesRoot, array("nupkg"), Settings::$MaxUploadBytes); $result = $uploader->Upload("fileName"); $fileName = basename($result["name"], ".nupkg"); $message = ""; if ($result["hasError"] == true) { $message = "Failed uploading '" . $result["name"] . "'."; $message .= "Error is: " . $result["errorMessage"]; if ($result["errorCode"] != null) { $message .= "Error code is:" . $result["errorCode"] . ".";
<?php require_once dirname(__FILE__) . "/../../root.php"; require_once __ROOT__ . "/settings.php"; require_once __ROOT__ . "/inc/api_users.php"; require_once __ROOT__ . "/inc/commons/url.php"; if (!$loginController->Admin) { $uid = UrlUtils::GetRequestParam("UserId"); if ($uid != $loginController->UserId) { HttpUtils::ApiError(500, "Unauthorized"); } } $api = new UsersApi(); $id = UrlUtils::GetRequestParamOrDefault("UserId", "get"); $api->Execute();
$token = strtoupper(trim(trim($_SERVER['HTTP_X_NUGET_APIKEY'], "{"), "}")); $db = new UserDb(); $os = new ObjectSearch(); $os->Parse("Token eq '{" . $token . "}'", $db->GetAllColumns()); $users = $db->GetAllRows(1, 0, $os); if (sizeof($users) != 1) { HttpUtils::ApiError('403', 'Invalid API key'); die; } $user = $users[0]; $uploader = new UploadUtils(Settings::$PackagesRoot, array("nupkg"), Settings::$MaxUploadBytes, true); $uploader->allowAll = true; $result = $uploader->Upload("package"); if ($result['hasError']) { throw new Exception($result['errorCode']); } $fileName = basename($result["name"], ".nupkg"); $nugetReader = new NugetManager(); $parsedNuspec = $nugetReader->LoadNuspecFromFile($result["destination"]); $parsedNuspec->UserId = $user->Id; $nuspecData = $nugetReader->SaveNuspec($result["destination"], $parsedNuspec); // All done! header('HTTP/1.1 201 Created'); } catch (Exception $ex) { if (array_key_exists("destination", $result)) { unlink($result["destination"]); } unlink($temp_file); HttpUtils::ApiError('500', $ex->getMessage()); die; }
public function Execute() { header('Content-Type: application/json'); $action = UrlUtils::GetRequestParamOrDefault("action", null); $packageId = UrlUtils::GetRequestParamOrDefault("id", "angularjs"); $version = UrlUtils::GetRequestParamOrDefault("version", "1.0.3"); $data = array(); switch ($action) { case 'resources': //header("Location: https://api.nuget.org/v3/index.json"); $data = $this->Resources(); break; case 'searchServices': //header("Location: https://api-search.nuget.org/"); $data = $this->SearchServices(); break; case 'searchResources': //header("Location: https://api-search.nuget.org/search"); $data = $this->SearchResources(); break; case 'searchFields': $data = "Location: https://api-search.nuget.org/search/fields"; break; case 'searchQuery': $data = "Location: https://api-search.nuget.org/search/query"; break; case 'searchDiag': $data = "Location: https://api-search.nuget.org/search/diag"; break; case 'packages': $data = "Location: https://api.nuget.org/v3/registration0/" . $packageId . "/index.json"; break; case 'package': $data = "Location: https://api.nuget.org/v3/registration0/" . $packageId . "/" . $version . ".json"; break; default: HttpUtils::ApiError(404, "Not found"); break; } echo json_encode($data, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT); die; }
public function RawRequest() { global $v2BatchDebug; if (!array_key_exists('CONTENT_TYPE', $_SERVER) && UrlUtils::RequestMethod() != "post") { HttpUtils::ApiError(405, "The HTTP verb used is not allowed."); } $a_data = array(); // read incoming data $input = file_get_contents('php://input'); if ($v2BatchDebug) { file_put_contents("batch.log", "REQUEST:" . $input . "\r\n", FILE_APPEND); file_put_contents("batch.log", "\r\n", FILE_APPEND); } // grab multipart boundary from content type header preg_match('/boundary=(.*)$/', $_SERVER['CONTENT_TYPE'], $matches); // content type is probably regular form-encoded if (!count($matches)) { return null; } $boundary = $matches[1]; $parsed = $this->ParseData($boundary, $input); $result = array(); if ($v2BatchDebug) { file_put_contents("batch.log", "PARSING:" . sizeof($parsed) . "\r\n", FILE_APPEND); file_put_contents("batch.log", "\r\n", FILE_APPEND); } for ($i = 0; $i < sizeof($parsed); $i++) { $item = $parsed[$i]; $item->ResultStatus = 200; if ($item->Method == "get") { $item->ResultData = HttpUtils::HttpGet($item->Action); } else { if ($item->Method == "get") { $item->ResultData = HttpUtils::HttpPost($item->Action, $item->Data, "application/atom+xml"); } } array_push($result, $item); } $response = Batcher::Elaborate($result); if ($v2BatchDebug) { file_put_contents("batch.log", "RESULT:" . $response . "\r\n", FILE_APPEND); file_put_contents("batch.log", "\r\n", FILE_APPEND); } }