protected function _getPagination($top = 10, $verbs = "all") { $pg = new Pagination(); $pg->Skip = UrlUtils::GetRequestParamOrDefault("skip", 0, $verbs); $pg->Top = UrlUtils::GetRequestParamOrDefault("top", $top, $verbs); return $pg; }
function _login() { $doLogin = UrlUtils::GetRequestParamOrDefault("DoLogin", "false", "all"); if ("false" == $doLogin) { session_unset(); session_destroy(); return; } $uid = UrlUtils::GetRequestParam("UserId", "post"); $pwd = md5(UrlUtils::GetRequestParam("Password", "post")); $udb = new UserDb(); $user = null; $ar = $udb->GetAllRows(); foreach ($ar as $row) { if ($row->Enabled && strtolower($uid) == strtolower($row->Email) || $uid == $row->UserId) { if ($pwd == $row->Md5Password) { $user = $row; break; } } } //echo "Loggedin ".$doLogin; if ($user == null) { session_unset(); session_destroy(); return; } $this->IsLoggedIn = true; $this->UserId = $row->UserId; $this->Admin = $row->Admin; $this->Packages = $row->Packages; $_SESSION["UserId"] = $this->UserId; $_SESSION["Admin"] = $this->Admin; $_SESSION["Packages"] = $this->Packages; }
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; }
<?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"; $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));
<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) { ?> Displaying results <?php echo $pg->Skip; ?> - <?php
function _buildLastQuery() { $this->_lastQuery = array(); $val = UrlUtils::GetRequestParamOrDefault("packageIds", null); if ($val != null) { $this->_lastQuery["packageIds"] = $val; } $val = UrlUtils::GetRequestParamOrDefault("versions", null); if ($val != null) { $this->_lastQuery["versions"] = $val; } $val = UrlUtils::GetRequestParamOrDefault("includePrerelease", null); if ($val != null) { $this->_lastQuery["includePrerelease"] = $val; } $val = UrlUtils::GetRequestParamOrDefault("includeAllVersions", null); if ($val != null) { $this->_lastQuery["includeAllVersions"] = $val; } $val = UrlUtils::GetRequestParamOrDefault("targetFrameworks", null); if ($val != null) { $this->_lastQuery["targetFrameworks"] = $val; } $val = UrlUtils::GetRequestParamOrDefault("versionConstraints", null); if ($val != null) { $this->_lastQuery["versionConstraints"] = $val; } $val = UrlUtils::GetRequestParamOrDefault("searchTerm", null); if ($val != null) { $this->_lastQuery["searchTerm"] = $val; } $val = UrlUtils::GetRequestParamOrDefault("\$filter", null); if ($val != null) { $this->_lastQuery["\$filter"] = $val; } $val = UrlUtils::GetRequestParamOrDefault("\$orderby", null); if ($val != null) { $this->_lastQuery["\$orderby"] = $val; } $val = UrlUtils::GetRequestParamOrDefault("id", null); if ($val != null) { $this->_lastQuery["id"] = $val; } }
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); }
<?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();
<?php require_once dirname(__FILE__) . "/root.php"; require_once __ROOT__ . "/inc/logincontroller.php"; $searchQuery = UrlUtils::GetRequestParamOrDefault("searchQuery", ""); ?> <link href="scripts/bootstrap/bootstrap.min.css" rel="stylesheet" /> <nav class="navbar navbar-default navbar-static-top navbar-inverse" role="navigation" id="headerBar"> <div class="container-fluid"> <div class="navbar-header"> <button type="button" data-target="#navbarCollapse" data-toggle="collapse" class="navbar-toggle"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <span class="navbar-brand">PhpNuget</span> </div> <div id="navbarCollapse" class="collapse navbar-collapse"> <form method="POST" action="<?php echo Settings::$SiteRoot; ?> ?specialType=packages" enctype="multipart/form-data" class="navbar-form navbar-left"> <div class="form-group"> <input type="text" class="form-control" id="searchQuery" name="searchQuery" value="<?php echo $searchQuery; ?> "/>
} else { $app = "/" . $app . "/"; } $r["@ApplicationPath@"] = $app; //Setup the settings Utils::ReplaceInFile(Path::Combine(__ROOT__, "inc/setup/settings.php.template"), $r, Path::Combine(__ROOT__, "settings.php")); echo "<li>Settings initialized.</li>"; //Setup the htaccess for api v2 and v1 $r["@HtAccess.V1@"] = Utils::ReplaceInFile(Path::Combine(__ROOT__, "inc/setup/htaccess.v1"), $r); $r["@HtAccess.V2@"] = Utils::ReplaceInFile(Path::Combine(__ROOT__, "inc/setup/htaccess.v2"), $r); $r["@HtAccess.V3@"] = Utils::ReplaceInFile(Path::Combine(__ROOT__, "inc/setup/htaccess.v3"), $r); //Write the root htacces Utils::ReplaceInFile(Path::Combine(__ROOT__, "inc/setup/htaccess.root", $r), $r, Path::Combine(__ROOT__, ".htaccess")); echo "<li>Htaccess initialized with path '" . $r["@ApplicationPath@"] . "'.</li>"; //Setup the web.config for api v2 and v1 $r["@WebConfig.PHPEXE@"] = UrlUtils::GetRequestParamOrDefault("phpCgi", "", "post"); $r["@WebConfig.V1@"] = Utils::ReplaceInFile(Path::Combine(__ROOT__, "inc/setup/webconfig.v1"), $r); $r["@WebConfig.V2@"] = Utils::ReplaceInFile(Path::Combine(__ROOT__, "inc/setup/webconfig.v2"), $r); $r["@WebConfig.V3@"] = Utils::ReplaceInFile(Path::Combine(__ROOT__, "inc/setup/webconfig.v3"), $r); //Write the root web.config if ($r["@WebConfig.PHPEXE@"] != "") { Utils::ReplaceInFile(Path::Combine(__ROOT__, "inc/setup/webconfig.root", $r), $r, Path::Combine(__ROOT__, "web.config")); } else { Utils::ReplaceInFile(Path::Combine(__ROOT__, "inc/setup/webconfignophpexe.root", $r), $r, Path::Combine(__ROOT__, "web.config")); } echo "<li>Web.config initialized with path '" . $r["@ApplicationPath@"] . "'.</li>"; require_once __ROOT__ . "/settings.php"; require_once __ROOT__ . "/inc/db_users.php"; $usersDb = new UserDb(); //Create user $userEntity = new UserEntity();
<?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"; $q = UrlUtils::GetRequestParamOrDefault("q", null); ?> <html><body> <form style="visibility: hidden" method="POST" name='frm' action="<?php echo Settings::$SiteRoot; ?> ?specialType=packages" enctype="multipart/form-data"> <input type="text" id="q" name="q" value="<?php echo $q; ?> "/> <input type="submit" value="Search" ></input> </form> <script language="JavaScript"> document.frm.submit(); </script> </body></html>
<script src="scripts/angular/angular-ui/ui-bootstrap-tpls.min.js"></script> <script src="scripts/angular/angular-ui/ui-router.min.js"></script> <script src="scripts/angular/angular-ui/ui-utils.js"></script> <script src="assets/app.js"></script> <script src="assets/commons/utils.js"></script> <script src="assets/commons/tabcontroller.js"></script> <script src="assets/initialize.js"></script> <script src="assets/route.js"></script> <script src="assets/views/users/module.js"></script> <script src="assets/views/profile/module.js"></script> </head> <body> <?php require_once __ROOT__ . "/_header.php"; require_once __ROOT__ . "/_navbar.php"; $specialType = strtolower(UrlUtils::GetRequestParamOrDefault("specialType", null)); if ($specialType == "packages") { $groupBy = " groupBy Id"; require_once __ROOT__ . "/inc/partials/_packages.php"; } else { if ($specialType == "singlepackage") { require_once __ROOT__ . "/inc/partials/_singlepackage.php"; } else { if ($specialType == "singleprofile") { require_once __ROOT__ . "/inc/partials/_singleprofile.php"; } else { if ($specialType == "logon") { require_once __ROOT__ . "/inc/partials/_logon.php"; } else { ?> <div ui-view>