From be0f29454c219223bebf307a78b766becc573b2f Mon Sep 17 00:00:00 2001 From: themohooks <81331307+themohooks@users.noreply.github.com> Date: Sun, 21 Jul 2024 04:43:25 +0300 Subject: [PATCH] admin fix --- .../Api/Admin/Images/SetVisibility.php | 15 ++++- composer.json | 3 +- composer.lock | 51 ++++++++++++++++- views/pages/Admin/Index.php | 14 +++++ views/pages/Admin/Photo.php | 56 +++++++++++-------- views/pages/Photo.php | 1 + views/pages/Profile/Index.php | 7 ++- views/pages/Profile/LK/History.php | 2 +- views/pages/Profile/LK/Profile.php | 1 + views/pages/Profile/UploadPhoto.php | 2 +- 10 files changed, 122 insertions(+), 30 deletions(-) diff --git a/app/Controllers/Api/Admin/Images/SetVisibility.php b/app/Controllers/Api/Admin/Images/SetVisibility.php index f378130..9797635 100644 --- a/app/Controllers/Api/Admin/Images/SetVisibility.php +++ b/app/Controllers/Api/Admin/Images/SetVisibility.php @@ -5,14 +5,25 @@ namespace App\Controllers\Api\Admin\Images; use App\Services\{Auth, Router, GenerateRandomStr, DB, Json, EXIF}; -use App\Models\{User, Vote}; +use App\Models\{User, Vote, Photo}; class SetVisibility { public function __construct() { - DB::query('UPDATE photos SET moderated=:mod, timeupload=:time WHERE id=:id', array(':id'=>$_GET['id'], ':mod'=>$_GET['mod'], ':time'=>time())); + $photo = new Photo($_GET['id']); + $data = json_decode($photo->i('content'), true); + + if (!array_key_exists('declineReason', $data)) { + $data['declineReason'] = null; + } + $data['declineReason'] = $_GET['decline_reason']; + + $updatedJsonString = json_encode($data); + + + DB::query('UPDATE photos SET moderated=:mod, timeupload=:time, content=:c WHERE id=:id', array(':id'=>$_GET['id'], ':mod'=>$_GET['mod'], ':time'=>time(), ':c'=>$updatedJsonString)); $uid = DB::query('SELECT user_id FROM photos WHERE id=:id', array(':id'=>$_GET['id']))[0]['user_id']; if ($_GET['mod'] === 1) { $followers = DB::query('SELECT * FROM followers WHERE user_id=:uid', array(':uid'=>$uid)); diff --git a/composer.json b/composer.json index 6d39818..3042664 100644 --- a/composer.json +++ b/composer.json @@ -18,6 +18,7 @@ "tracy/tracy": "^2.10", "symfony/yaml": "^7.1", "donatj/phpuseragentparser": "^1.8", - "php-ffmpeg/php-ffmpeg": "^1.2" + "php-ffmpeg/php-ffmpeg": "^1.2", + "chriskonnertz/bbcode": "^1.1" } } diff --git a/composer.lock b/composer.lock index 6235803..606798d 100644 --- a/composer.lock +++ b/composer.lock @@ -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": "c5d02d3389b70fa0d27b042ff4d6b096", + "content-hash": "a512719e60bd14a5a6c28c6f0ea14e46", "packages": [ { "name": "aws/aws-crt-php", @@ -155,6 +155,55 @@ }, "time": "2024-07-03T18:12:51+00:00" }, + { + "name": "chriskonnertz/bbcode", + "version": "v1.1.2", + "source": { + "type": "git", + "url": "https://github.com/chriskonnertz/bbcode.git", + "reference": "d3acd447ee11265d4ef38b9058cef32adcafa245" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/chriskonnertz/bbcode/zipball/d3acd447ee11265d4ef38b9058cef32adcafa245", + "reference": "d3acd447ee11265d4ef38b9058cef32adcafa245", + "shasum": "" + }, + "require": { + "php": ">=5.3.7" + }, + "require-dev": { + "phpunit/phpunit": "~4" + }, + "type": "library", + "autoload": { + "psr-0": { + "ChrisKonnertz\\BBCode": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kai Mallea", + "email": "kmallea@gmail.com" + }, + { + "name": "Chris Konnertz" + } + ], + "description": "A naive attempt at a BBCode 'parser' written in PHP. It uses regex and thus fails at complex, nested tags.", + "keywords": [ + "bbcode" + ], + "support": { + "issues": "https://github.com/chriskonnertz/bbcode/issues", + "source": "https://github.com/chriskonnertz/bbcode/tree/master" + }, + "time": "2018-06-17T13:58:51+00:00" + }, { "name": "donatj/phpuseragentparser", "version": "v1.8.0", diff --git a/views/pages/Admin/Index.php b/views/pages/Admin/Index.php index ea5ea77..00b590a 100644 --- a/views/pages/Admin/Index.php +++ b/views/pages/Admin/Index.php @@ -12,10 +12,24 @@ if (!isset($_GET['type']) || $_GET['type'] != 'Photo') { ?> + + + +
diff --git a/views/pages/Admin/Photo.php b/views/pages/Admin/Photo.php index a67674a..ab1bfa4 100644 --- a/views/pages/Admin/Photo.php +++ b/views/pages/Admin/Photo.php @@ -35,18 +35,10 @@ use \App\Models\User; } -

