Compare commits

..

4 commits

Author SHA1 Message Date
themohooks
dce7aa906a comments.php 2025-02-12 16:58:20 +03:00
themohooks
3078238206 fix place on photo 2025-02-12 16:35:08 +03:00
themohooks
69706f7df6 Update Comment.php 2025-02-12 13:00:02 +03:00
themohooks
ab9b61c3ea fix show delete & edit buttons in comments 2025-02-12 12:58:17 +03:00
7 changed files with 189 additions and 10 deletions

View file

@ -77,6 +77,11 @@ class MainController
{
Page::set('Errors/EmailVerify');
}
public static function comments()
{
Page::set('Comments/Index');
}
public static function tour()
{

View file

@ -9,7 +9,7 @@ class SearchController
{
public static function i()
{
Page::set('Search');
Page::set('Search/Index');
}

View file

@ -38,7 +38,7 @@ class Routes
Router::get('/article/$id', 'MainController@gallery');
Router::get('/voting', 'ContestsController@index');
Router::get('/voting/results', 'ContestsController@results');
Router::get('/comments', 'MainController@comments');
if (Auth::userid() > 0) {
$user = new \App\Models\User(Auth::userid());
Router::get('/lk', 'ProfileController@lk');

View file

@ -108,12 +108,19 @@ class Comment
if ($this->c['user_id'] === Auth::userid() || $photo->i('user_id') === Auth::userid()) {
echo '
<div class="dropdown">
<a style="color: #000" class="compl" href="/lk/ticket.php?action=add&amp;wid=3252565">...</a>
<div class="dropdown-content">'; ?>
<a style="margin-bottom: 10px;" href="#" onclick="createModal(<?= $this->c['id'] ?>, 'EDIT_COMMENT', '<?= htmlspecialchars($this->c['body']) ?>', 'modaledit<?= $this->c['id'] ?>'); return false;">Редактировать</a><br>
<a style="color: #000" class="compl" href="#">...</a>
<div class="dropdown-content">';
?>
<a href="#" onclick="pinComment(<?= $this->c['id'] ?>); return false;"><?=$pinc?></a><br>
<?php
if ($this->c['user_id'] === Auth::userid()) { ?>
<a style="margin-bottom: 10px;" href="#" onclick="createModal(<?= $this->c['id'] ?>, 'EDIT_COMMENT', '<?= htmlspecialchars($this->c['body']) ?>', 'modaledit<?= $this->c['id'] ?>'); return false;">Редактировать</a><br>
<a href="#" onclick="createModal(<?= $this->c['id'] ?>, 'DELETE_COMMENT', '', 'modaldel<?= $this->c['id'] ?>'); return false;">Удалить</a>
<?php
<?php }
echo '
</div>
</div>

View file

@ -51,7 +51,7 @@ if (NGALLERY['root']['registration']['emailverify'] === true && $user->i('status
</ul>
</div>
</li>
<li><a href="/comments.php" class="mm-item"><span class="mm-label">Комментарии</span></a></li>
<li><a href="/comments" class="mm-item"><span class="mm-label">Комментарии</span></a></li>
<li><a href="#" onclick="return false" class="mm-item"><span class="mm-label">Обновления</span><?=$nonrw?></a>
<div>
<ul class="mm-level-2">

View file

@ -0,0 +1,167 @@
<?php
use \App\Services\{Auth, DB, Date};
use \App\Models\{User, Photo, Vote};
?>
<!DOCTYPE html>
<html lang="ru">
<head>
<?php include($_SERVER['DOCUMENT_ROOT'] . '/views/components/LoadHead.php'); ?>
</head>
<body>
<div id="backgr"></div>
<table class="tmain">
<?php include($_SERVER['DOCUMENT_ROOT'] . '/views/components/Navbar.php'); ?>
<tr>
<td class="main">
<h1>Лента комментариев</h1>
<script src="/js/jquery-ui.js?1633005526"></script>
<script src="/js/selector.js?1730197663"></script>
<script>
$(document).ready(function() {
$('#cname').citySelector('cid', {
defaultLabel: 'Все города'
});
$('#type').val(0).change(function() {
$(this).attr('class', $('option:selected', this).attr('class'));
}).change();
$('#applyFilter').on('click', function() {
var cid = $('#cid').val();
var type = $('#type').val();
var redir = '/comments.php';
if (cid > 0 || type > 0) {
redir = redir + '?';
if (cid > 0) {
redir = redir + 'cid=' + cid;
if (type > 0) redir = redir + '&';
}
if (type > 0) redir = redir + 't=' + type;
}
window.location.href = redir;
});
});
</script>
<div id="upd_anchor"></div>
<?php
$comments = DB::query('SELECT * FROM photos_comments ORDER BY id DESC LIMIT 30');
foreach ($comments as $c) {
$user = new User($c['user_id']);
$content = json_decode($c['content'], true);
$photo = new Photo($c['photo_id']);
if ($user->i('admin') === 1) {
$admintype = ' · Администратор сервера';
} else if ($user->i('admin') === 2) {
$admintype = ' · Фотомодератор';
}
if ((int)Vote::countcommrates($c['id'], -1) >= 1) {
$commclass = 'pro';
$symb = '+';
} else if ((int)Vote::countcommrates($c['id'], -1) < 0) {
$commclass = 'con';
$symb = '';
} else if ((int)Vote::countcommrates($c['id'], -1) === 0) {
$commclass = '';
}
echo '<div class="p-comment p20p">
<div class="pc-photo"><a href="/photo/'.$c['photo_id'].'/?top=1" target="_blank" class="prw"><img src="/api/photo/compress?url='.$photo->i('photourl').'" class="f"></a></div>
<div class="pc-content">
<a class="pc-topost" href="/photo/'.$c['photo_id'].'/?top=1#' . $c['id'] . '" target="_blank">Ссылка</a>
<div class="pc-text">
<div><span class="cmt-aname">
<b><a href="/author/'.$c['user_id'].'/">'.$user->i('username').'</a></b></span> &middot; <span class="sm nw">'.Date::zmdate($c['posted_at']).'</span>
<div class="rank">Фото: '.Photo::fetchAll($c['user_id']).''.$admintype.'</div>
<div class="message-text feed">'.$c['body'].'</div>
</div>
</div>
<div class="pc-compl">
<div class="comment-votes-block">
<div class="wvote" wid="' . $c['id'] . '">
<a href="#" vote="1" class="w-btn s2"><span>+</span></a>
<div class="w-rating '.$commclass.' active">' . $symb . Vote::countcommrates($c['id'], -1) . '</div>
<div class="w-rating-ext">
<div><span class="pro">+' . Vote::countcommrates($c['id'], 1) . '</span> / <span class="con">' . Vote::countcommrates($c['id'], 0) . '</span></div>
</div>
<a href="#" vote="0" class="w-btn s5"><span></span></a>
</div>
</div>
</div>
</div>
</div>';
}
?>
<div id="scroll_anchor"></div>
<script src="/js/endless.js?031021"></script>
<script>
var ltime = 1739362440;
var last_k = 20;
var st = 20;
var cnt = -1;
var ajaxQuery = '/comments.php?ajax=1&cnt=-1';
</script>
<script>
var ftime = 1739367547;
function markAllRead(force) {
if (confirm('Вы действительно хотите отметить эти комментарии как прочитанные?')) {
var ts = force ? 0 : ltime + 1;
window.location.href = '?markread=' + ts;
}
return false;
}
var k = 20;
var new_cnt = 0;
function updateTitle() {
document.title = (new_cnt ? '(' + new_cnt + ') ' : '') + $('h1').text();
}
var updateInterval = setInterval(function() {
$.get('/comments.php?ajax=1&upd=1', {
ltime: ftime
}, function(r) {
if (!r) return;
if (r == 'logout') {
clearInterval(updateInterval);
document.location.href = '/login.php';
return;
}
if ($(window).scrollTop() > 100) {
var diff = $(document).height();
var wrapper = $('<div id="wrapper" style="display:none">' + r + '</div>').insertAfter('#upd_anchor');
$(window).scrollTop($(window).scrollTop() + wrapper.height());
wrapper.show();
wrapper.children().eq(0).unwrap();
} else $('#upd_anchor').after(r);
}, 'html');
}, 30000);
</script>
<div id="loader-anchor"></div>
</td>
</tr>
<?php include($_SERVER['DOCUMENT_ROOT'] . '/views/components/Footer.php'); ?>
</table>
</body>
</html>

View file

@ -172,8 +172,8 @@ if ($photo->i('id') !== null) {
<table class="pwrite">
<tr>
<?php
if ($photo->i('postbody') != null) { ?>
<td class="nw" valign="top" align="right"><b><?= htmlspecialchars($photo->i('postbody')) ?></b></td>
if ($photo->i('place') != null) { ?>
<td class="nw" valign="top" align="right"><b><?= htmlspecialchars($photo->i('place')) ?></b></td>
<?php } ?>
</tr>
@ -197,7 +197,7 @@ if ($photo->i('id') !== null) {
<?php } ?>
<div>
<?php
if ($photo->content('comment') != null) { ?>
if ($photo->content('comment') != null) { ?>
<div style="padding-top:8px"><?= htmlspecialchars($photo->content('comment')) ?></div>
<?php } ?>
</div><br>