mirror of
https://github.com/claradex/nativegallery.git
synced 2024-12-22 16:41:04 +03:00
favorite photos
This commit is contained in:
parent
f1dfb96864
commit
2995940e76
8 changed files with 275 additions and 113 deletions
25
app/Controllers/Api/Images/Favorite.php
Normal file
25
app/Controllers/Api/Images/Favorite.php
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controllers\Api\Images;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
use App\Services\{Auth, Router, GenerateRandomStr, DB, Json, EXIF};
|
||||||
|
use App\Models\{User, Vote};
|
||||||
|
|
||||||
|
|
||||||
|
class Favorite
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$postId = explode('/', $_SERVER['REQUEST_URI'])[3];
|
||||||
|
if (DB::query('SELECT * FROM photos_favorite WHERE photo_id = :id AND user_id=:uid', ['id' => $postId, ':uid'=>Auth::userid()])) {
|
||||||
|
DB::query('DELETE FROM photos_favorite WHERE photo_id = :id AND user_id=:uid', ['id' => $postId, ':uid'=>Auth::userid()]);
|
||||||
|
echo 0;
|
||||||
|
} else {
|
||||||
|
DB::query('INSERT INTO photos_favorite (photo_id, user_id) VALUES (:id, :uid)', ['id' => $postId, ':uid'=>Auth::userid()]);
|
||||||
|
echo 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,6 +11,7 @@ use \App\Controllers\Api\Images\Rate as PhotoVote;
|
||||||
use \App\Controllers\Api\Images\Compress as PhotoCompress;
|
use \App\Controllers\Api\Images\Compress as PhotoCompress;
|
||||||
use \App\Controllers\Api\Images\CheckAll as PhotoCheckAll;
|
use \App\Controllers\Api\Images\CheckAll as PhotoCheckAll;
|
||||||
use \App\Controllers\Api\Images\LoadRecent as PhotoLoadRecent;
|
use \App\Controllers\Api\Images\LoadRecent as PhotoLoadRecent;
|
||||||
|
use \App\Controllers\Api\Images\Favorite as PhotoFavorite;
|
||||||
use \App\Controllers\Api\Images\Stats as PhotoStats;
|
use \App\Controllers\Api\Images\Stats as PhotoStats;
|
||||||
use \App\Controllers\Api\Images\Comments\Create as PhotoComment;
|
use \App\Controllers\Api\Images\Comments\Create as PhotoComment;
|
||||||
use \App\Controllers\Api\Images\Comments\Edit as PhotoCommentEdit;
|
use \App\Controllers\Api\Images\Comments\Edit as PhotoCommentEdit;
|
||||||
|
@ -37,6 +38,9 @@ class ApiController
|
||||||
public static function photovote() {
|
public static function photovote() {
|
||||||
return new PhotoVote();
|
return new PhotoVote();
|
||||||
}
|
}
|
||||||
|
public static function photofavorite() {
|
||||||
|
return new PhotoFavorite();
|
||||||
|
}
|
||||||
public static function photocomment() {
|
public static function photocomment() {
|
||||||
return new PhotoComment();
|
return new PhotoComment();
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,11 @@ class MainController
|
||||||
{
|
{
|
||||||
Page::set('Feed');
|
Page::set('Feed');
|
||||||
|
|
||||||
|
}
|
||||||
|
public static function fav()
|
||||||
|
{
|
||||||
|
Page::set('Fav');
|
||||||
|
|
||||||
}
|
}
|
||||||
public static function favauthors()
|
public static function favauthors()
|
||||||
{
|
{
|
||||||
|
|
|
@ -46,9 +46,12 @@ class Routes
|
||||||
|
|
||||||
Router::get('/search', 'SearchController@i');
|
Router::get('/search', 'SearchController@i');
|
||||||
|
|
||||||
|
Router::get('/fav', 'MainController@fav');
|
||||||
|
|
||||||
Router::post('/api/upload', 'ApiController@upload');
|
Router::post('/api/upload', 'ApiController@upload');
|
||||||
Router::post('/api/profile/update', 'ApiController@updateprofile');
|
Router::post('/api/profile/update', 'ApiController@updateprofile');
|
||||||
Router::post('/api/photo/comment', 'ApiController@photocomment');
|
Router::post('/api/photo/comment', 'ApiController@photocomment');
|
||||||
|
Router::get('/api/photo/$id/favorite', 'ApiController@photofavorite');
|
||||||
Router::get('/api/subscribe', 'ApiController@subscribeuser');
|
Router::get('/api/subscribe', 'ApiController@subscribeuser');
|
||||||
Router::post('/api/photo/getcomments/$id', 'ApiController@photocommentload');
|
Router::post('/api/photo/getcomments/$id', 'ApiController@photocommentload');
|
||||||
Router::get('/api/photo/vote', 'ApiController@photovote');
|
Router::get('/api/photo/vote', 'ApiController@photovote');
|
||||||
|
|
|
@ -209,11 +209,14 @@ $(document).ready(function()
|
||||||
// Избранное
|
// Избранное
|
||||||
$('#favLink').click(function()
|
$('#favLink').click(function()
|
||||||
{
|
{
|
||||||
|
const url = window.location.pathname;
|
||||||
|
const segments = url.split('/');
|
||||||
|
const id = segments[segments.length - 1];
|
||||||
var faved = parseInt($(this).attr('faved'));
|
var faved = parseInt($(this).attr('faved'));
|
||||||
$(this).html(_text[faved ? 'P_ADDFAV' : 'P_DELFAV']).attr('faved', faved ? 0 : 1);
|
$(this).html(faved ? 'Добавить фото в Избранное' : 'Удалить фото из Избранного').attr('faved', faved ? 0 : 1);
|
||||||
if (!faved && subscr_fav) $('.toggle').attr('class', 'toggle on');
|
if (!faved) $('.toggle').attr('class', 'toggle on');
|
||||||
|
|
||||||
$.get('/api.php', { action: 'fav-photo', pid : pid }, function (r) { if (r != 0 && r != 1) alert(r); }).fail(function(jx) { if (jx.responseText != '') alert(jx.responseText); });
|
$.get('/api/photo/'+id+'/favorite', function (r) { if (r != 0 && r != 1) alert(r); }).fail(function(jx) { if (jx.responseText != '') alert(jx.responseText); });
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,7 @@ if ($noncheckedimgs > 0) {
|
||||||
<li><a href="/lk/ticket.php" class="mm-item"><span class="mm-icon"><i class="fas fa-sm fa-fw fa-question-circle"></i></span><span class="mm-label">Мои заявки</span></a></li>
|
<li><a href="/lk/ticket.php" class="mm-item"><span class="mm-icon"><i class="fas fa-sm fa-fw fa-question-circle"></i></span><span class="mm-label">Мои заявки</span></a></li>
|
||||||
<li><a href="/lk/profile" class="mm-item"><span class="mm-icon"><i class="fas fa-sm fa-fw fa-cog"></i></span><span class="mm-label">Настройки профиля</span></a></li>
|
<li><a href="/lk/profile" class="mm-item"><span class="mm-icon"><i class="fas fa-sm fa-fw fa-cog"></i></span><span class="mm-label">Настройки профиля</span></a></li>
|
||||||
<li><a href="/search?id=<?=Auth::userid()?>" class="mm-item"><span class="mm-icon"><i class="far fa-sm fa-fw fa-images"></i></span><span class="mm-label">Мои фотографии</span></a></li>
|
<li><a href="/search?id=<?=Auth::userid()?>" class="mm-item"><span class="mm-icon"><i class="far fa-sm fa-fw fa-images"></i></span><span class="mm-label">Мои фотографии</span></a></li>
|
||||||
<li><a href="/fav.php" class="mm-item"><span class="mm-icon"><i class="fas fa-sm fa-fw fa-star"></i></span><span class="mm-label">Избранные снимки</span></a></li>
|
<li><a href="/fav" class="mm-item"><span class="mm-icon"><i class="fas fa-sm fa-fw fa-star"></i></span><span class="mm-label">Избранные снимки</span></a></li>
|
||||||
<li><a href="/logout" class="mm-item"><span class="mm-icon"><i class="fas fa-sm fa-fw fa-sign-out-alt"></i></span><span class="mm-label">Выход</span></a></li>
|
<li><a href="/logout" class="mm-item"><span class="mm-icon"><i class="fas fa-sm fa-fw fa-sign-out-alt"></i></span><span class="mm-label">Выход</span></a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
99
views/pages/Fav.php
Normal file
99
views/pages/Fav.php
Normal file
|
@ -0,0 +1,99 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Services\{DB, Auth, Date, Json};
|
||||||
|
use App\Models\{User, Vote, Comment, Photo};
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="ru">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<?php include($_SERVER['DOCUMENT_ROOT'] . '/views/components/LoadHead.php'); ?>
|
||||||
|
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.ix-country {
|
||||||
|
padding-top: 3px;
|
||||||
|
white-space: nowrap;
|
||||||
|
font-family: var(--narrow-font);
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ix-country>a>b {
|
||||||
|
border-bottom: dotted 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ix-cities {
|
||||||
|
padding: 5px 0 15px 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ix-arrow {
|
||||||
|
display: inline-block;
|
||||||
|
width: 9px;
|
||||||
|
height: 9px;
|
||||||
|
background: url("/img/arrow_blue.png") no-repeat;
|
||||||
|
transition: transform .1s ease-out;
|
||||||
|
position: relative;
|
||||||
|
top: -1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ix-arrow.ix-arrow-expanded {
|
||||||
|
transform: rotate(90deg);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div id="backgr"></div>
|
||||||
|
<table class="tmain">
|
||||||
|
<?php include($_SERVER['DOCUMENT_ROOT'] . '/views/components/Navbar.php'); ?>
|
||||||
|
<tr>
|
||||||
|
<td class="main">
|
||||||
|
<h1>Избранные фотографии</h1>
|
||||||
|
|
||||||
|
|
||||||
|
<?php
|
||||||
|
$photos = DB::query('SELECT * FROM photos_favorite WHERE user_id=:uid ORDER BY id DESC LIMIT 100', array(':uid'=>Auth::userid()));
|
||||||
|
foreach ($photos as $p) {
|
||||||
|
$photo = new Photo($p['photo_id']);
|
||||||
|
$user = new User($p['user_id']);
|
||||||
|
echo ' <div class="p20p" style="padding:0 5px">
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<td class="pb_photo" id="p2017137"><a href="/photo/'.$photo->i('id').'" target="_blank" class="prw"><img class="f" src="/api/photo/compress?url=' . $photo->i('photourl') . '" alt="598 КБ">
|
||||||
|
<div class="hpshade">
|
||||||
|
<div class="eye-icon">'.DB::query('SELECT COUNT(*) FROM photos_views WHERE photo_id=:id', array(':id'=>$photo->i('id')))[0]['COUNT(*)'].'</div>
|
||||||
|
</div>
|
||||||
|
</a></td>
|
||||||
|
<td class="pb_descr">
|
||||||
|
<p>'.htmlspecialchars($photo->i('postbody')).'</p>
|
||||||
|
<p><b class="pw-place">'.htmlspecialchars($photo->i('place')).'</b></p>
|
||||||
|
<p class="sm"><b>'.Date::zmdate($photo->i('posted_at')).'</b><br>Автор: <a href="/author/'.$photo->i('user_id').'/">'.$user->i('username').'</a></p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div><br>';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div id="scroll_anchor"></div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<?php include($_SERVER['DOCUMENT_ROOT'] . '/views/components/Footer.php'); ?>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
|
@ -21,13 +21,12 @@ if ($photo->i('id') !== null) {
|
||||||
} else {
|
} else {
|
||||||
$moderated = false;
|
$moderated = false;
|
||||||
}
|
}
|
||||||
} else if ($photo->i('moderated') === 1) {
|
} else if ($photo->i('moderated') === 1) {
|
||||||
$moderated = true;
|
$moderated = true;
|
||||||
if (DB::query('SELECT * FROM photos_views WHERE user_id=:uid AND photo_id=:pid ORDER BY id DESC LIMIT 1', array(':uid' => Auth::userid(), ':pid' => $id))[0]['time'] <= time() - 86400) {
|
if (DB::query('SELECT * FROM photos_views WHERE user_id=:uid AND photo_id=:pid ORDER BY id DESC LIMIT 1', array(':uid' => Auth::userid(), ':pid' => $id))[0]['time'] <= time() - 86400) {
|
||||||
DB::query('INSERT INTO photos_views VALUES (\'0\', :uid, :pid, :time)', array(':uid' => Auth::userid(), ':pid' => $id, ':time' => time()));
|
DB::query('INSERT INTO photos_views VALUES (\'0\', :uid, :pid, :time)', array(':uid' => Auth::userid(), ':pid' => $id, ':time' => time()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -43,7 +42,7 @@ if ($photo->i('id') !== null) {
|
||||||
<link rel="alternate" hreflang="x-default" href="<?= $_SERVER['REQUEST_URI'] ?>">
|
<link rel="alternate" hreflang="x-default" href="<?= $_SERVER['REQUEST_URI'] ?>">
|
||||||
<meta property="og:image" content="<?= $photo->i('photourl') ?>">
|
<meta property="og:image" content="<?= $photo->i('photourl') ?>">
|
||||||
<?php include($_SERVER['DOCUMENT_ROOT'] . '/views/components/LoadHead.php'); ?>
|
<?php include($_SERVER['DOCUMENT_ROOT'] . '/views/components/LoadHead.php'); ?>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
||||||
|
@ -85,8 +84,8 @@ if ($photo->i('id') !== null) {
|
||||||
<?php
|
<?php
|
||||||
if ($photo->i('moderated') === 0 && $moderated === true) {
|
if ($photo->i('moderated') === 0 && $moderated === true) {
|
||||||
echo '<div class="label-orange" style="padding:10px; margin:0 -20px; color:#fff">
|
echo '<div class="label-orange" style="padding:10px; margin:0 -20px; color:#fff">
|
||||||
<center><h4 style="color:#fff; margin-bottom:3px">Это '.$extname.' пока не опубликовано</h4>
|
<center><h4 style="color:#fff; margin-bottom:3px">Это ' . $extname . ' пока не опубликовано</h4>
|
||||||
<div>Сейчас '.$extnamef.' рассматривается модераторами и пока не видна другим пользователям. Это может занять определённое время, иногда до нескольких дней.<br><br>
|
<div>Сейчас ' . $extnamef . ' рассматривается модераторами и пока не видна другим пользователям. Это может занять определённое время, иногда до нескольких дней.<br><br>
|
||||||
<b>Здесь Вы можете увидеть, как будет выглядеть страница с фотографией после публикации.</b></center></div>
|
<b>Здесь Вы можете увидеть, как будет выглядеть страница с фотографией после публикации.</b></center></div>
|
||||||
</div>';
|
</div>';
|
||||||
}
|
}
|
||||||
|
@ -94,7 +93,7 @@ if ($photo->i('id') !== null) {
|
||||||
echo '<div class="label-red" style="padding:10px; margin:0 -20px; color:#fff"><center>
|
echo '<div class="label-red" style="padding:10px; margin:0 -20px; color:#fff"><center>
|
||||||
<h4 style="color:#fff; margin-bottom:3px">Фотография не принята к публикации</h4>
|
<h4 style="color:#fff; margin-bottom:3px">Фотография не принята к публикации</h4>
|
||||||
<div></div>
|
<div></div>
|
||||||
<div style="margin-top:7px">'.$photo->declineReason($photo->content('declineReason')).'</div></center>
|
<div style="margin-top:7px">' . $photo->declineReason($photo->content('declineReason')) . '</div></center>
|
||||||
</div>';
|
</div>';
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -114,12 +113,12 @@ if ($photo->i('id') !== null) {
|
||||||
<div id="ph_frame">
|
<div id="ph_frame">
|
||||||
<?php
|
<?php
|
||||||
if ($photo->content('videourl') != null) { ?>
|
if ($photo->content('videourl') != null) { ?>
|
||||||
<video controls>
|
<video controls>
|
||||||
<source src="<?=$photo->content('videourl')?>">
|
<source src="<?= $photo->content('videourl') ?>">
|
||||||
</video>
|
</video>
|
||||||
|
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
<img onerror="errimg(); this.onerror = null;" class="nozoom" id="ph" src="<?= $photo->i('photourl') ?>" alt="" title="Фотография">
|
<img onerror="errimg(); this.onerror = null;" class="nozoom" id="ph" src="<?= $photo->i('photourl') ?>" alt="" title="Фотография">
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
if ($photo->i('priority') === 1) { ?>
|
if ($photo->i('priority') === 1) { ?>
|
||||||
|
@ -168,9 +167,9 @@ if ($photo->i('id') !== null) {
|
||||||
<div style="line-height:15px; margin-bottom:10px">
|
<div style="line-height:15px; margin-bottom:10px">
|
||||||
<table class="pwrite">
|
<table class="pwrite">
|
||||||
<tr>
|
<tr>
|
||||||
<?php
|
<?php
|
||||||
if ($photo->i('postbody') != null) { ?>
|
if ($photo->i('postbody') != null) { ?>
|
||||||
<td class="nw" valign="top" align="right"><b><?= htmlspecialchars($photo->i('postbody')) ?></b></td>
|
<td class="nw" valign="top" align="right"><b><?= htmlspecialchars($photo->i('postbody')) ?></b></td>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
@ -179,8 +178,8 @@ if ($photo->i('id') !== null) {
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<?php
|
<?php
|
||||||
if ($photo->content('comment') != null) { ?>
|
if ($photo->content('comment') != null) { ?>
|
||||||
<div style="padding-top:8px"><?= htmlspecialchars($photo->content('comment')) ?></div>
|
<div style="padding-top:8px"><?= htmlspecialchars($photo->content('comment')) ?></div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</div><br>
|
</div><br>
|
||||||
<?php
|
<?php
|
||||||
|
@ -199,60 +198,76 @@ if ($photo->i('id') !== null) {
|
||||||
<div class="sm">
|
<div class="sm">
|
||||||
<div style="margin-bottom:10px">Лицензия: <b>BY-NC</b></div>
|
<div style="margin-bottom:10px">Лицензия: <b>BY-NC</b></div>
|
||||||
Опубликовано <b><?= Date::zmdate($photo->i('timeupload')) ?></b><br>
|
Опубликовано <b><?= Date::zmdate($photo->i('timeupload')) ?></b><br>
|
||||||
Просмотров — <?=DB::query('SELECT COUNT(*) FROM photos_views WHERE photo_id=:id', array(':id'=>$id))[0]['COUNT(*)']?>
|
Просмотров — <?= DB::query('SELECT COUNT(*) FROM photos_views WHERE photo_id=:id', array(':id' => $id))[0]['COUNT(*)'] ?>
|
||||||
<br><br>
|
<br><br>
|
||||||
<a href="/photoext?id=<?=$id?>">Подробная информация</a>
|
<a href="/photoext?id=<?= $id ?>">Подробная информация</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="p0" id="pp-item-tools">
|
||||||
<?php if ($photo->i('moderated') === 1) { ?>
|
<h4 class="pp-item-header">Инструменты</h4>
|
||||||
<div class="p20a" id="pp-item-vote">
|
<div class="pp-item-body" style="margin:7px 5px">
|
||||||
<h4 class="pp-item-header">Оценка</h4>
|
<div class="sm">
|
||||||
<div class="sm">
|
<?php
|
||||||
<img class="loader" pid="1361063" src="/img/loader.png">
|
if (DB::query('SELECT user_id FROM photos_favorite WHERE photo_id=:pid AND user_id=:uid', array(':uid'=>Auth::userid(), ':pid'=>$id))) {
|
||||||
<div class="rtext">Рейтинг: <b id="rating"><?= Vote::count($id) ?></b></div>
|
$fav = 1;
|
||||||
<div class="star" pid="1361063"></div>
|
$textfav = 'Удалить фото из Избранного';
|
||||||
<?php
|
} else {
|
||||||
if (Auth::userid() > 0) { ?>
|
$fav = 0;
|
||||||
<div class="vote" pid="<?= $id ?>">
|
$textfav = 'Добавить фото в Избранное';
|
||||||
<a href="#" vote="1" class="vote_btn <?php if (Vote::photo(Auth::userid(), $id) === 1) {
|
}
|
||||||
echo 'voted';
|
?>
|
||||||
} ?>"><span>Интересная фотография!</span></a>
|
<a class="tool-link" href="#" id="favLink" faved="<?=$fav?>"><?=$textfav?></a>
|
||||||
<a href="#" vote="0" class="vote_btn <?php if (Vote::photo(Auth::userid(), $id) === 0) {
|
|
||||||
echo 'voted';
|
|
||||||
} ?>"><span>Мне не нравится</span></a>
|
|
||||||
</div>
|
|
||||||
<?php } ?>
|
|
||||||
<div id="votes" class="votes">
|
|
||||||
<table class="vblock pro">
|
|
||||||
<?php
|
|
||||||
$votespos = DB::query('SELECT * FROM photos_rates WHERE photo_id=:pid AND type=1 ORDER BY id DESC', array(':pid' => $id));
|
|
||||||
foreach ($votespos as $ps) {
|
|
||||||
$uservote = new User($ps['user_id']);
|
|
||||||
echo ' <tr>
|
|
||||||
<td><a href="/author/' . $ps['user_id'] . '/">' . htmlspecialchars($uservote->i('username')) . '</a></td>
|
|
||||||
<td class="vv">+1</td>
|
|
||||||
</tr>';
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
||||||
</table>
|
|
||||||
<table class="vblock coN">
|
|
||||||
<?php
|
|
||||||
$votespos = DB::query('SELECT * FROM photos_rates WHERE photo_id=:pid AND type=0 ORDER BY id DESC', array(':pid' => $id));
|
|
||||||
foreach ($votespos as $ps) {
|
|
||||||
$uservote = new User($ps['user_id']);
|
|
||||||
echo ' <tr>
|
|
||||||
<td><a href="/author/' . $ps['user_id'] . '/">' . htmlspecialchars($uservote->i('username')) . '</a></td>
|
|
||||||
<td class="vv">-1</td>
|
|
||||||
</tr>';
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<?php if ($photo->i('moderated') === 1) { ?>
|
||||||
|
<div class="p20a" id="pp-item-vote">
|
||||||
|
<h4 class="pp-item-header">Оценка</h4>
|
||||||
|
<div class="sm">
|
||||||
|
<img class="loader" pid="1361063" src="/img/loader.png">
|
||||||
|
<div class="rtext">Рейтинг: <b id="rating"><?= Vote::count($id) ?></b></div>
|
||||||
|
<div class="star" pid="1361063"></div>
|
||||||
|
<?php
|
||||||
|
if (Auth::userid() > 0) { ?>
|
||||||
|
<div class="vote" pid="<?= $id ?>">
|
||||||
|
<a href="#" vote="1" class="vote_btn <?php if (Vote::photo(Auth::userid(), $id) === 1) {
|
||||||
|
echo 'voted';
|
||||||
|
} ?>"><span>Интересная фотография!</span></a>
|
||||||
|
<a href="#" vote="0" class="vote_btn <?php if (Vote::photo(Auth::userid(), $id) === 0) {
|
||||||
|
echo 'voted';
|
||||||
|
} ?>"><span>Мне не нравится</span></a>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
|
<div id="votes" class="votes">
|
||||||
|
<table class="vblock pro">
|
||||||
|
<?php
|
||||||
|
$votespos = DB::query('SELECT * FROM photos_rates WHERE photo_id=:pid AND type=1 ORDER BY id DESC', array(':pid' => $id));
|
||||||
|
foreach ($votespos as $ps) {
|
||||||
|
$uservote = new User($ps['user_id']);
|
||||||
|
echo ' <tr>
|
||||||
|
<td><a href="/author/' . $ps['user_id'] . '/">' . htmlspecialchars($uservote->i('username')) . '</a></td>
|
||||||
|
<td class="vv">+1</td>
|
||||||
|
</tr>';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
<table class="vblock coN">
|
||||||
|
<?php
|
||||||
|
$votespos = DB::query('SELECT * FROM photos_rates WHERE photo_id=:pid AND type=0 ORDER BY id DESC', array(':pid' => $id));
|
||||||
|
foreach ($votespos as $ps) {
|
||||||
|
$uservote = new User($ps['user_id']);
|
||||||
|
echo ' <tr>
|
||||||
|
<td><a href="/author/' . $ps['user_id'] . '/">' . htmlspecialchars($uservote->i('username')) . '</a></td>
|
||||||
|
<td class="vv">-1</td>
|
||||||
|
</tr>';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
|
|
||||||
|
@ -342,44 +357,44 @@ if ($photo->i('id') !== null) {
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
if ($photo->i('moderated') === 1) {
|
if ($photo->i('moderated') === 1) {
|
||||||
$comments = DB::query('SELECT * FROM photos_comments WHERE photo_id=:pid', array(':pid' => $id));
|
$comments = DB::query('SELECT * FROM photos_comments WHERE photo_id=:pid', array(':pid' => $id));
|
||||||
?>
|
?>
|
||||||
<div class="p0" id="pp-item-comments">
|
<div class="p0" id="pp-item-comments">
|
||||||
<h4 class="pp-item-header">Комментарии<span style="font-weight:normal"> <span style="color:#aaa">·</span> <?=count($comments)?></span></h4>
|
<h4 class="pp-item-header">Комментарии<span style="font-weight:normal"> <span style="color:#aaa">·</span> <?= count($comments) ?></span></h4>
|
||||||
<div id="posts">
|
<div id="posts">
|
||||||
<?php
|
<?php
|
||||||
$number = 1;
|
$number = 1;
|
||||||
foreach ($comments as $c) {
|
foreach ($comments as $c) {
|
||||||
$comm = new Comment($c);
|
$comm = new Comment($c);
|
||||||
|
|
||||||
if ($number % 2 == 0) {
|
|
||||||
$class = 's11';
|
|
||||||
} else {
|
|
||||||
$class = 's1';
|
|
||||||
}
|
|
||||||
$comm->class($class);
|
|
||||||
$number++;
|
|
||||||
$comm->i();
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
<div class="cmt-write s1">
|
|
||||||
<h4 class="pp-item-header">Ваш комментарий</h4>
|
|
||||||
<div style="padding:0 11px 11px">
|
|
||||||
<form action="/comment.php" method="post" id="f1">
|
|
||||||
<input type="hidden" name="sid" value="hgdl6old9r9qodmvkn1r4t7d6h">
|
|
||||||
<input type="hidden" name="last_comment_rand" value="893329610">
|
|
||||||
<input type="hidden" name="id" id="id" value="<?= $id ?>">
|
|
||||||
<input type="hidden" name="subj" id="subj" value="p">
|
|
||||||
<textarea name="wtext" id="wtext"></textarea><br>
|
|
||||||
<p id="statusSend" style="display: none;">Ошибка</p>
|
|
||||||
<div class="cmt-submit"><input type="submit" value="Добавить комментарий" id="sbmt">  Ctrl + Enter
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
if ($number % 2 == 0) {
|
||||||
|
$class = 's11';
|
||||||
|
} else {
|
||||||
|
$class = 's1';
|
||||||
|
}
|
||||||
|
$comm->class($class);
|
||||||
|
$number++;
|
||||||
|
$comm->i();
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
<div class="cmt-write s1">
|
||||||
|
<h4 class="pp-item-header">Ваш комментарий</h4>
|
||||||
|
<div style="padding:0 11px 11px">
|
||||||
|
<form action="/comment.php" method="post" id="f1">
|
||||||
|
<input type="hidden" name="sid" value="hgdl6old9r9qodmvkn1r4t7d6h">
|
||||||
|
<input type="hidden" name="last_comment_rand" value="893329610">
|
||||||
|
<input type="hidden" name="id" id="id" value="<?= $id ?>">
|
||||||
|
<input type="hidden" name="subj" id="subj" value="p">
|
||||||
|
<textarea name="wtext" id="wtext"></textarea><br>
|
||||||
|
<p id="statusSend" style="display: none;">Ошибка</p>
|
||||||
|
<div class="cmt-submit"><input type="submit" value="Добавить комментарий" id="sbmt">  Ctrl + Enter
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -412,12 +427,18 @@ if ($photo->i('id') !== null) {
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
var jsonData = JSON.parse(response);
|
var jsonData = JSON.parse(response);
|
||||||
if (jsonData.errorcode == "1") {
|
if (jsonData.errorcode == "1") {
|
||||||
$('#statusSend').css({display: 'block', color: 'red'});
|
$('#statusSend').css({
|
||||||
|
display: 'block',
|
||||||
|
color: 'red'
|
||||||
|
});
|
||||||
$('#statusSend').text('Комментарий некорректен');
|
$('#statusSend').text('Комментарий некорректен');
|
||||||
//Notify.noty('danger', 'Комментарий неккоректен');
|
//Notify.noty('danger', 'Комментарий неккоректен');
|
||||||
//$("#result").html("<div class='alert alert-dangernew container mt-5' role='alert'>Неправильная почта или пароль!</div>");
|
//$("#result").html("<div class='alert alert-dangernew container mt-5' role='alert'>Неправильная почта или пароль!</div>");
|
||||||
} else if (jsonData.errorcode == "2") {
|
} else if (jsonData.errorcode == "2") {
|
||||||
$('#statusSend').css({display: 'block', color: 'yellow'});
|
$('#statusSend').css({
|
||||||
|
display: 'block',
|
||||||
|
color: 'yellow'
|
||||||
|
});
|
||||||
$('#statusSend').text('Пожалуйста, подождите...');
|
$('#statusSend').text('Пожалуйста, подождите...');
|
||||||
//Notify.noty('warning', 'Пожалуйста, подождите...');
|
//Notify.noty('warning', 'Пожалуйста, подождите...');
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
|
@ -425,7 +446,10 @@ if ($photo->i('id') !== null) {
|
||||||
}, 1000);
|
}, 1000);
|
||||||
} else if (jsonData.errorcode == "0") {
|
} else if (jsonData.errorcode == "0") {
|
||||||
$('#wtext').val('');
|
$('#wtext').val('');
|
||||||
$('#statusSend').css({display: 'block', color: 'green'});
|
$('#statusSend').css({
|
||||||
|
display: 'block',
|
||||||
|
color: 'green'
|
||||||
|
});
|
||||||
$('#statusSend').text('Комментарий отправлен!');
|
$('#statusSend').text('Комментарий отправлен!');
|
||||||
//Notify.noty('success', 'Комментарий отправлен!');
|
//Notify.noty('success', 'Комментарий отправлен!');
|
||||||
//$("#result").html("<div class='alert alert-successnew container mt-5' role='alert'>Успешный вход!</div>");
|
//$("#result").html("<div class='alert alert-successnew container mt-5' role='alert'>Успешный вход!</div>");
|
||||||
|
@ -456,22 +480,21 @@ if ($photo->i('id') !== null) {
|
||||||
});
|
});
|
||||||
|
|
||||||
function errimg() {
|
function errimg() {
|
||||||
const content = `<center>
|
const content = `<center>
|
||||||
<div class="p20 s5" style="border:none; margin:0 -20px; display:none;">
|
<div class="p20 s5" style="border:none; margin:0 -20px; display:none;">
|
||||||
<b>Фото потеряно при крахе винчестера</b>
|
<b>Фото потеряно при крахе винчестера</b>
|
||||||
<div class="sm" style="margin-top:5px">
|
<div class="sm" style="margin-top:5px">
|
||||||
Если у вас есть это фото, пожалуйста, пришлите его на
|
Если у вас есть это фото, пожалуйста, пришлите его на
|
||||||
<a href="mailto:<?=NGALLERY['root']['adminemail']?>?subject=Для восстановления фото <?=$id?>"><?=NGALLERY['root']['adminemail']?></a>
|
<a href="mailto:<?= NGALLERY['root']['adminemail'] ?>?subject=Для восстановления фото <?= $id ?>"><?= NGALLERY['root']['adminemail'] ?></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</center>`;
|
</center>`;
|
||||||
$('#err').html(content);
|
$('#err').html(content);
|
||||||
$('#err .p20').slideDown(500);
|
$('#err .p20').slideDown(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</html>
|
</html>
|
Loading…
Reference in a new issue