From ba984df67ac740cbe43923fed5f4234b67ce355a Mon Sep 17 00:00:00 2001 From: mirzaev Date: Sat, 30 Dec 2023 22:17:35 +0700 Subject: [PATCH] =?UTF-8?q?1.=20=D0=BD=D0=B0=D0=B7=D0=BD=D0=B0=D1=87=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20undecided=202.=20=D0=B4=D0=B5=D0=B4=D1=83?= =?UTF-8?q?=D0=BF=D0=BB=D0=B8=D0=BA=D0=B0=D1=86=D0=B8=D1=8F=20=D1=80=D0=BE?= =?UTF-8?q?=D0=BB=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + composer.json | 3 +- composer.lock | 958 ------------------ mirzaev/marina/system/controllers/core.php | 8 +- mirzaev/marina/system/controllers/index.php | 198 +++- mirzaev/marina/system/public/robot.php | 22 +- mirzaev/marina/system/settings/.gitignore | 1 + .../system/settings/discord/LINK.sample | 2 + .../system/settings/discord/robot.php.sample | 7 +- .../settings/discord/roles/xor.php.sample | 6 + .../discord/roles/xor_dublicates.php.sample | 7 + .../settings/discord/settings.php.sample | 6 - 12 files changed, 203 insertions(+), 1016 deletions(-) delete mode 100644 composer.lock create mode 100644 mirzaev/marina/system/settings/discord/LINK.sample create mode 100644 mirzaev/marina/system/settings/discord/roles/xor.php.sample create mode 100644 mirzaev/marina/system/settings/discord/roles/xor_dublicates.php.sample delete mode 100644 mirzaev/marina/system/settings/discord/settings.php.sample diff --git a/.gitignore b/.gitignore index 1dda020..c26c9a5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ !.gitignore composer.phar +composer.lock vendor diff --git a/composer.json b/composer.json index 97d4654..b03e1ae 100644 --- a/composer.json +++ b/composer.json @@ -34,8 +34,7 @@ "mirzaev/minimal": "^2.2", "mirzaev/arangodb": "^1.3.0", "triagens/arangodb": "~3.10.x-dev", - "guzzlehttp/guzzle": "^7.5", - "wohali/oauth2-discord-new": "^1.2" + "team-reflex/discord-php": "^10.0.0-RC6" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock deleted file mode 100644 index 697e681..0000000 --- a/composer.lock +++ /dev/null @@ -1,958 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", - "This file is @generated automatically" - ], - "content-hash": "35a83d010513f763290f92c01c2102aa", - "packages": [ - { - "name": "guzzlehttp/guzzle", - "version": "7.8.1", - "source": { - "type": "git", - "url": "https://github.com/guzzle/guzzle.git", - "reference": "41042bc7ab002487b876a0683fc8dce04ddce104" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/41042bc7ab002487b876a0683fc8dce04ddce104", - "reference": "41042bc7ab002487b876a0683fc8dce04ddce104", - "shasum": "" - }, - "require": { - "ext-json": "*", - "guzzlehttp/promises": "^1.5.3 || ^2.0.1", - "guzzlehttp/psr7": "^1.9.1 || ^2.5.1", - "php": "^7.2.5 || ^8.0", - "psr/http-client": "^1.0", - "symfony/deprecation-contracts": "^2.2 || ^3.0" - }, - "provide": { - "psr/http-client-implementation": "1.0" - }, - "require-dev": { - "bamarni/composer-bin-plugin": "^1.8.2", - "ext-curl": "*", - "php-http/client-integration-tests": "dev-master#2c025848417c1135031fdf9c728ee53d0a7ceaee as 3.0.999", - "php-http/message-factory": "^1.1", - "phpunit/phpunit": "^8.5.36 || ^9.6.15", - "psr/log": "^1.1 || ^2.0 || ^3.0" - }, - "suggest": { - "ext-curl": "Required for CURL handler support", - "ext-intl": "Required for Internationalized Domain Name (IDN) support", - "psr/log": "Required for using the Log middleware" - }, - "type": "library", - "extra": { - "bamarni-bin": { - "bin-links": true, - "forward-command": false - } - }, - "autoload": { - "files": [ - "src/functions_include.php" - ], - "psr-4": { - "GuzzleHttp\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Graham Campbell", - "email": "hello@gjcampbell.co.uk", - "homepage": "https://github.com/GrahamCampbell" - }, - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, - { - "name": "Jeremy Lindblom", - "email": "jeremeamia@gmail.com", - "homepage": "https://github.com/jeremeamia" - }, - { - "name": "George Mponos", - "email": "gmponos@gmail.com", - "homepage": "https://github.com/gmponos" - }, - { - "name": "Tobias Nyholm", - "email": "tobias.nyholm@gmail.com", - "homepage": "https://github.com/Nyholm" - }, - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com", - "homepage": "https://github.com/sagikazarmark" - }, - { - "name": "Tobias Schultze", - "email": "webmaster@tubo-world.de", - "homepage": "https://github.com/Tobion" - } - ], - "description": "Guzzle is a PHP HTTP client library", - "keywords": [ - "client", - "curl", - "framework", - "http", - "http client", - "psr-18", - "psr-7", - "rest", - "web service" - ], - "support": { - "issues": "https://github.com/guzzle/guzzle/issues", - "source": "https://github.com/guzzle/guzzle/tree/7.8.1" - }, - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://github.com/Nyholm", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle", - "type": "tidelift" - } - ], - "time": "2023-12-03T20:35:24+00:00" - }, - { - "name": "guzzlehttp/promises", - "version": "2.0.2", - "source": { - "type": "git", - "url": "https://github.com/guzzle/promises.git", - "reference": "bbff78d96034045e58e13dedd6ad91b5d1253223" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/bbff78d96034045e58e13dedd6ad91b5d1253223", - "reference": "bbff78d96034045e58e13dedd6ad91b5d1253223", - "shasum": "" - }, - "require": { - "php": "^7.2.5 || ^8.0" - }, - "require-dev": { - "bamarni/composer-bin-plugin": "^1.8.2", - "phpunit/phpunit": "^8.5.36 || ^9.6.15" - }, - "type": "library", - "extra": { - "bamarni-bin": { - "bin-links": true, - "forward-command": false - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Promise\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Graham Campbell", - "email": "hello@gjcampbell.co.uk", - "homepage": "https://github.com/GrahamCampbell" - }, - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, - { - "name": "Tobias Nyholm", - "email": "tobias.nyholm@gmail.com", - "homepage": "https://github.com/Nyholm" - }, - { - "name": "Tobias Schultze", - "email": "webmaster@tubo-world.de", - "homepage": "https://github.com/Tobion" - } - ], - "description": "Guzzle promises library", - "keywords": [ - "promise" - ], - "support": { - "issues": "https://github.com/guzzle/promises/issues", - "source": "https://github.com/guzzle/promises/tree/2.0.2" - }, - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://github.com/Nyholm", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/promises", - "type": "tidelift" - } - ], - "time": "2023-12-03T20:19:20+00:00" - }, - { - "name": "guzzlehttp/psr7", - "version": "2.6.2", - "source": { - "type": "git", - "url": "https://github.com/guzzle/psr7.git", - "reference": "45b30f99ac27b5ca93cb4831afe16285f57b8221" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/45b30f99ac27b5ca93cb4831afe16285f57b8221", - "reference": "45b30f99ac27b5ca93cb4831afe16285f57b8221", - "shasum": "" - }, - "require": { - "php": "^7.2.5 || ^8.0", - "psr/http-factory": "^1.0", - "psr/http-message": "^1.1 || ^2.0", - "ralouphie/getallheaders": "^3.0" - }, - "provide": { - "psr/http-factory-implementation": "1.0", - "psr/http-message-implementation": "1.0" - }, - "require-dev": { - "bamarni/composer-bin-plugin": "^1.8.2", - "http-interop/http-factory-tests": "^0.9", - "phpunit/phpunit": "^8.5.36 || ^9.6.15" - }, - "suggest": { - "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" - }, - "type": "library", - "extra": { - "bamarni-bin": { - "bin-links": true, - "forward-command": false - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Psr7\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Graham Campbell", - "email": "hello@gjcampbell.co.uk", - "homepage": "https://github.com/GrahamCampbell" - }, - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, - { - "name": "George Mponos", - "email": "gmponos@gmail.com", - "homepage": "https://github.com/gmponos" - }, - { - "name": "Tobias Nyholm", - "email": "tobias.nyholm@gmail.com", - "homepage": "https://github.com/Nyholm" - }, - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com", - "homepage": "https://github.com/sagikazarmark" - }, - { - "name": "Tobias Schultze", - "email": "webmaster@tubo-world.de", - "homepage": "https://github.com/Tobion" - }, - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com", - "homepage": "https://sagikazarmark.hu" - } - ], - "description": "PSR-7 message implementation that also provides common utility methods", - "keywords": [ - "http", - "message", - "psr-7", - "request", - "response", - "stream", - "uri", - "url" - ], - "support": { - "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/2.6.2" - }, - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://github.com/Nyholm", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7", - "type": "tidelift" - } - ], - "time": "2023-12-03T20:05:35+00:00" - }, - { - "name": "league/oauth2-client", - "version": "2.7.0", - "source": { - "type": "git", - "url": "https://github.com/thephpleague/oauth2-client.git", - "reference": "160d6274b03562ebeb55ed18399281d8118b76c8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thephpleague/oauth2-client/zipball/160d6274b03562ebeb55ed18399281d8118b76c8", - "reference": "160d6274b03562ebeb55ed18399281d8118b76c8", - "shasum": "" - }, - "require": { - "guzzlehttp/guzzle": "^6.0 || ^7.0", - "paragonie/random_compat": "^1 || ^2 || ^9.99", - "php": "^5.6 || ^7.0 || ^8.0" - }, - "require-dev": { - "mockery/mockery": "^1.3.5", - "php-parallel-lint/php-parallel-lint": "^1.3.1", - "phpunit/phpunit": "^5.7 || ^6.0 || ^9.5", - "squizlabs/php_codesniffer": "^2.3 || ^3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-2.x": "2.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "League\\OAuth2\\Client\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Alex Bilbie", - "email": "hello@alexbilbie.com", - "homepage": "http://www.alexbilbie.com", - "role": "Developer" - }, - { - "name": "Woody Gilk", - "homepage": "https://github.com/shadowhand", - "role": "Contributor" - } - ], - "description": "OAuth 2.0 Client Library", - "keywords": [ - "Authentication", - "SSO", - "authorization", - "identity", - "idp", - "oauth", - "oauth2", - "single sign on" - ], - "support": { - "issues": "https://github.com/thephpleague/oauth2-client/issues", - "source": "https://github.com/thephpleague/oauth2-client/tree/2.7.0" - }, - "time": "2023-04-16T18:19:15+00:00" - }, - { - "name": "mirzaev/arangodb", - "version": "1.3.0", - "source": { - "type": "git", - "url": "https://git.mirzaev.sexy/mirzaev/arangodb", - "reference": "d0ce9e47af189821bb6a3b7f54e228fb8c129aa3" - }, - "require": { - "php": "^8.2", - "triagens/arangodb": "~3.8" - }, - "require-dev": { - "phpunit/phpunit": "^9.3.3" - }, - "type": "library", - "autoload": { - "psr-4": { - "mirzaev\\arangodb\\": "mirzaev/arangodb/system" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "WTFPL" - ], - "authors": [ - { - "name": "Arsen Mirzaev Tatyano-Muradovich", - "email": "arsen@mirzaev.sexy", - "homepage": "https://mirzaev.sexy", - "role": "Developer" - } - ], - "description": "Simple PHP-framework for ArangoDB", - "homepage": "https://git.hood.su/mirzaev/arangodb", - "keywords": [ - "ArangoDb" - ], - "support": { - "email": "arsen@mirzaev.sexy", - "issues": "https://git.mirzaev.sexy/mirzaev/arangodb/issues", - "wiki": "https://git.mirzaev.sexy/mirzaev/arangodb/manual" - }, - "funding": [ - { - "url": "https://fund.mirzaev.sexy", - "type": "funding" - } - ], - "time": "2023-12-21T16:26:50+00:00" - }, - { - "name": "mirzaev/minimal", - "version": "2.2.0", - "source": { - "type": "git", - "url": "https://git.mirzaev.sexy/mirzaev/minimal", - "reference": "41bf8ab56a71f8df90ea0332469cf46acd6a762d" - }, - "require": { - "php": "~8.2" - }, - "type": "framework", - "autoload": { - "psr-4": { - "mirzaev\\minimal\\": "mirzaev/minimal/system" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "WTFPL" - ], - "authors": [ - { - "name": "Arsen Mirzaev Tatyano-Muradovich", - "email": "arsen@mirzaev.sexy", - "homepage": "https://mirzaev.sexy", - "role": "Developer" - } - ], - "description": "Lightweight MVC framework that manages only the basic mechanisms, leaving the development of the programmer and not overloading the project", - "homepage": "https://git.mirzaev.sexy/mirzaev/minimal", - "keywords": [ - "framework", - "lightweight", - "mvc" - ], - "support": { - "docs": "https://git.mirzaev.sexy/mirzaev/minimal/wiki", - "issues": "https://git.mirzaev.sexy/mirzaev/minimal/issues" - }, - "time": "2023-12-21T16:14:34+00:00" - }, - { - "name": "paragonie/random_compat", - "version": "v9.99.100", - "source": { - "type": "git", - "url": "https://github.com/paragonie/random_compat.git", - "reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/paragonie/random_compat/zipball/996434e5492cb4c3edcb9168db6fbb1359ef965a", - "reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a", - "shasum": "" - }, - "require": { - "php": ">= 7" - }, - "require-dev": { - "phpunit/phpunit": "4.*|5.*", - "vimeo/psalm": "^1" - }, - "suggest": { - "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." - }, - "type": "library", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Paragon Initiative Enterprises", - "email": "security@paragonie.com", - "homepage": "https://paragonie.com" - } - ], - "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", - "keywords": [ - "csprng", - "polyfill", - "pseudorandom", - "random" - ], - "support": { - "email": "info@paragonie.com", - "issues": "https://github.com/paragonie/random_compat/issues", - "source": "https://github.com/paragonie/random_compat" - }, - "time": "2020-10-15T08:29:30+00:00" - }, - { - "name": "psr/http-client", - "version": "1.0.3", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-client.git", - "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90", - "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90", - "shasum": "" - }, - "require": { - "php": "^7.0 || ^8.0", - "psr/http-message": "^1.0 || ^2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Client\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" - } - ], - "description": "Common interface for HTTP clients", - "homepage": "https://github.com/php-fig/http-client", - "keywords": [ - "http", - "http-client", - "psr", - "psr-18" - ], - "support": { - "source": "https://github.com/php-fig/http-client" - }, - "time": "2023-09-23T14:17:50+00:00" - }, - { - "name": "psr/http-factory", - "version": "1.0.2", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-factory.git", - "reference": "e616d01114759c4c489f93b099585439f795fe35" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-factory/zipball/e616d01114759c4c489f93b099585439f795fe35", - "reference": "e616d01114759c4c489f93b099585439f795fe35", - "shasum": "" - }, - "require": { - "php": ">=7.0.0", - "psr/http-message": "^1.0 || ^2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Message\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" - } - ], - "description": "Common interfaces for PSR-7 HTTP message factories", - "keywords": [ - "factory", - "http", - "message", - "psr", - "psr-17", - "psr-7", - "request", - "response" - ], - "support": { - "source": "https://github.com/php-fig/http-factory/tree/1.0.2" - }, - "time": "2023-04-10T20:10:41+00:00" - }, - { - "name": "psr/http-message", - "version": "2.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-message.git", - "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71", - "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Message\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" - } - ], - "description": "Common interface for HTTP messages", - "homepage": "https://github.com/php-fig/http-message", - "keywords": [ - "http", - "http-message", - "psr", - "psr-7", - "request", - "response" - ], - "support": { - "source": "https://github.com/php-fig/http-message/tree/2.0" - }, - "time": "2023-04-04T09:54:51+00:00" - }, - { - "name": "ralouphie/getallheaders", - "version": "3.0.3", - "source": { - "type": "git", - "url": "https://github.com/ralouphie/getallheaders.git", - "reference": "120b605dfeb996808c31b6477290a714d356e822" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", - "reference": "120b605dfeb996808c31b6477290a714d356e822", - "shasum": "" - }, - "require": { - "php": ">=5.6" - }, - "require-dev": { - "php-coveralls/php-coveralls": "^2.1", - "phpunit/phpunit": "^5 || ^6.5" - }, - "type": "library", - "autoload": { - "files": [ - "src/getallheaders.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ralph Khattar", - "email": "ralph.khattar@gmail.com" - } - ], - "description": "A polyfill for getallheaders.", - "support": { - "issues": "https://github.com/ralouphie/getallheaders/issues", - "source": "https://github.com/ralouphie/getallheaders/tree/develop" - }, - "time": "2019-03-08T08:55:37+00:00" - }, - { - "name": "symfony/deprecation-contracts", - "version": "v3.4.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/7c3aff79d10325257a001fcf92d991f24fc967cf", - "reference": "7c3aff79d10325257a001fcf92d991f24fc967cf", - "shasum": "" - }, - "require": { - "php": ">=8.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "3.4-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" - } - }, - "autoload": { - "files": [ - "function.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "A generic function and convention to trigger deprecation notices", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v3.4.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2023-05-23T14:45:45+00:00" - }, - { - "name": "triagens/arangodb", - "version": "3.10.x-dev", - "source": { - "type": "git", - "url": "https://github.com/arangodb/arangodb-php.git", - "reference": "a378f9595b54ff16c9533b264e8d0709a2432da0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/arangodb/arangodb-php/zipball/a378f9595b54ff16c9533b264e8d0709a2432da0", - "reference": "a378f9595b54ff16c9533b264e8d0709a2432da0", - "shasum": "" - }, - "require": { - "php": ">=5.6.0" - }, - "type": "library", - "autoload": { - "psr-0": { - "ArangoDBClient": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "Jan Steemann", - "homepage": "https://github.com/arangodb/arangodb-php", - "role": "Developer" - }, - { - "name": "Frank Mayer", - "homepage": "https://github.com/arangodb/arangodb-php", - "role": "Developer" - }, - { - "name": "Contributors", - "homepage": "https://github.com/arangodb/arangodb-php/graphs/contributors" - } - ], - "description": "ArangoDB PHP client", - "homepage": "https://github.com/arangodb/arangodb-php", - "keywords": [ - "Arango", - "ArangoDb", - "database", - "distributed", - "document store", - "graph database", - "multi-model", - "nosql" - ], - "support": { - "issues": "https://github.com/arangodb/arangodb-php/issues", - "source": "https://github.com/arangodb/arangodb-php/tree/3.10" - }, - "time": "2022-10-21T15:30:45+00:00" - }, - { - "name": "wohali/oauth2-discord-new", - "version": "1.2.1", - "source": { - "type": "git", - "url": "https://github.com/wohali/oauth2-discord-new.git", - "reference": "2df4d2a882e04c749880797704e4bde8f00ea1d9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/wohali/oauth2-discord-new/zipball/2df4d2a882e04c749880797704e4bde8f00ea1d9", - "reference": "2df4d2a882e04c749880797704e4bde8f00ea1d9", - "shasum": "" - }, - "require": { - "ext-json": "*", - "league/oauth2-client": "^2.0", - "php": "^7.2|^8.0" - }, - "conflict": { - "team-reflex/oauth2-discord": ">=1.0" - }, - "require-dev": { - "mockery/mockery": "~1.3.0", - "php-parallel-lint/php-parallel-lint": "~0.9", - "phpunit/phpunit": "~8.0", - "squizlabs/php_codesniffer": "^2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Wohali\\OAuth2\\Client\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Joan Touzet", - "email": "code@atypical.net", - "homepage": "https://github.com/wohali" - } - ], - "description": "Discord OAuth 2.0 Client Provider for The PHP League OAuth2-Client", - "keywords": [ - "authorisation", - "authorization", - "client", - "discord", - "oauth", - "oauth2" - ], - "support": { - "issues": "https://github.com/wohali/oauth2-discord-new/issues", - "source": "https://github.com/wohali/oauth2-discord-new/tree/1.2.1" - }, - "time": "2022-12-29T18:45:10+00:00" - } - ], - "packages-dev": [], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": { - "triagens/arangodb": 20 - }, - "prefer-stable": false, - "prefer-lowest": false, - "platform": { - "php": "~8.2" - }, - "platform-dev": [], - "plugin-api-version": "2.2.0" -} diff --git a/mirzaev/marina/system/controllers/core.php b/mirzaev/marina/system/controllers/core.php index 31b49c0..0f174f7 100644 --- a/mirzaev/marina/system/controllers/core.php +++ b/mirzaev/marina/system/controllers/core.php @@ -11,7 +11,7 @@ use mirzaev\marina\models\core as model; use mirzaev\minimal\controller; // Discord framework -use Wohali\OAuth2\Client\Provider\Discord as provider; +use Discord\Discord as discord; /** * Ядро контроллеров @@ -29,7 +29,7 @@ class core extends controller /** * Discord provider */ - readonly public provider $provider; + readonly public discord $discord; /** * Реестр ошибок @@ -51,8 +51,8 @@ class core extends controller // Инициализация ядра моделей (соединение с базой данных...) new model(); - // Initialize of discord provider - $this->provider = new provider(require '../settings/discord/robot.php'); + // Initialize of discord handler + $this->discord = new discord(require '../settings/discord/robot.php'); } } diff --git a/mirzaev/marina/system/controllers/index.php b/mirzaev/marina/system/controllers/index.php index 913c5dd..02e0d77 100644 --- a/mirzaev/marina/system/controllers/index.php +++ b/mirzaev/marina/system/controllers/index.php @@ -7,6 +7,14 @@ namespace mirzaev\marina\controllers; // Файлы проекта use mirzaev\marina\controllers\core; +// Discord framework +use Discord\Discord as discord, + Discord\Parts\Channel\Message as message, + Discord\Parts\Guild\Role as role, + Discord\Parts\User\Member as member, + Discord\WebSockets\Event as event, + Discord\Builders\MessageBuilder as _message; + // Встроенные библиотеки use exception; @@ -22,50 +30,174 @@ final class index extends core * Главная страница * * @param array $parameters Параметры запроса + * + * @return void */ - public function index(array $parameters = []): ?string + public function index(array $parameters = []): void { - if (!isset($parameters['code'])) { + $this->discord->on('init', function (discord $discord) { + // Запись в буфер вывода (терминал) + echo "Marina is ready!", PHP_EOL; - // Step 1. Get authorization code - $_SESSION['oauth2state'] = $this->provider->getState(); - header('Location: ' . $this->provider->getAuthorizationUrl(require '../settings/discord/settings.php')); + // Сообщение: "марина" + $discord->on(event::MESSAGE_CREATE, function (message $message, discord $discord) { + if ($message->author->bot) { + // Do nothing + return; + } - // Check given state against previously stored one to mitigate CSRF attack - } elseif (empty($parameters['state']) || ($parameters['state'] !== $_SESSION['oauth2state'])) { + // Запись в буфер вывода (терминал) + echo "{$message->author->username}: {$message->content}", PHP_EOL; - unset($_SESSION['oauth2state']); - exit('Invalid state'); - } else { + if (mb_stristr($message->content, 'марина') !== false) { + $message->reply(_message::new()->setContent('ЗДАРОВА')); + } + }); - // Step 2. Get an access token using the provided authorization code - $token = $this->provider->getAccessToken('authorization_code', [ - 'code' => $parameters['code'] - ]); + // Пользователь: обновление роли + $discord->on(event::GUILD_MEMBER_UPDATE, function (member $new, discord $discord, ?member $old = null) { + // Запись в буфер вывода (терминал) - // Show some token details - echo '

