Compare commits
No commits in common. "b7e26f01cac46f79de093253ef7235ffa7ef943f" and "4b0a1a1c34128c281b83485cde53d97df6c82a49" have entirely different histories.
b7e26f01ca
...
4b0a1a1c34
|
@ -1,37 +1,30 @@
|
|||
{
|
||||
"name": "mirzaev/accounts",
|
||||
"type": "library",
|
||||
"description": "Simple accounts manager",
|
||||
"readme": "README.md",
|
||||
"description": "Менеджер аккаунтов",
|
||||
"keywords": [
|
||||
"accounts"
|
||||
],
|
||||
"homepage": "https://git.mirzaev.sexy/mirzaev/accounts",
|
||||
"homepage": "https://git.hood.su/mirzaev/accounts",
|
||||
"license": "WTFPL",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Arsen Mirzaev Tatyano-Muradovich",
|
||||
"email": "arsen@mirzaev.sexy",
|
||||
"homepage": "https://mirzaev.sexy",
|
||||
"name": "Arsen Mirzaev",
|
||||
"email": "red@hood.su",
|
||||
"homepage": "https://hood.su/sex",
|
||||
"role": "Programmer"
|
||||
}
|
||||
],
|
||||
"support": {
|
||||
"email": "arsen@mirzaev.sexy",
|
||||
"wiki": "https://git.mirzaev.sexy/mirzaev/accounts/wiki",
|
||||
"issues": "https://git.mirzaev.sexy/mirzaev/accounts/issues"
|
||||
"docs": "https://git.hood.su/mirzaev/accounts/manual",
|
||||
"issues": "https://git.hood.su/mirzaev/accounts/issues",
|
||||
"chat": "https://vk.me/darkweb228"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"type": "funding",
|
||||
"url": "https://fund.mirzaev.sexy"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "~8.1",
|
||||
"php": "~8.0",
|
||||
"ext-dom": "20031129",
|
||||
"ext-libxml": "^7.4",
|
||||
"guzzlehttp/guzzle": "^7.2"
|
||||
"ext-libxml": "~8.0",
|
||||
"guzzlehttp/guzzle": "~7.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpdocumentor/phpdocumentor": ">=2.9",
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,161 +0,0 @@
|
|||
<?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,14 +4,13 @@ declare(strict_types=1);
|
|||
|
||||
namespace mirzaev\accounts;
|
||||
|
||||
// Браузер
|
||||
use GuzzleHttp\Client as browser;
|
||||
|
||||
/**
|
||||
* Аккаунт
|
||||
*
|
||||
* @package mirzaev\accounts
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <red@hood.su>
|
||||
*/
|
||||
class account
|
||||
{
|
||||
|
@ -30,6 +29,7 @@ class account
|
|||
*/
|
||||
protected string $path;
|
||||
|
||||
|
||||
/**
|
||||
* Конструктор
|
||||
*
|
||||
|
|
|
@ -5,7 +5,7 @@ declare(strict_types=1);
|
|||
namespace mirzaev\accounts\auth;
|
||||
|
||||
/**
|
||||
* Базовая аутентификация
|
||||
* Базовая авторизация
|
||||
*/
|
||||
interface basic
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue