4 Commits

5 changed files with 295 additions and 47 deletions

View File

@@ -1,30 +1,37 @@
{
"name": "mirzaev/accounts",
"type": "library",
"description": "Менеджер аккаунтов",
"description": "Simple accounts manager",
"readme": "README.md",
"keywords": [
"accounts"
],
"homepage": "https://git.hood.su/mirzaev/accounts",
"homepage": "https://git.mirzaev.sexy/mirzaev/accounts",
"license": "WTFPL",
"authors": [
{
"name": "Arsen Mirzaev",
"email": "red@hood.su",
"homepage": "https://hood.su/sex",
"name": "Arsen Mirzaev Tatyano-Muradovich",
"email": "arsen@mirzaev.sexy",
"homepage": "https://mirzaev.sexy",
"role": "Programmer"
}
],
"support": {
"docs": "https://git.hood.su/mirzaev/accounts/manual",
"issues": "https://git.hood.su/mirzaev/accounts/issues",
"chat": "https://vk.me/darkweb228"
"email": "arsen@mirzaev.sexy",
"wiki": "https://git.mirzaev.sexy/mirzaev/accounts/wiki",
"issues": "https://git.mirzaev.sexy/mirzaev/accounts/issues"
},
"funding": [
{
"type": "funding",
"url": "https://fund.mirzaev.sexy"
}
],
"require": {
"php": "~8.0",
"php": "~8.1",
"ext-dom": "20031129",
"ext-libxml": "~8.0",
"guzzlehttp/guzzle": "~7.2"
"ext-libxml": "~8.1.1",
"guzzlehttp/guzzle": "^7.2"
},
"require-dev": {
"phpdocumentor/phpdocumentor": ">=2.9",

146
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "23c3ffec0f7ab8375317cd34400df0c6",
"content-hash": "692ab4dc45591b983920eb547fc37a45",
"packages": [
{
"name": "guzzlehttp/guzzle",
@@ -613,6 +613,86 @@
],
"time": "2020-11-10T18:47:58+00:00"
},
{
"name": "doctrine/lexer",
"version": "1.2.1",
"source": {
"type": "git",
"url": "https://github.com/doctrine/lexer.git",
"reference": "e864bbf5904cb8f5bb334f99209b48018522f042"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/lexer/zipball/e864bbf5904cb8f5bb334f99209b48018522f042",
"reference": "e864bbf5904cb8f5bb334f99209b48018522f042",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0"
},
"require-dev": {
"doctrine/coding-standard": "^6.0",
"phpstan/phpstan": "^0.11.8",
"phpunit/phpunit": "^8.2"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.2.x-dev"
}
},
"autoload": {
"psr-4": {
"Doctrine\\Common\\Lexer\\": "lib/Doctrine/Common/Lexer"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com"
},
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
},
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com"
}
],
"description": "PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.",
"homepage": "https://www.doctrine-project.org/projects/lexer.html",
"keywords": [
"annotations",
"docblock",
"lexer",
"parser",
"php"
],
"support": {
"issues": "https://github.com/doctrine/lexer/issues",
"source": "https://github.com/doctrine/lexer/tree/1.2.1"
},
"funding": [
{
"url": "https://www.doctrine-project.org/sponsorship.html",
"type": "custom"
},
{
"url": "https://www.patreon.com/phpdoctrine",
"type": "patreon"
},
{
"url": "https://tidelift.com/funding/github/packagist/doctrine%2Flexer",
"type": "tidelift"
}
],
"time": "2020-05-25T17:44:05+00:00"
},
{
"name": "jawira/plantuml",
"version": "v1.59.0",
@@ -819,16 +899,16 @@
},
{
"name": "league/flysystem",
"version": "1.1.4",
"version": "1.1.5",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/flysystem.git",
"reference": "f3ad69181b8afed2c9edf7be5a2918144ff4ea32"
"reference": "18634df356bfd4119fe3d6156bdb990c414c14ea"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/f3ad69181b8afed2c9edf7be5a2918144ff4ea32",
"reference": "f3ad69181b8afed2c9edf7be5a2918144ff4ea32",
"url": "https://api.github.com/repos/thephpleague/flysystem/zipball/18634df356bfd4119fe3d6156bdb990c414c14ea",
"reference": "18634df356bfd4119fe3d6156bdb990c414c14ea",
"shasum": ""
},
"require": {
@@ -901,7 +981,7 @@
],
"support": {
"issues": "https://github.com/thephpleague/flysystem/issues",
"source": "https://github.com/thephpleague/flysystem/tree/1.1.4"
"source": "https://github.com/thephpleague/flysystem/tree/1.1.5"
},
"funding": [
{
@@ -909,7 +989,7 @@
"type": "other"
}
],
"time": "2021-06-23T21:56:05+00:00"
"time": "2021-08-17T13:49:42+00:00"
},
{
"name": "league/mime-type-detection",
@@ -1865,20 +1945,21 @@
},
{
"name": "phpdocumentor/phpdocumentor",
"version": "v3.1.0",
"version": "v3.1.1",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/phpDocumentor.git",
"reference": "7015b11cf0733aaa94a059328bb8d948991630e1"
"reference": "d4449d5d9765caa92c9647b2ac50131aa5a93106"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/phpDocumentor/zipball/7015b11cf0733aaa94a059328bb8d948991630e1",
"reference": "7015b11cf0733aaa94a059328bb8d948991630e1",
"url": "https://api.github.com/repos/phpDocumentor/phpDocumentor/zipball/d4449d5d9765caa92c9647b2ac50131aa5a93106",
"reference": "d4449d5d9765caa92c9647b2ac50131aa5a93106",
"shasum": ""
},
"require": {
"doctrine/event-manager": "^1.1",
"doctrine/lexer": "^1.2",
"ext-ctype": "*",
"ext-hash": "*",
"ext-iconv": "*",
@@ -1983,22 +2064,22 @@
],
"support": {
"issues": "https://github.com/phpDocumentor/phpDocumentor/issues",
"source": "https://github.com/phpDocumentor/phpDocumentor/tree/v3.1.0"
"source": "https://github.com/phpDocumentor/phpDocumentor/tree/v3.1.1"
},
"time": "2021-07-07T18:11:22+00:00"
"time": "2021-08-20T07:40:11+00:00"
},
{
"name": "phpdocumentor/reflection",
"version": "5.0.0",
"version": "5.0.1",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/Reflection.git",
"reference": "1b70ad9839e288f98f8d162f88754598f207fcae"
"reference": "140db6834feec47ebebc195463771c7377c73010"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/Reflection/zipball/1b70ad9839e288f98f8d162f88754598f207fcae",
"reference": "1b70ad9839e288f98f8d162f88754598f207fcae",
"url": "https://api.github.com/repos/phpDocumentor/Reflection/zipball/140db6834feec47ebebc195463771c7377c73010",
"reference": "140db6834feec47ebebc195463771c7377c73010",
"shasum": ""
},
"require": {
@@ -2039,9 +2120,9 @@
],
"support": {
"issues": "https://github.com/phpDocumentor/Reflection/issues",
"source": "https://github.com/phpDocumentor/Reflection/tree/5.0.0"
"source": "https://github.com/phpDocumentor/Reflection/tree/5.0.1"
},
"time": "2021-07-01T17:51:41+00:00"
"time": "2021-08-08T09:55:07+00:00"
},
{
"name": "phpdocumentor/reflection-common",
@@ -2588,16 +2669,16 @@
},
{
"name": "phpunit/phpunit",
"version": "9.5.7",
"version": "9.5.8",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "d0dc8b6999c937616df4fb046792004b33fd31c5"
"reference": "191768ccd5c85513b4068bdbe99bb6390c7d54fb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d0dc8b6999c937616df4fb046792004b33fd31c5",
"reference": "d0dc8b6999c937616df4fb046792004b33fd31c5",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/191768ccd5c85513b4068bdbe99bb6390c7d54fb",
"reference": "191768ccd5c85513b4068bdbe99bb6390c7d54fb",
"shasum": ""
},
"require": {
@@ -2609,7 +2690,7 @@
"ext-xml": "*",
"ext-xmlwriter": "*",
"myclabs/deep-copy": "^1.10.1",
"phar-io/manifest": "^2.0.1",
"phar-io/manifest": "^2.0.3",
"phar-io/version": "^3.0.2",
"php": ">=7.3",
"phpspec/prophecy": "^1.12.1",
@@ -2675,7 +2756,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.7"
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.8"
},
"funding": [
{
@@ -2687,7 +2768,7 @@
"type": "github"
}
],
"time": "2021-07-19T06:14:47+00:00"
"time": "2021-07-31T15:17:34+00:00"
},
{
"name": "psr/cache",
@@ -3739,7 +3820,6 @@
"type": "github"
}
],
"abandoned": true,
"time": "2020-09-28T06:45:17+00:00"
},
{
@@ -4799,16 +4879,16 @@
},
{
"name": "symfony/flex",
"version": "v1.13.3",
"version": "v1.14.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/flex.git",
"reference": "2597d0dda8042c43eed44a9cd07236b897e427d7"
"reference": "b298435b9df8d7c7d7d5473d4b9f850a7844d7ea"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/flex/zipball/2597d0dda8042c43eed44a9cd07236b897e427d7",
"reference": "2597d0dda8042c43eed44a9cd07236b897e427d7",
"url": "https://api.github.com/repos/symfony/flex/zipball/b298435b9df8d7c7d7d5473d4b9f850a7844d7ea",
"reference": "b298435b9df8d7c7d7d5473d4b9f850a7844d7ea",
"shasum": ""
},
"require": {
@@ -4847,7 +4927,7 @@
"description": "Composer plugin for Symfony",
"support": {
"issues": "https://github.com/symfony/flex/issues",
"source": "https://github.com/symfony/flex/tree/v1.13.3"
"source": "https://github.com/symfony/flex/tree/v1.14.0"
},
"funding": [
{
@@ -4863,7 +4943,7 @@
"type": "tidelift"
}
],
"time": "2021-05-19T07:19:15+00:00"
"time": "2021-08-20T17:26:27+00:00"
},
{
"name": "symfony/framework-bundle",

View 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
};
}
}

View File

@@ -4,13 +4,14 @@ declare(strict_types=1);
namespace mirzaev\accounts;
// Браузер
use GuzzleHttp\Client as browser;
/**
* Аккаунт
*
* @package mirzaev\accounts
* @author Arsen Mirzaev Tatyano-Muradovich <red@hood.su>
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
class account
{
@@ -29,7 +30,6 @@ class account
*/
protected string $path;
/**
* Конструктор
*

View File

@@ -5,7 +5,7 @@ declare(strict_types=1);
namespace mirzaev\accounts\auth;
/**
* Базовая авторизация
* Базовая аутентификация
*/
interface basic
{