Compare commits
	
		
			7 Commits
		
	
	
		
			1.0.0
			...
			4d6df00dc9
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 4d6df00dc9 | |||
| 16d5924320 | |||
| b7e26f01ca | |||
| 0b236a672c | |||
| e2e5635cd3 | |||
| 4fc8e011d0 | |||
| 
						 | 
					4b0a1a1c34 | 
@@ -1,29 +1,36 @@
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    "name": "mirzaev/accounts",
 | 
					    "name": "mirzaev/accounts",
 | 
				
			||||||
    "type": "library",
 | 
					    "type": "library",
 | 
				
			||||||
    "description": "Менеджер аккаунтов",
 | 
					    "description": "Simple accounts manager",
 | 
				
			||||||
 | 
					    "readme": "README.md",
 | 
				
			||||||
    "keywords": [
 | 
					    "keywords": [
 | 
				
			||||||
        "accounts"
 | 
					        "accounts"
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
    "homepage": "https://git.hood.su/mirzaev/accounts",
 | 
					    "homepage": "https://git.mirzaev.sexy/mirzaev/accounts",
 | 
				
			||||||
    "license": "WTFPL",
 | 
					    "license": "WTFPL",
 | 
				
			||||||
    "authors": [
 | 
					    "authors": [
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            "name": "Arsen Mirzaev",
 | 
					            "name": "Arsen Mirzaev Tatyano-Muradovich",
 | 
				
			||||||
            "email": "red@hood.su",
 | 
					            "email": "arsen@mirzaev.sexy",
 | 
				
			||||||
            "homepage": "https://hood.su/sex",
 | 
					            "homepage": "https://mirzaev.sexy",
 | 
				
			||||||
            "role": "Programmer"
 | 
					            "role": "Programmer"
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
    "support": {
 | 
					    "support": {
 | 
				
			||||||
        "docs": "https://git.hood.su/mirzaev/accounts/manual",
 | 
					        "email": "arsen@mirzaev.sexy",
 | 
				
			||||||
        "issues": "https://git.hood.su/mirzaev/accounts/issues",
 | 
					        "wiki": "https://git.mirzaev.sexy/mirzaev/accounts/wiki",
 | 
				
			||||||
        "chat": "https://vk.me/darkweb228"
 | 
					        "issues": "https://git.mirzaev.sexy/mirzaev/accounts/issues"
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					    "funding": [
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            "type": "funding",
 | 
				
			||||||
 | 
					            "url": "https://fund.mirzaev.sexy"
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    ],
 | 
				
			||||||
    "require": {
 | 
					    "require": {
 | 
				
			||||||
        "php": "~8.0",
 | 
					        "php": "~8.1",
 | 
				
			||||||
        "ext-dom": "20031129",
 | 
					        "ext-dom": "20031129",
 | 
				
			||||||
        "ext-libxml": "^7.4",
 | 
					        "ext-libxml": "~8.1.1",
 | 
				
			||||||
        "guzzlehttp/guzzle": "^7.2"
 | 
					        "guzzlehttp/guzzle": "^7.2"
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "require-dev": {
 | 
					    "require-dev": {
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										5030
									
								
								composer.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										5030
									
								
								composer.lock
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										161
									
								
								mirzaev/accounts/system/account.1.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										161
									
								
								mirzaev/accounts/system/account.1.php
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,161 @@
 | 
				
			|||||||
 | 
					<?php
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					declare(strict_types=1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace hood\accounts;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use GuzzleHttp\Client as guzzle;
 | 
				
			||||||
 | 
					use GuzzleHttp\Cookie\FileCookieJar;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use Exception;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Аккаунт
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * @package hood\accounts
 | 
				
			||||||
 | 
					 * @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					abstract class account
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * @var guzzle $browser Браузер
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    protected guzzle $browser;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * @var bool $ssl SSL-протокол
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    protected bool $ssl = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Конструктор
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @var int $id Идентификатор
 | 
				
			||||||
 | 
					     * @var string $path Корневой каталог аккаунтов
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function __construct(
 | 
				
			||||||
 | 
					        protected int $id,
 | 
				
			||||||
 | 
					        protected string $path = __DIR__ . DIRECTORY_SEPARATOR . 'accounts'
 | 
				
			||||||
 | 
					    ) {
 | 
				
			||||||
 | 
					        // Инициализация
 | 
				
			||||||
 | 
					        $this->path($path . DIRECTORY_SEPARATOR . $id);
 | 
				
			||||||
 | 
					        $this->browser();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Деструктор
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @todo Разработать
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function __destruct()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // Деаутентификация
 | 
				
			||||||
 | 
					        // $this->deauth();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Инициализация браузера
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    protected function browser(): guzzle
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return isset($this->path, $this->ssl) ? $this->browser = new guzzle([
 | 
				
			||||||
 | 
					            'verify' => $this->ssl,
 | 
				
			||||||
 | 
					            'cookies' => (new FileCookieJar($this->path . DIRECTORY_SEPARATOR . 'cookie.txt'))
 | 
				
			||||||
 | 
					        ]) : throw new Exception('Не удалось записать браузер');
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Инициализация директории пользователя
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param string $path Путь к директории
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    protected function path(string $path): string
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // Инициализация директории
 | 
				
			||||||
 | 
					        if (file_exists($this->path = $path) || mkdir($this->path, 0775, true)) {
 | 
				
			||||||
 | 
					            return $this->path;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        throw new Exception('Не удалось записать путь к директории');
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Запись свойства
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param string $name Название
 | 
				
			||||||
 | 
					     * @param mixed $value Значение
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function __set(string $name, mixed $value): void
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        match ($name) {
 | 
				
			||||||
 | 
					            'id' => match (false) {
 | 
				
			||||||
 | 
					                isset($this->id) => $this->id = $value,
 | 
				
			||||||
 | 
					                default => throw new Exception('Запрещено перезаписывать идентификатор')
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            'browser' => match (false) {
 | 
				
			||||||
 | 
					                isset($this->browser) => $this->browser = $value,
 | 
				
			||||||
 | 
					                default => throw new Exception('Запрещено перезаписывать браузер')
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            'path' => match (false) {
 | 
				
			||||||
 | 
					                isset($this->path) => $this->path($value),
 | 
				
			||||||
 | 
					                default => throw new Exception('Запрещено перезаписывать путь к директории')
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            'ssl' => $this->ssl = $value,
 | 
				
			||||||
 | 
					            default => throw new Exception('Не найдено: ' . $name, 404)
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Чтение свойства
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param string $name Название
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function __get(string $name): mixed
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return match ($name) {
 | 
				
			||||||
 | 
					            'id' => $this->id,
 | 
				
			||||||
 | 
					            'browser' => $this->browser,
 | 
				
			||||||
 | 
					            'path' => $this->path,
 | 
				
			||||||
 | 
					            'ssl' => $this->ssl,
 | 
				
			||||||
 | 
					            default => throw new Exception('Не найдено: ' . $name, 404)
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Проверка инициализации
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param mixed $name Название
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function __isset(string $name): bool
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return match ($name) {
 | 
				
			||||||
 | 
					            'id' => isset($this->id),
 | 
				
			||||||
 | 
					            'browser' => isset($this->browser),
 | 
				
			||||||
 | 
					            'path' => isset($this->path),
 | 
				
			||||||
 | 
					            'ssl' => isset($this->ssl),
 | 
				
			||||||
 | 
					            default => false
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Удаление свойства
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param mixed $name Название
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    public function __unset(string $name): void
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        match ($name) {
 | 
				
			||||||
 | 
					            'id' => throw new Exception('Запрещено деинициализировать идентификатор'),
 | 
				
			||||||
 | 
					            'browser' =>  function () {
 | 
				
			||||||
 | 
					                unset($this->browser);
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            'path' =>  function () {
 | 
				
			||||||
 | 
					                unset($this->path);
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            'ssl' =>  function () {
 | 
				
			||||||
 | 
					                unset($this->ssl);
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            default => null
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -4,13 +4,14 @@ declare(strict_types=1);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace mirzaev\accounts;
 | 
					namespace mirzaev\accounts;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Браузер
 | 
				
			||||||
use GuzzleHttp\Client as browser;
 | 
					use GuzzleHttp\Client as browser;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Аккаунт
 | 
					 * Аккаунт
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * @package mirzaev\accounts
 | 
					 * @package mirzaev\accounts
 | 
				
			||||||
 * @author Arsen Mirzaev Tatyano-Muradovich <red@hood.su>
 | 
					 * @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
class account
 | 
					class account
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -29,7 +30,6 @@ class account
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    protected string $path;
 | 
					    protected string $path;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Конструктор
 | 
					     * Конструктор
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,7 +5,7 @@ declare(strict_types=1);
 | 
				
			|||||||
namespace mirzaev\accounts\auth;
 | 
					namespace mirzaev\accounts\auth;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Базовая авторизация
 | 
					 * Базовая аутентификация
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
interface basic
 | 
					interface basic
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user