admin fix

This commit is contained in:
themohooks 2024-07-21 04:43:25 +03:00
parent b7ab465486
commit be0f29454c
10 changed files with 122 additions and 30 deletions

View file

@ -5,14 +5,25 @@ namespace App\Controllers\Api\Admin\Images;
use App\Services\{Auth, Router, GenerateRandomStr, DB, Json, EXIF}; use App\Services\{Auth, Router, GenerateRandomStr, DB, Json, EXIF};
use App\Models\{User, Vote}; use App\Models\{User, Vote, Photo};
class SetVisibility class SetVisibility
{ {
public function __construct() 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']; $uid = DB::query('SELECT user_id FROM photos WHERE id=:id', array(':id'=>$_GET['id']))[0]['user_id'];
if ($_GET['mod'] === 1) { if ($_GET['mod'] === 1) {
$followers = DB::query('SELECT * FROM followers WHERE user_id=:uid', array(':uid'=>$uid)); $followers = DB::query('SELECT * FROM followers WHERE user_id=:uid', array(':uid'=>$uid));

View file

@ -18,6 +18,7 @@
"tracy/tracy": "^2.10", "tracy/tracy": "^2.10",
"symfony/yaml": "^7.1", "symfony/yaml": "^7.1",
"donatj/phpuseragentparser": "^1.8", "donatj/phpuseragentparser": "^1.8",
"php-ffmpeg/php-ffmpeg": "^1.2" "php-ffmpeg/php-ffmpeg": "^1.2",
"chriskonnertz/bbcode": "^1.1"
} }
} }

51
composer.lock generated
View file

