예제 #1
0
 function RedirectIfNotLoggedIn()
 {
     if ($this->IsLoggedIn) {
         return;
     }
     $location = UrlUtils::CurrentUrl(Settings::$SiteRoot . "?specialType=logon");
     header("Location: " . $location);
     die;
 }
예제 #2
0
 public static function ForceResponse($method, $url, $requestData)
 {
     UrlUtils::$_method = strtolower($method);
     UrlUtils::$_requestData = json_encode($requestData);
     UrlUtils::$_mainUrl = UrlUtils::CurrentUrl(Settings::$SiteRoot);
     UrlUtils::$_query = array();
     $queryIndex = indexOf($url, "?");
     if ($queryIndex > 0) {
         $query = substr($url, $queryIndex + 1);
         UrlUtils::$_query = parse_str($query);
     }
     UrlUtils::$_fake = true;
 }
예제 #3
0
 private function SearchResources()
 {
     $baseUrl = UrlUtils::CurrentUrl(Settings::$SiteRoot) . "/";
     $current = UrlUtils::CurrentUrl(UrlUtils::GetUrlDirectory());
     $result = array();
     $result["name"] = "PhpNuget v." . Settings::$Version;
     $result["service"] = "search";
     $resources = array();
     $resources["fields"] = $baseUrl . "api/v3/search/service/fields";
     $resources["query"] = $baseUrl . "api/v3/search/service/query";
     $resources["diagnostics"] = $baseUrl . "api/v3/search/service/diag";
     $result["resources"] = $resources;
     return $result;
 }
예제 #4
0
 function _query($query)
 {
     $pg = $this->_getPagination();
     $db = new NuGetDb();
     $os = new PhpNugetObjectSearch();
     if (strlen($query) > 0) {
         $os->Parse($query, $db->GetAllColumns());
     } else {
         $os = null;
     }
     $count = UrlUtils::GetRequestParamOrDefault("count", "false");
     if ($count == "true") {
         $allRows = $db->GetAllRows(999999, 0, $os);
         HttpUtils::WriteData(sizeof($allRows));
     }
     $allRows = $db->GetAllRows($pg->Top + 1, $pg->Skip, $os);
     if (!UrlUtils::IsFake()) {
         header('Content-Type: 	application/atom+xml;type=feed;charset=utf-8');
     }
     $baseUrl = UrlUtils::CurrentUrl(Settings::$SiteRoot);
     //
     $r = array();
     $r["@BASEURL@"] = $baseUrl;
     $r["@NEXTITEM@"] = "";
     echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
     echo Utils::ReplaceInFile(Path::Combine($this->_path, "entrytemplatepre.xml"), $r);
     for ($i = 0; $i < sizeof($allRows) && $i < $pg->Top; $i++) {
         $row = $allRows[$i];
         echo $this->_buildNuspecEntity($baseUrl, $row);
     }
     if (sizeof($allRows) >= $pg->Top) {
         $act = strtolower(UrlUtils::GetRequestParamOrDefault("action", null));
         if ($act == "packages") {
             $act = "Packages";
         }
         if ($act == "search") {
             $act = "Search";
         }
         if ($act == "findpackagesbyd") {
             $act = "FindPackagesById";
         }
         if ($act == "getupdates") {
             $act = "GetUpdates";
         }
         $nq = $this->_setupLastQuery();
         if ($act != "Search") {
             $nq = "\$skip=" . ($pg->Skip + $pg->Top) . "&amp;\$top=" . $pg->Top . $nq;
             echo "<link rel=\"next\" href=\"" . $baseUrl . "/api/" . $this->_version . "/" . $act . "?" . $nq . "\"/>";
         }
         /*?><link rel="next" href="http://localhost:8020/phpnuget/api/v2/Search?$skip=30&amp;$top=30&amp;searchTerm=''&amp;$filter=IsAbsoluteLatestVersion&amp;$orderby=DownloadCount+desc%2CId"/><?php*/
     }
     echo Utils::ReplaceInFile(Path::Combine($this->_path, "entrytemplatepost.xml"), $r);
     die;
 }
