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; }
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"); }
public static function run() { self::resolveURI(); switch (self::$scope) { case "setup": $db = new RestaurantDb(); $db->createTables(); $db->insertInitialData(); $db2 = new UserDb(); $db2->createTables(); $db2->insertInitialData(); $db3 = new ReviewDb(); $db3->createTables(); break; case "api": self::runApi(); break; default: echo "<h1>Foodo</h1>"; break; } }
<?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/commons/apibase.php"; require_once __ROOT__ . "/inc/commons/smalltextdbapibase.php"; require_once __ROOT__ . "/inc/db_nugetpackages.php"; require_once __ROOT__ . "/inc/phpnugetobjectsearch.php"; require_once __ROOT__ . "/inc/db_users.php"; $id = UrlUtils::GetRequestParamOrDefault("id", null); $db = new UserDb(); $os = new PhpNugetObjectSearch(); $query = "UserId eq '" . $id . "' or Name eq '" . $id . "'"; $os->Parse($query, $db->GetAllColumns()); $items = $db->GetAllRows(1, 0, $os); $inferred = false; if (sizeof($items) == 0) { $nu = new UserEntity(); $nu->UserId = $id; $nu->Name = $id; $items = array(); $items[] = $nu; $inferred = true; } $item = $items[0]; ?> <h3><?php echo $item->Name;
<?php require_once __DIR__ . '/../../bootstrap.php'; require_once __DIR__ . '/UserDb.php'; use Thruway\Authentication\WampCraAuthProvider; use Thruway\Peer\Router; use Thruway\Transport\RatchetTransportProvider; $router = new Router(); // setup some users to auth against $userDb = new UserDb(); $userDb->add('peter', 'secret1', 'salt123'); $userDb->add('joe', 'secret2', "mmm...salt"); /** * The AuthenticationManager is both an internal client and also responsible * for handling all authentication for the router. * * When authentication is needed, the router consults the AuthenticationManager * which will consult registered Authentication Providers to do the actual authentication. * * The Authentication providers and the AuthenticationManager communicate through WAMP * in the thruway.auth realm. */ $authMgr = new \Thruway\Authentication\AuthenticationManager(); $router->registerModule($authMgr); $authProvClient = new WampCraAuthProvider(["realm1"]); $authProvClient->setUserDb($userDb); $router->addInternalClient($authProvClient); $router->registerModule(new RatchetTransportProvider("127.0.0.1", 9090)); $router->start();
<?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">
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); } }
if (sizeof($_POST) > 0) { file_put_contents("upload.log", var_export($_POST, true) . "\r\n", FILE_APPEND); } if (sizeof($_GET) > 0) { file_put_contents("upload.log", var_export($_GET, true) . "\r\n", FILE_APPEND); } } $temp_file = tempnam(sys_get_temp_dir(), 'Tux'); $result = array(); try { if (empty($_SERVER['HTTP_X_NUGET_APIKEY'])) { HttpUtils::ApiError('403', 'Invalid API key'); die; } $token = strtoupper(trim(trim($_SERVER['HTTP_X_NUGET_APIKEY'], "{"), "}")); $db = new UserDb(); $os = new ObjectSearch(); $os->Parse("Token eq '{" . $token . "}'", $db->GetAllColumns()); $users = $db->GetAllRows(1, 0, $os); if (sizeof($users) != 1) { HttpUtils::ApiError('403', 'Invalid API key'); die; } $user = $users[0]; $uploader = new UploadUtils(Settings::$PackagesRoot, array("nupkg"), Settings::$MaxUploadBytes, true); $uploader->allowAll = true; $result = $uploader->Upload("package"); if ($result['hasError']) { throw new Exception($result['errorCode']); } $fileName = basename($result["name"], ".nupkg");
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(); $userEntity->UserId = $r["@AdminUserId@"]; $userEntity->Md5Password = md5($r["@AdminPassword@"]); $userEntity->Enabled = "true"; $userEntity->Admin = "true"; $userEntity->Name = "Administrator"; $userEntity->Company = ""; $userEntity->Email = $r["@AdminEmail@"]; $usersDb->AddRow($userEntity, true); echo "<li>Admin User '" . $userEntity->UserId . "' added.</li>"; ?> </ul> </body> </html>