@ -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": "c5d02d3389b70fa0d27b042ff4d6b096", "content-hash": "a512719e60bd14a5a6c28c6f0ea14e46",
"packages": [ "packages": [
{ {
"name": "aws/aws-crt-php", "name": "aws/aws-crt-php",
@ -155,6 +155,55 @@
}, },
"time": "2024-07-03T18:12:51+00:00" "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", "name": "donatj/phpuseragentparser",
"version": "v1.8.0", "version": "v1.8.0",

View file

@ -12,10 +12,24 @@ if (!isset($_GET['type']) || $_GET['type'] != 'Photo') {
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="ru"> <html lang="ru">
<script src="https://code.jquery.com/jquery-3.7.1.js"></script>
<link rel="stylesheet" href="/static/css/notie.css<?php if (NGALLERY['root']['cloudflare-caching'] === true) { echo '?'.time(); } ?>">
<script src="/static/js/notie.js<?php if (NGALLERY['root']['cloudflare-caching'] === true) { echo '?'.time(); } ?>"></script>
<script>
notie.setOptions({
transitionCurve: 'cubic-bezier(0.2, 0, 0.2, 1)'
});
var Notify = {
noty: function(status, text) {
if (status == 'danger') status = 'error';
return notie.alert({ type: status, text: text })
},
}
</script>
<body> <body>
<div class="container"> <div class="container">
<?=\App\Controllers\AdminController::loadMenu();?> <?=\App\Controllers\AdminController::loadMenu();?>

View file

@ -35,18 +35,10 @@ use \App\Models\User;
} }
</style> </style>
<td class="main"> <td class="main">
<h1>Журнал</h1> <h1><b>Журнал</b></h1>
<script src="/js/diff.js"></script> <script src="/js/diff.js"></script>
<script src="/js/pwrite-compare.js"></script> <script src="/js/pwrite-compare.js"></script>
<div class="sm"> <br clear="all"><br>
<div class="p20 s1" style="float:left; padding:1px 5px 2px; margin-right:15px">Требуют рассмотрения</div>
<div class="p20 s2" style="float:left; padding:1px 5px 2px; margin-right:15px">Принято</div>
<div class="p20 s7" style="float:left; padding:1px 5px 2px; margin-right:15px">Принято условно</div>
<div class="p20 s9" style="float:left; padding:1px 5px 2px; margin-right:15px">Принято как временное</div>
<div class="p20 s3" style="float:left; padding:1px 5px 2px; margin-right:15px">Задержано до исправления замечаний</div>
<div class="p20 s5" style="float:left; padding:1px 5px 2px; margin-right:15px">Не подходит для сайта</div>
<div class="p20 s8" style="float:left; padding:1px 5px 2px; margin-right:15px">Удалено</div>
</div><br clear="all"><br>
<div class="p20w" style="display:block"> <div class="p20w" style="display:block">
<table class="table"> <table class="table">
<tbody> <tbody>
@ -67,7 +59,7 @@ use \App\Models\User;
$color = 's12'; $color = 's12';
} }
$author = new User($p['user_id']); $author = new User($p['user_id']);
echo ' <tr class="'.$color.'"> echo ' <tr id="pht'.$p['id'].'" class="'.$color.'">
<td> <td>
<a href="/photo/'.$p['id'].'/" target="_blank" class="prw"> <a href="/photo/'.$p['id'].'/" target="_blank" class="prw">
<img src="'.$p['photourl'].'" class="f"> <img src="'.$p['photourl'].'" class="f">
@ -102,40 +94,41 @@ use \App\Models\User;
</div> </div>
<div class="modal-body"> <div class="modal-body">
<div class="form-check"> <div class="form-check">
<input class="form-check-input" type="radio" name="flexRadioDefault" id="flexRadioDefault1"> <input name="decline" value="1" class="form-check-input" type="radio" name="flexRadioDefault" id="declineReason1">
<label class="form-check-label" for="flexRadioDefault1"> <label class="form-check-label" for="declineReason1">
Малоинформативный бред Малоинформативный бред
</label> </label>
</div> </div>
<div class="form-check"> <div class="form-check">
<input class="form-check-input" type="radio" name="flexRadioDefault" id="flexRadioDefault1"> <input name="decline'.$p['id'].'" checked value="2" class="form-check-input" type="radio" name="flexRadioDefault" id="declineReason2">
<label class="form-check-label" for="flexRadioDefault1"> <label class="form-check-label" for="declineReason2">
Не подходит для сайта Не подходит для сайта
</label> </label>
</div> </div>
<div class="form-check"> <div class="form-check">
<input class="form-check-input" type="radio" name="flexRadioDefault" id="flexRadioDefault1"> <input name="decline'.$p['id'].'" value="3" class="form-check-input" type="radio" name="flexRadioDefault" id="declineReason3">
<label class="form-check-label" for="flexRadioDefault1"> <label class="form-check-label" for="declineReason3">
Порнография Порнография
</label> </label>
</div> </div>
<div class="form-check"> <div class="form-check">
<input class="form-check-input" type="radio" name="flexRadioDefault" id="flexRadioDefault1"> <input name="decline'.$p['id'].'" value="4" class="form-check-input" type="radio" name="flexRadioDefault" id="declineReason4">
<label class="form-check-label" for="flexRadioDefault1"> <label class="form-check-label" for="declineReason4">
Травля/издевательство над человеком Травля/издевательство над человеком
</label> </label>
</div> </div>
<div class="form-check"> <div class="form-check">
<input class="form-check-input" type="radio" name="flexRadioDefault" id="flexRadioDefault1"> <input name="decline'.$p['id'].'" value="5" class="form-check-input" type="radio" name="flexRadioDefault" id="declineReason5">
<label class="form-check-label" for="flexRadioDefault1"> <label class="form-check-label" for="declineReason5">
Расчленёнка Расчленёнка
</label> </label>
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Отмена</button> <a type="button" class="btn btn-secondary" data-bs-dismiss="modal">Отмена</a>'; ?>
<button type="button" class="btn btn-primary">Сохранить</button> <a href="#" onclick="photoAction(<?=$p['id']?>, document.querySelector(`input[name='decline<?=$p['id']?>']:checked`).value, 2); return false;" data-bs-dismiss="modal" class="btn btn-primary">Сохранить</a>
<?php echo '
</div> </div>
</div> </div>
</div> </div>
@ -152,4 +145,21 @@ use \App\Models\User;
</td> </td>
</tr> </tr>
<script>
function photoAction(photo_id, decline_reason, mod) {
$.ajax({
type: "GET",
url: '/api/admin/images/setvisibility?id='+photo_id+'&mod='+mod+'&decline_reason='+decline_reason,
data: $(this).serialize(),
success: function(response) {
$('#pht'+photo_id).remove();
Notify.noty('success', 'OK!');
//$("#result").html("<div class='alert alert-successnew container mt-5' role='alert'>Успешный вход!</div>");
}
});
}
</script>

View file

@ -14,6 +14,7 @@ if ($photo->i('id') !== null) {
$extnamef = 'фотография'; $extnamef = 'фотография';
} }
$photouser = new \App\Models\User($photo->i('user_id')); $photouser = new \App\Models\User($photo->i('user_id'));
$user = new \App\Models\User(Auth::userid());
if ($photo->i('moderated') === 0) { if ($photo->i('moderated') === 0) {
if ($photo->i('user_id') === Auth::userid() || $user->i('admin') > 0) { if ($photo->i('user_id') === Auth::userid() || $user->i('admin') > 0) {
$moderated = true; $moderated = true;

View file

@ -176,7 +176,12 @@ $userprofile = new User(explode('/', $_SERVER['REQUEST_URI'])[2]);
if (json_decode($userprofile->i('content'), true)['aboutmemo']['value'] != null) { ?> if (json_decode($userprofile->i('content'), true)['aboutmemo']['value'] != null) { ?>
<div class="p20"> <div class="p20">
<h4>О себе</h4> <h4>О себе</h4>
<?=nl2br(htmlspecialchars(json_decode($userprofile->i('content'), true)['aboutmemo']['value']))?> <?php
$bbcode= new ChrisKonnertz\BBCode\BBCode();
$rendered = $bbcode->render(nl2br(htmlspecialchars(json_decode($userprofile->i('content'), true)['aboutmemo']['value'])));
echo $rendered;
?>
</div> </div>
<?php } ?> <?php } ?>
</td> </td>

View file

@ -67,7 +67,7 @@ use \App\Models\{User, Photo};
<p><span style="word-spacing:-1px"><b>'.htmlspecialchars($p['place']).'</b></span></p> <p><span style="word-spacing:-1px"><b>'.htmlspecialchars($p['place']).'</b></span></p>
<p class="sm"><b>'.Date::zmdate($p['posted_at']).'</b><br>Автор: <a href="/author/'.$p['user_id'].'/">'.htmlspecialchars($author->i('username')).'</a></p>'; <p class="sm"><b>'.Date::zmdate($p['posted_at']).'</b><br>Автор: <a href="/author/'.$p['user_id'].'/">'.htmlspecialchars($author->i('username')).'</a></p>';
if ($p['moderated'] === 2) { if ($p['moderated'] === 2) {
echo '<p class="sm"><b>Причина отклонения: '.$photo->declineReason($photo->content('declineReason')).'</b></p>'; echo '<p class="sm"><b>Причина отклонения: '.$photo->declineReason((int)$photo->content('declineReason')).'</b></p>';
} }
echo ' echo '

View file

@ -272,6 +272,7 @@ $user = new User(Auth::userid());
<textarea name="aboutmemo" style="width:100%; height:200px"><?= json_decode($user->i('content'), true)['aboutmemo']['value'] ?></textarea> <textarea name="aboutmemo" style="width:100%; height:200px"><?= json_decode($user->i('content'), true)['aboutmemo']['value'] ?></textarea>
</div> </div>
<div class="sm">BBcode: [b] [i] [u] [s] [sub] [sup] [size] [img] [url]</div>
<div style="margin-bottom:3px; margin-top:5px">Telegram</div> <div style="margin-bottom:3px; margin-top:5px">Telegram</div>
<input type="text" name="abouttelegram" id="live" style="width:100%" maxlength="50" value="<?= json_decode($user->i('content'), true)['abouttelegram']['value'] ?>"> <input type="text" name="abouttelegram" id="live" style="width:100%" maxlength="50" value="<?= json_decode($user->i('content'), true)['abouttelegram']['value'] ?>">
<div style="margin-bottom:3px; margin-top:5px">ВКонтакте</div> <div style="margin-bottom:3px; margin-top:5px">ВКонтакте</div>

View file

@ -251,7 +251,7 @@ $user = new User(Auth::userid());
<td style="padding:2px 15px 5px 2px"> <td style="padding:2px 15px 5px 2px">
<label class="button"> <label class="button">
Выбрать файл... <input type="file" name="image" id="image" accept="image/*"> Выбрать файл... <input type="file" name="image" id="image" accept="image/*, video/*">
</label> </label>
&nbsp; <span id="filename"></span> &nbsp; <span id="filename"></span>
<div style="padding:5px 0 10px" class="sm">Принимаемые форматы:<br> <div style="padding:5px 0 10px" class="sm">Принимаемые форматы:<br>