forked from mirzaev/pot-php
Compare commits
72 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8b5a49747b | |||
| f2eb59336e | |||
| 913dfb8a92 | |||
| 372d008545 | |||
| e38a870e71 | |||
| 36b48d14d1 | |||
| 1261738c3d | |||
| 9718bec887 | |||
| 7f8525789e | |||
| c6f7f65360 | |||
| c65f7d4055 | |||
| bdef194b68 | |||
| a3eeacc4b4 | |||
| da69b20491 | |||
| 1d4d3e5f24 | |||
| 2b417f1649 | |||
| 1ee4c9a7dd | |||
| ece40a8644 | |||
| 6e5339a7d9 | |||
| b989a89e2b | |||
| fbcb72a47b | |||
| 485ac59c69 | |||
| 315f9bb7e3 | |||
| 9baf88d93c | |||
| d3a47b04fb | |||
| 1a05a0413d | |||
| 8c777e72c7 | |||
| a62b5ad3e5 | |||
| 4eecb4c5ed | |||
| ff663e7bf7 | |||
| 32d92bcc7e | |||
| 5c06ec423a | |||
| 41c0e2717c | |||
| 6109c2dd2f | |||
| 9f375114ef | |||
| f8f6119ef6 | |||
| 9ef52e1dfc | |||
| d3775bf96d | |||
| 510a80665b | |||
| e805fe9e76 | |||
| 2c29d0c842 | |||
| 93311f1857 | |||
| b86e856fe7 | |||
| a893aa6b5a | |||
| 321c28a53e | |||
| 9b958b6a88 | |||
| 24fcef43f7 | |||
| c9e5cb3762 | |||
| 2c6ed07ded | |||
| 96388c220e | |||
| c2cba489d1 | |||
| aad0a5a051 | |||
| 8159f6866d | |||
| 9dccb451f6 | |||
| 9f3b87c1ed | |||
| e0845e2ef1 | |||
| 5c0f1815c0 | |||
| 6a4cfb8e2f | |||
| 7ddf05ead3 | |||
| b6d2725848 | |||
| 3a2e102e11 | |||
| 3aa8936fc5 | |||
| 3af08b07ed | |||
| 4f4d31b64a | |||
| c0515a4171 | |||
| 02d1350982 | |||
| 37ae0546fd | |||
| 0510dca375 | |||
| 2b3f624199 | |||
| 0843fd83a5 | |||
| 7f7cdced69 | |||
| 04f8b49075 |
2
.gitea/template
Normal file → Executable file
2
.gitea/template
Normal file → Executable file
@@ -1 +1 @@
|
||||
*
|
||||
**
|
||||
|
||||
1
.gitignore
vendored
Normal file → Executable file
1
.gitignore
vendored
Normal file → Executable file
@@ -1,4 +1,3 @@
|
||||
!.gitignore
|
||||
composer.phar
|
||||
composer.lock
|
||||
vendor
|
||||
|
||||
128
author/project/system/controllers/core.php
Normal file → Executable file
128
author/project/system/controllers/core.php
Normal file → Executable file
@@ -5,117 +5,79 @@ declare(strict_types=1);
|
||||
namespace ${REPO_OWNER}\${REPO_NAME}\controllers;
|
||||
|
||||
// Files of the project
|
||||
use ${REPO_OWNER}\${REPO_NAME}\views\manager,
|
||||
${REPO_OWNER}\${REPO_NAME}\models\core as models,
|
||||
${REPO_OWNER}\${REPO_NAME}\models\account_model as account,
|
||||
${REPO_OWNER}\${REPO_NAME}\models\session_model as session;
|
||||
use ${REPO_OWNER}\${REPO_NAME}\views\templater,
|
||||
${REPO_OWNER}\${REPO_NAME}\models\core as models;
|
||||
|
||||
// Library for ArangoDB
|
||||
use ArangoDBClient\Document as _document;
|
||||
// Library for languages support
|
||||
use mirzaev\languages\language;
|
||||
|
||||
// Framework for PHP
|
||||
use mirzaev\minimal\controller;
|
||||
use mirzaev\minimal\core as minimal,
|
||||
mirzaev\minimal\controller,
|
||||
mirzaev\minimal\http\response,
|
||||
mirzaev\minimal\http\enumerations\status;
|
||||
|
||||
/**
|
||||
* Core of controllers
|
||||
* Controllers core
|
||||
*
|
||||
* @package ${REPO_OWNER}\${REPO_NAME}\controllers
|
||||
* @author ${REPO_OWNER} < mail >
|
||||
*
|
||||
* @param language $$language Language
|
||||
* @param response $$response Response
|
||||
* @param array $$errors Registry of errors
|
||||
*
|
||||
* @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 <arsen@mirzaev.sexy>
|
||||
*/
|
||||
class core extends controller
|
||||
{
|
||||
/**
|
||||
* Postfix for name of controllers files
|
||||
* Language
|
||||
*
|
||||
* @var language $$language Language
|
||||
*/
|
||||
final public const POSTFIX = '';
|
||||
protected language $$language = language::en;
|
||||
|
||||
/**
|
||||
* Instance of a session
|
||||
* Response
|
||||
*
|
||||
* @see https://wiki.php.net/rfc/property-hooks (find a table about backed and virtual hooks)
|
||||
*
|
||||
* @var response $$response Response
|
||||
*/
|
||||
protected readonly session $session;
|
||||
protected response $$response {
|
||||
// Read
|
||||
get => $$this->response ??= $$this->request->response();
|
||||
}
|
||||
|
||||
/**
|
||||
* Instance of an account
|
||||
* Errors
|
||||
*
|
||||
* @var array $$errors Registry of errors
|
||||
*/
|
||||
protected readonly ?account $account;
|
||||
|
||||
/**
|
||||
* Registry of errors
|
||||
*/
|
||||
protected array $errors = [
|
||||
'session' => [],
|
||||
'account' => []
|
||||
protected array $$errors = [
|
||||
'system' => []
|
||||
];
|
||||
|
||||
/**
|
||||
* Constructor of an instance
|
||||
* Constructor
|
||||
*
|
||||
* @param bool $initialize Initialize a controller?
|
||||
* @param minimal $$core Instance of the MINIMAL
|
||||
* @param bool $$initialize Initialize a controller?
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(bool $initialize = true)
|
||||
public function __construct(minimal $$core)
|
||||
{
|
||||
// Blocking requests from CloudFlare (better to write this blocking into nginx config file)
|
||||
if ($_SERVER['HTTP_USER_AGENT'] === 'nginx-ssl early hints') return;
|
||||
if (isset($$_SERVER['HTTP_USER_AGENT']) && $$_SERVER['HTTP_USER_AGENT'] === 'nginx-ssl early hints') return status::bruh->label;
|
||||
|
||||
// Initializing the view template engine instance
|
||||
$$this->view = new templater();
|
||||
|
||||
// For the extends system
|
||||
parent::__construct($initialize);
|
||||
|
||||
if ($initialize) {
|
||||
// Initializing is requested
|
||||
|
||||
// Initializing of models core (connect to ArangoDB...)
|
||||
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);
|
||||
parent::__construct(core: $$core);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check of initialization
|
||||
*
|
||||
* Checks whether a property is initialized in a document instance from ArangoDB
|
||||
*
|
||||
* @param string $name Name of the property from ArangoDB
|
||||
*
|
||||
* @return bool The property is initialized?
|
||||
*/
|
||||
public function __isset(string $name): bool
|
||||
{
|
||||
// Check of initialization of the property and exit (success)
|
||||
return match ($name) {
|
||||
default => isset($this->{$name})
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
52
author/project/system/controllers/index.php
Normal file → Executable file
52
author/project/system/controllers/index.php
Normal file → Executable file
@@ -7,24 +7,62 @@ namespace ${REPO_OWNER}\${REPO_NAME}\controllers;
|
||||
// Files of the project
|
||||
use ${REPO_OWNER}\${REPO_NAME}\controllers\core;
|
||||
|
||||
// Framework for PHP
|
||||
use mirzaev\minimal\http\enumerations\content,
|
||||
mirzaev\minimal\http\enumerations\status;
|
||||
|
||||
/**
|
||||
* Index controller
|
||||
* Index
|
||||
*
|
||||
* @package ${REPO_OWNER}\${REPO_NAME}\controllers
|
||||
* @author ${REPO_OWNER} < mail >
|
||||
*
|
||||
* @param array $$errors Registry of errors
|
||||
*
|
||||
* @method null index() Main page
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
*/
|
||||
final class index extends core
|
||||
{
|
||||
/**
|
||||
* Render the main page
|
||||
* Errors
|
||||
*
|
||||
* @param array $parameters Parameters of the request (POST + GET)
|
||||
* @var array $$errors Registry of errors
|
||||
*/
|
||||
public function index(array $parameters = []): ?string
|
||||
protected array $$errors = [
|
||||
'system' => []
|
||||
];
|
||||
|
||||
/**
|
||||
* Main page
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function index(): null
|
||||
{
|
||||
if (str_contains($$this->request->headers['accept'] ?? '', content::html->value)) {
|
||||
// Request for HTML response
|
||||
|
||||
// Render page
|
||||
$$page = $$this->view->render('index.html');
|
||||
|
||||
// Sending response
|
||||
$$this->response
|
||||
->start()
|
||||
->clean()
|
||||
->sse()
|
||||
->write($$page)
|
||||
->validate($$this->request)
|
||||
?->body()
|
||||
->end();
|
||||
|
||||
// Deinitializing rendered page
|
||||
unset($$page);
|
||||
|
||||
// Exit (success)
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'GET') return $this->view->render(DIRECTORY_SEPARATOR . 'index.html');
|
||||
else if ($_SERVER['REQUEST_METHOD'] === 'POST') return $main;
|
||||
return null;
|
||||
}
|
||||
|
||||
// Exit (fail)
|
||||
return null;
|
||||
|
||||
3
author/project/system/databases/.gitignore
vendored
Normal file
3
author/project/system/databases/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
!.gitignore
|
||||
!*.php
|
||||
*.baza
|
||||
71
author/project/system/databases/scripts/account.php
Normal file
71
author/project/system/databases/scripts/account.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ${REPO_OWNER}\${REPO_NAME};
|
||||
|
||||
// Files of the project
|
||||
use ${REPO_OWNER}\${REPO_NAME}\models\account,
|
||||
${REPO_OWNER}\${REPO_NAME}\models\authorizations,
|
||||
${REPO_OWNER}\${REPO_NAME}\models\chat,
|
||||
${REPO_OWNER}\${REPO_NAME}\models\tariff;
|
||||
|
||||
// Svoboda time
|
||||
use svoboda\time\statement as svoboda;
|
||||
|
||||
// Baza database
|
||||
use mirzaev\baza\record;
|
||||
|
||||
// Enabling debugging
|
||||
/* ini_set('error_reporting', E_ALL);
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1); */
|
||||
|
||||
// Initializing path to the public directory
|
||||
define('INDEX', __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'public');
|
||||
|
||||
// Initializing path to the root directory
|
||||
define('ROOT', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR);
|
||||
|
||||
// Initializing path to the settings directory
|
||||
define('SETTINGS', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'settings');
|
||||
|
||||
// Initializing path to the storage directory
|
||||
define('STORAGE', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'storage');
|
||||
|
||||
// Initializing path to the databases directory
|
||||
define('DATABASES', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'databases');
|
||||
|
||||
// Initializing path to the localizations directory
|
||||
define('LOCALIZATIONS', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'localizations');
|
||||
|
||||
// Initiailizing telegram data
|
||||
require(SETTINGS . DIRECTORY_SEPARATOR . 'telegram.php');
|
||||
|
||||
// Initializing dependencies
|
||||
require ROOT . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
|
||||
|
||||
// Initializing the account model
|
||||
$$account_model = new account();
|
||||
|
||||
// Searching for the account
|
||||
$$account = $$account_model->database->read(
|
||||
filter: fn(record $$record) => $$record->domain === 'buddy_volkodav',
|
||||
amount: 1,
|
||||
offset: 0
|
||||
)[0] ?? null;
|
||||
|
||||
var_dump($$account);
|
||||
|
||||
// Initializing the account authorizations model
|
||||
$$authorizations_model = new authorizations();
|
||||
|
||||
// Searching for the account authorizations
|
||||
$$authorizations = $$authorizations_model->database->read(
|
||||
filter: fn(record $$record) => $$record->account === $$account->identifier,
|
||||
amount: 1,
|
||||
offset: 0
|
||||
)[0] ?? null;
|
||||
|
||||
var_dump($$authorizations);
|
||||
|
||||
6
author/project/system/localizations/english.php
Normal file
6
author/project/system/localizations/english.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
// Exit (success)
|
||||
return [
|
||||
'' => ''
|
||||
]
|
||||
6
author/project/system/localizations/russian.php
Normal file
6
author/project/system/localizations/russian.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
// Exit (success)
|
||||
return [
|
||||
'' => ''
|
||||
]
|
||||
377
author/project/system/models/account.php
Normal file
377
author/project/system/models/account.php
Normal file
@@ -0,0 +1,377 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ${REPO_OWNER}\${REPO_NAME}\models;
|
||||
|
||||
// Files of the project
|
||||
use ${REPO_OWNER}\${REPO_NAME}\models\core,
|
||||
${REPO_OWNER}\${REPO_NAME}\models\authorizations,
|
||||
${REPO_OWNER}\${REPO_NAME}\models\chat,
|
||||
${REPO_OWNER}\${REPO_NAME}\models\settings,
|
||||
${REPO_OWNER}\${REPO_NAME}\models\tariff,
|
||||
${REPO_OWNER}\${REPO_NAME}\models\code,
|
||||
${REPO_OWNER}\${REPO_NAME}\models\enumerations\tariff as tariff_type;
|
||||
|
||||
// The library for languages support
|
||||
use mirzaev\languages\language;
|
||||
|
||||
// Baza database
|
||||
use mirzaev\baza\database,
|
||||
mirzaev\baza\column,
|
||||
mirzaev\baza\record,
|
||||
mirzaev\baza\enumerations\encoding,
|
||||
mirzaev\baza\enumerations\type;
|
||||
|
||||
// Active Record pattern
|
||||
use mirzaev\record\interfaces\record as record_interface,
|
||||
mirzaev\record\traits\record as record_trait;
|
||||
|
||||
// Svoboda time
|
||||
use svoboda\time\statement as svoboda;
|
||||
|
||||
// Framework for Telegram
|
||||
use Zanzara\Telegram\Type\User as telegram_user;
|
||||
|
||||
// Built-in libraries
|
||||
use Exception as exception,
|
||||
RuntimeException as exception_runtime;
|
||||
|
||||
/**
|
||||
* Account
|
||||
*
|
||||
* @package ${REPO_OWNER}\${REPO_NAME}\models
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
*/
|
||||
final class account extends core implements record_interface
|
||||
{
|
||||
use record_trait;
|
||||
|
||||
/**
|
||||
* File
|
||||
*
|
||||
* @var string $$database Path to the database file
|
||||
*/
|
||||
protected string $$file = DATABASES . DIRECTORY_SEPARATOR . 'accounts.baza';
|
||||
|
||||
/**
|
||||
* Database
|
||||
*
|
||||
* @var database $$database The database
|
||||
*/
|
||||
public protected(set) database $$database;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @method record|null $$record The record
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(?record $$record = null)
|
||||
{
|
||||
// Initializing the database
|
||||
$$this->database = new database()
|
||||
->encoding(encoding::utf8)
|
||||
->columns(
|
||||
new column('identifier', type::long_long_unsigned),
|
||||
new column('identifier_telegram', type::long_long_unsigned),
|
||||
new column('domain', type::string, ['length' => 32]),
|
||||
new column('name_first', type::string, ['length' => 64]),
|
||||
new column('name_second', type::string, ['length' => 64]),
|
||||
new column('language', type::string, ['length' => 2]),
|
||||
new column('robot', type::char),
|
||||
/* new column('', type::), */
|
||||
new column('updated', type::integer_unsigned),
|
||||
new column('created', type::integer_unsigned)
|
||||
)
|
||||
->connect($$this->file);
|
||||
|
||||
// Initializing the record
|
||||
$$record instanceof record and $$this->record = $$record;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*
|
||||
* @param telegram_user $$telegram The telegram account
|
||||
*
|
||||
* @throws exception_runtime if update the account record in the database by the telegram account values
|
||||
* @throws exception_runtime if failed to find the registered account
|
||||
* @throws exception_runtime if failed to registrate the account
|
||||
*
|
||||
* @return static|null The account, if found, updated or created
|
||||
*/
|
||||
public function initialize(telegram_user $$telegram): ?static
|
||||
{
|
||||
// Searching for the account in the database
|
||||
$$account = $$this->database->read(filter: fn(record $$record) => $$record->identifier_telegram === $$telegram->getId(), amount: 1)[0] ?? null;
|
||||
|
||||
if ($$account instanceof record) {
|
||||
// Found the account record
|
||||
|
||||
if (
|
||||
$$account->domain !== (string) $$telegram->getUsername() ||
|
||||
$$account->name_first !== (string) $$telegram->getFirstName() ||
|
||||
$$account->name_second !== (string) $$telegram->getLastName() ||
|
||||
$$account->language !== (string) $$telegram->getLanguageCode()
|
||||
) {
|
||||
// The telegram account was updated
|
||||
|
||||
// Updating the account in the database
|
||||
$$updated = $$this->database->read(
|
||||
filter: fn(record $$record) => $$record->identifier_telegram === $$telegram->getId(),
|
||||
update: function (record &$$record) use ($$telegram) {
|
||||
// Writing new values into the record
|
||||
$$record->domain = (string) $$telegram->getUsername();
|
||||
$$record->name_first = (string) $$telegram->getFirstName();
|
||||
$$record->name_second = (string) $$telegram->getLastName();
|
||||
$$record->language = (string) $$telegram->getLanguageCode();
|
||||
$$record->updated = svoboda::timestamp();
|
||||
},
|
||||
amount: 1
|
||||
)[0] ?? null;
|
||||
|
||||
if ($$updated instanceof record && $$updated->values() !== $$account->values()) {
|
||||
// Updated the account in the database
|
||||
|
||||
// Writing the updated record into the account object
|
||||
$$this->record = $$updated;
|
||||
|
||||
// Deserializing parameters
|
||||
$$this->deserialize();
|
||||
|
||||
// Exit (success)
|
||||
return $$this;
|
||||
} else {
|
||||
// Not updated the account in the database
|
||||
|
||||
// Exit (fail)
|
||||
throw new exception_runtime('Failed to update the account record in the database by the telegram account values');
|
||||
}
|
||||
}
|
||||
|
||||
// Writing the found record into the account object
|
||||
$$this->record = $$account;
|
||||
|
||||
// Deserializing parameters
|
||||
$$this->deserialize();
|
||||
|
||||
// Exit (success)
|
||||
return $$this;
|
||||
} else {
|
||||
// Not found the account record
|
||||
|
||||
if ($$this->registrate($$telegram)) {
|
||||
// Registered the account
|
||||
|
||||
// Searching for the registered account in the database
|
||||
$$registered = $$this->database->read(filter: fn(record $$record) => $$record->identifier_telegram === $$telegram->getId(), amount: 1)[0] ?? null;
|
||||
|
||||
if ($$registered instanceof record) {
|
||||
// Found the registered account
|
||||
|
||||
// Writing the registered record into the account object
|
||||
$$this->record = $$registered;
|
||||
|
||||
// Deserializing parameters
|
||||
$$this->deserialize();
|
||||
|
||||
// Exit (success)
|
||||
return $$this;
|
||||
} else {
|
||||
// Not found the registered account
|
||||
|
||||
// Exit (fail)
|
||||
throw new exception_runtime('Failed to find the registered account');
|
||||
}
|
||||
} else {
|
||||
// Not registered the account
|
||||
|
||||
// Exit (fail)
|
||||
throw new exception_runtime('Failed to registrate the account');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registrate
|
||||
*
|
||||
* Create the account by the telegram account data
|
||||
*
|
||||
* @param telegram_user $$telegram The telegram account
|
||||
*
|
||||
* @return record|false The record, if created
|
||||
*/
|
||||
public function registrate(telegram_user $$telegram): record|false
|
||||
{
|
||||
// Creating the record
|
||||
$$record = $$this->write(
|
||||
telegram_identifier: (int) $$telegram->getId(),
|
||||
name_first: (string) $$telegram->getFirstName(),
|
||||
name_last: (string) $$telegram->getLastName(),
|
||||
domain: (string) $$telegram->getUsername(),
|
||||
language: (string) $$telegram->getLanguageCode(),
|
||||
robot: (bool) $$telegram->isBot()
|
||||
);
|
||||
|
||||
if ($$record instanceof record) {
|
||||
// The record was writed into the database
|
||||
|
||||
// Initializing the authorizations model
|
||||
$$authorizations = new authorizations();
|
||||
|
||||
// Creating the authorizations record
|
||||
$$authorizations->write(account: $$record->identifier);
|
||||
|
||||
// Initializing the settings model
|
||||
$$settings = new settings();
|
||||
|
||||
// Creating the account settings
|
||||
$$settings->write(account: $$record->identifier);
|
||||
|
||||
// Initializing the chat model
|
||||
$$chat = new chat();
|
||||
|
||||
// Creating the account chat
|
||||
$$record->chat = $$chat->write(account: $$record->identifier, network: NETWORK_DEFAULT);
|
||||
|
||||
// Initializing the tariff model
|
||||
$$tariff = new tariff();
|
||||
|
||||
// Creating the tariff record
|
||||
$$record->tariff = $$tariff->write(account: $$record->identifier, invoice: 0, active: 1, type: TARIFF_DEFAULT ?? tariff_type::free);
|
||||
|
||||
// Writing the record into the database
|
||||
$$record = $$this->database->read(
|
||||
filter: fn(record $$_record) => $$_record->identifier === $$record->identifier,
|
||||
update: fn(record &$$_record) => $$_record = $$record,
|
||||
amount: 1
|
||||
)[0] ?? null;
|
||||
|
||||
// Exit (success)
|
||||
return $$record;
|
||||
}
|
||||
|
||||
// Exit (fail)
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write
|
||||
*
|
||||
* @param int $$telegram_identifier The telegram account identifier
|
||||
* @param string $$name_first
|
||||
* @param string $$name_last
|
||||
* @param string $$domain
|
||||
* @param language|string $$language
|
||||
* @param bool $$robot Is a robot?
|
||||
*
|
||||
* @return record|false The record, if created
|
||||
*/
|
||||
public function write(
|
||||
int $$telegram_identifier,
|
||||
string $$domain = '',
|
||||
string $$name_first = '',
|
||||
string $$name_last = '',
|
||||
language|string $$language = LANGUAGE_DEFAULT ?? language::en,
|
||||
bool $$robot = false,
|
||||
): record|false {
|
||||
// Initializing the record
|
||||
$$record = $$this->database->record(
|
||||
$$this->database->count() + 1,
|
||||
(int) $$telegram_identifier,
|
||||
$$domain,
|
||||
$$name_first,
|
||||
$$name_last,
|
||||
$$language instanceof language ? $$language->name : (string) $$language,
|
||||
(int) $$robot,
|
||||
/* */
|
||||
svoboda::timestamp(),
|
||||
svoboda::timestamp()
|
||||
);
|
||||
|
||||
// Writing the record into the database
|
||||
$$created = $$this->database->write($$record);
|
||||
|
||||
// Exit (success)
|
||||
return $$created ? $$record : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize
|
||||
*
|
||||
* @return self The instance from which the method was called (fluent interface)
|
||||
*/
|
||||
public function serialize(): self
|
||||
{
|
||||
// Serializing the record parameters
|
||||
$$this->record->language = $$this->record->language->name;
|
||||
|
||||
// Exit (success)
|
||||
return $$this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserialize
|
||||
*
|
||||
* @return self The instance from which the method was called (fluent interface)
|
||||
*/
|
||||
public function deserialize(): self
|
||||
{
|
||||
// Deserializing the record parameters
|
||||
$$this->record->language = language::{$$this->record->language} ?? LANGUAGE_DEFAULT ?? language::en;
|
||||
|
||||
// Exit (success)
|
||||
return $$this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Authorizations
|
||||
*
|
||||
* Search for the account authorizations
|
||||
*
|
||||
* @return authorizations|null The account authorizations
|
||||
*/
|
||||
public function authorizations(): ?authorizations
|
||||
{
|
||||
// Search for the account authorizations
|
||||
$$authorizations = new authorizations()->read(filter: fn(record $$record) => $$record->active === 1 && $$record->account === $$this->identifier);
|
||||
|
||||
if ($$authorizations instanceof authorizations) {
|
||||
// Found the account authorizations
|
||||
|
||||
// Exit (success)
|
||||
return $$authorizations;
|
||||
}
|
||||
|
||||
// Exit (fail)
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Settings
|
||||
*
|
||||
* Search for the account settings
|
||||
*
|
||||
* @return settings|null The account settings
|
||||
*/
|
||||
public function settings(): ?settings
|
||||
{
|
||||
// Search for the account settings
|
||||
$$settings = new settings()->read(filter: fn(record $$record) => $$record->active === 1 && $$record->account === $$this->identifier);
|
||||
|
||||
if ($$settings instanceof settings) {
|
||||
// Found the account settings
|
||||
|
||||
// Exit (success)
|
||||
return $$settings;
|
||||
}
|
||||
|
||||
// Exit (fail)
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
120
author/project/system/models/authorizations.php
Normal file
120
author/project/system/models/authorizations.php
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ${REPO_OWNER}\${REPO_NAME}\models;
|
||||
|
||||
// Files of the project
|
||||
use ${REPO_OWNER}\${REPO_NAME}\models\core;
|
||||
|
||||
// Baza database
|
||||
use mirzaev\baza\database,
|
||||
mirzaev\baza\column,
|
||||
mirzaev\baza\record,
|
||||
mirzaev\baza\enumerations\encoding,
|
||||
mirzaev\baza\enumerations\type;
|
||||
|
||||
// Active Record pattern
|
||||
use mirzaev\record\interfaces\record as record_interface,
|
||||
mirzaev\record\traits\record as record_trait;
|
||||
|
||||
// Svoboda time
|
||||
use svoboda\time\statement as svoboda;
|
||||
|
||||
// Framework for Telegram
|
||||
use Zanzara\Telegram\Type\User as telegram;
|
||||
|
||||
// Built-in libraries
|
||||
use Exception as exception,
|
||||
RuntimeException as exception_runtime;
|
||||
|
||||
/**
|
||||
* Authorizations
|
||||
*
|
||||
* @package ${REPO_OWNER}\${REPO_NAME}\models
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
*/
|
||||
final class authorizations extends core implements record_interface
|
||||
{
|
||||
use record_trait;
|
||||
|
||||
/**
|
||||
* File
|
||||
*
|
||||
* @var string $$database Path to the database file
|
||||
*/
|
||||
protected string $$file = DATABASES . DIRECTORY_SEPARATOR . 'authorizations.baza';
|
||||
|
||||
/**
|
||||
* Database
|
||||
*
|
||||
* @var database $$database The database
|
||||
*/
|
||||
public protected(set) database $$database;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @method record|null $$record The record
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(?record $$record = null)
|
||||
{
|
||||
// Initializing the database
|
||||
$$this->database = new database()
|
||||
->encoding(encoding::utf8)
|
||||
->columns(
|
||||
new column('identifier', type::long_long_unsigned),
|
||||
new column('account', type::long_long_unsigned),
|
||||
new column('system', type::char),
|
||||
new column('settings', type::char),
|
||||
new column('chat', type::char),
|
||||
/* new column('', type::char), */
|
||||
new column('system_settings', type::char),
|
||||
new column('updated', type::integer_unsigned),
|
||||
new column('created', type::integer_unsigned)
|
||||
)
|
||||
->connect($$this->file);
|
||||
|
||||
// Initializing the record
|
||||
$$record instanceof record and $$this->record = $$record;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write
|
||||
*
|
||||
* @param int $$account The account identifier
|
||||
* @param int $$system
|
||||
* @param int $$settings
|
||||
* @param int $$system_settings
|
||||
*
|
||||
* @return int|false The record identifier, if created
|
||||
*/
|
||||
public function write(
|
||||
int $$account,
|
||||
int $$system = 1,
|
||||
int $$settings = 1,
|
||||
int $$system_settings = 0,
|
||||
): int|false
|
||||
{
|
||||
$$record = $$this->database->record(
|
||||
$$this->database->count() + 1,
|
||||
$$account,
|
||||
$$system,
|
||||
$$settings,
|
||||
$$system_settings,
|
||||
svoboda::timestamp(),
|
||||
svoboda::timestamp()
|
||||
);
|
||||
|
||||
// Writing the record into the database
|
||||
$$created = $$this->database->write($$record);
|
||||
|
||||
// Exit (success)
|
||||
return $$created ? $$record->identifier : false;
|
||||
}
|
||||
}
|
||||
|
||||
283
author/project/system/models/core.php
Normal file → Executable file
283
author/project/system/models/core.php
Normal file → Executable file
@@ -5,285 +5,40 @@ declare(strict_types=1);
|
||||
namespace ${REPO_OWNER}\${REPO_NAME}\models;
|
||||
|
||||
// Framework for PHP
|
||||
use mirzaev\minimal\model;
|
||||
|
||||
// Framework for ArangoDB
|
||||
use mirzaev\arangodb\connection as arangodb,
|
||||
mirzaev\arangodb\collection,
|
||||
mirzaev\arangodb\document;
|
||||
|
||||
// Libraries for ArangoDB
|
||||
use ArangoDBClient\Document as _document,
|
||||
ArangoDBClient\DocumentHandler as _document_handler;
|
||||
use mirzaev\minimal\model,
|
||||
mirzaev\minimal\http\enumerations\status;
|
||||
|
||||
// Built-in libraries
|
||||
use exception;
|
||||
|
||||
/**
|
||||
* Core of models
|
||||
* Models core
|
||||
*
|
||||
* @package ${REPO_OWNER}\${REPO_NAME}\controllers
|
||||
* @author ${REPO_OWNER} < mail >
|
||||
* @package ${REPO_OWNER}\${REPO_NAME}\models
|
||||
*
|
||||
* @method void __construct() Constructor
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
*/
|
||||
class core extends model
|
||||
{
|
||||
/**
|
||||
* Postfix for name of models files
|
||||
*/
|
||||
final public const POSTFIX = '';
|
||||
|
||||
/**
|
||||
* Path to the file with settings of connecting to the ArangoDB
|
||||
*/
|
||||
final public const ARANGODB = '../settings/arangodb.php';
|
||||
|
||||
/**
|
||||
* Instance of the session of ArangoDB
|
||||
*/
|
||||
protected static arangodb $arangodb;
|
||||
|
||||
/**
|
||||
* Name of the collection in ArangoDB
|
||||
*/
|
||||
public const COLLECTION = 'THIS_COLLECTION_SHOULD_NOT_EXIST_REPLACE_IT_IN_THE_MODEL';
|
||||
|
||||
/**
|
||||
* Constructor of an instance
|
||||
* File
|
||||
*
|
||||
* @param bool $initialize Initialize a model?
|
||||
* @param ?arangodb $arangodb Instance of a session of ArangoDB
|
||||
* @var string $database Path to the database file
|
||||
*/
|
||||
protected string $$file = DATABASES . DIRECTORY_SEPARATOR . 'example.baza';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* Initialize the database
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(bool $initialize = true, ?arangodb $arangodb = null)
|
||||
public function __construct()
|
||||
{
|
||||
// For the extends system
|
||||
parent::__construct($initialize);
|
||||
|
||||
if ($initialize) {
|
||||
// Initializing is requested
|
||||
|
||||
if (isset($arangodb)) {
|
||||
// Recieved an instance of a session of ArangoDB
|
||||
|
||||
// Write an instance of a session of ArangoDB to the property
|
||||
$this->__set('arangodb', $arangodb);
|
||||
} else {
|
||||
// Not recieved an instance of a session of ArangoDB
|
||||
|
||||
// Initializing of an instance of a session of ArangoDB
|
||||
$this->__get('arangodb');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read from ArangoDB
|
||||
*
|
||||
* @param string $filter Expression for filtering (AQL)
|
||||
* @param string $sort Expression for sorting (AQL)
|
||||
* @param int $amount Amount of documents for collect
|
||||
* @param int $page Page
|
||||
* @param string $return Expression describing the parameters to return (AQL)
|
||||
* @param array &$errors The registry on errors
|
||||
*
|
||||
* @return _document|array|null An array of instances of documents from ArangoDB, if they are found
|
||||
*/
|
||||
public static function read(
|
||||
string $filter = '',
|
||||
string $sort = 'd.created DESC, d._key DESC',
|
||||
int $amount = 1,
|
||||
int $page = 1,
|
||||
string $return = 'd',
|
||||
array &$errors = []
|
||||
): _document|array|null {
|
||||
try {
|
||||
if (collection::init(static::$arangodb->session, static::COLLECTION)) {
|
||||
// Initialized the collection
|
||||
|
||||
// Read from ArangoDB and exit (success)
|
||||
return collection::search(
|
||||
static::$arangodb->session,
|
||||
sprintf(
|
||||
<<<'AQL'
|
||||
FOR d IN %s
|
||||
%s
|
||||
%s
|
||||
LIMIT %d, %d
|
||||
RETURN %s
|
||||
AQL,
|
||||
static::COLLECTION,
|
||||
empty($filter) ? '' : "FILTER $filter",
|
||||
empty($sort) ? '' : "SORT $sort",
|
||||
--$page <= 0 ? 0 : $amount * $page,
|
||||
$amount,
|
||||
$return
|
||||
)
|
||||
);
|
||||
} else throw new exception('Failed to initialize the collection');
|
||||
} catch (exception $e) {
|
||||
// Write to the registry of errors
|
||||
$errors[] = [
|
||||
'text' => $e->getMessage(),
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
'stack' => $e->getTrace()
|
||||
];
|
||||
}
|
||||
|
||||
// Exit (fail)
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete from ArangoDB
|
||||
*
|
||||
* @param _document $instance Instance of the document from ArangoDB
|
||||
* @param array &$errors The registry on errors
|
||||
*
|
||||
* @return bool Deleted from ArangoDB without errors?
|
||||
*/
|
||||
public static function delete(_document $instance, array &$errors = []): bool
|
||||
{
|
||||
try {
|
||||
if (collection::init(static::$arangodb->session, static::COLLECTION)) {
|
||||
// Initialized the collection
|
||||
|
||||
// Delete from ArangoDB and exit (success)
|
||||
return (new _document_handler(static::$arangodb->session))->remove($instance);
|
||||
} else throw new exception('Failed to initialize the collection');
|
||||
} catch (exception $e) {
|
||||
// Write to the registry of errors
|
||||
$errors[] = [
|
||||
'text' => $e->getMessage(),
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
'stack' => $e->getTrace()
|
||||
];
|
||||
}
|
||||
|
||||
// Exit (fail)
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update in ArangoDB
|
||||
*
|
||||
* @param _document $instance Instance of the document from ArangoDB
|
||||
*
|
||||
* @return bool Writed to ArangoDB without errors?
|
||||
*/
|
||||
public static function update(_document $instance): bool
|
||||
{
|
||||
// Update in ArangoDB and exit (success)
|
||||
return document::update(static::$arangodb->session, $instance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write
|
||||
*
|
||||
* @param string $name Name of the property
|
||||
* @param mixed $value Value of the property
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __set(string $name, mixed $value = null): void
|
||||
{
|
||||
match ($name) {
|
||||
'arangodb' => (function () use ($value) {
|
||||
if ($this->__isset('arangodb')) {
|
||||
// Is alredy initialized
|
||||
|
||||
// Exit (fail)
|
||||
throw new exception('Forbidden to reinitialize the session of ArangoDB ($this::$arangodb)', 500);
|
||||
} else {
|
||||
// Is not already initialized
|
||||
|
||||
if ($value instanceof arangodb) {
|
||||
// Recieved an appropriate value
|
||||
|
||||
// Write the property and exit (success)
|
||||
self::$arangodb = $value;
|
||||
} else {
|
||||
// Recieved an inappropriate value
|
||||
|
||||
// Exit (fail)
|
||||
throw new exception('Session of ArangoDB ($this::$arangodb) is need to be mirzaev\arangodb\connection', 500);
|
||||
}
|
||||
}
|
||||
})(),
|
||||
default => parent::__set($name, $value)
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Read
|
||||
*
|
||||
* @param string $name Name of the property
|
||||
*
|
||||
* @return mixed Content of the property, if they are found
|
||||
*/
|
||||
public function __get(string $name): mixed
|
||||
{
|
||||
return match ($name) {
|
||||
'arangodb' => (function () {
|
||||
try {
|
||||
if (!$this->__isset('arangodb')) {
|
||||
// Is not initialized
|
||||
|
||||
// Initializing of a default value from settings
|
||||
$this->__set('arangodb', new arangodb(require static::ARANGODB));
|
||||
}
|
||||
|
||||
// Exit (success)
|
||||
return self::$arangodb;
|
||||
} catch (exception) {
|
||||
// Exit (fail)
|
||||
return null;
|
||||
}
|
||||
})(),
|
||||
default => parent::__get($name)
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete
|
||||
*
|
||||
* @param string $name Name of the property
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __unset(string $name): void
|
||||
{
|
||||
// Deleting a property and exit (success)
|
||||
parent::__unset($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check of initialization
|
||||
*
|
||||
* @param string $name Name of the property
|
||||
*
|
||||
* @return bool The property is initialized?
|
||||
*/
|
||||
public function __isset(string $name): bool
|
||||
{
|
||||
// Check of initialization of the property and exit (success)
|
||||
return parent::__isset($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call a static property or method
|
||||
*
|
||||
* @param string $name Name of the property or the method
|
||||
* @param array $arguments Arguments for the method
|
||||
*/
|
||||
public static function __callStatic(string $name, array $arguments): mixed
|
||||
{
|
||||
match ($name) {
|
||||
'arangodb' => (new static)->__get('arangodb'),
|
||||
default => throw new exception("Not found: $name", 500)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,276 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ${REPO_OWNER}\${REPO_NAME}\models;
|
||||
|
||||
// Files of the project
|
||||
use mirzaev\ebala\models\account,
|
||||
mirzaev\ebala\models\traits\status;
|
||||
|
||||
// Framework for ArangoDB
|
||||
use mirzaev\arangodb\collection,
|
||||
mirzaev\arangodb\document;
|
||||
|
||||
// Library для ArangoDB
|
||||
use ArangoDBClient\Document as _document;
|
||||
|
||||
// Built-in libraries
|
||||
use exception;
|
||||
|
||||
/**
|
||||
* Model of session
|
||||
*
|
||||
* @package ${REPO_OWNER}\${REPO_NAME}\controllers
|
||||
* @author ${REPO_OWNER} < mail >
|
||||
*/
|
||||
final class session extends core
|
||||
{
|
||||
/**
|
||||
* Name of the collection in ArangoDB
|
||||
*/
|
||||
final public const COLLECTION = 'session';
|
||||
|
||||
/**
|
||||
* An instance of the ArangoDB document from ArangoDB
|
||||
*/
|
||||
protected readonly _document $document;
|
||||
|
||||
/**
|
||||
* Constructor of an instance
|
||||
*
|
||||
* Initialize of a session and write them to the $this->document property
|
||||
*
|
||||
* @param ?string $hash Hash of the session in ArangoDB
|
||||
* @param ?int $expires Date of expiring of the session (used for creating a new session)
|
||||
* @param array &$errors Registry of errors
|
||||
*
|
||||
* @return static instance of the ArangoDB document of session
|
||||
*/
|
||||
public function __construct(?string $hash = null, ?int $expires = null, array &$errors = [])
|
||||
{
|
||||
try {
|
||||
if (collection::init(static::$arangodb->session, self::COLLECTION)) {
|
||||
// Initialized the collection
|
||||
|
||||
if ($this->search($hash, $errors)) {
|
||||
// Found an instance of the ArangoDB document of session and received a session hash
|
||||
} else {
|
||||
// Not found an instance of the ArangoDB document of session
|
||||
|
||||
// Initializing a new session and write they into ArangoDB
|
||||
$_id = document::write($this::$arangodb->session, self::COLLECTION, [
|
||||
'active' => true,
|
||||
'expires' => $expires ?? time() + 604800,
|
||||
'ip' => $_SERVER['REMOTE_ADDR'],
|
||||
'x-forwarded-for' => $_SERVER['HTTP_X_FORWARDED_FOR'] ?? null,
|
||||
'referer' => $_SERVER['HTTP_REFERER'] ?? null,
|
||||
'useragent' => $_SERVER['HTTP_USER_AGENT'] ?? null
|
||||
]);
|
||||
|
||||
if ($session = collection::search($this::$arangodb->session, sprintf(
|
||||
<<<AQL
|
||||
FOR d IN %s
|
||||
FILTER d._id == '%s' && d.expires > %d && d.active == true
|
||||
RETURN d
|
||||
AQL,
|
||||
self::COLLECTION,
|
||||
$_id,
|
||||
time()
|
||||
))) {
|
||||
// Found an instance of just created new session
|
||||
|
||||
// Generate a hash and write into an instance of the ArangoDB document of session property
|
||||
$session->hash = sodium_bin2hex(sodium_crypto_generichash($_id));
|
||||
|
||||
if (document::update($this::$arangodb->session, $session)) {
|
||||
// Is writed update
|
||||
|
||||
// Write instance of the ArangoDB document of session into property and exit (success)
|
||||
$this->document = $session;
|
||||
} else throw new exception('Could not write the session data');
|
||||
} else throw new exception('Could not create or find just created session');
|
||||
}
|
||||
} else throw new exception('Could not initialize the collection');
|
||||
} catch (exception $e) {
|
||||
// Write to the registry of errors
|
||||
$errors[] = [
|
||||
'text' => $e->getMessage(),
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
'stack' => $e->getTrace()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Search
|
||||
*
|
||||
* Search for the session in ArangoDB by hash and write they into $this->document property if they are found
|
||||
*
|
||||
* @param ?string $hash Hash of the session in ArangoDB
|
||||
* @param array &$errors Registry of errors
|
||||
*
|
||||
* @return static instance of the ArangoDB document of session
|
||||
*/
|
||||
public function search(?string $hash, array &$errors = []): bool
|
||||
{
|
||||
try {
|
||||
if (isset($hash)) {
|
||||
// Recieved a hash
|
||||
|
||||
// Search the session data in ArangoDB
|
||||
$_document = $session = collection::search($this::$arangodb->session, sprintf(
|
||||
<<<AQL
|
||||
FOR d IN %s
|
||||
FILTER d.hash == '%s' && d.expires > %d && d.active == true
|
||||
RETURN d
|
||||
AQL,
|
||||
self::COLLECTION,
|
||||
$hash,
|
||||
time()
|
||||
));
|
||||
|
||||
if ($_document instanceof _document) {
|
||||
// An instance of the ArangoDB document of session is found
|
||||
|
||||
// Write the session data to the property
|
||||
$this->document = $_document;
|
||||
|
||||
// Exit (success)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (exception $e) {
|
||||
// Write to the registry of errors
|
||||
$errors[] = [
|
||||
'text' => $e->getMessage(),
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
'stack' => $e->getTrace()
|
||||
];
|
||||
}
|
||||
|
||||
// Exit (fail)
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write to buffer of the session
|
||||
*
|
||||
* @param array $data Data for merging
|
||||
* @param array &$errors Registry of errors
|
||||
*
|
||||
* @return bool Is data has written into the session buffer?
|
||||
*/
|
||||
public function write(array $data, array &$errors = []): bool
|
||||
{
|
||||
try {
|
||||
if (collection::init($this::$arangodb->session, self::COLLECTION)) {
|
||||
// Initialized the collection
|
||||
|
||||
// An instance of the ArangoDB document of session is initialized?
|
||||
if (!isset($this->document)) throw new exception('An instance of the ArangoDB document of session is not initialized');
|
||||
|
||||
// Write data into buffwer of an instance of the ArangoDB document of session
|
||||
$this->document->buffer = array_replace_recursive(
|
||||
$this->document->buffer ?? [],
|
||||
[$_SERVER['INTERFACE'] => array_replace_recursive($this->document->buffer[$_SERVER['INTERFACE']] ?? [], $data)]
|
||||
);
|
||||
|
||||
// Write to ArangoDB and exit (success)
|
||||
return document::update($this::$arangodb->session, $this->document) ? true : throw new exception('Не удалось записать данные в буфер сессии');
|
||||
} else throw new exception('Could not initialize the collection');
|
||||
} catch (exception $e) {
|
||||
// Write to the registry of errors
|
||||
$errors[] = [
|
||||
'text' => $e->getMessage(),
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
'stack' => $e->getTrace()
|
||||
];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write
|
||||
*
|
||||
* Write a property into an instance of the ArangoDB document
|
||||
*
|
||||
* @param string $name Name of the property
|
||||
* @param mixed $value Content of the property
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __set(string $name, mixed $value = null): void
|
||||
{
|
||||
// Write to the property into an instance of the ArangoDB document and exit (success)
|
||||
$this->document->{$name} = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read
|
||||
*
|
||||
* Read a property from an instance of the ArangoDB docuemnt
|
||||
*
|
||||
* @param string $name Name of the property
|
||||
*
|
||||
* @return mixed Content of the property
|
||||
*/
|
||||
public function __get(string $name): mixed
|
||||
{
|
||||
// Read a property from an instance of the ArangoDB document and exit (success)
|
||||
return match ($name) {
|
||||
'arangodb' => $this::$arangodb,
|
||||
default => $this->document->{$name}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete
|
||||
*
|
||||
* Deinitialize the property in an instance of the ArangoDB document
|
||||
*
|
||||
* @param string $name Name of the property
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __unset(string $name): void
|
||||
{
|
||||
// Delete the property in an instance of the ArangoDB document and exit (success)
|
||||
unset($this->document->{$name});
|
||||
}
|
||||
|
||||
/**
|
||||
* Check of initialization
|
||||
*
|
||||
* Check of initialization of the property into an instance of the ArangoDB document
|
||||
*
|
||||
* @param string $name Name of the property
|
||||
*
|
||||
* @return bool The property is initialized?
|
||||
*/
|
||||
public function __isset(string $name): bool
|
||||
{
|
||||
// Check of initializatio nof the property and exit (success)
|
||||
return isset($this->document->{$name});
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a method
|
||||
*
|
||||
* Execute a method from an instance of the ArangoDB document
|
||||
*
|
||||
* @param string $name Name of the method
|
||||
* @param array $arguments Arguments for the method
|
||||
*
|
||||
* @return mixed Result of execution of the method
|
||||
*/
|
||||
public function __call(string $name, array $arguments = []): mixed
|
||||
{
|
||||
// Execute the method and exit (success)
|
||||
if (method_exists($this->document, $name)) return $this->document->{$name}($arguments);
|
||||
}
|
||||
}
|
||||
106
author/project/system/models/settings.php
Normal file
106
author/project/system/models/settings.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ${REPO_OWNER}\${REPO_NAME}\models;
|
||||
|
||||
// Files of the project
|
||||
use ${REPO_OWNER}\${REPO_NAME}\models\core,
|
||||
${REPO_OWNER}\${REPO_NAME}\models\tariff,
|
||||
${REPO_OWNER}\${REPO_NAME}\models\enumerations\tariff as tariff_type,
|
||||
${REPO_OWNER}\${REPO_NAME}\models\enumerations\acquiring as acquiring;
|
||||
|
||||
// Baza database
|
||||
use mirzaev\baza\database,
|
||||
mirzaev\baza\column,
|
||||
mirzaev\baza\record,
|
||||
mirzaev\baza\enumerations\encoding,
|
||||
mirzaev\baza\enumerations\type;
|
||||
|
||||
// Active Record pattern
|
||||
use mirzaev\record\interfaces\record as record_interface,
|
||||
mirzaev\record\traits\record as record_trait;
|
||||
|
||||
// Svoboda time
|
||||
use svoboda\time\statement as svoboda;
|
||||
|
||||
// Built-in libraries
|
||||
use Exception as exception,
|
||||
RuntimeException as exception_runtime;
|
||||
|
||||
/**
|
||||
* Settings
|
||||
*
|
||||
* @package ${REPO_OWNER}\${REPO_NAME}\models
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
*/
|
||||
final class settings extends core implements record_interface
|
||||
{
|
||||
use record_trait;
|
||||
|
||||
/**
|
||||
* File
|
||||
*
|
||||
* @var string $$database Path to the database file
|
||||
*/
|
||||
protected string $$file = DATABASES . DIRECTORY_SEPARATOR . 'settings.baza';
|
||||
|
||||
/**
|
||||
* Database
|
||||
*
|
||||
* @var database $$database The database
|
||||
*/
|
||||
public protected(set) database $$database;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @method record|null $$record The record
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(?record $$record = null)
|
||||
{
|
||||
// Initializing the database
|
||||
$$this->database = new database()
|
||||
->encoding(encoding::utf8)
|
||||
->columns(
|
||||
new column('identifier', type::long_long_unsigned),
|
||||
new column('account', type::long_long_unsigned),
|
||||
/* new column('', type::), */
|
||||
new column('updated', type::integer_unsigned),
|
||||
new column('created', type::integer_unsigned)
|
||||
)
|
||||
->connect($$this->file);
|
||||
|
||||
// Initializing the record
|
||||
$$record instanceof record and $$this->record = $$record;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write
|
||||
*
|
||||
* @param int $$account The account identifier (0 for disable)
|
||||
*
|
||||
* @return int|false The record identifier, if created
|
||||
*/
|
||||
public function write(
|
||||
int $$account = 0,
|
||||
): int|false {
|
||||
$$record = $$this->database->record(
|
||||
$$this->database->count() + 1,
|
||||
$$account,
|
||||
svoboda::timestamp(),
|
||||
svoboda::timestamp()
|
||||
);
|
||||
|
||||
// Writing the record into the database
|
||||
$$created = $$this->database->write($$record);
|
||||
|
||||
// Exit (success)
|
||||
return $$created ? $$record->identifier : false;
|
||||
}
|
||||
}
|
||||
|
||||
393
author/project/system/models/telegram/commands.php
Normal file
393
author/project/system/models/telegram/commands.php
Normal file
@@ -0,0 +1,393 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ${REPO_OWNER}\${REPO_NAME}\models\telegram;
|
||||
|
||||
// Files of the project
|
||||
use ${REPO_OWNER}\${REPO_NAME}\models\core,
|
||||
${REPO_OWNER}\${REPO_NAME}\models\account,
|
||||
${REPO_OWNER}\${REPO_NAME}\models\settings,
|
||||
${REPO_OWNER}\${REPO_NAME}\models\telegram\settings as telegram_settings,
|
||||
${REPO_OWNER}\${REPO_NAME}\models\telegram\processes\language\select as process_language_select;
|
||||
|
||||
// Library for languages support
|
||||
use mirzaev\languages\language;
|
||||
|
||||
// The library for escaping all markdown symbols
|
||||
use function mirzaev\unmarkdown;
|
||||
|
||||
// Framework for Telegram
|
||||
use Zanzara\Context as context,
|
||||
Zanzara\Telegram\Type\Message as message,
|
||||
Zanzara\Telegram\Type\Input\InputFile as file_input;
|
||||
|
||||
/**
|
||||
* Telegram commands
|
||||
*
|
||||
* @package ${REPO_OWNER}\${REPO_NAME}\models\telegram
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
*/
|
||||
final class commands extends core
|
||||
{
|
||||
/**
|
||||
* Start
|
||||
*
|
||||
* Responce for command: "/start"
|
||||
*
|
||||
* @param context $$context Request data from Telegram
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function start(context $$context): void
|
||||
{
|
||||
static::menu($$context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu
|
||||
*
|
||||
* Responce for command: '/menu'
|
||||
*
|
||||
* @param context $$context Request data from Telegram
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function menu(context $$context): void
|
||||
{
|
||||
// Initializing the account
|
||||
$$account = $$context->get('account');
|
||||
|
||||
if ($$account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing the language
|
||||
$$language = $$context->get('language');
|
||||
|
||||
if ($$language instanceof language) {
|
||||
// Initialized the language
|
||||
|
||||
// Initializing localization
|
||||
$$localization = $$context->get('localization');
|
||||
|
||||
if ($$localization) {
|
||||
// Initialized localization
|
||||
|
||||
// Initializing the title
|
||||
$$title = '📋 *' . $$localization['menu_title'] . '*';
|
||||
|
||||
// Initializing accounts
|
||||
/* $$accounts_message = '*' . $$localization['menu_accounts'] . ':* ' . ((new account)->database->count() ?? 0); */
|
||||
|
||||
// Initializing the account tariff
|
||||
$$tariff = $$account->tariff();
|
||||
|
||||
// Declaring the tariff button
|
||||
$$tariff_button = [];
|
||||
|
||||
if ($$tariff instanceof tariff) {
|
||||
// Initialized the account tariff
|
||||
|
||||
// Initializing the tariff button
|
||||
$$tariff_button = [
|
||||
'text' => '🔐 ' . $$tariff->type->label($$language) . ' (' . $$tariff->used . '/' . $$tariff->tokens . ')',
|
||||
'callback_data' => 'tariffs'
|
||||
];
|
||||
} else {
|
||||
|
||||
// Initialized the account tariff
|
||||
|
||||
// Initializing the tariff button
|
||||
$$tariff_button = [
|
||||
'text' => '⚠️ ' . $$localization['menu_tariff_empty'],
|
||||
'callback_data' => 'tariffs'
|
||||
];
|
||||
}
|
||||
|
||||
// Initializing the account chat
|
||||
$$chat = $$account->chat();
|
||||
|
||||
// Initializing the chto text
|
||||
$$howto = $$localization['menu_howto'];
|
||||
|
||||
// Sending the message
|
||||
$$context->sendMessage(
|
||||
<<<TXT
|
||||
$$title
|
||||
|
||||
$$howto
|
||||
TXT,
|
||||
[
|
||||
'reply_markup' => [
|
||||
'inline_keyboard' => [
|
||||
/* [
|
||||
[
|
||||
'text' => '⚙️ ' . $$localization[''],
|
||||
'callback_data' => ''
|
||||
]
|
||||
] */
|
||||
],
|
||||
'disable_notification' => true,
|
||||
'remove_keyboard' => true
|
||||
],
|
||||
]
|
||||
)->then(function (message $$message) use ($$context) {
|
||||
// Sended the message
|
||||
|
||||
});
|
||||
} else {
|
||||
// Not initialized localization
|
||||
|
||||
// Sending the message
|
||||
$$context->sendMessage('⚠️ *Failed to initialize localization*')
|
||||
->then(function (message $$message) use ($$context) {
|
||||
// Ending the conversation process
|
||||
$$context->endConversation();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Not initialized language
|
||||
|
||||
// Sending the message
|
||||
$$context->sendMessage('⚠️ *Failed to initialize language*')
|
||||
->then(function (message $$message) use ($$context) {
|
||||
// Sended the message
|
||||
|
||||
// Ending the conversation process
|
||||
$$context->endConversation();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
->then(function (message $$message) use ($$context) {
|
||||
// Ending the conversation process
|
||||
$$context->endConversation();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Account
|
||||
*
|
||||
* Responce for the command: "/account"
|
||||
*
|
||||
* Sends information about account with menu
|
||||
*
|
||||
* @param context $$context Request data from Telegram
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function account(context $$context): void
|
||||
{
|
||||
// Initializing the account
|
||||
$$account = $$context->get('account');
|
||||
|
||||
if ($$account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
$$localization = $$context->get('localization');
|
||||
|
||||
if ($$localization) {
|
||||
// Initialized localization
|
||||
|
||||
// Initializing title for the message
|
||||
$$title = '🫵 ' . $$localization['account_title'];
|
||||
|
||||
// Declaring buufer of rows about authorizations
|
||||
$$authorizations = '';
|
||||
|
||||
// Initializing rows about authorization
|
||||
foreach ($$account->values() as $$key => $$value) {
|
||||
// Iterating over account parameters
|
||||
|
||||
if (str_starts_with($$key, 'authorized_')) {
|
||||
// Iterating over account authorizations
|
||||
|
||||
// Skipping system authorizations
|
||||
if (str_starts_with($$key, 'authorized_system_')) continue;
|
||||
|
||||
// Writing into buffer of rows about authorizations
|
||||
$$authorizations .= ($$value ? '✅' : '❎') . ' *' . ($$localization["account_$$key"] ?? $$key) . ':* ' . ($$value ? $$localization['yes'] : $$localization['no']) . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Trimming the last line break character
|
||||
$$authorizations = trim($$authorizations, "\n");
|
||||
|
||||
// Sending the message
|
||||
$$context->sendMessage(
|
||||
<<<TXT
|
||||
$$title
|
||||
|
||||
$$authorizations
|
||||
TXT,
|
||||
[
|
||||
'reply_markup' => [
|
||||
'remove_keyboard' => true,
|
||||
'disable_notification' => true
|
||||
],
|
||||
'link_preview_options' => [
|
||||
'is_disabled' => true
|
||||
]
|
||||
]
|
||||
);
|
||||
} else {
|
||||
// Not initialized localization
|
||||
|
||||
// Sending the message
|
||||
$$context->sendMessage('⚠️ *Failed to initialize localization*')
|
||||
->then(function (message $$message) use ($$context) {
|
||||
// Ending the conversation process
|
||||
$$context->endConversation();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
->then(function (message $$message) use ($$context) {
|
||||
// Ending the conversation process
|
||||
$$context->endConversation();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Language
|
||||
*
|
||||
* Responce for the command: "/language"
|
||||
*
|
||||
* Send the language selection menu
|
||||
*
|
||||
* @param context $$context Request data from Telegram
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function language(context $$context): void
|
||||
{
|
||||
// Initializing the account
|
||||
$$account = $$context->get('account');
|
||||
|
||||
if ($$account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing language
|
||||
$$language = $$context->get('language');
|
||||
|
||||
if ($$language instanceof language) {
|
||||
// Initialized language
|
||||
|
||||
// Initializing localization
|
||||
$$localization = $$context->get('localization');
|
||||
|
||||
if ($$localization) {
|
||||
// Initialized localization
|
||||
|
||||
// Sending the language selection
|
||||
process_language_select::menu(
|
||||
context: $$context,
|
||||
prefix: 'settings_language_',
|
||||
title: '🌏 *' . $$localization['settings_select_language_title'] . '*',
|
||||
description: '🌏 *' . $$localization['settings_select_language_description'] . '*'
|
||||
);
|
||||
} else {
|
||||
// Not initialized localization
|
||||
|
||||
// Sending the message
|
||||
$$context->sendMessage('⚠️ *Failed to initialize localization*')
|
||||
->then(function (message $$message) use ($$context) {
|
||||
// Sended the message
|
||||
|
||||
// Ending the conversation process
|
||||
$$context->endConversation();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Not initialized language
|
||||
|
||||
// Sending the message
|
||||
$$context->sendMessage('⚠️ *Failed to initialize language*')
|
||||
->then(function (message $$message) use ($$context) {
|
||||
// Sended the message
|
||||
|
||||
// Ending the conversation process
|
||||
$$context->endConversation();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
->then(function (message $$message) use ($$context) {
|
||||
// Sended the message
|
||||
|
||||
// Ending the conversation process
|
||||
$$context->endConversation();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Society
|
||||
*
|
||||
* Responce for the command: "/society"
|
||||
*
|
||||
* Sends the "mushroom" image and the localized text "why so shroomious"
|
||||
*
|
||||
* @param context $$context Request data from Telegram
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function society(context $$context): void
|
||||
{
|
||||
// Initializing the account
|
||||
$$account = $$context->get('account');
|
||||
|
||||
if ($$account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing localization
|
||||
$$localization = $$context->get('localization');
|
||||
|
||||
if ($$localization) {
|
||||
// Initialized localization
|
||||
|
||||
// Sending the message
|
||||
$$context->sendPhoto(
|
||||
new file_input(STORAGE . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'mushroom.jpg'),
|
||||
[
|
||||
'caption' => $$localization['why_so_shroomious'],
|
||||
'disable_notification' => true
|
||||
]
|
||||
);
|
||||
} else {
|
||||
// Not initialized localization
|
||||
|
||||
// Sending the message
|
||||
$$context->sendMessage('⚠️ *Failed to initialize localization*')
|
||||
->then(function (message $$message) use ($$context) {
|
||||
// Ending the conversation process
|
||||
$$context->endConversation();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
->then(function (message $$message) use ($$context) {
|
||||
// Ending the conversation process
|
||||
$$context->endConversation();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
469
author/project/system/models/telegram/middlewares.php
Normal file
469
author/project/system/models/telegram/middlewares.php
Normal file
@@ -0,0 +1,469 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ${REPO_OWNER}\${REPO_NAME}\models\telegram;
|
||||
|
||||
// Files of the project
|
||||
use ${REPO_OWNER}\${REPO_NAME}\models\core,
|
||||
${REPO_OWNER}\${REPO_NAME}\models\account,
|
||||
${REPO_OWNER}\${REPO_NAME}\models\authorizations;
|
||||
|
||||
// The library for languages support
|
||||
use mirzaev\languages\language;
|
||||
|
||||
// The library for escaping all markdown symbols
|
||||
use function mirzaev\unmarkdown;
|
||||
|
||||
// Framework for Telegram
|
||||
use Zanzara\Context as context,
|
||||
Zanzara\Telegram\Type\Message as message,
|
||||
Zanzara\Middleware\MiddlewareNode as node;
|
||||
|
||||
// Built-in libraries
|
||||
use Error as error;
|
||||
|
||||
/**
|
||||
* Telegram middlewares
|
||||
*
|
||||
* @package ${REPO_OWNER}\${REPO_NAME}\models\telegram
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
*/
|
||||
final class middlewares extends core
|
||||
{
|
||||
/**
|
||||
* Account (middleware)
|
||||
*
|
||||
* Initialize or registrate the account and write it into the `account` variable inside the `$$context`
|
||||
*
|
||||
* @param context $$context
|
||||
* @param node $$next
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function account(context $$context, node $$next): void
|
||||
{
|
||||
// Is the process stopped?
|
||||
if ($$context->get('stop')) return;
|
||||
|
||||
// Initializing the telegram account
|
||||
$$telegram = $$context->getEffectiveUser();
|
||||
|
||||
// Initializing the account
|
||||
$$account = new account()->initialize($$telegram);
|
||||
|
||||
if ($$account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Writing the account into the context variable
|
||||
$$context->set('account', $$account);
|
||||
|
||||
// Continuation of the process
|
||||
$$next($$context);
|
||||
} else {
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
->then(function (message $$message) use ($$context) {
|
||||
// Sended the message
|
||||
|
||||
// Ending the conversation process
|
||||
$$context->endConversation();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Authorizations (middleware)
|
||||
*
|
||||
* Initialize the account authorizations and write them into the `authorizations` variable inside the `$$context`
|
||||
*
|
||||
* @param context $$context
|
||||
* @param node $$next
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function authorizations(context $$context, node $$next): void
|
||||
{
|
||||
// Is the process stopped?
|
||||
if ($$context->get('stop')) return;
|
||||
|
||||
// Initializing the account
|
||||
$$account = $$context->get('account');
|
||||
|
||||
if ($$account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing the account authorizations
|
||||
$$authorizations = $$account->authorizations();
|
||||
|
||||
if ($$authorizations instanceof authorizations) {
|
||||
// Initialized the account authorizations
|
||||
|
||||
// Writing the account authorizations into the context variable
|
||||
$$context->set('authorizations', $$authorizations);
|
||||
|
||||
// Continuation of the process
|
||||
$$next($$context);
|
||||
} else {
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$$context->sendMessage('⚠️ *Failed to initialize your Telegram account authorizations*')
|
||||
->then(function (message $$message) use ($$context) {
|
||||
// Sended the message
|
||||
|
||||
// Ending the conversation process
|
||||
$$context->endConversation();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
->then(function (message $$message) use ($$context) {
|
||||
// Sended the message
|
||||
|
||||
// Ending the conversation process
|
||||
$$context->endConversation();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Language (middleware)
|
||||
*
|
||||
* Implement the account language
|
||||
*
|
||||
* @param context $$context
|
||||
* @param node $$next
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function language(context $$context, node $$next): void
|
||||
{
|
||||
// Is the process stopped?
|
||||
if ($$context->get('stop')) return;
|
||||
|
||||
// Initializing the account
|
||||
$$account = $$context->get('account');
|
||||
|
||||
if ($$account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
if ($$account->language instanceof language) {
|
||||
// Initialized the language parameter
|
||||
|
||||
try {
|
||||
// Writing the account language into the context variable
|
||||
$$context->set('language', $$account->language);
|
||||
} catch (error $$error) {
|
||||
// Not initialized the language
|
||||
|
||||
// Writing the default language into the context variable
|
||||
$$context->set('language', LANGUAGE_DEFAULT ?? language::en);
|
||||
}
|
||||
} else {
|
||||
// Not initialized the language parameter
|
||||
|
||||
// Writing the default language into the context variable
|
||||
$$context->set('language', LANGUAGE_DEFAULT ?? language::en);
|
||||
}
|
||||
|
||||
// Continuation of the process
|
||||
$$next($$context);
|
||||
} else {
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
->then(function (message $$message) use ($$context) {
|
||||
// Sended the message
|
||||
|
||||
// Ending the conversation process
|
||||
$$context->endConversation();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Localization (middleware)
|
||||
*
|
||||
* Implement the account language and initialize the localization file
|
||||
*
|
||||
* @param context $$context
|
||||
* @param node $$next
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function localization(context $$context, node $$next): void
|
||||
{
|
||||
// Is the process stopped?
|
||||
if ($$context->get('stop')) return;
|
||||
|
||||
// Initializing the account
|
||||
$$account = $$context->get('account');
|
||||
|
||||
if ($$account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing the language
|
||||
$$language = $$context->get('language');
|
||||
|
||||
if ($$language instanceof language) {
|
||||
// Initialized the language
|
||||
|
||||
// Initializing path to the localization file
|
||||
$$file = LOCALIZATIONS . DIRECTORY_SEPARATOR . strtolower($$language->label()) . '.php';
|
||||
|
||||
if (file_exists($$file) && is_readable($$file)) {
|
||||
// Found the localization file
|
||||
|
||||
// Initializing localization
|
||||
$$localization = require($$file);
|
||||
|
||||
if (is_array($$localization)) {
|
||||
// Initialized the localization
|
||||
|
||||
// Writing localization into the context variable
|
||||
$$context->set('localization', $$localization);
|
||||
|
||||
// Continuation of the process
|
||||
$$next($$context);
|
||||
} else {
|
||||
// Not initialized the localization
|
||||
|
||||
// Sending the message
|
||||
$$context->sendMessage('⚠️ *Failed to initialize localization*')
|
||||
->then(function (message $$message) use ($$context) {
|
||||
// Sended the message
|
||||
|
||||
// Ending the conversation process
|
||||
$$context->endConversation();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Not found the localization file
|
||||
|
||||
// Sending the message
|
||||
$$context->sendMessage('⚠️ *Failed to initialize the localization file*')
|
||||
->then(function (message $$message) use ($$context) {
|
||||
// Sended the message
|
||||
|
||||
// Ending the conversation process
|
||||
$$context->endConversation();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Not initialized language
|
||||
|
||||
// Sending the message
|
||||
$$context->sendMessage('⚠️ *Failed to initialize language*')
|
||||
->then(function (message $$message) use ($$context) {
|
||||
// Sended the message
|
||||
|
||||
// Ending the conversation process
|
||||
$$context->endConversation();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
->then(function (message $$message) use ($$context) {
|
||||
// Sended the message
|
||||
|
||||
// Ending the conversation process
|
||||
$$context->endConversation();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Settings (middleware)
|
||||
*
|
||||
* Check the account for access to the settings
|
||||
*
|
||||
* @param context $$context
|
||||
* @param node $$next
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function settings(context $$context, node $$next): void
|
||||
{
|
||||
// Is the process stopped?
|
||||
if ($$context->get('stop')) return;
|
||||
|
||||
// Initializing the account
|
||||
$$account = $$context->get('account');
|
||||
|
||||
if ($$account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing the account authorizations
|
||||
$$authorizations = $$context->get('authorizations');
|
||||
|
||||
if ($$authorizations instanceof authorizations) {
|
||||
// Initialized the account authorizations
|
||||
|
||||
if ($$authorizations->settings) {
|
||||
// Authorized the account to the settings
|
||||
|
||||
// Continuation of the process
|
||||
$$next($$context);
|
||||
} else {
|
||||
// Not authorized the account to the settings
|
||||
|
||||
// Initializing localization
|
||||
$$localization = $$context->get('localization');
|
||||
|
||||
if ($$localization) {
|
||||
// Initialized localization
|
||||
|
||||
// Sending the message
|
||||
$$context->sendMessage('⛔ *' . $$localization['not_authorized_settings'] . '*')
|
||||
->then(function (message $$message) use ($$context) {
|
||||
// Sended the message
|
||||
|
||||
// Ending the conversation process
|
||||
$$context->endConversation();
|
||||
});
|
||||
|
||||
// Stopping the process
|
||||
$$context->set('stop', true);
|
||||
} else {
|
||||
// Not initialized localization
|
||||
|
||||
// Sending the message
|
||||
$$context->sendMessage('⚠️ *Failed to initialize localization*')
|
||||
->then(function (message $$message) use ($$context) {
|
||||
// Sended the message
|
||||
|
||||
// Ending the conversation process
|
||||
$$context->endConversation();
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Not initialized the account authorizations
|
||||
|
||||
// Sending the message
|
||||
$$context->sendMessage('⚠️ *Failed to initialize your Telegram account authorizations*')
|
||||
->then(function (message $$message) use ($$context) {
|
||||
// Sended the message
|
||||
|
||||
// Ending the conversation process
|
||||
$$context->endConversation();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
->then(function (message $$message) use ($$context) {
|
||||
// Sended the message
|
||||
|
||||
// Ending the conversation process
|
||||
$$context->endConversation();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* System settings (middleware)
|
||||
*
|
||||
* Check the account for access to the system settings
|
||||
*
|
||||
* @param context $$context
|
||||
* @param node $$next
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function system_settings(context $$context, node $$next): void
|
||||
{
|
||||
// Is the process stopped?
|
||||
if ($$context->get('stop')) return;
|
||||
|
||||
// Initializing the account
|
||||
$$account = $$context->get('account');
|
||||
|
||||
if ($$account instanceof account) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing the account authorizations
|
||||
$$authorizations = $$context->get('authorizations');
|
||||
|
||||
if ($$authorizations instanceof authorizations) {
|
||||
// Initialized the account authorizations
|
||||
|
||||
if ($$authorizations->system_settings) {
|
||||
// Authorized the account to the system settings
|
||||
|
||||
// Continuation of the process
|
||||
$$next($$context);
|
||||
} else {
|
||||
// Not authorized the account to the system settings
|
||||
|
||||
// Initializing localization
|
||||
$$localization = $$context->get('localization');
|
||||
|
||||
if ($$localization) {
|
||||
// Initialized localization
|
||||
|
||||
// Sending the message
|
||||
$$context->sendMessage('⛔ *' . $$localization['not_authorized_system_settings'] . '*')
|
||||
->then(function (message $$message) use ($$context) {
|
||||
// Sended the message
|
||||
|
||||
// Ending the conversation process
|
||||
$$context->endConversation();
|
||||
});
|
||||
|
||||
// Stopping the process
|
||||
$$context->set('stop', true);
|
||||
} else {
|
||||
// Not initialized localization
|
||||
|
||||
// Sending the message
|
||||
$$context->sendMessage('⚠️ *Failed to initialize localization*')
|
||||
->then(function (message $$message) use ($$context) {
|
||||
// Sended the message
|
||||
|
||||
// Ending the conversation process
|
||||
$$context->endConversation();
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$$context->sendMessage('⚠️ *Failed to initialize your Telegram account authorizations*')
|
||||
->then(function (message $$message) use ($$context) {
|
||||
// Sended the message
|
||||
|
||||
// Ending the conversation process
|
||||
$$context->endConversation();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
->then(function (message $$message) use ($$context) {
|
||||
// Sended the message
|
||||
|
||||
// Ending the conversation process
|
||||
$$context->endConversation();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ${REPO_OWNER}\${REPO_NAME}\models\telegram\processes\language;
|
||||
|
||||
// Files of the project
|
||||
use ${REPO_OWNER}\${REPO_NAME}\models\core;
|
||||
|
||||
// Library for languages support
|
||||
use mirzaev\languages\language;
|
||||
|
||||
// Baza database
|
||||
use mirzaev\baza\record;
|
||||
|
||||
// Framework for Telegram
|
||||
use Zanzara\Context as context,
|
||||
Zanzara\Telegram\Type\Message as message;
|
||||
|
||||
/**
|
||||
* Telegram language select
|
||||
*
|
||||
* @package ${REPO_OWNER}\${REPO_NAME}\models\telegram\processes\language
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
*/
|
||||
final class select extends core
|
||||
{
|
||||
/**
|
||||
* Language
|
||||
*
|
||||
* Send the language choose menu
|
||||
*
|
||||
* @param context $$context Request data from Telegram
|
||||
* @param string $$prefix Prefix for 'callback_data' (`$$prefix . $$language->name`)
|
||||
* @param string $$title Title of the message
|
||||
* @param string $$description Description of the message
|
||||
* @param array $$exclude Languages that will be excluded ['ru', 'en'...]
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function menu(context $$context, string $$prefix, string $$title, string $$description, array $$exclude = []): void
|
||||
{
|
||||
// Initializing the account
|
||||
$$account = $$context->get('account');
|
||||
|
||||
if ($$account instanceof record) {
|
||||
// Initialized the account
|
||||
|
||||
// Initializing language
|
||||
$$language = $$context->get('language');
|
||||
|
||||
if ($$language) {
|
||||
// Initialized language
|
||||
|
||||
// Initializing localization
|
||||
$$localization = $$context->get('localization');
|
||||
|
||||
if ($$localization) {
|
||||
// Initialized localization
|
||||
|
||||
// Declaring the buffer of generated keyboard with languages
|
||||
$$keyboard = [];
|
||||
|
||||
// Initializing the iterator of rows
|
||||
$$row = 0;
|
||||
|
||||
// Initializing buffer of languages
|
||||
$$languages = language::cases();
|
||||
|
||||
// Deleting the actual language from buffer of languages
|
||||
unset($$languages[array_search($$language, $$languages, strict: true)]);
|
||||
|
||||
// Sorting buffer of languages by the actual language
|
||||
$$languages = [$$language, ...$$languages];
|
||||
|
||||
foreach ($$languages as $$language) {
|
||||
// Iterating over languages
|
||||
|
||||
// Skipping excluded languages
|
||||
if (array_search($$language->name, $$exclude, strict: true) !== false) continue;
|
||||
|
||||
// Initializing the row
|
||||
$$keyboard[$$row] ??= [];
|
||||
|
||||
// Writing the language choose button into the buffer of generated keyboard with languages
|
||||
$$keyboard[$$row][] = [
|
||||
'text' => ($$language->flag() ? $$language->flag() . ' ' : '') . $$language->label($$language),
|
||||
'callback_data' => $$prefix . $$language->name
|
||||
];
|
||||
|
||||
// When reaching 4 buttons in a row, move to the next row
|
||||
if (count($$keyboard[$$row]) === 4) ++$$row;
|
||||
}
|
||||
|
||||
// Writing the button for helping lozalizing
|
||||
$$keyboard[$$row === 0 && empty($$keyboard[0]) ? 0 : ++$$row] = [
|
||||
[
|
||||
'text' => '🗂 ' . $$localization['select_language_button_add'],
|
||||
'url' => 'https://git.svoboda.works/${REPO_OWNER}\${REPO_NAME}/src/branch/stable/kodorvan/neurobot/system/localizations'
|
||||
]
|
||||
];
|
||||
|
||||
// Sending the message
|
||||
$$context->sendMessage(
|
||||
$$title ?? '🌏 *' . $$localization['select_language_title'] . "*\n" . ($$description ?? $$localization['select_language_description']),
|
||||
[
|
||||
'reply_markup' => [
|
||||
'inline_keyboard' => $$keyboard,
|
||||
'disable_notification' => true
|
||||
],
|
||||
]
|
||||
);
|
||||
} else {
|
||||
// Not initialized localization
|
||||
|
||||
// Sending the message
|
||||
$$context->sendMessage('⚠️ *Failed to initialize localization*')
|
||||
->then(function (message $$message) use ($$context) {
|
||||
// Sended the message
|
||||
|
||||
// Ending the conversation process
|
||||
$$context->endConversation();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Not initialized language
|
||||
|
||||
// Sending the message
|
||||
$$context->sendMessage('⚠️ *Failed to initialize language*')
|
||||
->then(function (message $$message) use ($$context) {
|
||||
// Sended the message
|
||||
|
||||
// Ending the conversation process
|
||||
$$context->endConversation();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Not initialized the account
|
||||
|
||||
// Sending the message
|
||||
$$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
|
||||
->then(function (message $$message) use ($$context) {
|
||||
// Sended the message
|
||||
|
||||
// Ending the conversation process
|
||||
$$context->endConversation();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ${REPO_OWNER}\${REPO_NAME}\models\traits;
|
||||
|
||||
// Built-in libraries
|
||||
use exception;
|
||||
|
||||
/**
|
||||
* Trait fo initialization of a status
|
||||
*
|
||||
* @package ${REPO_OWNER}\${REPO_NAME}\models\traits
|
||||
*
|
||||
* @author ${REPO_OWNER} < mail >
|
||||
*/
|
||||
trait status
|
||||
{
|
||||
/**
|
||||
* Initialize of a status
|
||||
*
|
||||
* @param array &$errors Registry of errors
|
||||
*
|
||||
* @return ?bool Status, if they are found
|
||||
*/
|
||||
public function status(array &$errors = []): ?bool
|
||||
{
|
||||
try {
|
||||
// Read from ArangoDB and exit (success)
|
||||
return $this->document->active ?? false;
|
||||
} catch (exception $e) {
|
||||
// Write to the registry of errors
|
||||
$errors[] = [
|
||||
'text' => $e->getMessage(),
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
'stack' => $e->getTrace()
|
||||
];
|
||||
}
|
||||
|
||||
// Exit (fail)
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
34
author/project/system/public/css/fonts/dejavu.css
Executable file
34
author/project/system/public/css/fonts/dejavu.css
Executable file
@@ -0,0 +1,34 @@
|
||||
@font-face {
|
||||
font-family: 'DejaVu';
|
||||
src: url("/fonts/dejavu/DejaVuLGCSans-ExtraLight.ttf");
|
||||
font-weight: 200;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'DejaVu';
|
||||
src: url("/fonts/dejavu/DejaVuLGCSans.ttf");
|
||||
font-weight: 400;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'DejaVu';
|
||||
src: url("/fonts/dejavu/DejaVuLGCSans-Oblique.ttf");
|
||||
font-weight: 400;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'DejaVu';
|
||||
src: url("/fonts/dejavu/DejaVuLGCSans-Bold.ttf");
|
||||
font-weight: 500;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'DejaVu';
|
||||
src: url("/fonts/dejavu/DejaVuLGCSans-BoldOblique.ttf");
|
||||
font-weight: 500;
|
||||
font-style: italic;
|
||||
}
|
||||
139
author/project/system/public/css/fonts/fira.css
Executable file
139
author/project/system/public/css/fonts/fira.css
Executable file
@@ -0,0 +1,139 @@
|
||||
@font-face {
|
||||
font-family: 'Fira';
|
||||
src: url('/fonts/fira/FiraSans-Hair.woff2') format('woff2'), url('/fonts/fira/FiraSans-Hair.woff') format('woff');
|
||||
font-weight: 100;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Fira';
|
||||
src: url('/fonts/fira/FiraSans-HairItalic.woff2') format('woff2'), url('/fonts/fira/FiraSans-HairItalic.woff') format('woff');
|
||||
font-weight: 100;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Fira';
|
||||
src: url('/fonts/fira/FiraSans-UltraLight.woff2') format('woff2'), url('/fonts/fira/FiraSans-UltraLight.woff') format('woff');
|
||||
font-weight: 200;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Fira';
|
||||
src: url('/fonts/fira/FiraSans-UltraLightItalic.woff2') format('woff2'), url('/fonts/fira/FiraSans-UltraLightItalic.woff') format('woff');
|
||||
font-weight: 200;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Fira';
|
||||
src: url('/fonts/fira/FiraSans-Light.woff2') format('woff2'), url('/fonts/fira/FiraSans-Light.woff') format('woff');
|
||||
font-weight: 300;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Fira';
|
||||
src: url('/fonts/fira/FiraSans-LightItalic.woff2') format('woff2'), url('/fonts/fira/FiraSans-LightItalic.woff') format('woff');
|
||||
font-weight: 300;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Fira';
|
||||
src: url('/fonts/fira/FiraSans-Regular.woff2') format('woff2'), url('/fonts/fira/FiraSans-Regular.woff') format('woff');
|
||||
font-weight: 400;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Fira';
|
||||
src: url('/fonts/fira/FiraSans-Italic.woff2') format('woff2'), url('/fonts/fira/FiraSans-Italic.woff') format('woff');
|
||||
font-weight: 400;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Fira';
|
||||
src: url('/fonts/fira/FiraMono-Medium.woff2') format('woff2'), url('/fonts/fira/FiraMono-Medium.woff') format('woff');
|
||||
font-weight: 500;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Fira';
|
||||
src: url('/fonts/fira/FiraSans-MediumItalic.woff2') format('woff2'), url('/fonts/fira/FiraSans-MediumItalic.woff') format('woff');
|
||||
font-weight: 500;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Fira';
|
||||
src: url('/fonts/fira/FiraSans-SemiBold.woff2') format('woff2'), url('/fonts/fira/FiraSans-SemiBold.woff') format('woff');
|
||||
font-weight: 600;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Fira';
|
||||
src: url('/fonts/fira/FiraSans-SemiBoldItalic.woff2') format('woff2'), url('/fonts/fira/FiraSans-SemiBoldItalic.woff') format('woff');
|
||||
font-weight: 600;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Fira';
|
||||
src: url('/fonts/fira/FiraSans-Bold.woff2') format('woff2'), url('/fonts/fira/FiraSans-Bold.woff') format('woff');
|
||||
font-weight: 700;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Fira';
|
||||
src: url('/fonts/fira/FiraSans-BoldItalic.woff2') format('woff2'), url('/fonts/fira/FiraSans-BoldItalic.woff') format('woff');
|
||||
font-weight: 700;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Fira';
|
||||
src: url('/fonts/fira/FiraSans-ExtraBold.woff2') format('woff2'), url('/fonts/fira/FiraSans-ExtraBold.woff') format('woff');
|
||||
font-weight: 800;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Fira';
|
||||
src: url('/fonts/fira/FiraSans-ExtraBoldItalic.woff2') format('woff2'), url('/fonts/fira/FiraSans-ExtraBoldItalic.woff') format('woff');
|
||||
font-weight: 800;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Fira';
|
||||
src: url('/fonts/fira/FiraSans-Heavy.woff2') format('woff2'), url('/fonts/fira/FiraSans-Heavy.woff') format('woff');
|
||||
font-weight: 900;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Fira';
|
||||
src: url('/fonts/fira/FiraSans-HeavyItalic.woff2') format('woff2'), url('/fonts/fira/FiraSans-HeavyItalic.woff') format('woff');
|
||||
font-weight: 900;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Fira' Mono;
|
||||
src: url('/fonts/fira/FiraMono-Regular.woff2') format('woff2'), url('/fonts/fira/FiraMono-Regular.woff') format('woff');
|
||||
font-weight: 400;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Fira' Mono;
|
||||
src: url('/fonts/fira/FiraMono-Bold.woff2') format('woff2'), url('/fonts/fira/FiraMono-Bold.woff') format('woff');
|
||||
font-weight: 600;
|
||||
font-style: normal;
|
||||
}
|
||||
31
author/project/system/public/css/fonts/hack.css
Executable file
31
author/project/system/public/css/fonts/hack.css
Executable file
@@ -0,0 +1,31 @@
|
||||
@font-face {
|
||||
font-family: 'Hack';
|
||||
src: url('/fonts/hack/hack-regular.woff2?sha=3114f1256') format('woff2'), url('/fonts/hack/hack-regular.woff?sha=3114f1256') format('woff');
|
||||
font-weight: 400;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Hack';
|
||||
src: url('/fonts/hack/hack-bold.woff2?sha=3114f1256') format('woff2'), url('/fonts/hack/hack-bold.woff?sha=3114f1256') format('woff');
|
||||
font-weight: 700;
|
||||
font-style: normal;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Hack';
|
||||
src: url('/fonts/hack/hack-italic.woff2?sha=3114f1256') format('woff2'), url('/fonts/hack/hack-italic.woff?sha=3114f1256') format('woff');
|
||||
font-weight: 400;
|
||||
font-style: italic;
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Hack';
|
||||
src: url('/fonts/hack/hack-bolditalic.woff2?sha=3114f1256') format('woff2'), url('/fonts/hack/hack-bolditalic.woff?sha=3114f1256') format('woff');
|
||||
font-weight: 700;
|
||||
font-style: italic;
|
||||
font-display: swap;
|
||||
}
|
||||
BIN
author/project/system/public/fonts/commissioner.ttf
Executable file
BIN
author/project/system/public/fonts/commissioner.ttf
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSans-Bold.ttf
Executable file
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSans-Bold.ttf
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSans-BoldOblique.ttf
Executable file
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSans-BoldOblique.ttf
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSans-ExtraLight.ttf
Executable file
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSans-ExtraLight.ttf
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSans-Oblique.ttf
Executable file
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSans-Oblique.ttf
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSans.ttf
Executable file
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSans.ttf
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSansCondensed-Bold.ttf
Executable file
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSansCondensed-Bold.ttf
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSansCondensed-BoldOblique.ttf
Executable file
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSansCondensed-BoldOblique.ttf
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSansCondensed-Oblique.ttf
Executable file
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSansCondensed-Oblique.ttf
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSansCondensed.ttf
Executable file
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSansCondensed.ttf
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSansMono-Bold.ttf
Executable file
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSansMono-Bold.ttf
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSansMono-BoldOblique.ttf
Executable file
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSansMono-BoldOblique.ttf
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSansMono-Oblique.ttf
Executable file
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSansMono-Oblique.ttf
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSansMono.ttf
Executable file
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSansMono.ttf
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSerif-Bold.ttf
Executable file
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSerif-Bold.ttf
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSerif-BoldItalic.ttf
Executable file
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSerif-BoldItalic.ttf
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSerif-Italic.ttf
Executable file
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSerif-Italic.ttf
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSerif.ttf
Executable file
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSerif.ttf
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSerifCondensed-Bold.ttf
Executable file
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSerifCondensed-Bold.ttf
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSerifCondensed-BoldItalic.ttf
Executable file
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSerifCondensed-BoldItalic.ttf
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSerifCondensed-Italic.ttf
Executable file
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSerifCondensed-Italic.ttf
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSerifCondensed.ttf
Executable file
BIN
author/project/system/public/fonts/dejavu/DejaVuLGCSerifCondensed.ttf
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraMono-Bold.woff
Executable file
BIN
author/project/system/public/fonts/fira/FiraMono-Bold.woff
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraMono-Bold.woff2
Executable file
BIN
author/project/system/public/fonts/fira/FiraMono-Bold.woff2
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraMono-Medium.woff
Executable file
BIN
author/project/system/public/fonts/fira/FiraMono-Medium.woff
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraMono-Medium.woff2
Executable file
BIN
author/project/system/public/fonts/fira/FiraMono-Medium.woff2
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraMono-Regular.woff
Executable file
BIN
author/project/system/public/fonts/fira/FiraMono-Regular.woff
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraMono-Regular.woff2
Executable file
BIN
author/project/system/public/fonts/fira/FiraMono-Regular.woff2
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-Bold.woff
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-Bold.woff
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-Bold.woff2
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-Bold.woff2
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-BoldItalic.woff
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-BoldItalic.woff
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-BoldItalic.woff2
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-BoldItalic.woff2
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-Book.woff
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-Book.woff
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-Book.woff2
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-Book.woff2
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-BookItalic.woff
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-BookItalic.woff
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-BookItalic.woff2
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-BookItalic.woff2
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-Eight.woff
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-Eight.woff
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-Eight.woff2
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-Eight.woff2
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-EightItalic.woff
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-EightItalic.woff
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-EightItalic.woff2
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-EightItalic.woff2
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-ExtraBold.woff
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-ExtraBold.woff
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-ExtraBold.woff2
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-ExtraBold.woff2
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-ExtraBoldItalic.woff
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-ExtraBoldItalic.woff
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-ExtraBoldItalic.woff2
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-ExtraBoldItalic.woff2
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-ExtraLight.woff
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-ExtraLight.woff
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-ExtraLight.woff2
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-ExtraLight.woff2
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-ExtraLightItalic.woff
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-ExtraLightItalic.woff
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-ExtraLightItalic.woff2
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-ExtraLightItalic.woff2
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-Four.woff
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-Four.woff
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-Four.woff2
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-Four.woff2
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-FourItalic.woff
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-FourItalic.woff
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-FourItalic.woff2
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-FourItalic.woff2
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-Hair.woff
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-Hair.woff
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-Hair.woff2
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-Hair.woff2
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-HairItalic.woff
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-HairItalic.woff
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-HairItalic.woff2
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-HairItalic.woff2
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-Heavy.woff
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-Heavy.woff
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-Heavy.woff2
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-Heavy.woff2
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-HeavyItalic.woff
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-HeavyItalic.woff
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-HeavyItalic.woff2
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-HeavyItalic.woff2
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-Italic.woff
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-Italic.woff
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-Italic.woff2
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-Italic.woff2
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-Light.woff
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-Light.woff
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-Light.woff2
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-Light.woff2
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-LightItalic.woff
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-LightItalic.woff
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-LightItalic.woff2
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-LightItalic.woff2
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-Medium.woff
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-Medium.woff
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-Medium.woff2
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-Medium.woff2
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-MediumItalic.woff
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-MediumItalic.woff
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-MediumItalic.woff2
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-MediumItalic.woff2
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-Regular.woff
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-Regular.woff
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-Regular.woff2
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-Regular.woff2
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-SemiBold.woff
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-SemiBold.woff
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-SemiBold.woff2
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-SemiBold.woff2
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-SemiBoldItalic.woff
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-SemiBoldItalic.woff
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-SemiBoldItalic.woff2
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-SemiBoldItalic.woff2
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-Thin.woff
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-Thin.woff
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-Thin.woff2
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-Thin.woff2
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-ThinItalic.woff
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-ThinItalic.woff
Executable file
Binary file not shown.
BIN
author/project/system/public/fonts/fira/FiraSans-ThinItalic.woff2
Executable file
BIN
author/project/system/public/fonts/fira/FiraSans-ThinItalic.woff2
Executable file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user