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 ReadList()
 {
     $ndb = new NuGetDb();
     $queryString = UrlUtils::GetRequestParam("searchQuery", "post");
     if ($queryString == null) {
         return $ndb->GetAllRows(Settings::$ResultsPerPage);
     }
     return array();
 }
Esempio n. 3
0
 public function Execute($method = null)
 {
     if ($method == null) {
         $method = UrlUtils::RequestMethod();
         if (UrlUtils::ExistRequestParam("method")) {
             $method = strtolower(UrlUtils::GetRequestParam("method"));
         }
     }
     $availableMethods = get_class_methods(get_class($this));
     $function = "do" . $method;
     try {
         if (in_array($function, $availableMethods)) {
             $this->{$function}();
         } else {
             ApiBase::ReturnError("Invalid method", 405);
         }
     } catch (Exception $ex) {
         ApiBase::ReturnError($ex->getMessage(), 500);
     }
 }
Esempio n. 4
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);
     }
 }
Esempio n. 5
0
<?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();
Esempio n. 6
0
<?php

require_once dirname(__FILE__) . "/root.php";
require_once __ROOT__ . "/inc/commons/url.php";
require_once __ROOT__ . "/inc/commons/utils.php";
require_once __ROOT__ . "/inc/commons/path.php";
if (!defined('__INSETUP__')) {
    define('__INSETUP__', "__INSETUP__");
}
$applicationPath = UrlUtils::GetUrlDirectory();
if (!UrlUtils::ExistRequestParam("dosetup")) {
    require_once __ROOT__ . "/inc/setup/_01_accessdataandsettings.php";
} else {
    if (UrlUtils::GetRequestParam("dosetup", "post") == "importUsers") {
        require_once __ROOT__ . "/inc/setup/_02_importusers.php";
    } else {
        die("Error");
    }
}
Esempio n. 7
0
 protected function _buildEntityFromRequest($db)
 {
     $userEntity = new UserEntity();
     $error = true;
     foreach ($db->GetAllColumns() as $row) {
         if (UrlUtils::ExistRequestParam($row)) {
             $userEntity->{$row} = UrlUtils::GetRequestParam($row);
         }
     }
     return $userEntity;
 }
Esempio n. 8
0
 public static function GetBooleanRequestParam($key, $verb = "all")
 {
     $var = UrlUtils::GetRequestParam($key, $verb);
     if (strtolower($var) == "true" || strtolower($var) == "yes") {
         return "true";
     }
     return "false";
 }
Esempio n. 9
0
<?php

require_once dirname(__FILE__) . "/../../root.php";
require_once __ROOT__ . "/settings.php";
require_once __ROOT__ . "/inc/api_packages.php";
require_once __ROOT__ . "/inc/commons/url.php";
$id = UrlUtils::GetRequestParam("Query");
$api = new PackagesApi();
if ($id != null) {
    $api->Execute("getbyquery");
} else {
    $api->Execute();
}