예제 #1
0
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";
$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');
예제 #2
0
    $inferred = true;
}
$item = $items[0];
?>
<h3><?php 
echo $item->Name;
?>
's Profile</h3> 
<?php 
if ($inferred) {
    echo "This profile is extrapolated from the data.<br>";
    echo "It <b>DOES NOT EXISTS</b> on this server.<br>";
}
$query = "substringof('" . $item->Name . "',Author) or substringof('" . $item->UserId . "',Author) orderby Title asc, Version desc groupby Id";
$db = new NuGetDb();
$os = new PhpNugetObjectSearch();
$os->Parse($query, $db->GetAllColumns());
$pg = new Pagination();
$pg->Skip = UrlUtils::GetRequestParamOrDefault("skip", 0);
$pg->Top = UrlUtils::GetRequestParamOrDefault("top", 10);
$items = $db->GetAllRows(999999, 0, $os);
$count = sizeof($items);
?>
<h3> There are <?php 
echo $count;
?>
 packages for the given profile</h3> 

<?php 
if (sizeof($items) > 0) {
    ?>
예제 #3
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;
 }
예제 #4
0
$os = null;
if ($searchQuery != null) {
    if ($orderBy != null) {
        $orderBy = " orderby " . $orderBy;
    } else {
        $orderBy = " orderby Title asc,Version desc";
    }
    $os = new PhpNugetObjectSearch();
    $os->Parse("(" . $searchQuery . ") and Listed eq true " . $orderBy . $groupBy, $db->GetAllColumns());
} else {
    if ($orderBy != null) {
        $orderBy = "orderby " . $orderBy;
        $os = new PhpNugetObjectSearch();
        $os->Parse("Listed eq true " . $orderBy . $groupBy, $db->GetAllColumns());
    } else {
        $os = new PhpNugetObjectSearch();
        $os->Parse("orderby Title asc, Version desc" . $groupBy, $db->GetAllColumns());
    }
}
$next = Settings::$SiteRoot . "?specialType=packages";
if ($searchQuery != null) {
    $next .= "&searchQuery=" . urlencode($searchQuery);
}
$items = $db->GetAllRows(999999, 0, $os);
$count = sizeof($items);
$items = $db->GetAllRows($pg->Top, $pg->Skip, $os);
?>
<h3> There are <?php 
echo $count;
?>
 packages</h3> 
예제 #5
0
 public function dogetbyquery()
 {
     $query = UrlUtils::GetRequestParam("Query");
     $doGroup = UrlUtils::GetRequestParamOrDefault("DoGroup", "false");
     global $loginController;
     if (!$loginController->Admin) {
         if (strlen($query) > 0) {
             $query = " and (" . $query . ")";
         }
         $udb = new UserDb();
         $user = $udb->GetByUserId($loginController->UserId);
         $query = "(UserId eq '" . $user->Id . "')" . $query;
     }
     $query .= " orderBy Title asc, Version desc";
     if ($doGroup == "true") {
         $query .= " groupby Id";
     }
     $this->_preExecute();
     $pg = $this->_getPagination();
     $db = $this->_openDb();
     $os = new PhpNugetObjectSearch();
     $os->Parse($query, $db->GetAllColumns());
     $count = sizeof($db->GetAllRows(999999, 0, $os));
     $allRows = $db->GetAllRows($pg->Top, $pg->Skip, $os);
     //$allRows = $os->DoSort($allRows,NuGetDb::RowTypes());
     ApiBase::ReturnSuccess($allRows, "", "", $count);
 }
예제 #6
0
 public function SaveNuspec($nupkgFile, $e)
 {
     global $loginController;
     $nugetDb = new NuGetDb();
     $os = new PhpNugetObjectSearch();
     $query = "Id eq '" . $e->Id . "' orderby Version desc";
     $os->Parse($query, $nugetDb->GetAllColumns());
     $res = $nugetDb->GetAllRows(999999, 0, $os);
     if (sizeof($res) > 0 && !$loginController->Admin) {
         $id = $res[0]->UserId;
         if ($id != $e->UserId) {
             throw new Exception("Unauthorized!");
         }
     } else {
         if (sizeof($res) > 0 && $loginController->Admin) {
             $e->UserId = $res[0]->UserId;
         }
     }
     $e->IsPreRelease = indexOf($e->Version, "-") > 0;
     if ($nugetDb->AddRow($e, false)) {
         $destination = Path::Combine(Settings::$PackagesRoot, $e->Id . "." . $e->Version . ".nupkg");
         if (strtolower($nupkgFile) != strtolower($destination)) {
             if (file_exists($destination)) {
                 unlink($destination);
             }
             rename($nupkgFile, $destination);
         }
     } else {
         if (strtlower($nupkgFile) != strtlower($destination)) {
             if (file_exists($nupkgFile)) {
                 unlink($nupkgFile);
             }
         }
     }
 }