API refactor + CLI docker
This commit is contained in:
parent
8a7e25837f
commit
28c9222b98
14
cli.php
14
cli.php
@ -39,8 +39,20 @@ function getDatabaseConfig(): ConnectionData {
|
||||
return new $configClass();
|
||||
}
|
||||
|
||||
$config = new Configuration();
|
||||
$database = $config->getDatabase();
|
||||
if ($database !== null && $database->getProperty("isDocker", false) && !is_file("/.dockerenv")) {
|
||||
$command = array_merge(["docker", "exec", "-it", "php", "php"], /*array_map(function ($arg) { return escapeshellarg($arg); }, */$argv);
|
||||
var_dump(implode(" ", $command));
|
||||
$proc = proc_open($command, [1 => STDOUT, 2 => STDERR], $pipes, "/application");
|
||||
sleep(1);
|
||||
/*var_dump(stream_get_contents($pipes[1]));
|
||||
var_dump(stream_get_contents($pipes[2]));*/
|
||||
exit(proc_close($proc));
|
||||
}
|
||||
|
||||
function getUser(): ?User {
|
||||
$config = new Configuration();
|
||||
global $config;
|
||||
$user = new User($config);
|
||||
if (!$user->getSQL() || !$user->getSQL()->isConnected()) {
|
||||
printLine("Could not establish database connection");
|
||||
|
@ -45,12 +45,7 @@ namespace Api\ApiKey {
|
||||
$this->loginRequired = true;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
|
||||
if(!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function _execute(): bool {
|
||||
$apiKey = generateRandomString(64);
|
||||
$sql = $this->user->getSQL();
|
||||
$validUntil = (new \DateTime())->modify("+30 DAY");
|
||||
@ -83,11 +78,7 @@ namespace Api\ApiKey {
|
||||
$this->loginRequired = true;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if(!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function _execute(): bool {
|
||||
$sql = $this->user->getSQL();
|
||||
$query = $sql->select("uid", "api_key", "valid_until", "active")
|
||||
->from("ApiKey")
|
||||
@ -129,11 +120,7 @@ namespace Api\ApiKey {
|
||||
$this->loginRequired = true;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if(!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function _execute(): bool {
|
||||
$id = $this->getParam("id");
|
||||
if(!$this->apiKeyExists($id))
|
||||
return false;
|
||||
@ -164,11 +151,7 @@ namespace Api\ApiKey {
|
||||
$this->loginRequired = true;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if(!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function _execute(): bool {
|
||||
$id = $this->getParam("id");
|
||||
if (!$this->apiKeyExists($id))
|
||||
return false;
|
||||
|
@ -64,11 +64,7 @@ namespace Api\Contact {
|
||||
parent::__construct($user, $externalCall, $parameters);
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function _execute(): bool {
|
||||
$settings = $this->user->getConfiguration()->getSettings();
|
||||
if ($settings->isRecaptchaEnabled()) {
|
||||
$captcha = $this->getParam("captcha");
|
||||
@ -184,11 +180,7 @@ namespace Api\Contact {
|
||||
->execute();
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function _execute(): bool {
|
||||
$message = $this->getParam("message");
|
||||
$senderMail = $this->getSenderMail();
|
||||
if (!$this->success) {
|
||||
@ -219,11 +211,7 @@ namespace Api\Contact {
|
||||
$this->csrfTokenRequired = false;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function _execute(): bool {
|
||||
$sql = $this->user->getSQL();
|
||||
$res = $sql->select("ContactRequest.uid", "from_name", "from_email", "from_name",
|
||||
new Sum(new CaseWhen(new CondNot("ContactMessage.read"), 1, 0), "unread"))
|
||||
@ -270,11 +258,7 @@ namespace Api\Contact {
|
||||
->execute();
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function _execute(): bool {
|
||||
$requestId = $this->getParam("requestId");
|
||||
$sql = $this->user->getSQL();
|
||||
|
||||
|
@ -54,11 +54,7 @@ namespace Api\Groups {
|
||||
return $this->success;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if(!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function _execute(): bool {
|
||||
$page = $this->getParam("page");
|
||||
if($page < 1) {
|
||||
return $this->createError("Invalid page count");
|
||||
@ -116,11 +112,7 @@ namespace Api\Groups {
|
||||
));
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function _execute(): bool {
|
||||
$name = $this->getParam("name");
|
||||
if (preg_match("/^[a-zA-Z][a-zA-Z0-9_-]*$/", $name) !== 1) {
|
||||
return $this->createError("Invalid name");
|
||||
@ -162,11 +154,7 @@ namespace Api\Groups {
|
||||
));
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function _execute(): bool {
|
||||
$id = $this->getParam("uid");
|
||||
if (in_array($id, DEFAULT_GROUPS)) {
|
||||
return $this->createError("You cannot delete a default group.");
|
||||
|
@ -23,11 +23,7 @@ namespace Api\Language {
|
||||
parent::__construct($user, $externalCall, array());
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if(!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function _execute(): bool {
|
||||
$sql = $this->user->getSQL();
|
||||
$res = $sql->select("uid", "code", "name")
|
||||
->from("Language")
|
||||
@ -108,11 +104,7 @@ namespace Api\Language {
|
||||
return $this->success;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if(!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function _execute(): bool {
|
||||
if(!$this->checkLanguage())
|
||||
return false;
|
||||
|
||||
|
@ -59,10 +59,7 @@ namespace Api\Mail {
|
||||
));
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
$receiver = $this->getParam("receiver");
|
||||
$req = new \Api\Mail\Send($this->user);
|
||||
@ -94,10 +91,7 @@ namespace Api\Mail {
|
||||
$this->isPublic = false;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
$mailConfig = $this->getMailConfig();
|
||||
if (!$this->success) {
|
||||
@ -402,10 +396,7 @@ namespace Api\Mail {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
if (!function_exists("imap_open")) {
|
||||
return $this->createError("IMAP is not enabled. Enable it inside the php config. For more information visit: https://www.php.net/manual/en/imap.setup.php");
|
||||
@ -473,10 +464,7 @@ namespace Api\Mail {
|
||||
$this->isPublic = false;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
$debug = $this->getParam("debug");
|
||||
$startTime = time();
|
||||
|
@ -29,11 +29,7 @@ namespace Api\News {
|
||||
]);
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function _execute(): bool {
|
||||
$sql = $this->user->getSQL();
|
||||
$query = $sql->select("News.uid", "title", "text", "publishedAt",
|
||||
"User.uid as publisherId", "User.name as publisherName", "User.fullName as publisherFullName")
|
||||
@ -88,11 +84,7 @@ namespace Api\News {
|
||||
]);
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function _execute(): bool {
|
||||
$sql = $this->user->getSQL();
|
||||
$title = $this->getParam("title");
|
||||
$text = $this->getParam("text");
|
||||
@ -120,11 +112,7 @@ namespace Api\News {
|
||||
]);
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function _execute(): bool {
|
||||
$sql = $this->user->getSQL();
|
||||
$id = $this->getParam("id");
|
||||
$res = $sql->select("publishedBy")
|
||||
@ -161,10 +149,7 @@ namespace Api\News {
|
||||
]);
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
$sql = $this->user->getSQL();
|
||||
$id = $this->getParam("id");
|
||||
|
@ -108,11 +108,7 @@ namespace Api\Notifications {
|
||||
return $this->success;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if(!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function _execute(): bool {
|
||||
$userId = $this->getParam("userId");
|
||||
$groupId = $this->getParam("groupId");
|
||||
$title = $this->getParam("title");
|
||||
@ -214,11 +210,7 @@ namespace Api\Notifications {
|
||||
return $this->success;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if(!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function _execute(): bool {
|
||||
$this->notifications = array();
|
||||
$this->notificationids = array();
|
||||
if ($this->fetchUserNotifications() && $this->fetchGroupNotifications()) {
|
||||
@ -236,10 +228,7 @@ namespace Api\Notifications {
|
||||
$this->loginRequired = true;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
$sql = $this->user->getSQL();
|
||||
$res = $sql->update("UserNotification")
|
||||
|
@ -36,10 +36,7 @@ namespace Api\Permission {
|
||||
$this->isPublic = false;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
$method = $this->getParam("method");
|
||||
$sql = $this->user->getSQL();
|
||||
@ -104,10 +101,7 @@ namespace Api\Permission {
|
||||
return $this->success;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
if (!$this->fetchGroups()) {
|
||||
return false;
|
||||
@ -149,10 +143,7 @@ namespace Api\Permission {
|
||||
));
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
if (!$this->checkStaticPermission()) {
|
||||
return false;
|
||||
|
@ -6,7 +6,7 @@ use Api\Parameter\Parameter;
|
||||
use Objects\User;
|
||||
use PhpMqtt\Client\MqttClient;
|
||||
|
||||
class Request {
|
||||
abstract class Request {
|
||||
|
||||
protected User $user;
|
||||
protected array $params;
|
||||
@ -107,7 +107,9 @@ class Request {
|
||||
die($data);
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
protected abstract function _execute(): bool;
|
||||
|
||||
public final function execute($values = array()): bool {
|
||||
|
||||
$this->params = array_merge([], $this->defaultParams);
|
||||
$this->success = false;
|
||||
@ -223,9 +225,15 @@ class Request {
|
||||
return false;
|
||||
}
|
||||
|
||||
$success = $this->_execute();
|
||||
if ($this->success !== $success) {
|
||||
// _execute returns a different value then it set for $this->success
|
||||
// this should actually not occur, how to handle this case?
|
||||
$this->success = $success;
|
||||
}
|
||||
|
||||
$this->user->getSQL()->setLastError('');
|
||||
$this->success = true;
|
||||
return true;
|
||||
return $this->success;
|
||||
}
|
||||
|
||||
protected function createError($err): bool {
|
||||
|
@ -74,11 +74,7 @@ namespace Api\Routes {
|
||||
parent::__construct($user, $externalCall, array());
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if(!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function _execute(): bool {
|
||||
$sql = $this->user->getSQL();
|
||||
|
||||
$res = $sql
|
||||
@ -121,11 +117,7 @@ namespace Api\Routes {
|
||||
$this->isPublic = false;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if(!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function _execute(): bool {
|
||||
$request = $this->getParam('request');
|
||||
if (!startsWith($request, '/')) {
|
||||
$request = "/$request";
|
||||
@ -174,11 +166,7 @@ namespace Api\Routes {
|
||||
));
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if(!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function _execute(): bool {
|
||||
if (!$this->validateRoutes()) {
|
||||
return false;
|
||||
}
|
||||
@ -263,10 +251,7 @@ namespace Api\Routes {
|
||||
$this->isPublic = false;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
$request = $this->formatRegex($this->getParam("request"), true);
|
||||
$action = $this->getParam("action");
|
||||
@ -299,10 +284,7 @@ namespace Api\Routes {
|
||||
$this->isPublic = false;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
$uid = $this->getParam("uid");
|
||||
if (!$this->routeExists($uid)) {
|
||||
@ -339,10 +321,7 @@ namespace Api\Routes {
|
||||
$this->isPublic = false;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
$uid = $this->getParam("uid");
|
||||
if (!$this->routeExists($uid)) {
|
||||
@ -367,10 +346,7 @@ namespace Api\Routes {
|
||||
$this->isPublic = false;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
$uid = $this->getParam("uid");
|
||||
return $this->toggleRoute($uid, true);
|
||||
@ -385,10 +361,7 @@ namespace Api\Routes {
|
||||
$this->isPublic = false;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
$uid = $this->getParam("uid");
|
||||
return $this->toggleRoute($uid, false);
|
||||
|
@ -29,11 +29,7 @@ namespace Api\Settings {
|
||||
));
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if(!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function _execute(): bool {
|
||||
$key = $this->getParam("key");
|
||||
$sql = $this->user->getSQL();
|
||||
|
||||
@ -72,11 +68,7 @@ namespace Api\Settings {
|
||||
));
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function _execute(): bool {
|
||||
$values = $this->getParam("settings");
|
||||
if (empty($values)) {
|
||||
return $this->createError("No values given.");
|
||||
|
@ -66,11 +66,7 @@ class Stats extends Request {
|
||||
return ($this->success ? $res[0]["count"] : $this->success);
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if(!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function _execute(): bool {
|
||||
$userCount = $this->getUserCount();
|
||||
$pageCount = $this->getPageCount();
|
||||
$req = new \Api\Visitors\Stats($this->user);
|
||||
@ -108,7 +104,6 @@ class Stats extends Request {
|
||||
"mail" => $this->mailConfigured,
|
||||
"reCaptcha" => $this->recaptchaConfigured
|
||||
);
|
||||
|
||||
return $this->success;
|
||||
}
|
||||
|
||||
|
@ -12,11 +12,7 @@ class Swagger extends Request {
|
||||
$this->csrfTokenRequired = false;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function _execute(): bool {
|
||||
header("Content-Type: application/x-yaml");
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
die($this->getDocumentation());
|
||||
|
@ -35,11 +35,7 @@ namespace Api\Template {
|
||||
]);
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function _execute(): bool {
|
||||
$templateFile = $this->getParam("file");
|
||||
$parameters = $this->getParam("parameters");
|
||||
$extension = pathinfo($templateFile, PATHINFO_EXTENSION);
|
||||
|
@ -72,10 +72,7 @@ namespace Api\TFA {
|
||||
]);
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
$token = $this->user->getTwoFactorToken();
|
||||
if (!$token) {
|
||||
@ -148,10 +145,7 @@ namespace Api\TFA {
|
||||
$this->csrfTokenRequired = false;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
$twoFactorToken = $this->user->getTwoFactorToken();
|
||||
if ($twoFactorToken && $twoFactorToken->isConfirmed()) {
|
||||
@ -188,10 +182,7 @@ namespace Api\TFA {
|
||||
$this->loginRequired = true;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
$twoFactorToken = $this->user->getTwoFactorToken();
|
||||
if ($twoFactorToken->isConfirmed()) {
|
||||
@ -218,10 +209,7 @@ namespace Api\TFA {
|
||||
$this->csrfTokenRequired = false;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
$session = $this->user->getSession();
|
||||
if (!$session) {
|
||||
@ -254,10 +242,7 @@ namespace Api\TFA {
|
||||
]);
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
$clientDataJSON = json_decode($this->getParam("clientDataJSON"), true);
|
||||
$attestationObjectRaw = base64_decode($this->getParam("attestationObject"));
|
||||
@ -358,10 +343,7 @@ namespace Api\TFA {
|
||||
$this->csrfTokenRequired = false;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
$session = $this->user->getSession();
|
||||
if (!$session) {
|
||||
|
@ -173,10 +173,7 @@ namespace Api\User {
|
||||
$this->loginRequired = true;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
$username = $this->getParam('username');
|
||||
$email = $this->getParam('email');
|
||||
@ -250,10 +247,7 @@ namespace Api\User {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
$page = $this->getParam("page");
|
||||
if ($page < 1) {
|
||||
@ -343,10 +337,7 @@ namespace Api\User {
|
||||
$this->loginRequired = true;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
$sql = $this->user->getSQL();
|
||||
$userId = $this->getParam("id");
|
||||
@ -435,10 +426,7 @@ namespace Api\User {
|
||||
$this->csrfTokenRequired = false;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
if (!$this->user->isLoggedIn()) {
|
||||
$this->result["loggedIn"] = false;
|
||||
@ -479,10 +467,7 @@ namespace Api\User {
|
||||
$this->loginRequired = true;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
$username = $this->getParam('username');
|
||||
$email = $this->getParam('email');
|
||||
@ -572,10 +557,7 @@ namespace Api\User {
|
||||
return $this->success;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
if ($this->user->isLoggedIn()) {
|
||||
return $this->createError("You are already logged in.");
|
||||
@ -637,10 +619,7 @@ namespace Api\User {
|
||||
return $this->success;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
if ($this->user->isLoggedIn()) {
|
||||
return $this->createError("You are already logged in.");
|
||||
@ -689,10 +668,7 @@ namespace Api\User {
|
||||
return $this->createError(L('Wrong username or password'));
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
if ($this->user->isLoggedIn()) {
|
||||
$this->lastError = L('You are already logged in');
|
||||
@ -765,10 +741,7 @@ namespace Api\User {
|
||||
$this->forbidMethod("GET");
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
if (!$this->user->isLoggedIn()) {
|
||||
return $this->createError("You are not logged in.");
|
||||
@ -802,10 +775,7 @@ namespace Api\User {
|
||||
$this->csrfTokenRequired = false;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
if ($this->user->isLoggedIn()) {
|
||||
return $this->createError(L('You are already logged in'));
|
||||
@ -916,10 +886,7 @@ namespace Api\User {
|
||||
return array();
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
$token = $this->getParam('token');
|
||||
$tokenEntry = $this->checkToken($token);
|
||||
@ -961,10 +928,7 @@ namespace Api\User {
|
||||
$this->forbidMethod("GET");
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
$id = $this->getParam("id");
|
||||
$user = $this->getUser($id);
|
||||
@ -1062,10 +1026,7 @@ namespace Api\User {
|
||||
$this->loginRequired = true;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
$id = $this->getParam("id");
|
||||
if ($id === $this->user->getId()) {
|
||||
@ -1103,10 +1064,7 @@ namespace Api\User {
|
||||
parent::__construct($user, $externalCall, $parameters);
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
if ($this->user->isLoggedIn()) {
|
||||
return $this->createError("You already logged in.");
|
||||
@ -1208,10 +1166,7 @@ namespace Api\User {
|
||||
parent::__construct($user, $externalCall, $parameters);
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
if ($this->user->isLoggedIn()) {
|
||||
return $this->createError("You already logged in.");
|
||||
@ -1324,10 +1279,7 @@ namespace Api\User {
|
||||
return $this->success;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
if ($this->user->isLoggedIn()) {
|
||||
return $this->createError("You are already logged in.");
|
||||
@ -1373,10 +1325,7 @@ namespace Api\User {
|
||||
$this->forbidMethod("GET");
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
$newUsername = $this->getParam("username");
|
||||
$oldPassword = $this->getParam("oldPassword");
|
||||
@ -1463,10 +1412,7 @@ namespace Api\User {
|
||||
}
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
$gpgKey = $this->user->getGPG();
|
||||
if ($gpgKey) {
|
||||
@ -1569,10 +1515,7 @@ namespace Api\User {
|
||||
$this->forbidMethod("GET");
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
$gpgKey = $this->user->getGPG();
|
||||
if (!$gpgKey) {
|
||||
@ -1618,10 +1561,7 @@ namespace Api\User {
|
||||
$this->loginRequired = true;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
$gpgKey = $this->user->getGPG();
|
||||
if (!$gpgKey) {
|
||||
@ -1683,10 +1623,7 @@ namespace Api\User {
|
||||
$this->csrfTokenRequired = false;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
$allowedFormats = ["json", "ascii", "gpg"];
|
||||
$format = $this->getParam("format");
|
||||
@ -1824,10 +1761,7 @@ namespace Api\User {
|
||||
return $fileName;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
$userId = $this->user->getId();
|
||||
$uploadDir = WEBROOT . "/img/uploads/user/$userId";
|
||||
@ -1865,10 +1799,7 @@ namespace Api\User {
|
||||
$this->loginRequired = true;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
public function _execute(): bool {
|
||||
|
||||
$pfp = $this->user->getProfilePicture();
|
||||
if (!$pfp) {
|
||||
|
@ -16,11 +16,7 @@ class VerifyCaptcha extends Request {
|
||||
$this->isPublic = false;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if(!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function _execute(): bool {
|
||||
$settings = $this->user->getConfiguration()->getSettings();
|
||||
if (!$settings->isRecaptchaEnabled()) {
|
||||
return $this->createError("Google reCaptcha is not enabled.");
|
||||
|
@ -31,11 +31,7 @@ namespace Api\Visitors {
|
||||
$this->isPublic = false;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function _execute(): bool {
|
||||
$sql = $this->user->getSQL();
|
||||
$cookie = $this->getParam("cookie");
|
||||
$day = (new DateTime())->format("Ymd");
|
||||
@ -58,7 +54,7 @@ namespace Api\Visitors {
|
||||
));
|
||||
}
|
||||
|
||||
private function setConditions(string $type, DateTime $date, Select $query) {
|
||||
private function setConditions(string $type, DateTime $date, Select $query): bool {
|
||||
if ($type === "yearly") {
|
||||
$yearStart = $date->format("Y0000");
|
||||
$yearEnd = $date->modify("+1 year")->format("Y0000");
|
||||
@ -75,15 +71,13 @@ namespace Api\Visitors {
|
||||
$query->where(new Compare("day", $weekStart, ">="));
|
||||
$query->where(new Compare("day", $weekEnd, "<="));
|
||||
} else {
|
||||
$this->createError("Invalid scope: $type");
|
||||
return $this->createError("Invalid scope: $type");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function execute($values = array()): bool {
|
||||
if (!parent::execute($values)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function _execute(): bool {
|
||||
$date = $this->getParam("date");
|
||||
$type = $this->getParam("type");
|
||||
|
||||
@ -95,7 +89,7 @@ namespace Api\Visitors {
|
||||
->orderBy("day")
|
||||
->ascending();
|
||||
|
||||
$this->setConditions($type, $date, $query);
|
||||
$this->success = $this->setConditions($type, $date, $query);
|
||||
if (!$this->success) {
|
||||
return false;
|
||||
}
|
||||
|
@ -325,6 +325,7 @@ namespace Documents\Install {
|
||||
$connectionData->setProperty('database', $database);
|
||||
$connectionData->setProperty('encoding', $encoding);
|
||||
$connectionData->setProperty('type', $type);
|
||||
$connectionData->setProperty('isDocker', $this->isDocker());
|
||||
$sql = SQL::createConnection($connectionData);
|
||||
$success = false;
|
||||
if (is_string($sql)) {
|
||||
|
@ -18,7 +18,7 @@ class ConnectionData {
|
||||
$this->properties = array();
|
||||
}
|
||||
|
||||
public function getProperties() {
|
||||
public function getProperties(): array {
|
||||
return $this->properties;
|
||||
}
|
||||
|
||||
@ -26,8 +26,8 @@ class ConnectionData {
|
||||
return $this->properties[$key] ?? $defaultValue;
|
||||
}
|
||||
|
||||
public function setProperty($key, $val) {
|
||||
if(!is_string($val)) {
|
||||
public function setProperty($key, $val): bool {
|
||||
if (!is_scalar($val)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -35,8 +35,8 @@ class ConnectionData {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getHost() { return $this->host; }
|
||||
public function getPort() { return $this->port; }
|
||||
public function getLogin() { return $this->login; }
|
||||
public function getPassword() { return $this->password; }
|
||||
public function getHost(): string { return $this->host; }
|
||||
public function getPort(): int { return $this->port; }
|
||||
public function getLogin(): string { return $this->login; }
|
||||
public function getPassword(): string { return $this->password; }
|
||||
}
|
@ -5,7 +5,7 @@ if (is_file($autoLoad)) {
|
||||
require_once $autoLoad;
|
||||
}
|
||||
|
||||
define("WEBBASE_VERSION", "1.4.3");
|
||||
define("WEBBASE_VERSION", "1.4.4");
|
||||
|
||||
spl_autoload_extensions(".php");
|
||||
spl_autoload_register(function($class) {
|
||||
|
Loading…
Reference in New Issue
Block a user