Журнал

+

Журнал

-
-
Требуют рассмотрения
-
Принято
-
Принято условно
-
Принято как временное
-
Задержано до исправления замечаний
-
Не подходит для сайта
-
Удалено
-


+

@@ -67,7 +59,7 @@ use \App\Models\User; $color = 's12'; } $author = new User($p['user_id']); - echo ' + echo ' + \ No newline at end of file diff --git a/views/pages/Photo.php b/views/pages/Photo.php index daf9175..04b748f 100644 --- a/views/pages/Photo.php +++ b/views/pages/Photo.php @@ -14,6 +14,7 @@ if ($photo->i('id') !== null) { $extnamef = 'фотография'; } $photouser = new \App\Models\User($photo->i('user_id')); + $user = new \App\Models\User(Auth::userid()); if ($photo->i('moderated') === 0) { if ($photo->i('user_id') === Auth::userid() || $user->i('admin') > 0) { $moderated = true; diff --git a/views/pages/Profile/Index.php b/views/pages/Profile/Index.php index ed1de46..fee872a 100644 --- a/views/pages/Profile/Index.php +++ b/views/pages/Profile/Index.php @@ -176,7 +176,12 @@ $userprofile = new User(explode('/', $_SERVER['REQUEST_URI'])[2]); if (json_decode($userprofile->i('content'), true)['aboutmemo']['value'] != null) { ?>

О себе

-i('content'), true)['aboutmemo']['value']))?> +render(nl2br(htmlspecialchars(json_decode($userprofile->i('content'), true)['aboutmemo']['value']))); +echo $rendered; +?>
diff --git a/views/pages/Profile/LK/History.php b/views/pages/Profile/LK/History.php index 759aed5..2a69431 100644 --- a/views/pages/Profile/LK/History.php +++ b/views/pages/Profile/LK/History.php @@ -67,7 +67,7 @@ use \App\Models\{User, Photo};

'.htmlspecialchars($p['place']).'

'.Date::zmdate($p['posted_at']).'
Автор: '.htmlspecialchars($author->i('username')).'

'; if ($p['moderated'] === 2) { - echo '

Причина отклонения: '.$photo->declineReason($photo->content('declineReason')).'

'; + echo '

Причина отклонения: '.$photo->declineReason((int)$photo->content('declineReason')).'

'; } echo ' diff --git a/views/pages/Profile/LK/Profile.php b/views/pages/Profile/LK/Profile.php index c6bbf88..28bfccf 100644 --- a/views/pages/Profile/LK/Profile.php +++ b/views/pages/Profile/LK/Profile.php @@ -272,6 +272,7 @@ $user = new User(Auth::userid()); +
BBcode: [b] [i] [u] [s] [sub] [sup] [size] [img] [url]
Telegram
ВКонтакте
diff --git a/views/pages/Profile/UploadPhoto.php b/views/pages/Profile/UploadPhoto.php index bd480eb..af336c9 100644 --- a/views/pages/Profile/UploadPhoto.php +++ b/views/pages/Profile/UploadPhoto.php @@ -251,7 +251,7 @@ $user = new User(Auth::userid());
@@ -102,40 +94,41 @@ use \App\Models\User; @@ -152,4 +145,21 @@ use \App\Models\User;
 
Принимаемые форматы: