From a62b5ad3e5f34bbc52b144b314f40d4c3ee16c8d Mon Sep 17 00:00:00 2001 From: mirzaev Date: Wed, 26 Feb 2025 13:40:06 +0700 Subject: [PATCH] resolved #13, resolved #14, resolved #15 --- author/project/system/controllers/core.php | 54 ++------------------- author/project/system/controllers/index.php | 3 +- author/project/system/databases/.gitignore | 3 ++ author/project/system/public/index.php | 3 ++ author/project/system/views/templater.php | 11 ++--- composer.json | 15 +++--- 6 files changed, 22 insertions(+), 67 deletions(-) create mode 100644 author/project/system/databases/.gitignore diff --git a/author/project/system/controllers/core.php b/author/project/system/controllers/core.php index 1bdbec0..56eb645 100755 --- a/author/project/system/controllers/core.php +++ b/author/project/system/controllers/core.php @@ -21,25 +21,18 @@ use mirzaev\minimal\core as minimal, * * @package ${REPO_OWNER}\${REPO_NAME}\controllers * - * @param session $$session Instance of the session * @param language $$language Language * @param response $$response Response * @param array $$errors Registry of errors * - * @method void __construct(minimal $$minimal, bool $$initialize) Constructor + * @method void __construct(minimal $$minimal) Constructor * * @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License + * @author Arsen Mirzaev Tatyano-Muradovich * @author ${REPO_OWNER} */ class core extends controller { - /** - * Session - * - * @var session|null $$session Instance of the session - */ - protected readonly session $$session; - /** * Language * @@ -65,8 +58,7 @@ class core extends controller * @var array $$errors Registry of errors */ protected array $$errors = [ - 'session' => [], - 'account' => [] + 'system' => [] ]; /** @@ -77,50 +69,12 @@ class core extends controller * * @return void */ - public function __construct(minimal $$core, bool $$initialize = true) + public function __construct(minimal $$core) { // Blocking requests from CloudFlare (better to write this blocking into nginx config file) if (isset($$_SERVER['HTTP_USER_AGENT']) && $$_SERVER['HTTP_USER_AGENT'] === 'nginx-ssl early hints') return status::bruh->label; // For the extends system parent::__construct(core: $$core); - - if ($$initialize) { - // Requestet initializing - - // Initializing core of the models - new models(); - - // Initializing of the date until which the session will be active - $$expires = strtotime('+1 week'); - - // Initializing of default value of hash of the session - $$_COOKIE["session"] ??= null; - - // Initializing of session - $$this->session = new session($$_COOKIE["session"], $$expires, $$this->errors['session']); - - // Handle a problems with initializing a session - if (!empty($$this->errors['session'])) die; - else if ($$_COOKIE["session"] !== $$this->session->hash) { - // Hash of the session is changed (implies that the session has expired and recreated) - - // Write a new hash of the session to cookies - setcookie( - 'session', - $$this->session->hash, - [ - 'expires' => $$expires, - 'path' => '/', - 'secure' => true, - 'httponly' => true, - 'samesite' => 'strict' - ] - ); - } - - // Initializing of preprocessor of views - $$this->view = new templater($$this->session); - } } } diff --git a/author/project/system/controllers/index.php b/author/project/system/controllers/index.php index 2726db0..0b1d706 100755 --- a/author/project/system/controllers/index.php +++ b/author/project/system/controllers/index.php @@ -21,6 +21,7 @@ use mirzaev\minimal\http\enumerations\content, * @method null index() Main page * * @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License + * @author Arsen Mirzaev Tatyano-Muradovich * @author ${REPO_OWNER} */ final class index extends core @@ -31,7 +32,7 @@ final class index extends core * @var array $$errors Registry of errors */ protected array $$errors = [ - 'session' => [] + 'system' => [] ]; /** diff --git a/author/project/system/databases/.gitignore b/author/project/system/databases/.gitignore new file mode 100644 index 0000000..c936709 --- /dev/null +++ b/author/project/system/databases/.gitignore @@ -0,0 +1,3 @@ +!.gitignore +*.baza +*.php diff --git a/author/project/system/public/index.php b/author/project/system/public/index.php index 239476d..cfdca49 100755 --- a/author/project/system/public/index.php +++ b/author/project/system/public/index.php @@ -31,6 +31,9 @@ require SETTINGS . DIRECTORY_SEPARATOR . 'system.php'; // Initializing path to the directory of the storage define('STORAGE', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'storage'); +// Initializing path to the databases directory +define('DATABASES', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'databases'); + // Initializing dependencies require ROOT . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'; diff --git a/author/project/system/views/templater.php b/author/project/system/views/templater.php index 32d523a..756c99b 100755 --- a/author/project/system/views/templater.php +++ b/author/project/system/views/templater.php @@ -5,8 +5,7 @@ declare(strict_types=1); namespace ${REPO_OWNER}\${REPO_NAME}\views; // Files of the project -use ${REPO_OWNER}\${REPO_NAME}\models\session, - ${REPO_OWNER}\${REPO_NAME}\models\enumerations\language; +use ${REPO_OWNER}\${REPO_NAME}\models\enumerations\language; // Framework for PHP use mirzaev\minimal\controller; @@ -30,10 +29,11 @@ use ArrayAccess as array_access, * @param twig $$twig Instance of the twig templater * @param array $$variables Registry of view global variables * - * @method void __construct(?session &$$session) Constructor + * @method void __construct() Constructor * @method string|null render(string $$file, ?array $$variables) Render the HTML-document * * @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License + * @author Arsen Mirzaev Tatyano-Muradovich * @author ${REPO_OWNER} */ final class templater extends controller implements array_access @@ -55,11 +55,9 @@ final class templater extends controller implements array_access /** * Constructor of an instance * - * @param ?session $$session Instance of the session in ArangoDB - * * @return void */ - public function __construct(?session &$$session = null) + public function __construct() { // Initializing the Twig instance $$this->twig = new twig(new FilesystemLoader(VIEWS)); @@ -68,7 +66,6 @@ final class templater extends controller implements array_access $$this->twig->addGlobal('theme', 'default'); $$this->twig->addGlobal('server', $$_SERVER); $$this->twig->addGlobal('cookies', $$_COOKIE); - if (!empty($$session->status())) $$this->twig->addGlobal('session', $$session); $$this->twig->addGlobal('language', $$language = $$session?->buffer['language'] ?? language::en); } diff --git a/composer.json b/composer.json index ee93435..a72b97f 100755 --- a/composer.json +++ b/composer.json @@ -1,10 +1,11 @@ { "name": "${REPO_OWNER}/${REPO_NAME}", "description": "${REPO_DESCRIPTION}", - "homepage": "https://git.mirzaev.sexy${REPO_LINK}", + "homepage": "https://git.svoboda.works${REPO_LINK}", "type": "site", "keywords": [ - "minimal" + "minimal", + "baza" ], "readme": "README.md", "license": "WTFPL", @@ -17,21 +18,17 @@ } ], "support": { - "wiki": "https://git.mirzaev.sexy${REPO_LINK}/wiki", - "issues": "https://git.mirzaev.sexy${REPO_LINK}/issues" + "wiki": "https://git.svoboda.works${REPO_LINK}/wiki", + "issues": "https://git.svoboda.works${REPO_LINK}/issues" }, "require": { "php": "^8.4", - "triagens/arangodb": "^3.8", "mirzaev/minimal": "^3.4", - "mirzaev/arangodb": "^1.3", + "mirzaev/baza": "^3.3", "twig/twig": "^3.10", "twig/extra-bundle": "^3.7", "twig/intl-extra": "^3.10" }, - "require-dev": { - "phpunit/phpunit": "~9.5" - }, "autoload": { "psr-4": { "${REPO_OWNER}\\${REPO_NAME}\\": "${REPO_OWNER}/${REPO_NAME}/system"