Compare commits
2 commits
9025435dff
...
ada2baee17
Author | SHA1 | Date | |
---|---|---|---|
ada2baee17 | |||
6dc0ccd9bf |
9 changed files with 133 additions and 141 deletions
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"require": {
|
"require": {
|
||||||
"flashwave/index": "^0.2410",
|
"flashwave/index": "^0.2410",
|
||||||
|
"flashii/apii": "^0.2",
|
||||||
"erusev/parsedown": "~1.6",
|
"erusev/parsedown": "~1.6",
|
||||||
"sentry/sdk": "^4.0"
|
"sentry/sdk": "^4.0"
|
||||||
},
|
},
|
||||||
|
|
147
composer.lock
generated
147
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": "0fcc2129a9e1c99597116e91c7bb2df1",
|
"content-hash": "f71663659023233c6bbd47cc74f1d954",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "erusev/parsedown",
|
"name": "erusev/parsedown",
|
||||||
|
@ -56,13 +56,50 @@
|
||||||
},
|
},
|
||||||
"time": "2019-12-30T22:54:17+00:00"
|
"time": "2019-12-30T22:54:17+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "flashii/apii",
|
||||||
|
"version": "v0.2.1",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://patchii.net/flashii/apii-php.git",
|
||||||
|
"reference": "6a93d31375dd7e75ff9264f3024f2208ce602f49"
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=8.1"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpstan/phpstan": "^1.12",
|
||||||
|
"phpunit/phpunit": "^10.5"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Flashii\\": "src"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"bsd-3-clause-clear"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "flashwave",
|
||||||
|
"email": "packagist@flash.moe",
|
||||||
|
"homepage": "https://flash.moe",
|
||||||
|
"role": "mom"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Client library for the Flashii.net API.",
|
||||||
|
"homepage": "https://api.flashii.net",
|
||||||
|
"time": "2024-11-16T16:03:42+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "flashwave/index",
|
"name": "flashwave/index",
|
||||||
"version": "v0.2410.51409",
|
"version": "v0.2410.191603",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://patchii.net/flash/index.git",
|
"url": "https://patchii.net/flash/index.git",
|
||||||
"reference": "c43c6eb334f85edf8fa7b5e4058b3ba35a27d960"
|
"reference": "17cdb4d1c239241200d7e30968122a8cd8b26509"
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"ext-mbstring": "*",
|
"ext-mbstring": "*",
|
||||||
|
@ -83,6 +120,14 @@
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"src/Cache/ArrayCache/_ndx.php",
|
||||||
|
"src/Cache/Memcached/_ndx.php",
|
||||||
|
"src/Cache/Valkey/_ndx.php",
|
||||||
|
"src/Db/MariaDb/_ndx.php",
|
||||||
|
"src/Db/NullDb/_ndx.php",
|
||||||
|
"src/Db/Sqlite/_ndx.php"
|
||||||
|
],
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Index\\": "src"
|
"Index\\": "src"
|
||||||
}
|
}
|
||||||
|
@ -101,7 +146,7 @@
|
||||||
],
|
],
|
||||||
"description": "Composer package for the common library for my projects.",
|
"description": "Composer package for the common library for my projects.",
|
||||||
"homepage": "https://railgun.sh/index",
|
"homepage": "https://railgun.sh/index",
|
||||||
"time": "2024-10-05T14:10:08+00:00"
|
"time": "2024-10-19T16:04:17+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "guzzlehttp/psr7",
|
"name": "guzzlehttp/psr7",
|
||||||
|
@ -221,28 +266,28 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "jean85/pretty-package-versions",
|
"name": "jean85/pretty-package-versions",
|
||||||
"version": "2.0.6",
|
"version": "2.1.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/Jean85/pretty-package-versions.git",
|
"url": "https://github.com/Jean85/pretty-package-versions.git",
|
||||||
"reference": "f9fdd29ad8e6d024f52678b570e5593759b550b4"
|
"reference": "3c4e5f62ba8d7de1734312e4fff32f67a8daaf10"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/f9fdd29ad8e6d024f52678b570e5593759b550b4",
|
"url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/3c4e5f62ba8d7de1734312e4fff32f67a8daaf10",
|
||||||
"reference": "f9fdd29ad8e6d024f52678b570e5593759b550b4",
|
"reference": "3c4e5f62ba8d7de1734312e4fff32f67a8daaf10",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"composer-runtime-api": "^2.0.0",
|
"composer-runtime-api": "^2.1.0",
|
||||||
"php": "^7.1|^8.0"
|
"php": "^7.4|^8.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"friendsofphp/php-cs-fixer": "^3.2",
|
"friendsofphp/php-cs-fixer": "^3.2",
|
||||||
"jean85/composer-provided-replaced-stub-package": "^1.0",
|
"jean85/composer-provided-replaced-stub-package": "^1.0",
|
||||||
"phpstan/phpstan": "^1.4",
|
"phpstan/phpstan": "^1.4",
|
||||||
"phpunit/phpunit": "^7.5|^8.5|^9.4",
|
"phpunit/phpunit": "^7.5|^8.5|^9.6",
|
||||||
"vimeo/psalm": "^4.3"
|
"vimeo/psalm": "^4.3 || ^5.0"
|
||||||
},
|
},
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
|
@ -274,9 +319,9 @@
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/Jean85/pretty-package-versions/issues",
|
"issues": "https://github.com/Jean85/pretty-package-versions/issues",
|
||||||
"source": "https://github.com/Jean85/pretty-package-versions/tree/2.0.6"
|
"source": "https://github.com/Jean85/pretty-package-versions/tree/2.1.0"
|
||||||
},
|
},
|
||||||
"time": "2024-03-08T09:58:59+00:00"
|
"time": "2024-11-18T16:19:46+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "psr/http-factory",
|
"name": "psr/http-factory",
|
||||||
|
@ -537,16 +582,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sentry/sentry",
|
"name": "sentry/sentry",
|
||||||
"version": "4.9.0",
|
"version": "4.10.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/getsentry/sentry-php.git",
|
"url": "https://github.com/getsentry/sentry-php.git",
|
||||||
"reference": "788ec170f51ebb22f2809a1e3f78b19ccd39b70d"
|
"reference": "2af937d47d8aadb8dab0b1d7b9557e495dd12856"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/getsentry/sentry-php/zipball/788ec170f51ebb22f2809a1e3f78b19ccd39b70d",
|
"url": "https://api.github.com/repos/getsentry/sentry-php/zipball/2af937d47d8aadb8dab0b1d7b9557e495dd12856",
|
||||||
"reference": "788ec170f51ebb22f2809a1e3f78b19ccd39b70d",
|
"reference": "2af937d47d8aadb8dab0b1d7b9557e495dd12856",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -564,12 +609,12 @@
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"friendsofphp/php-cs-fixer": "^3.4",
|
"friendsofphp/php-cs-fixer": "^3.4",
|
||||||
"guzzlehttp/promises": "^1.0|^2.0",
|
"guzzlehttp/promises": "^2.0.3",
|
||||||
"guzzlehttp/psr7": "^1.8.4|^2.1.1",
|
"guzzlehttp/psr7": "^1.8.4|^2.1.1",
|
||||||
"monolog/monolog": "^1.6|^2.0|^3.0",
|
"monolog/monolog": "^1.6|^2.0|^3.0",
|
||||||
"phpbench/phpbench": "^1.0",
|
"phpbench/phpbench": "^1.0",
|
||||||
"phpstan/phpstan": "^1.3",
|
"phpstan/phpstan": "^1.3",
|
||||||
"phpunit/phpunit": "^8.5.14|^9.4",
|
"phpunit/phpunit": "^8.5|^9.6",
|
||||||
"symfony/phpunit-bridge": "^5.2|^6.0|^7.0",
|
"symfony/phpunit-bridge": "^5.2|^6.0|^7.0",
|
||||||
"vimeo/psalm": "^4.17"
|
"vimeo/psalm": "^4.17"
|
||||||
},
|
},
|
||||||
|
@ -610,7 +655,7 @@
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/getsentry/sentry-php/issues",
|
"issues": "https://github.com/getsentry/sentry-php/issues",
|
||||||
"source": "https://github.com/getsentry/sentry-php/tree/4.9.0"
|
"source": "https://github.com/getsentry/sentry-php/tree/4.10.0"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
|
@ -622,7 +667,7 @@
|
||||||
"type": "custom"
|
"type": "custom"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2024-08-08T14:40:50+00:00"
|
"time": "2024-11-06T07:44:19+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/deprecation-contracts",
|
"name": "symfony/deprecation-contracts",
|
||||||
|
@ -693,16 +738,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/mime",
|
"name": "symfony/mime",
|
||||||
"version": "v7.1.5",
|
"version": "v7.1.6",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/mime.git",
|
"url": "https://github.com/symfony/mime.git",
|
||||||
"reference": "711d2e167e8ce65b05aea6b258c449671cdd38ff"
|
"reference": "caa1e521edb2650b8470918dfe51708c237f0598"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/mime/zipball/711d2e167e8ce65b05aea6b258c449671cdd38ff",
|
"url": "https://api.github.com/repos/symfony/mime/zipball/caa1e521edb2650b8470918dfe51708c237f0598",
|
||||||
"reference": "711d2e167e8ce65b05aea6b258c449671cdd38ff",
|
"reference": "caa1e521edb2650b8470918dfe51708c237f0598",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -757,7 +802,7 @@
|
||||||
"mime-type"
|
"mime-type"
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"source": "https://github.com/symfony/mime/tree/v7.1.5"
|
"source": "https://github.com/symfony/mime/tree/v7.1.6"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
|
@ -773,20 +818,20 @@
|
||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2024-09-20T08:28:38+00:00"
|
"time": "2024-10-25T15:11:02+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/options-resolver",
|
"name": "symfony/options-resolver",
|
||||||
"version": "v7.1.1",
|
"version": "v7.1.6",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/options-resolver.git",
|
"url": "https://github.com/symfony/options-resolver.git",
|
||||||
"reference": "47aa818121ed3950acd2b58d1d37d08a94f9bf55"
|
"reference": "85e95eeede2d41cd146146e98c9c81d9214cae85"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/options-resolver/zipball/47aa818121ed3950acd2b58d1d37d08a94f9bf55",
|
"url": "https://api.github.com/repos/symfony/options-resolver/zipball/85e95eeede2d41cd146146e98c9c81d9214cae85",
|
||||||
"reference": "47aa818121ed3950acd2b58d1d37d08a94f9bf55",
|
"reference": "85e95eeede2d41cd146146e98c9c81d9214cae85",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -824,7 +869,7 @@
|
||||||
"options"
|
"options"
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"source": "https://github.com/symfony/options-resolver/tree/v7.1.1"
|
"source": "https://github.com/symfony/options-resolver/tree/v7.1.6"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
|
@ -840,7 +885,7 @@
|
||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2024-05-31T14:57:53+00:00"
|
"time": "2024-09-25T14:20:29+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/polyfill-ctype",
|
"name": "symfony/polyfill-ctype",
|
||||||
|
@ -1243,16 +1288,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "twig/html-extra",
|
"name": "twig/html-extra",
|
||||||
"version": "v3.13.0",
|
"version": "v3.15.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/twigphp/html-extra.git",
|
"url": "https://github.com/twigphp/html-extra.git",
|
||||||
"reference": "8229e750091171c1f11801a525927811c7ac5a7e"
|
"reference": "2086023d3ffc4bae2b1115f715d17f97fd013665"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/twigphp/html-extra/zipball/8229e750091171c1f11801a525927811c7ac5a7e",
|
"url": "https://api.github.com/repos/twigphp/html-extra/zipball/2086023d3ffc4bae2b1115f715d17f97fd013665",
|
||||||
"reference": "8229e750091171c1f11801a525927811c7ac5a7e",
|
"reference": "2086023d3ffc4bae2b1115f715d17f97fd013665",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -1295,7 +1340,7 @@
|
||||||
"twig"
|
"twig"
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"source": "https://github.com/twigphp/html-extra/tree/v3.13.0"
|
"source": "https://github.com/twigphp/html-extra/tree/v3.15.0"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
|
@ -1307,20 +1352,20 @@
|
||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2024-09-03T13:08:40+00:00"
|
"time": "2024-09-30T06:41:48+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "twig/twig",
|
"name": "twig/twig",
|
||||||
"version": "v3.14.0",
|
"version": "v3.15.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/twigphp/Twig.git",
|
"url": "https://github.com/twigphp/Twig.git",
|
||||||
"reference": "126b2c97818dbff0cdf3fbfc881aedb3d40aae72"
|
"reference": "2d5b3964cc21d0188633d7ddce732dc8e874db02"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/twigphp/Twig/zipball/126b2c97818dbff0cdf3fbfc881aedb3d40aae72",
|
"url": "https://api.github.com/repos/twigphp/Twig/zipball/2d5b3964cc21d0188633d7ddce732dc8e874db02",
|
||||||
"reference": "126b2c97818dbff0cdf3fbfc881aedb3d40aae72",
|
"reference": "2d5b3964cc21d0188633d7ddce732dc8e874db02",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -1374,7 +1419,7 @@
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/twigphp/Twig/issues",
|
"issues": "https://github.com/twigphp/Twig/issues",
|
||||||
"source": "https://github.com/twigphp/Twig/tree/v3.14.0"
|
"source": "https://github.com/twigphp/Twig/tree/v3.15.0"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
|
@ -1386,22 +1431,22 @@
|
||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2024-09-09T17:55:12+00:00"
|
"time": "2024-11-17T15:59:19+00:00"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"packages-dev": [
|
"packages-dev": [
|
||||||
{
|
{
|
||||||
"name": "phpstan/phpstan",
|
"name": "phpstan/phpstan",
|
||||||
"version": "1.12.5",
|
"version": "1.12.11",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/phpstan/phpstan.git",
|
"url": "https://github.com/phpstan/phpstan.git",
|
||||||
"reference": "7e6c6cb7cecb0a6254009a1a8a7d54ec99812b17"
|
"reference": "0d1fc20a962a91be578bcfe7cf939e6e1a2ff733"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/7e6c6cb7cecb0a6254009a1a8a7d54ec99812b17",
|
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/0d1fc20a962a91be578bcfe7cf939e6e1a2ff733",
|
||||||
"reference": "7e6c6cb7cecb0a6254009a1a8a7d54ec99812b17",
|
"reference": "0d1fc20a962a91be578bcfe7cf939e6e1a2ff733",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -1446,7 +1491,7 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2024-09-26T12:45:22+00:00"
|
"time": "2024-11-17T14:08:01+00:00"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"aliases": [],
|
"aliases": [],
|
||||||
|
|
|
@ -1,24 +1,29 @@
|
||||||
<?php
|
<?php
|
||||||
namespace Seria;
|
namespace Seria;
|
||||||
|
|
||||||
use Seria\Auth\ChatAuth;
|
use Flashii\{FlashiiClient,FlashiiUrls};
|
||||||
|
use Flashii\Credentials\MisuzuCredentials;
|
||||||
use Seria\Users\UserInfo;
|
use Seria\Users\UserInfo;
|
||||||
|
|
||||||
require_once __DIR__ . '/../seria.php';
|
require_once __DIR__ . '/../seria.php';
|
||||||
|
|
||||||
$authToken = (string)filter_input(INPUT_COOKIE, 'msz_auth');
|
$authToken = (string)filter_input(INPUT_COOKIE, 'msz_auth');
|
||||||
$authInfo = ChatAuth::attempt($cfg->scopeTo('cauth'), $authToken);
|
$flashii = new FlashiiClient('Seria', new MisuzuCredentials($authToken), new FlashiiUrls(
|
||||||
|
$cfg->getString('apii:api', FlashiiUrls::PROD_API_URL),
|
||||||
|
$cfg->getString('apii:id', FlashiiUrls::PROD_ID_URL)
|
||||||
|
));
|
||||||
|
$authInfo = $flashii->v1()->me();
|
||||||
|
|
||||||
if($authInfo->success) {
|
if($authInfo !== null) {
|
||||||
$users = $seria->getUsersContext()->getUsers();
|
$users = $seria->getUsersContext()->getUsers();
|
||||||
$users->syncChatUser($authInfo);
|
$users->syncApiUser($authInfo);
|
||||||
$sUserInfo = $users->getUser($authInfo->user_id, 'id');
|
$sUserInfo = $users->getUser($authInfo->getId(), 'id');
|
||||||
$seria->getAuthInfo()->setInfo($sUserInfo);
|
$seria->getAuthInfo()->setInfo($sUserInfo);
|
||||||
} else $sUserInfo = null;
|
} else $sUserInfo = null;
|
||||||
|
|
||||||
$seria->startCSRFP(
|
$seria->startCSRFP(
|
||||||
$cfg->getString('csrfp:secret', 'mewow'),
|
$cfg->getString('csrfp:secret', 'mewow'),
|
||||||
$authInfo->success ? $authToken : (string)filter_input(INPUT_SERVER, 'REMOTE_ADDR')
|
$authInfo === null ? (string)filter_input(INPUT_SERVER, 'REMOTE_ADDR') : $authToken
|
||||||
);
|
);
|
||||||
|
|
||||||
$seria->startTemplating();
|
$seria->startTemplating();
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
namespace Seria;
|
namespace Seria;
|
||||||
|
|
||||||
use Index\Config\Fs\FsConfig;
|
use Index\Config\Fs\FsConfig;
|
||||||
use Index\Db\DbTools;
|
use Index\Db\DbBackends;
|
||||||
|
|
||||||
define('SERIA_STARTUP', microtime(true));
|
define('SERIA_STARTUP', microtime(true));
|
||||||
define('SERIA_ROOT', __DIR__);
|
define('SERIA_ROOT', __DIR__);
|
||||||
|
@ -32,7 +32,7 @@ if($cfg->hasValues('sentry:dsn'))
|
||||||
});
|
});
|
||||||
})($cfg->scopeTo('sentry'));
|
})($cfg->scopeTo('sentry'));
|
||||||
|
|
||||||
$db = DbTools::create($cfg->getString('database:dsn', 'null:'));
|
$db = DbBackends::create($cfg->getString('database:dsn', 'null:'));
|
||||||
$db->execute('SET SESSION time_zone = \'+00:00\', sql_mode = \'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION\';');
|
$db->execute('SET SESSION time_zone = \'+00:00\', sql_mode = \'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION\';');
|
||||||
|
|
||||||
$seria = new SeriaContext($db, $cfg);
|
$seria = new SeriaContext($db, $cfg);
|
||||||
|
|
|
@ -1,55 +0,0 @@
|
||||||
<?php
|
|
||||||
namespace Seria\Auth;
|
|
||||||
|
|
||||||
use stdClass;
|
|
||||||
use Index\Config\Config;
|
|
||||||
|
|
||||||
final class ChatAuth {
|
|
||||||
public static function attempt(Config $config, string $cookie): object {
|
|
||||||
if(!empty($cookie)) {
|
|
||||||
$method = 'Misuzu';
|
|
||||||
$signature = sprintf('verify#%s#%s#%s', $method, $cookie, $_SERVER['REMOTE_ADDR']);
|
|
||||||
$signature = hash_hmac('sha256', $signature, $config->getString('secret'));
|
|
||||||
|
|
||||||
$login = curl_init($config->getString('endpoint'));
|
|
||||||
curl_setopt_array($login, [
|
|
||||||
CURLOPT_AUTOREFERER => false,
|
|
||||||
CURLOPT_FAILONERROR => false,
|
|
||||||
CURLOPT_FOLLOWLOCATION => true,
|
|
||||||
CURLOPT_HEADER => false,
|
|
||||||
CURLOPT_POST => true,
|
|
||||||
CURLOPT_POSTFIELDS => http_build_query([
|
|
||||||
'method' => $method,
|
|
||||||
'token' => $cookie,
|
|
||||||
'ipaddr' => $_SERVER['REMOTE_ADDR'],
|
|
||||||
], '', '&', PHP_QUERY_RFC3986),
|
|
||||||
CURLOPT_RETURNTRANSFER => true,
|
|
||||||
CURLOPT_TCP_FASTOPEN => true,
|
|
||||||
CURLOPT_CONNECTTIMEOUT => 2,
|
|
||||||
CURLOPT_MAXREDIRS => 2,
|
|
||||||
CURLOPT_PROTOCOLS => CURLPROTO_HTTPS,
|
|
||||||
CURLOPT_TIMEOUT => 5,
|
|
||||||
CURLOPT_USERAGENT => 'Seria',
|
|
||||||
CURLOPT_HTTPHEADER => [
|
|
||||||
'Content-Type: application/x-www-form-urlencoded',
|
|
||||||
'X-SharpChat-Signature: ' . $signature,
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
$userInfo = json_decode(curl_exec($login));
|
|
||||||
curl_close($login);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(empty($userInfo->success)) {
|
|
||||||
$userInfo = new stdClass;
|
|
||||||
$userInfo->success = false;
|
|
||||||
$userInfo->user_id = 0;
|
|
||||||
$userInfo->username = 'Anonymous';
|
|
||||||
$userInfo->colour_raw = 0x40000000;
|
|
||||||
$userInfo->rank = 0;
|
|
||||||
$userInfo->hierarchy = 0;
|
|
||||||
$userInfo->perms = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $userInfo;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -4,7 +4,7 @@ namespace Seria;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use Index\CsrfToken;
|
use Index\CsrfToken;
|
||||||
use Index\Config\Config;
|
use Index\Config\Config;
|
||||||
use Index\Db\DbTransactions;
|
use Index\Db\DbConnection;
|
||||||
use Index\Db\Migration\{DbMigrationManager,DbMigrationRepo,FsDbMigrationRepo};
|
use Index\Db\Migration\{DbMigrationManager,DbMigrationRepo,FsDbMigrationRepo};
|
||||||
use Index\Templating\TplEnvironment;
|
use Index\Templating\TplEnvironment;
|
||||||
use Seria\Auth\AuthInfo;
|
use Seria\Auth\AuthInfo;
|
||||||
|
@ -12,7 +12,7 @@ use Seria\Torrents\TorrentsContext;
|
||||||
use Seria\Users\UsersContext;
|
use Seria\Users\UsersContext;
|
||||||
|
|
||||||
final class SeriaContext {
|
final class SeriaContext {
|
||||||
private DbTransactions $dbConn;
|
private DbConnection $dbConn;
|
||||||
private Config $config;
|
private Config $config;
|
||||||
private ?TplEnvironment $templating = null;
|
private ?TplEnvironment $templating = null;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ final class SeriaContext {
|
||||||
private TorrentsContext $torrentsCtx;
|
private TorrentsContext $torrentsCtx;
|
||||||
private UsersContext $usersCtx;
|
private UsersContext $usersCtx;
|
||||||
|
|
||||||
public function __construct(DbTransactions $dbConn, Config $config) {
|
public function __construct(DbConnection $dbConn, Config $config) {
|
||||||
$this->dbConn = $dbConn;
|
$this->dbConn = $dbConn;
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ final class SeriaContext {
|
||||||
$this->usersCtx = new UsersContext($dbConn);
|
$this->usersCtx = new UsersContext($dbConn);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDbConn(): DbTransactions {
|
public function getDbConn(): DbConnection {
|
||||||
return $this->dbConn;
|
return $this->dbConn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ use Exception;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
use Index\Bencode\Bencode;
|
use Index\Bencode\Bencode;
|
||||||
use Index\Db\{DbTools,DbTransactions};
|
use Index\Db\DbConnection;
|
||||||
use Seria\Users\UserInfo;
|
use Seria\Users\UserInfo;
|
||||||
|
|
||||||
class TorrentBuilder {
|
class TorrentBuilder {
|
||||||
|
@ -101,12 +101,12 @@ class TorrentBuilder {
|
||||||
return hash('sha1', Bencode::encode($info), true);
|
return hash('sha1', Bencode::encode($info), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create(DbTransactions $dbConn, TorrentsContext $torrentsCtx): string {
|
public function create(DbConnection $dbConn, TorrentsContext $torrentsCtx): string {
|
||||||
$torrents = $torrentsCtx->getTorrents();
|
$torrents = $torrentsCtx->getTorrents();
|
||||||
$pieces = $torrentsCtx->getPieces();
|
$pieces = $torrentsCtx->getPieces();
|
||||||
$files = $torrentsCtx->getFiles();
|
$files = $torrentsCtx->getFiles();
|
||||||
|
|
||||||
$dbConn->beginTransaction();
|
$tx = $dbConn->beginTransaction();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$infoHash = $this->calculateInfoHash();
|
$infoHash = $this->calculateInfoHash();
|
||||||
|
@ -121,9 +121,9 @@ class TorrentBuilder {
|
||||||
foreach($this->pieces as $piece)
|
foreach($this->pieces as $piece)
|
||||||
$pieces->createPiece($torrentId, $piece);
|
$pieces->createPiece($torrentId, $piece);
|
||||||
|
|
||||||
$dbConn->commit();
|
$tx->commit();
|
||||||
} catch(Exception $ex) {
|
} catch(Exception $ex) {
|
||||||
$dbConn->rollBack();
|
$tx->rollback();
|
||||||
throw $ex;
|
throw $ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ namespace Seria\Torrents;
|
||||||
use Exception;
|
use Exception;
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
use Index\CsrfToken;
|
use Index\CsrfToken;
|
||||||
use Index\Db\DbTransactions;
|
use Index\Db\DbConnection;
|
||||||
use Index\Http\Routing\{HttpGet,HttpMiddleware,HttpPost,RouteHandler,RouteHandlerTrait};
|
use Index\Http\Routing\{HttpGet,HttpMiddleware,HttpPost,RouteHandler,RouteHandlerTrait};
|
||||||
use Index\Templating\TplEnvironment;
|
use Index\Templating\TplEnvironment;
|
||||||
use Seria\Auth\AuthInfo;
|
use Seria\Auth\AuthInfo;
|
||||||
|
@ -14,7 +14,7 @@ class TorrentCreateRouting implements RouteHandler {
|
||||||
use RouteHandlerTrait;
|
use RouteHandlerTrait;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private DbTransactions $dbConn,
|
private DbConnection $dbConn,
|
||||||
private AuthInfo $authInfo,
|
private AuthInfo $authInfo,
|
||||||
private TorrentsContext $torrentsCtx,
|
private TorrentsContext $torrentsCtx,
|
||||||
private CsrfToken $csrfp,
|
private CsrfToken $csrfp,
|
||||||
|
|
|
@ -3,9 +3,10 @@ namespace Seria\Users;
|
||||||
|
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
|
use Flashii\V1\Users\V1User;
|
||||||
use Index\XString;
|
use Index\XString;
|
||||||
use Index\Colour\Colour;
|
use Index\Colour\Colour;
|
||||||
use Index\Db\{DbConnection,DbStatementCache,DbTools};
|
use Index\Db\{DbConnection,DbStatementCache};
|
||||||
|
|
||||||
class Users {
|
class Users {
|
||||||
private DbStatementCache $cache;
|
private DbStatementCache $cache;
|
||||||
|
@ -18,21 +19,16 @@ class Users {
|
||||||
return XString::random(48);
|
return XString::random(48);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function syncChatUser(object $authInfo): void {
|
public function syncApiUser(V1User $authInfo): void {
|
||||||
if(!$authInfo->success)
|
$userColourUnfixed = $authInfo->getColourRaw() ?? 0x40000000;
|
||||||
return;
|
$stmt = $this->cache->get('INSERT INTO ser_users (user_id, user_name, user_colour, user_rank, user_permissions) VALUES (?, ?, ?, ?, 0) ON DUPLICATE KEY UPDATE user_name = ?, user_colour = ?, user_rank = ?');
|
||||||
|
$stmt->nextParameter($authInfo->getId());
|
||||||
$userColourFixed = /*($authInfo->colour_raw & 0x40000000) ? null :*/ $authInfo->colour_raw;
|
$stmt->nextParameter($authInfo->getName());
|
||||||
$stmt = $this->cache->get('INSERT INTO ser_users (user_id, user_name, user_colour, user_rank, user_permissions) VALUES (?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE user_name = ?, user_colour = ?, user_rank = ?, user_permissions = ?');
|
$stmt->nextParameter($userColourUnfixed);
|
||||||
$stmt->addParameter(1, $authInfo->user_id);
|
$stmt->nextParameter($authInfo->getRank());
|
||||||
$stmt->addParameter(2, $authInfo->username);
|
$stmt->nextParameter($authInfo->getName());
|
||||||
$stmt->addParameter(3, $userColourFixed);
|
$stmt->nextParameter($userColourUnfixed);
|
||||||
$stmt->addParameter(4, $authInfo->rank);
|
$stmt->nextParameter($authInfo->getRank());
|
||||||
$stmt->addParameter(5, $authInfo->perms);
|
|
||||||
$stmt->addParameter(6, $authInfo->username);
|
|
||||||
$stmt->addParameter(7, $userColourFixed);
|
|
||||||
$stmt->addParameter(8, $authInfo->rank);
|
|
||||||
$stmt->addParameter(9, $authInfo->perms);
|
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue