Router, Logger, Bump v1.5
This commit is contained in:
@@ -31,12 +31,12 @@ class Configuration {
|
||||
return $this->settings;
|
||||
}
|
||||
|
||||
public function create(string $className, $data) {
|
||||
public static function create(string $className, $data) {
|
||||
$path = getClassPath("\\Configuration\\$className");
|
||||
|
||||
if ($data) {
|
||||
if (is_string($data)) {
|
||||
$key = addslashes($data);
|
||||
$key = var_export($data, true);
|
||||
$code = intendCode(
|
||||
"<?php
|
||||
|
||||
@@ -45,23 +45,23 @@ class Configuration {
|
||||
class $className extends KeyData {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct('$key');
|
||||
parent::__construct($key);
|
||||
}
|
||||
|
||||
}", false
|
||||
);
|
||||
} else if ($data instanceof ConnectionData) {
|
||||
$superClass = get_class($data);
|
||||
$host = addslashes($data->getHost());
|
||||
$port = $data->getPort();
|
||||
$login = addslashes($data->getLogin());
|
||||
$password = addslashes($data->getPassword());
|
||||
$host = var_export($data->getHost(), true);
|
||||
$port = var_export($data->getPort(), true);
|
||||
$login = var_export($data->getLogin(), true);
|
||||
$password = var_export($data->getPassword(), true);
|
||||
|
||||
$properties = "";
|
||||
foreach ($data->getProperties() as $key => $val) {
|
||||
$key = addslashes($key);
|
||||
$val = is_string($val) ? "'" . addslashes($val) . "'" : $val;
|
||||
$properties .= "\n\$this->setProperty('$key', $val);";
|
||||
$key = var_export($key, true);
|
||||
$val = var_export($val, true);
|
||||
$properties .= "\n\$this->setProperty($key, $val);";
|
||||
}
|
||||
|
||||
$code = intendCode(
|
||||
@@ -72,7 +72,7 @@ class Configuration {
|
||||
class $className extends \\$superClass {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct('$host', $port, '$login', '$password');$properties
|
||||
parent::__construct($host, $port, $login, $password);$properties
|
||||
}
|
||||
}", false
|
||||
);
|
||||
@@ -94,4 +94,8 @@ class Configuration {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function setDatabase(ConnectionData $connectionData) {
|
||||
$this->database = $connectionData;
|
||||
}
|
||||
}
|
||||
@@ -151,18 +151,19 @@ class CreateDatabase extends DatabaseScript {
|
||||
->addString("target", 128)
|
||||
->addString("extra", 64, true)
|
||||
->addBool("active", true)
|
||||
->addBool("exact", true)
|
||||
->primaryKey("uid")
|
||||
->unique("request");
|
||||
|
||||
$queries[] = $sql->insert("Route", array("request", "action", "target", "extra"))
|
||||
->addRow("^/admin(/.*)?$", "dynamic", "\\Documents\\Admin", NULL)
|
||||
->addRow("^/register/?$", "dynamic", "\\Documents\\Account", "account/register.twig")
|
||||
->addRow("^/confirmEmail/?$", "dynamic", "\\Documents\\Account", "account/confirm_email.twig")
|
||||
->addRow("^/acceptInvite/?$", "dynamic", "\\Documents\\Account", "account/accept_invite.twig")
|
||||
->addRow("^/resetPassword/?$", "dynamic", "\\Documents\\Account", "account/reset_password.twig")
|
||||
->addRow("^/login/?$", "dynamic", "\\Documents\\Account", "account/login.twig")
|
||||
->addRow("^/resendConfirmEmail/?$", "dynamic", "\\Documents\\Account", "account/resend_confirm_email.twig")
|
||||
->addRow("^/$", "static", "/static/welcome.html", NULL);
|
||||
$queries[] = $sql->insert("Route", ["request", "action", "target", "extra", "exact"])
|
||||
->addRow("/admin", "dynamic", "\\Documents\\Admin", NULL, false)
|
||||
->addRow("/register", "dynamic", "\\Documents\\Account", json_encode(["account/register.twig"]), true)
|
||||
->addRow("/confirmEmail", "dynamic", "\\Documents\\Account", json_encode(["account/confirm_email.twig"]), true)
|
||||
->addRow("/acceptInvite", "dynamic", "\\Documents\\Account", json_encode(["account/accept_invite.twig"]), true)
|
||||
->addRow("/resetPassword", "dynamic", "\\Documents\\Account", json_encode(["account/reset_password.twig"]), true)
|
||||
->addRow("/login", "dynamic", "\\Documents\\Account", json_encode(["account/login.twig"]), true)
|
||||
->addRow("/resendConfirmEmail", "dynamic", "\\Documents\\Account", json_encode(["account/resend_confirm_email.twig"]), true)
|
||||
->addRow("/", "static", "/static/welcome.html", NULL, true);
|
||||
|
||||
$queries[] = $sql->createTable("Settings")
|
||||
->addString("name", 32)
|
||||
|
||||
24
core/Configuration/Patch/SystemLog_2022_03_30.class.php
Normal file
24
core/Configuration/Patch/SystemLog_2022_03_30.class.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Configuration\Patch;
|
||||
|
||||
use Configuration\DatabaseScript;
|
||||
use Driver\SQL\SQL;
|
||||
|
||||
class SystemLog_2022_03_30 extends DatabaseScript {
|
||||
|
||||
public static function createQueries(SQL $sql): array {
|
||||
return [
|
||||
$sql->createTable("SystemLog")
|
||||
->onlyIfNotExists()
|
||||
->addSerial("id")
|
||||
->addDateTime("timestamp", false, $sql->now())
|
||||
->addString("message")
|
||||
->addString("module", 64, false, "global")
|
||||
->addEnum("severity", ["debug", "info", "warning", "error", "severe"])
|
||||
->primaryKey("id"),
|
||||
$sql->insert("ApiPermission", ["method", "groups", "description"])
|
||||
->addRow("Logs/get", [USER_GROUP_ADMIN], "Allows users to fetch system logs")
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user