начало работы над логикой
This commit is contained in:
		@@ -1,6 +1,6 @@
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    "name": "mirzaev/site-stdm-registry",
 | 
					    "name": "mirzaev/site-stdm-registry",
 | 
				
			||||||
    "description": "Interface with access to the data register with spare parts for special equipment",
 | 
					    "description": "Interface with access to the data registry with spare parts for special equipment",
 | 
				
			||||||
    "readme": "README.md",
 | 
					    "readme": "README.md",
 | 
				
			||||||
    "keywords": [
 | 
					    "keywords": [
 | 
				
			||||||
        "registry",
 | 
					        "registry",
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								composer.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								composer.lock
									
									
									
										generated
									
									
									
								
							@@ -4,7 +4,7 @@
 | 
				
			|||||||
        "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
 | 
					        "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
 | 
				
			||||||
        "This file is @generated automatically"
 | 
					        "This file is @generated automatically"
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
    "content-hash": "fc26b5dfc36fdab31f67aaa3a6a09e06",
 | 
					    "content-hash": "eb3974d37e16f19a4c1ca43c8ac73a61",
 | 
				
			||||||
    "packages": [
 | 
					    "packages": [
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            "name": "guzzlehttp/guzzle",
 | 
					            "name": "guzzlehttp/guzzle",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -51,7 +51,7 @@ class core extends controller
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    // Инициализация журнала ошибок
 | 
					    // Инициализация журнала ошибок
 | 
				
			||||||
    $this->variables['errors'] = [
 | 
					    $this->variables['errors'] = [
 | 
				
			||||||
      'vk' => []
 | 
					      'account' => []
 | 
				
			||||||
    ];
 | 
					    ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Инициализация препроцессора представления
 | 
					    // Инициализация препроцессора представления
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,82 +0,0 @@
 | 
				
			|||||||
<?php
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
declare(strict_types=1);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace mirzaev\site\stdm\registry\controllers;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// Файлы проекта
 | 
					 | 
				
			||||||
use mirzaev\site\stdm\registry\controllers\core;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Контроллер бегущей строки
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * @package mirzaev\site\stdm\registry\controllers
 | 
					 | 
				
			||||||
 * @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
final class hotline_controller extends core
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * Страница с бегущей строкой
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * Можно использовать совместно с элементом <iframe> для изоляции
 | 
					 | 
				
			||||||
     * содержимого бегущей строки от поисковых роботов
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @param array $parameters
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public function index(array $parameters = []): ?string
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        // Инициализация элементов для генерации в головном элементе
 | 
					 | 
				
			||||||
        $this->variables['head'] = [
 | 
					 | 
				
			||||||
            'title' => 'Бегущая строка',
 | 
					 | 
				
			||||||
            'metas' => [
 | 
					 | 
				
			||||||
                [
 | 
					 | 
				
			||||||
                    'attributes' => [
 | 
					 | 
				
			||||||
                        'name' => 'robots',
 | 
					 | 
				
			||||||
                        'content' => 'nofollow'
 | 
					 | 
				
			||||||
                    ]
 | 
					 | 
				
			||||||
                ]
 | 
					 | 
				
			||||||
            ]
 | 
					 | 
				
			||||||
        ];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Инициализация бегущей строки
 | 
					 | 
				
			||||||
        $this->variables['hotline'] = [
 | 
					 | 
				
			||||||
            'id' => $this->variables['request']['id'] ?? 'hotline'
 | 
					 | 
				
			||||||
        ];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Инициализация параметров бегущей строки
 | 
					 | 
				
			||||||
        $this->variables['hotline']['parameters'] = [
 | 
					 | 
				
			||||||
            // 'step' => 2
 | 
					 | 
				
			||||||
        ];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Инициализация аттрибутов бегущей строки
 | 
					 | 
				
			||||||
        $this->variables['hotline']['attributes'] = [
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        ];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Инициализация элементов бегущей строки
 | 
					 | 
				
			||||||
        $this->variables['hotline']['elements'] = [
 | 
					 | 
				
			||||||
            ['content' => '1'],
 | 
					 | 
				
			||||||
            [
 | 
					 | 
				
			||||||
                'tag' => 'article',
 | 
					 | 
				
			||||||
                'content' => '2'
 | 
					 | 
				
			||||||
            ],
 | 
					 | 
				
			||||||
            ['content' => '3'],
 | 
					 | 
				
			||||||
            ['content' => '4'],
 | 
					 | 
				
			||||||
            ['content' => '5'],
 | 
					 | 
				
			||||||
            ['content' => '6'],
 | 
					 | 
				
			||||||
            ['content' => '7'],
 | 
					 | 
				
			||||||
            ['content' => '8'],
 | 
					 | 
				
			||||||
            ['content' => '9'],
 | 
					 | 
				
			||||||
            ['content' => '10'],
 | 
					 | 
				
			||||||
            ['content' => '11'],
 | 
					 | 
				
			||||||
            ['content' => '12'],
 | 
					 | 
				
			||||||
            ['content' => '13'],
 | 
					 | 
				
			||||||
            ['content' => '14'],
 | 
					 | 
				
			||||||
            ['content' => '15']
 | 
					 | 
				
			||||||
        ];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Генерация представления
 | 
					 | 
				
			||||||
        return $this->view->render(DIRECTORY_SEPARATOR . 'hotline' . DIRECTORY_SEPARATOR . 'index.html', $this->variables);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
							
								
								
									
										29
									
								
								mirzaev/site/stdm/registry/system/controllers/search_controller.php
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										29
									
								
								mirzaev/site/stdm/registry/system/controllers/search_controller.php
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,29 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					declare(strict_types=1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace mirzaev\site\stdm\registry\controllers;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Файлы проекта
 | 
				
			||||||
 | 
					use mirzaev\site\stdm\registry\controllers\core,
 | 
				
			||||||
 | 
					    mirzaev\site\stdm\registry\models\keys_model as key,
 | 
				
			||||||
 | 
					    mirzaev\site\stdm\registry\models\account_model as account;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Контроллер поиска 
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @package mirzaev\site\stdm\registry\controllers
 | 
				
			||||||
 | 
					 * @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					final class search_controller extends core
 | 
				
			||||||
 | 
					{    
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * Поиск 
 | 
				
			||||||
 | 
					   *
 | 
				
			||||||
 | 
					   * @param array $parameters Параметры запроса
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  public function search(array $parameters = []): ?string {
 | 
				
			||||||
 | 
					    var_dump(account::authorization($parameters['key'], $this->variables['errors']['account']));
 | 
				
			||||||
 | 
					    return null;
 | 
				
			||||||
 | 
					  }  
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										70
									
								
								mirzaev/site/stdm/registry/system/models/account_model.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								mirzaev/site/stdm/registry/system/models/account_model.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,70 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					declare(strict_types=1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace mirzaev\site\stdm\registry\models;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Фреймворк ArangoDB
 | 
				
			||||||
 | 
					use mirzaev\arangodb\collection,
 | 
				
			||||||
 | 
					    mirzaev\arangodb\document;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Библиотека для ArangoDB
 | 
				
			||||||
 | 
					use ArangoDBClient\Document as _document;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Встроенные библиотеки
 | 
				
			||||||
 | 
					use exception;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Модель аккаунта 
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @package mirzaev\site\stdm\registry\models
 | 
				
			||||||
 | 
					 * @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					final class account_model extends core
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * Коллекция
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  public const COLLECTION = 'account';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * Авторизация
 | 
				
			||||||
 | 
					   *
 | 
				
			||||||
 | 
					   * @param string $key Ключ доступа
 | 
				
			||||||
 | 
					   * @param array &$errors Журнал ошибок
 | 
				
			||||||
 | 
					   *
 | 
				
			||||||
 | 
					   * @return bool Найден ли аккаунт и есть ли у него доступ
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  public static function authorization(string $key, array &$errors = []): bool {
 | 
				
			||||||
 | 
					    try {
 | 
				
			||||||
 | 
					      if (collection::init(static::$db->session, self::COLLECTION)) {
 | 
				
			||||||
 | 
					        // Инициализированы коллекции
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if ($account = collection::search(static::$db->session, sprintf(
 | 
				
			||||||
 | 
					          <<<AQL
 | 
				
			||||||
 | 
					            FOR document IN %s
 | 
				
			||||||
 | 
					              FILTER document.key == "%s" 
 | 
				
			||||||
 | 
					              LIMIT 1
 | 
				
			||||||
 | 
					              RETURN document
 | 
				
			||||||
 | 
					          AQL,
 | 
				
			||||||
 | 
					          static::COLLECTION,
 | 
				
			||||||
 | 
					          $key
 | 
				
			||||||
 | 
					        ))) {
 | 
				
			||||||
 | 
					          // Найдена инстанция ключа 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					          return $account->access;
 | 
				
			||||||
 | 
					        } else throw new exception('Не удалось найти аккаунт');
 | 
				
			||||||
 | 
					      } else throw new exception('Не удалось инициализировать коллекцию');
 | 
				
			||||||
 | 
					    } catch (exception $e) {
 | 
				
			||||||
 | 
					      // Запись в журнал ошибок
 | 
				
			||||||
 | 
					      $errors[] = [
 | 
				
			||||||
 | 
					        'text' => $e->getMessage(),
 | 
				
			||||||
 | 
					        'file' => $e->getFile(),
 | 
				
			||||||
 | 
					        'line' => $e->getLine(),
 | 
				
			||||||
 | 
					        'stack' => $e->getTrace()
 | 
				
			||||||
 | 
					      ];
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return false;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -18,6 +18,31 @@ use exception;
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
class core extends model
 | 
					class core extends model
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Коллекция в которой хранятся аккаунты
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public const SETTINGS = '../settings/arangodb.php';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Соединение с базой данных
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    protected static connection $db;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public function __construct(connection $db = null)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (isset($db)) {
 | 
				
			||||||
 | 
					            // Получена инстанция соединения с базой данных
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // Запись и инициализация соединения с базой данных
 | 
				
			||||||
 | 
					            $this->__set('db', $db);
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            // Не получена инстанция соединения с базой данных
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // Инициализация соединения с базой данных по умолчанию
 | 
				
			||||||
 | 
					            $this->__get('db');
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Записать свойство
 | 
					     * Записать свойство
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										29
									
								
								mirzaev/site/stdm/registry/system/models/keys_model.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								mirzaev/site/stdm/registry/system/models/keys_model.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,29 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					declare(strict_types=1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace mirzaev\site\stdm\registry\models;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Фреймворк ArangoDB
 | 
				
			||||||
 | 
					use mirzaev\arangodb\collection,
 | 
				
			||||||
 | 
					    mirzaev\arangodb\document;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Библиотека для ArangoDB
 | 
				
			||||||
 | 
					use ArangoDBClient\Document as _document;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Встроенные библиотеки
 | 
				
			||||||
 | 
					use exception;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Модель ключей доступа
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @package mirzaev\site\stdm\registry\models
 | 
				
			||||||
 | 
					 * @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					final class keys_model extends core
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * Коллекция
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  public const COLLECTION = 'keys';
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -126,6 +126,7 @@ main>form#panel>section#result {
 | 
				
			|||||||
  display: flex;
 | 
					  display: flex;
 | 
				
			||||||
  justify-content: center;
 | 
					  justify-content: center;
 | 
				
			||||||
  align-items: center;
 | 
					  align-items: center;
 | 
				
			||||||
 | 
					  border-radius: 3px;
 | 
				
			||||||
  background-color: var(--background-light-inner);
 | 
					  background-color: var(--background-light-inner);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
main>form#panel>label>button[type="submit"] {
 | 
					main>form#panel>label>button[type="submit"] {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -23,7 +23,7 @@ $router = new router;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// Запись маршрутов
 | 
					// Запись маршрутов
 | 
				
			||||||
$router->write('/', 'index', 'index');
 | 
					$router->write('/', 'index', 'index');
 | 
				
			||||||
$router->write('/system/hotline', 'hotline', 'index');
 | 
					$router->write('/search', 'search', 'search', 'POST');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Инициализация ядра
 | 
					// Инициализация ядра
 | 
				
			||||||
$core = new core(namespace: __NAMESPACE__, router: $router);
 | 
					$core = new core(namespace: __NAMESPACE__, router: $router);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user