Token details:

'; - echo 'Token: ' . $token->getToken() . "
"; - echo 'Refresh token: ' . $token->getRefreshToken() . "
"; - echo 'Expires: ' . $token->getExpires() . " - "; - echo ($token->hasExpired() ? 'expired' : 'not expired') . "
"; + // Инициализация реестра ролей пользователя + $_roles = array_reverse($new->roles->toArray()); - // Step 3. (Optional) Look up the user's profile with the provided token - try { + /** + * + * НАЧАЛО БЛОКА: "если ни одна роль не назначена, то назначить другие роли" + * + */ - $user = $this->provider->getResourceOwner($token); + // Инициализация реестров ролей + $roles = require '../settings/discord/roles/xor.php'; - echo '

Resource owner details:

'; - printf('Hello %s#%s!

', $user->getUsername(), $user->getDiscriminator()); - var_export($user->toArray()); - } catch (exception $e) { + // Инициализация статуса о том, что ни одна из ролей в реестре необходимых ролей не назначена + $fail = true; - // Failed to get user details - exit('fail'); - } - } + // Проверка на назначение хотя бы одной роли из реестра необходимых ролей + foreach ($_roles as $role) + if (in_array($role->id, $roles['required'], true)) $fail = false; - // Возврат (провал) - return null; + // Если ни одна роль из реестра не назначена, то выдать роли из реестра ролей назначения, иначе удалить роли из реестра ролей назначения + if ($fail) foreach ($roles['else'] as $role => $reason) $new->addRole($role, $reason); + else foreach ($roles['else'] as $role => $reason) $new->removeRole($role, 'CONDITION NOT COMPLIED: ' . $reason); + + // Деинициализация неактуальных переменных + unset($roles, $fail); + + /** + * + * КОНЕЦ БЛОКА: "если ни одна роль не назначена, то назначить другие роли" + * + */ + + /** + * + * НАЧАЛО БЛОКА: "если есть дубликаты ролей, то назначить доминирующую, если нет других доминирующих" + * + */ + + // Инициализация реестра ролей + $roles = require '../settings/discord/roles/xor_dublicates.php'; + + // Инициализация реестра найденных основных специальностей + $mains = []; + + // Инициализация буфера идентификатора основной роли (после обработки) + $id; + + // Поиск основной специальности + foreach ($_roles as $role) + if (in_array($role->id, $roles, true)) $mains[] = $role; + + // Подсчёт количества найденных основных специальностей + $amount = count($mains); + + if ($amount > 1) { + // Найдено несколько основных специальностей + + // Если не передано старое состояние аккаунта, то пропустить проверку старого состояния + if (is_null($old)) goto deduplication; + + // Поиск добавленных ролей + $diff = array_values(array_diff($_roles, $old->roles->toArray())); + + if (count($diff) === 1 && in_array($diff[0]->id, $roles, true)) { + // Добавлена одна роль и она является доминирующей + + // Удаление всех основных ролей кроме добавленной + foreach ($mains as $role) + if ($role->id === $diff[0]->id) continue; + else $new->removeRole($role); + } else { + // Добавлено несколько ролей, либо добавлена одна роль, но она не является доминирующей + + deduplication: + + for ($i = $amount - 1; $i > 0; --$i) { + // Перебор реестра найденных основных ролей + + // Удаление основной роли (будут удалены все кроме первой в списке, то есть самой приоритетной в discord) + $new->removeRole($mains[$i]); + + // Инициализация основной роли + $id = $mains[0]->id; + } + } + } else if ($amount === 1) $id = $mains[0]->id; + else if ($amount === 0) { + // Не найдена основная специальность + + foreach ($_roles as $role) { + // Перебор ролей + + if (array_key_exists($role->id, $roles)) { + // Найдена вторичная специальность + + // Замена вторичной специальности основной специальностью + $new->removeRole($role->id, 'Main specialty chosen'); + $new->addRole($roles[$role->id], 'Main specialty chosen'); + + // Реинициализация основной роли + $id = $roles[$role->id]; + + // Завершение выполнения (успех) + break; + } + } + } + + if (isset($id)) { + // Найден идентификатор основной роли + + // Инициализация дубликата основной роли (вторичная роль) + $secondary = array_flip($roles)[$id]; + + foreach ($_roles as $role) { + // Перебор ролей + + if ($role->id === (string) $secondary) { + // Найдена вторичная специальность дублирующая основную + + // Замена вторичной специальности основной специальностью + $new->removeRole($secondary, 'Main specialty chosen'); + + // Завершение выполнения (успех) + break; + } + } + } + + // Деиницализация неактуальных перменных + unset($roles, $mains, $id, $amount); + + /** + * + * КОНЕЦ БЛОКА: "если ни одна роль не назначена, то назначить другие роли" + * + */ + }); + }); + + $this->discord->run(); } } diff --git a/mirzaev/marina/system/public/robot.php b/mirzaev/marina/system/public/robot.php index a58539f..7f93dfb 100644 --- a/mirzaev/marina/system/public/robot.php +++ b/mirzaev/marina/system/public/robot.php @@ -21,24 +21,26 @@ define('STORAGE', realpath('..' . DIRECTORY_SEPARATOR . 'storage')); define('INDEX', __DIR__); // Автозагрузка -require __DIR__ - . DIRECTORY_SEPARATOR . '..' - . DIRECTORY_SEPARATOR . '..' - . DIRECTORY_SEPARATOR . '..' - . DIRECTORY_SEPARATOR . '..' - . DIRECTORY_SEPARATOR . 'vendor' +require __DIR__ + . DIRECTORY_SEPARATOR . '..' + . DIRECTORY_SEPARATOR . '..' + . DIRECTORY_SEPARATOR . '..' + . DIRECTORY_SEPARATOR . '..' + . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'; // Инициализация маршрутазитора $router = new router; // Запись маршрутов -$router->write('/', 'index', 'index', 'GET'); +$router->write('/', 'index', 'index', 'POST'); // Инициализация ядра $core = new core(namespace: __NAMESPACE__, router: $router, controller: new controller(false), model: new model(false)); +if (php_sapi_name() === 'cli') { + // Выполнение только через CLI -// Обработка запроса -echo $core->start(); - + // Обработка запроса + echo $router->handle('/', 'POST', $core); +} else echo 'you will never have a girlfriend'; diff --git a/mirzaev/marina/system/settings/.gitignore b/mirzaev/marina/system/settings/.gitignore index 3ad8936..0c407de 100644 --- a/mirzaev/marina/system/settings/.gitignore +++ b/mirzaev/marina/system/settings/.gitignore @@ -2,3 +2,4 @@ !.gitignore !*.sample !discord +!discord/roles diff --git a/mirzaev/marina/system/settings/discord/LINK.sample b/mirzaev/marina/system/settings/discord/LINK.sample new file mode 100644 index 0000000..001153f --- /dev/null +++ b/mirzaev/marina/system/settings/discord/LINK.sample @@ -0,0 +1,2 @@ +// Place a link here to invite a robot (just so you don't lose it) +https://discord.com/api/oauth2/authorize?client_id=&permissions=&scope=bot diff --git a/mirzaev/marina/system/settings/discord/robot.php.sample b/mirzaev/marina/system/settings/discord/robot.php.sample index 73aa790..e9519bc 100644 --- a/mirzaev/marina/system/settings/discord/robot.php.sample +++ b/mirzaev/marina/system/settings/discord/robot.php.sample @@ -1,7 +1,8 @@ '', - 'clientSecret' => '', - 'redirectUri' => '' + 'token' => '', + 'intents' => intents::getDefaultIntents() ]; diff --git a/mirzaev/marina/system/settings/discord/roles/xor.php.sample b/mirzaev/marina/system/settings/discord/roles/xor.php.sample new file mode 100644 index 0000000..8d42b39 --- /dev/null +++ b/mirzaev/marina/system/settings/discord/roles/xor.php.sample @@ -0,0 +1,6 @@ + ['role_id_1', 'role_id_2'], + 'else' => ['role_id_3' => 'reason for audit log'] +]; diff --git a/mirzaev/marina/system/settings/discord/roles/xor_dublicates.php.sample b/mirzaev/marina/system/settings/discord/roles/xor_dublicates.php.sample new file mode 100644 index 0000000..e0a8b86 --- /dev/null +++ b/mirzaev/marina/system/settings/discord/roles/xor_dublicates.php.sample @@ -0,0 +1,7 @@ + 'to_role_id', +]; diff --git a/mirzaev/marina/system/settings/discord/settings.php.sample b/mirzaev/marina/system/settings/discord/settings.php.sample deleted file mode 100644 index 3f1e8f3..0000000 --- a/mirzaev/marina/system/settings/discord/settings.php.sample +++ /dev/null @@ -1,6 +0,0 @@ - 'OPTIONAL_CUSTOM_CONFIGURED_STATE', - 'scope' => ['identify', 'email'] -];