Added integration with MonsterID 🎇 (#1546)

* Added integration with MonsterID 🎇

* Updated

* Update usercp_register.tpl

* Revert "Updated"

This reverts commit b85c2b9f4d.

* Update Upload.php

* Update register.php

* Update register.php

* Update usercp_register.tpl

* Updated

* Update CHANGELOG.md
This commit is contained in:
Roman Kelesidis 2024-07-19 15:29:54 +07:00 committed by GitHub
commit 918902e7e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 455 additions and 3 deletions

View file

@ -8,6 +8,7 @@
- Release 2.4.4 🦩 ([belomaxorka](https://github.com/belomaxorka))
- CWE-502 Fixed: Deserialization of untrusted data ([belomaxorka](https://github.com/belomaxorka))
- Create tech stack docs (techstack.yml and techstack.md) [\#1521](https://github.com/torrentpier/torrentpier/pull/1521), [\#1522](https://github.com/torrentpier/torrentpier/pull/1522) ([belomaxorka](https://github.com/belomaxorka))
- Added integration with MonsterID 🎇 [\#1546](https://github.com/torrentpier/torrentpier/pull/1546) ([belomaxorka](https://github.com/belomaxorka))
- Added ability to reset ratio [\#1545](https://github.com/torrentpier/torrentpier/pull/1545) ([belomaxorka](https://github.com/belomaxorka))
- Fixed broken "Disable Board" function [\#1529](https://github.com/torrentpier/torrentpier/pull/1529) ([belomaxorka](https://github.com/belomaxorka))
- Fixed seed bonus accrual [\#1518](https://github.com/torrentpier/torrentpier/pull/1518) ([belomaxorka](https://github.com/belomaxorka))

View file

@ -38,6 +38,7 @@
"require": {
"php": "^8.1",
"arokettu/bencode": "^4.1.0",
"arokettu/monsterid": "^4.0",
"arokettu/torrent-file": "^5.2.1",
"bugsnag/bugsnag": "^v3.29.1",
"claviska/simpleimage": "^4.0",
@ -63,7 +64,10 @@
},
"config": {
"sort-packages": true,
"optimize-autoloader": true
"optimize-autoloader": true,
"allow-plugins": {
"php-http/discovery": true
}
},
"minimum-stability": "stable",
"prefer-stable": true

425
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": "0262bbf45b724f07d7e21875b5eafa44",
"content-hash": "4978862c1744c10fc0986a0ef31f0e81",
"packages": [
{
"name": "arokettu/bencode",
@ -137,6 +137,143 @@
},
"time": "2023-08-28T12:32:54+00:00"
},
{
"name": "arokettu/monsterid",
"version": "4.0.0",
"source": {
"type": "git",
"url": "https://github.com/arokettu/monsterid.git",
"reference": "f9c59ae43b8b5a3e4361b65eb240f1a62562f5e1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/arokettu/monsterid/zipball/f9c59ae43b8b5a3e4361b65eb240f1a62562f5e1",
"reference": "f9c59ae43b8b5a3e4361b65eb240f1a62562f5e1",
"shasum": ""
},
"require": {
"arokettu/is-resource": "^1.0",
"arokettu/random-polyfill": "^1.0.1",
"ext-gd": "*",
"php": "^8.0",
"php-http/discovery": "^1.19",
"psr/http-factory": "^1.0"
},
"require-dev": {
"arokettu/random-polyfill": ">= 1.0.1 < 1.99",
"httpsoft/http-message": "^1.1",
"phpunit/phpunit": ">= 7.0 < 10",
"psy/psysh": "*",
"sandfox.dev/code-standard": "^1.2023.12.09",
"squizlabs/php_codesniffer": "*",
"vimeo/psalm": "^5.4"
},
"type": "library",
"autoload": {
"files": [
"src/functions.php"
],
"psr-4": {
"Arokettu\\MonsterID\\": "src/classes"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Andreas Gohr",
"homepage": "https://www.splitbrain.org/",
"role": "developer"
},
{
"name": "Anton Smirnov",
"email": "sandfox@sandfox.me",
"homepage": "https://sandfox.me/",
"role": "maintainer"
}
],
"description": "MonsterID is a method to generate a unique monster image based upon a certain identifier (IP address, email address, whatever). It can be used to automatically provide personal avatar images in blog comments or other community services.",
"homepage": "https://sandfox.dev/php/monsterid.html",
"keywords": [
"avatar",
"monsterid"
],
"support": {
"docs": "https://monsterid.readthedocs.io/",
"issues": "https://gitlab.com/sandfox/monsterid/-/issues",
"source": "https://gitlab.com/sandfox/monsterid"
},
"time": "2024-01-03T01:03:52+00:00"
},
{
"name": "arokettu/random-polyfill",
"version": "1.0.2",
"source": {
"type": "git",
"url": "https://github.com/arokettu/php-random-polyfill.git",
"reference": "1c36416a2b507d5aa6c0a6d7f7b8aa2c539f8361"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/arokettu/php-random-polyfill/zipball/1c36416a2b507d5aa6c0a6d7f7b8aa2c539f8361",
"reference": "1c36416a2b507d5aa6c0a6d7f7b8aa2c539f8361",
"shasum": ""
},
"require": {
"arokettu/unsigned": "^1.2.1",
"php": "^7.1 | ^8.0",
"symfony/polyfill-php80": "^1.22",
"symfony/polyfill-php81": "^1.22",
"symfony/polyfill-php82": "^1.27"
},
"provide": {
"ext-random": "8.2.0"
},
"require-dev": {
"phpunit/phpunit": "^7.5 | ^8.5 | 9.5.*",
"psy/psysh": "*",
"sandfox.dev/code-standard": "^1",
"squizlabs/php_codesniffer": "*",
"vimeo/psalm": "^4.24"
},
"suggest": {
"ext-gmp": "For significantly faster calculation"
},
"type": "library",
"autoload": {
"psr-0": {
"Random\\": "src",
"Arokettu\\Random\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Anton Smirnov",
"email": "sandfox@sandfox.me",
"homepage": "https://sandfox.me/",
"role": "developer"
}
],
"description": "Random Extension Polyfill for PHP",
"homepage": "https://sandfox.dev/php/random-polyfill.html",
"keywords": [
"polyfill",
"random"
],
"support": {
"chat": "https://gitter.im/arokettu/community",
"docs": "https://php-random-polyfill.readthedocs.io/",
"issues": "https://github.com/arokettu/php-random-polyfill/issues",
"source": "https://github.com/arokettu/php-random-polyfill"
},
"time": "2023-09-07T13:01:52+00:00"
},
{
"name": "arokettu/system-clock",
"version": "2.0.0",
@ -271,6 +408,61 @@
},
"time": "2024-01-31T20:45:07+00:00"
},
{
"name": "arokettu/unsigned",
"version": "1.3.5",
"source": {
"type": "git",
"url": "https://github.com/arokettu/unsigned.git",
"reference": "559dd1247fb4bbc9d70a6ff8581d8e9fd742e096"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/arokettu/unsigned/zipball/559dd1247fb4bbc9d70a6ff8581d8e9fd742e096",
"reference": "559dd1247fb4bbc9d70a6ff8581d8e9fd742e096",
"shasum": ""
},
"require": {
"php": "^7.0 | ^8.0"
},
"require-dev": {
"phpunit/phpunit": ">= 6.5 <10",
"psy/psysh": "*",
"sandfox.dev/code-standard": "^1.2023.12.09",
"squizlabs/php_codesniffer": "*"
},
"type": "library",
"autoload": {
"files": [
"src/lib.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-2-Clause"
],
"authors": [
{
"name": "Anton Smirnov",
"email": "sandfox@sandfox.me",
"homepage": "https://sandfox.me/",
"role": "developer"
}
],
"description": "Fixed length unsigned arithmetic emulation",
"homepage": "https://sandfox.dev/php/unsigned.html",
"keywords": [
"arithmetic",
"unsigned"
],
"support": {
"chat": "https://gitter.im/arokettu/community",
"docs": "https://php-unsigned.readthedocs.io/",
"issues": "https://gitlab.com/sandfox/unsigned/-/issues",
"source": "https://gitlab.com/sandfox/unsigned"
},
"time": "2024-02-01T20:40:11+00:00"
},
{
"name": "bugsnag/bugsnag",
"version": "v3.29.1",
@ -1571,6 +1763,85 @@
},
"time": "2024-03-19T20:45:05+00:00"
},
{
"name": "php-http/discovery",
"version": "1.19.4",
"source": {
"type": "git",
"url": "https://github.com/php-http/discovery.git",
"reference": "0700efda8d7526335132360167315fdab3aeb599"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-http/discovery/zipball/0700efda8d7526335132360167315fdab3aeb599",
"reference": "0700efda8d7526335132360167315fdab3aeb599",
"shasum": ""
},
"require": {
"composer-plugin-api": "^1.0|^2.0",
"php": "^7.1 || ^8.0"
},
"conflict": {
"nyholm/psr7": "<1.0",
"zendframework/zend-diactoros": "*"
},
"provide": {
"php-http/async-client-implementation": "*",
"php-http/client-implementation": "*",
"psr/http-client-implementation": "*",
"psr/http-factory-implementation": "*",
"psr/http-message-implementation": "*"
},
"require-dev": {
"composer/composer": "^1.0.2|^2.0",
"graham-campbell/phpspec-skip-example-extension": "^5.0",
"php-http/httplug": "^1.0 || ^2.0",
"php-http/message-factory": "^1.0",
"phpspec/phpspec": "^5.1 || ^6.1 || ^7.3",
"sebastian/comparator": "^3.0.5 || ^4.0.8",
"symfony/phpunit-bridge": "^6.4.4 || ^7.0.1"
},
"type": "composer-plugin",
"extra": {
"class": "Http\\Discovery\\Composer\\Plugin",
"plugin-optional": true
},
"autoload": {
"psr-4": {
"Http\\Discovery\\": "src/"
},
"exclude-from-classmap": [
"src/Composer/Plugin.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Márk Sági-Kazár",
"email": "mark.sagikazar@gmail.com"
}
],
"description": "Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations",
"homepage": "http://php-http.org",
"keywords": [
"adapter",
"client",
"discovery",
"factory",
"http",
"message",
"psr17",
"psr7"
],
"support": {
"issues": "https://github.com/php-http/discovery/issues",
"source": "https://github.com/php-http/discovery/tree/1.19.4"
},
"time": "2024-03-29T13:00:05+00:00"
},
{
"name": "phpoption/phpoption",
"version": "1.9.2",
@ -3105,6 +3376,158 @@
],
"time": "2024-05-31T15:07:36+00:00"
},
{
"name": "symfony/polyfill-php81",
"version": "v1.30.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php81.git",
"reference": "3fb075789fb91f9ad9af537c4012d523085bd5af"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/3fb075789fb91f9ad9af537c4012d523085bd5af",
"reference": "3fb075789fb91f9ad9af537c4012d523085bd5af",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"type": "library",
"extra": {
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
}
},
"autoload": {
"files": [
"bootstrap.php"
],
"psr-4": {
"Symfony\\Polyfill\\Php81\\": ""
},
"classmap": [
"Resources/stubs"
]
},
"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": "Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"polyfill",
"portable",
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-php81/tree/v1.30.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": "2024-06-19T12:30:46+00:00"
},
{
"name": "symfony/polyfill-php82",
"version": "v1.30.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php82.git",
"reference": "77ff49780f56906788a88974867ed68bc49fae5b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php82/zipball/77ff49780f56906788a88974867ed68bc49fae5b",
"reference": "77ff49780f56906788a88974867ed68bc49fae5b",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"type": "library",
"extra": {
"thanks": {
"name": "symfony/polyfill",
"url": "https://github.com/symfony/polyfill"
}
},
"autoload": {
"files": [
"bootstrap.php"
],
"psr-4": {
"Symfony\\Polyfill\\Php82\\": ""
},
"classmap": [
"Resources/stubs"
]
},
"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": "Symfony polyfill backporting some PHP 8.2+ features to lower PHP versions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"polyfill",
"portable",
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-php82/tree/v1.30.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": "2024-06-19T12:30:46+00:00"
},
{
"name": "symfony/service-contracts",
"version": "v3.5.0",

View file

@ -375,6 +375,27 @@ foreach ($profile_fields as $field => $can_edit) {
*/
case 'avatar_ext_id':
if ($submit && !bf($pr_data['user_opt'], 'user_opt', 'dis_avatar')) {
// Integration with MonsterID
if (!isset($_POST['delete_avatar']) && isset($_POST['use_monster_avatar'])) {
$monsterAvatar = new Arokettu\MonsterID\Monster($pr_data['user_email'], $bb_cfg['avatars']['max_height']);
$tempAvatar = tmpfile();
$tempAvatarMeta = stream_get_meta_data($tempAvatar);
$monsterAvatar->writeToStream($tempAvatar);
// Manual filling $_FILES['avatar']
$_FILES['avatar'] = array();
if (!empty($tempAvatarMeta['uri']) && is_file($tempAvatarMeta['uri'])) {
$_FILES['avatar'] = [
'name' => 'MonsterID.png',
'full_path' => 'MonsterID.png',
'type' => 'image/png',
'tmp_name' => $tempAvatarMeta['uri'],
'error' => 0,
'size' => filesize($tempAvatarMeta['uri'])
];
}
}
if (isset($_POST['delete_avatar'])) {
delete_avatar($pr_data['user_id'], $pr_data['avatar_ext_id']);
$pr_data['avatar_ext_id'] = 0;
@ -382,7 +403,7 @@ foreach ($profile_fields as $field => $can_edit) {
} elseif (!empty($_FILES['avatar']['name']) && $bb_cfg['avatars']['up_allowed']) {
$upload = new TorrentPier\Legacy\Common\Upload();
if ($upload->init($bb_cfg['avatars'], $_FILES['avatar']) and $upload->store('avatar', $pr_data)) {
if ($upload->init($bb_cfg['avatars'], $_FILES['avatar'], !isset($_POST['use_monster_avatar'])) and $upload->store('avatar', $pr_data)) {
$pr_data['avatar_ext_id'] = $upload->file_ext_id;
$db_data['avatar_ext_id'] = (int)$upload->file_ext_id;
} else {

View file

@ -607,6 +607,7 @@ $lang['RETURN_PROFILE'] = 'Return to profile';
$lang['SELECT_CATEGORY'] = 'Select category';
$lang['DELETE_IMAGE'] = 'Delete image';
$lang['SET_MONSTERID_AVATAR'] = 'Set avatar from MonsterID';
$lang['CURRENT_IMAGE'] = 'Current image';
$lang['NOTIFY_ON_PRIVMSG'] = 'Notify on new private message';

View file

@ -36,6 +36,7 @@ class Upload
*/
public array $file = [
'name' => '',
'full_path' => '',
'type' => '',
'size' => 0,
'tmp_name' => '',

View file

@ -315,6 +315,7 @@
<td class="tCenter nowrap">
<p class="mrg_6">{AVATAR_IMG}</p>
<p><label><input type="checkbox" name="delete_avatar"/> {L_DELETE_IMAGE}</label></p>
<p><label><input type="checkbox" name="use_monster_avatar"/> {L_SET_MONSTERID_AVATAR}</label></p>
</td>
</tr>
</table>