예제 #5
0
<div ng-controller="packagesUploadController">
<div class="panel panel-default">
<div class="panel-heading">Upload Package</div>
<div class="panel-body">
To upload packagase through the command line:<br><br>
<pre>
	NuGet SetApiKey <?php 
echo trim(trim($user->Token, "}"), "{");
?>
 -Source <?php 
echo UrlUtils::CurrentUrl(Settings::$SiteRoot . "upload");
?>
	
	NuGet Push mypackage.nupkg -Source <?php 
echo UrlUtils::CurrentUrl(Settings::$SiteRoot . "upload");
?>
</pre>
<br>
<form method="POST" action="<?php 
echo Settings::$SiteRoot;
?>
uploadnupkg.php"  enctype="multipart/form-data" target="output_frame">
	<div class="form-group col-md-12">
		<div class="col-md-1">
			<label for="fileName">Filename</label>
		</div>
		<div class="col-md-2">
			<input type="file" id="fileName" name="fileName" class="btn btn-default"/>
		</div>
	</div>
예제 #6
0
 public function dodownload()
 {
     $tempFile = "";
     try {
         $this->_preExecute();
         $url = UrlUtils::GetRequestParam("Url");
         $id = UrlUtils::GetRequestParam("Id");
         $version = UrlUtils::GetRequestParam("Version");
         if ($id == null || $url == null || $version == null) {
             throw new Exception("Missing data");
         }
         global $loginController;
         if (!$loginController->Admin) {
             throw new Exception("Unauthorized");
         }
         $url = str_replace("@ID", $id, $url);
         $url = str_replace("@VERSION", $version, $url);
         $nupackage = getSslPage($url);
         $tempFile = Utils::WriteTemporaryFile($nupackage);
         $udb = new UserDb();
         $user = $udb->GetByUserId($loginController->UserId);
         $baseUrl = UrlUtils::CurrentUrl(Settings::$SiteRoot);
         $nugetReader = new NugetManager();
         $parsedNuspec = $nugetReader->LoadNuspecFromFile($tempFile);
         $parsedNuspec->UserId = $user->Id;
         $nuspecData = $nugetReader->SaveNuspec($tempFile, $parsedNuspec);
     } catch (Exception $ex) {
         if (file_exists($tempFile)) {
             unlink($tempFile);
         }
         ApiBase::ReturnError($ex->getMessage(), 500);
     }
     if (file_exists($tempFile)) {
         unlink($tempFile);
     }
     ApiBase::ReturnSuccess(null);
 }
예제 #7
0
 public function GetAllRows($limit = 9999999, $skip = 0, $objectSearch = null)
 {
     $this->initialize();
     $toret = array();
     $dbInstance = new SmallTxtDb("3.0.0.0", __MYTXTDB_PKG__, __MYTXTDBROWS_PKG__, __MYTXTDBROWS_PKG_TYPES__);
     $dbInstance->BuildItem = 'nugetDbPackageBuilder';
     $res = $dbInstance->GetAll($limit, $skip, $objectSearch);
     foreach ($res as $row) {
         if (ends_with(strtolower($row->IconUrl), strtolower("packagedefaulticon-50x50.png"))) {
             $row->IconUrl = UrlUtils::CurrentUrl(Settings::$SiteRoot . "content/packagedefaulticon-50x50.png");
         }
     }
     return $res;
 }
예제 #8
0
 public function BuildSubBatch($src)
 {
     global $v2BatchDebug;
     $res = new SubBatch();
     $i = 0;
     $res->Action = null;
     $res->ContentId = null;
     for (; $i < sizeof($src); $i++) {
         $li = $src[$i];
         if (starts_with($li, "Content-ID")) {
             $res->ContentId = substr($li, strlen("Content-ID:") + 1);
         } else {
             if (starts_with($li, "POST")) {
                 $res->Action = substr($li, strlen("POST") + 1);
                 $res->Method = "post";
             } else {
                 if (starts_with($li, "GET")) {
                     $res->Action = substr($li, strlen("GET") + 1);
                     $res->Method = "get";
                     break;
                 } else {
                     if (starts_with($li, "PUT")) {
                         $res->Action = substr($li, strlen("PUT") + 1);
                         $res->Method = "put";
                     } else {
                         if (starts_with($li, "DELETE")) {
                             $res->Action = substr($li, strlen("DELETE") + 1);
                             $res->Method = "delete";
                         } else {
                             if (starts_with($li, "Content-Length")) {
                                 $res->ContentLength = substr($li, strlen("Content-Length:") + 1);
                                 $i += 2;
                                 break;
                             }
                         }
                     }
                 }
             }
         }
     }
     if ($res->Action != null) {
         $http = indexOf($res->Action, " HTTP");
         if ($http > 0) {
             $res->Action = substr($res->Action, 0, $http);
         }
         if (indexOf($res->Action, "http") != 0) {
             $res->Action = UrlUtils::CurrentUrl($res->Action);
         }
     }
     //Add the space after the method
     $res->Data = "";
     while ($i < sizeof($src) && $res->Method != "get") {
         if ($res->Data != "") {
             $res->Data .= "\n" . $src[$i];
         } else {
             $res->Data .= $src[$i];
         }
         $i++;
     }
     return $res;
 }
예제 #9
0
</a>
							<?php 
    }
    ?>
</li>
	
	<li><?php 
    echo $item->Description;
    ?>
</li>
	<li><b>Total downloads:</b> <?php 
    echo $item->VersionDownloadCount;
    ?>
 </li>
	<li><b>Download package:</b> <a href="<?php 
    echo UrlUtils::CurrentUrl(Settings::$SiteRoot . "/api/?id=" . $item->Id . "&version=" . $item->Version);
    ?>
">Here</a> </li>
	<li><b>Tags:</b> <?php 
    echo $item->Tags;
    ?>
</li>
	<?php 
    if (sizeof($item->Dependencies) > 0) {
        ?>
	<li><b>Dependencies</b>
		<ul>
		<?php 
        if (is_array($item->Dependencies)) {
            for ($i = 0; $i < sizeof($item->Dependencies); $i++) {
                $d = $item->Dependencies[$i];
예제 #10
0
 public function LoadXml($e, $m, $xml)
 {
     $this->SpecialChars($m);
     $e->Version = $m["version"];
     $e->Id = $m["id"];
     if (array_key_exists("title", $m)) {
         $e->Title = $m["title"];
     }
     if (sizeof($e->Title) == 0 || $e->Title == "") {
         $e->Title = $e->Id;
     }
     if (sizeof($e->Id) == 0 || $e->Id == "") {
         $e->Id = $e->Title;
     }
     $e->IsPreRelease = PhpNugetObjectSearch::IsPreRelease($e->Version);
     $e->Listed = true;
     if (array_key_exists("licenseurl", $m)) {
         $e->LicenseUrl = $m["licenseurl"];
     }
     if (array_key_exists("iconurl", $m)) {
         $e->IconUrl = $m["iconurl"];
     } else {
         $e->IconUrl = UrlUtils::CurrentUrl(Settings::$SiteRoot . "content/packagedefaulticon-50x50.png");
     }
     if (array_key_exists("projecturl", $m)) {
         $e->ProjectUrl = $m["projecturl"];
     }
     $e->RequireLicenseAcceptance = $m["requirelicenseacceptance"];
     $e->Description = $m["description"];
     if (array_key_exists("tags", $m)) {
         $e->Tags = $m["tags"];
     }
     if (array_key_exists("author", $m)) {
         $e->Author = $m["author"];
     }
     if (array_key_exists("authors", $m)) {
         $e->Author = $m["authors"];
     }
     if (array_key_exists("summary", $m)) {
         $e->Summary = $m["summary"];
     }
     $e->Published = Utils::FormatToIso8601Date();
     if (array_key_exists("copyright", $m)) {
         $e->Copyright = $m["copyright"];
     } else {
         $e->Copyright = $m["owners"];
     }
     if (array_key_exists("owners", $m)) {
         $e->Owners = $m["owners"];
     }
 }