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') { ?> + + + +
@@ -102,40 +94,41 @@ use \App\Models\User;
-
-
-
-
-
-
-
-
-
-
|
Принимаемые форматы: |