示例#1
0
 protected function _verifyInsert($db, $item)
 {
     UrlUtils::InitializeJsonInput();
     $udb = new UserDb();
     $user = $udb->GetByUserId($item->UserId);
     if ($user != null) {
         throw new Exception("UserId duplicated!");
     }
     $passwordConfirm = UrlUtils::GetRequestParam("PasswordConfirm");
     $password = UrlUtils::GetRequestParam("Password");
     if ($password != $passwordConfirm) {
         throw new Exception("Passwords must match!");
     }
     if (strlen($password) < 8) {
         throw new Exception("Passwords must be at least 8 chars wide!");
     }
     $item->Md5Password = md5($password);
     $item->Enabled = UrlUtils::GetRequestParam("Enabled");
     $item->Admin = UrlUtils::GetRequestParam("IsAdmin");
 }
<?php

require_once dirname(__FILE__) . "/../../../root.php";
require_once __ROOT__ . "/settings.php";
$udb = new UserDb();
$user = $udb->GetByUserId($loginController->UserId);
?>

<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">
示例#3
0
 public function dorefreshpackages()
 {
     $results = array();
     $i = 0;
     try {
         $this->_preExecute();
         global $loginController;
         if (!$loginController->Admin) {
             throw new Exception("Unauthorized");
         }
         $files = scandir(Settings::$PackagesRoot);
         $skip = intval(UrlUtils::GetRequestParam("Skip"));
         $count = intval(UrlUtils::GetRequestParam("Count"));
         $total = sizeof($files);
         var_dump($files);
         $udb = new UserDb();
         $user = $udb->GetByUserId($loginController->UserId);
         for ($x = $skip; $x < $total; $x++) {
             $file = $files[$x];
             $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
             if ($ext == "nupkg") {
                 $m = $this->_loadNupkg(Path::Combine(Settings::$PackagesRoot, $file), $user->Id);
                 if (!$m->Success) {
                     $results[] = $m;
                 } else {
                     $i++;
                 }
             }
         }
         if (sizeof($results) > 0) {
             $message = "Refreshed " . $i . " packages over " . sizeof($results) . ".";
             ApiBase::ReturnErrorData($results, "", "", sizeof($results), $message, 500);
         } else {
             $message = "Refreshed " . $i . " packages.";
             ApiBase::ReturnSuccess($message);
         }
     } catch (Exception $ex) {
         $message = "Refreshed " . $i . " packages over " . sizeof($results) . ".";
         ApiBase::ReturnError($message . "\r\n" . $ex->getMessage(), 500);
     }
 }