2024-07-05 09:49:49 +03:00
< ? php
use App\Services\ { DB , Auth , Date , Json };
2024-07-05 11:51:14 +03:00
use App\Models\ { User , Vote , Comment };
2024-07-05 09:49:49 +03:00
2024-07-05 11:13:28 +03:00
$id = explode ( '/' , $_SERVER [ 'REQUEST_URI' ])[ 2 ];
$photo = new \App\Models\Photo ( $id );
2024-07-08 20:17:49 +03:00
if ( $photo -> i ( 'id' ) !== null ) {
$photouser = new \App\Models\User ( $photo -> i ( 'user_id' ));
2024-07-17 03:51:15 +03:00
if ( $photo -> i ( 'moderated' ) === 0 ) {
2024-07-19 00:59:51 +03:00
if ( $photo -> i ( 'user_id' ) === Auth :: userid () || $user -> i ( 'admin' ) > 0 ) {
2024-07-17 03:51:15 +03:00
$moderated = true ;
} else {
$moderated = false ;
}
2024-07-21 01:35:44 +03:00
} else if ( $photo -> i ( 'moderated' ) === 1 ) {
2024-07-17 03:51:15 +03:00
$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 ) {
DB :: query ( 'INSERT INTO photos_views VALUES (\'0\', :uid, :pid, :time)' , array ( ':uid' => Auth :: userid (), ':pid' => $id , ':time' => time ()));
}
2024-07-08 23:41:43 +03:00
}
2024-07-17 03:51:15 +03:00
2024-07-08 20:17:49 +03:00
}
2024-07-05 09:49:49 +03:00
?>
2024-07-04 12:36:23 +03:00
<! DOCTYPE html >
< html lang = " ru " >
< head >
2024-07-07 08:05:44 +03:00
< meta http - equiv = " content-type " content = " text/html;charset=UTF-8 " >
2024-07-10 13:23:05 +03:00
< meta name = " description " content = " <?= NGALLERY['root']['description'] ?> " >
< meta name = " keywords " content = " <?= NGALLERY['root']['keywords'] ?> " >
< meta property = " og:title " content = " <?= $photo->i ('title') ?> — Фото " >
< link rel = " alternate " hreflang = " x-default " href = " <?= $_SERVER['REQUEST_URI'] ?> " >
< meta property = " og:image " content = " <?= $photo->i ('photourl') ?> " >
2024-07-18 19:52:04 +03:00
< ? php include ( $_SERVER [ 'DOCUMENT_ROOT' ] . '/views/components/LoadHead.php' ); ?>
2024-07-04 12:36:23 +03:00
</ head >
< body >
< div id = " backgr " ></ div >
< table class = " tmain " >
2024-07-05 09:49:49 +03:00
< ? php include ( $_SERVER [ 'DOCUMENT_ROOT' ] . '/views/components/Navbar.php' ); ?>
2024-07-04 12:36:23 +03:00
< tr >
2024-07-10 13:23:05 +03:00
< script src = " https://unpkg.com/leaflet@1.7.1/dist/leaflet.js " ></ script >
< link rel = " stylesheet " href = " https://unpkg.com/leaflet@1.7.1/dist/leaflet.css " />
< style >
#map_canvas {
width : 600 px ! important ;
}
#photobar {
box - shadow : 0 1 px 2 px rgba ( 0 , 0 , 0 , 0.4 );
- moz - box - shadow : 0 1 px 2 px rgba ( 0 , 0 , 0 , 0.4 );
- webkit - box - shadow : 0 1 px 2 px rgba ( 0 , 0 , 0 , 0.4 );
}
#photobar {
background - color : #000;
}
#photobar {
box - shadow : 0 1 px 2 px rgba ( 0 , 0 , 0 , 0.4 );
- moz - box - shadow : 0 1 px 2 px rgba ( 0 , 0 , 0 , 0.4 );
- webkit - box - shadow : 0 1 px 2 px rgba ( 0 , 0 , 0 , 0.4 );
}
#photobar {
margin : 0 - 20 px ;
position : relative ;
background - color : #333;
}
</ style >
2024-07-04 12:36:23 +03:00
< td class = " main " >
2024-07-17 03:15:53 +03:00
< ? php
2024-07-17 03:51:15 +03:00
if ( $photo -> i ( 'moderated' ) === 0 && $moderated === true ) {
2024-07-17 03:15:53 +03:00
echo ' < div class = " label-orange " style = " padding:10px; margin:0 -20px; color:#fff " >
2024-07-17 03:58:19 +03:00
< center >< h4 style = " color:#fff; margin-bottom:3px " > Это фото пока не опубликовано </ h4 >
2024-07-17 03:15:53 +03:00
< div > Сейчас фотография рассматривается модераторами и пока не видна другим пользователям . Это может занять определённое время , иногда до нескольких дней .< br >< br >
2024-07-17 03:58:19 +03:00
< b > Здесь Вы можете увидеть , как будет выглядеть страница с фотографией после публикации .</ b ></ center ></ div >
2024-07-20 23:22:36 +03:00
</ div > ' ;
}
if ( $photo -> i ( 'moderated' ) === 2 && $moderated === true ) {
2024-07-20 23:24:50 +03:00
echo ' < div class = " label-red " style = " padding:10px; margin:0 -20px; color:#fff " >< center >
2024-07-20 23:22:36 +03:00
< h4 style = " color:#fff; margin-bottom:3px " > Фотография не принята к публикации </ h4 >
< div ></ div >
2024-07-20 23:24:50 +03:00
< div style = " margin-top:7px " > '.$photo->declineReason($photo->content(' declineReason ')).' </ div ></ center >
2024-07-17 03:15:53 +03:00
</ div > ' ;
}
?>
2024-07-12 01:02:00 +03:00
< div id = " err " ></ div >
2024-07-08 20:17:49 +03:00
< ? php
2024-07-17 03:51:15 +03:00
if ( $photo -> i ( 'id' ) !== null && $moderated === true ) {
2024-07-10 13:23:05 +03:00
?>
< center >
< div id = " photobar " >
< div id = " prev " title = " Переход по профилю Т С " >< span >& lt ; </ span ></ div >
< div id = " next " title = " Переход по профилю Т С " >< span >& gt ; </ span ></ div >
< div style = " display:inline-block " >
< div id = " underphoto_frame " >
< div id = " ph_frame " >
2024-07-21 02:59:40 +03:00
< ? php
if ( $photo -> content ( 'videourl' ) != null ) { ?>
< video controls >
< source src = " <?= $photo->content ('videourl')?> " >
</ video >
< ? php } else { ?>
2024-07-12 01:02:00 +03:00
< img onerror = " errimg(); this.onerror = null; " class = " nozoom " id = " ph " src = " <?= $photo->i ('photourl') ?> " alt = " " title = " Фотография " >
2024-07-10 13:23:05 +03:00
< ? php
2024-07-21 02:59:40 +03:00
}
2024-07-10 13:23:05 +03:00
if ( $photo -> i ( 'priority' ) === 1 ) { ?>
< div class = " underphoto s17 " style = " cursor:help " title = " Фотография не удовлетворяет действующим на момент публикации критериям качества снимков. " >< i style = " position:relative; top:1px " class = " fas fa-info-circle " ></ i >& ensp ; < b class = " dot " > Условная публикация </ b ></ div >
< ? php } else if ( $photo -> i ( 'priority' ) === 2 ) { ?>
< div class = " underphoto s19 " style = " cursor:help " title = " Изображение будет удалено с сайта через некоторое время " >< i style = " position:relative; top:1px " class = " fas fa-clock " ></ i >& ensp ; < b class = " dot " > Временная публикация </ b ></ div >
< ? php } ?>
</ div >
2024-07-04 12:36:23 +03:00
</ div >
</ div >
</ div >
2024-07-10 13:23:05 +03:00
< script >
function checkPhotoSize () {
var photo = $ ( '#ph' );
if ( ! photo . length ) return ;
var w = photo [ 0 ] . naturalWidth ;
var h = photo [ 0 ] . naturalHeight ;
var pw = photo . width ();
var ww = $ ( window ) . width ();
var wh = $ ( window ) . height ();
if ( h > w && w < ww )
photo . addClass ( 'v-zoom' );
else photo . removeClass ( 'v-zoom' );
if ( w === undefined || w == 0 || w > pw || w > ww || ( h > wh && h > w )) {
photo . removeClass ( 'nozoom' ) . off ( 'click' ) . on ( 'click' , function () {
photo . toggleClass ( 'zoomed' );
});
} else photo . addClass ( 'nozoom' ) . off ( 'click' );
}
// Масштабирование фото
$ ( '#ph' ) . on ( 'load' , checkPhotoSize );
$ ( window ) . on ( 'resize' , checkPhotoSize );
checkPhotoSize ();
</ script >
</ center >
2024-07-04 12:36:23 +03:00
</ td >
</ tr >
</ table >
< div id = " pmain " >
< div >
< div style = " line-height:15px; margin-bottom:10px " >
< table class = " pwrite " >
< tr >
2024-07-12 00:24:58 +03:00
< ? php
2024-07-17 01:37:42 +03:00
if ( $photo -> i ( 'postbody' ) != null ) { ?>
< td class = " nw " valign = " top " align = " right " >< b >< ? = htmlspecialchars ( $photo -> i ( 'postbody' )) ?> </b></td>
2024-07-12 00:24:58 +03:00
< ? php } ?>
2024-07-04 12:36:23 +03:00
</ tr >
2024-07-05 09:49:49 +03:00
2024-07-04 12:36:23 +03:00
</ table >
</ div >
</ div >
2024-07-05 09:49:49 +03:00
< div >
2024-07-12 00:24:58 +03:00
< ? php
if ( $photo -> content ( 'comment' ) != null ) { ?>
2024-07-17 01:37:42 +03:00
< div style = " padding-top:8px " >< ? = htmlspecialchars ( $photo -> content ( 'comment' )) ?> </div>
2024-07-12 00:24:58 +03:00
< ? php } ?>
2024-07-04 12:36:23 +03:00
</ div >< br >
2024-07-06 10:28:50 +03:00
< ? php
2024-07-17 05:03:01 +03:00
if ( $photo -> i ( 'posted_at' ) === 943909200 || Date :: zmdate ( $photo -> i ( 'posted_at' )) === '30 ноября 1999 в 00:00' ) {
2024-07-10 13:23:05 +03:00
$date = 'не указана' ;
} else {
$date = Date :: zmdate ( $photo -> i ( 'posted_at' ));
}
2024-07-06 10:28:50 +03:00
?>
< div > Прислал < a href = " /author/<?= $photo->i ('user_id') ?>/ " >< ? = $photouser -> i ( 'username' ) ?> </a> Дата: <b><?= $date ?></b></div>
2024-07-04 12:36:23 +03:00
< table id = " pp-items " >
< tr >
< td id = " pp-left-col " >
< div class = " p20a " id = " pp-item-info " >
< h4 > Статистика </ h4 >
< div class = " sm " >
< div style = " margin-bottom:10px " > Лицензия : < b > BY - NC </ b ></ div >
2024-07-05 11:51:14 +03:00
Опубликовано < b >< ? = Date :: zmdate ( $photo -> i ( 'timeupload' )) ?> </b><br>
2024-07-21 00:48:11 +03:00
Просмотров — < ? = DB :: query ( 'SELECT COUNT(*) FROM photos_views WHERE photo_id=:id' , array ( ':id' => $id ))[ 0 ][ 'COUNT(*)' ] ?>
< br >< br >
< a href = " /photoext?id=<?= $id ?> " > Подробная информация </ a >
2024-07-04 12:36:23 +03:00
</ div >
</ div >
2024-07-20 23:24:50 +03:00
< ? php if ( $photo -> i ( 'moderated' ) === 1 ) { ?>
2024-07-04 12:36:23 +03:00
< 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 " >
2024-07-05 11:51:14 +03:00
< div class = " rtext " > Рейтинг : < b id = " rating " >< ? = Vote :: count ( $id ) ?> </b></div>
2024-07-04 12:36:23 +03:00
< div class = " star " pid = " 1361063 " ></ div >
2024-07-10 12:44:20 +03:00
< ? php
if ( Auth :: userid () > 0 ) { ?>
2024-07-10 13:23:05 +03:00
< 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 >
2024-07-10 12:44:20 +03:00
< ? php } ?>
2024-07-04 12:36:23 +03:00
< div id = " votes " class = " votes " >
< table class = " vblock pro " >
2024-07-05 11:51:14 +03:00
< ? php
2024-07-12 01:14:28 +03:00
$votespos = DB :: query ( 'SELECT * FROM photos_rates WHERE photo_id=:pid AND type=1 ORDER BY id DESC' , array ( ':pid' => $id ));
2024-07-05 11:51:14 +03:00
foreach ( $votespos as $ps ) {
$uservote = new User ( $ps [ 'user_id' ]);
echo ' < tr >
2024-07-10 13:23:05 +03:00
< td >< a href = " /author/' . $ps['user_id'] . '/ " > ' . htmlspecialchars($uservote->i(' username ')) . ' </ a ></ td >
2024-07-05 11:13:28 +03:00
< td class = " vv " >+ 1 </ td >
</ tr > ' ;
2024-07-05 11:51:14 +03:00
}
?>
2024-07-05 11:13:28 +03:00
</ table >
< table class = " vblock coN " >
2024-07-05 11:51:14 +03:00
< ? php
$votespos = DB :: query ( 'SELECT * FROM photos_rates WHERE photo_id=:pid AND type=0' , array ( ':pid' => $id ));
foreach ( $votespos as $ps ) {
$uservote = new User ( $ps [ 'user_id' ]);
echo ' < tr >
2024-07-10 13:23:05 +03:00
< td >< a href = " /author/' . $ps['user_id'] . '/ " > ' . htmlspecialchars($uservote->i(' username ')) . ' </ a ></ td >
2024-07-05 11:13:28 +03:00
< td class = " vv " >- 1 </ td >
</ tr > ' ;
2024-07-05 11:51:14 +03:00
}
?>
2024-07-04 12:36:23 +03:00
</ table >
</ div >
</ div >
</ div >
2024-07-20 23:24:50 +03:00
< ? php } ?>
2024-07-04 12:36:23 +03:00
< div class = " p20a " id = " pp-item-link " >
< h4 style = " margin-bottom:7px " > Постоянная ссылка на фото </ h4 >
2024-07-05 11:51:14 +03:00
< input type = " text " value = " https://<?= $_SERVER['SERVER_NAME'] ?>/photo/<?= $id ?>/ " readonly = " readonly " class = " pp-link " onclick = " this.select() " >
< script src = " https://yastatic.net/share2/share.js " ></ script >
< div class = " ya-share2 " data - curtain data - size = " s " data - shape = " round " data - services = " vkontakte,odnoklassniki,telegram,twitter,whatsapp " ></ div >
2024-07-04 12:36:23 +03:00
</ div >
</ td >
2024-07-10 13:23:05 +03:00
2024-07-04 12:36:23 +03:00
< td id = " pp-main-col " >
< div id = " pp-item-vdata " >
2024-07-10 13:23:05 +03:00
< ? php
if ( $photo -> content ( 'type' ) != 'none' ) {
?>
< div class = " p0 " id = " pp-item-exif " >
< h4 class = " pp-item-header " > Параметры съёмки </ h4 >
< div class = " pp-item-body " >
< table class = " linetable " id = " exif " >
< ? php
$data = json_decode ( $photo -> i ( 'exif' ), true );
foreach ( $data as $key => $value ) {
if ( $key === 'FILE.FileDateTime' ) {
$value = Date :: zmdate ( $value );
}
if ( is_array ( $value )) {
$value = implode ( ', ' , $value ); // Convert array to a comma-separated string
}
echo '
2024-07-05 09:49:49 +03:00
< tr class = " s11 h21 " >
< td class = " ds nw " width = " 30% " > ' . htmlspecialchars($key) . ' :</ td >
< td class = " ds " > ' . htmlspecialchars($value) . ' </ td >
</ tr > ' ;
2024-07-10 13:23:05 +03:00
}
2024-07-05 09:49:49 +03:00
2024-07-10 13:23:05 +03:00
?>
2024-07-05 09:49:49 +03:00
2024-07-10 13:23:05 +03:00
</ table >
</ div >
2024-07-04 12:36:23 +03:00
</ div >
2024-07-09 00:00:18 +03:00
< ? php } ?>
2024-07-06 08:26:29 +03:00
< ? php
if ( $photo -> content ( 'lat' ) != null && $photo -> content ( 'lng' ) != null ) { ?>
2024-07-10 13:23:05 +03:00
< div class = " p0 " id = " pp-item-exif " >
< h4 class = " pp-item-header " > Место на карте </ h4 >
< div class = " pp-item-body " >
< table class = " linetable " id = " exif " >
< tr class = " upl-map " >
< div id = " map_frame " class = " s11 p20 " style = " display:inline-block; padding:3px " >
< div id = " map_canvas " ></ div >
</ div >
< script >
// Координаты выбранной точки
const selectedPoint = {
lat : < ? = $photo -> content ( 'lat' ) ?> , // Пример: Широта Москвы
lng : < ? = $photo -> content ( 'lng' ) ?> // Пример: Долгота Москвы
};
// Создание карты
const map = L . map ( 'map_canvas' ) . setView ([ selectedPoint . lat , selectedPoint . lng ], 13 );
// Добавление базового слоя карты (OpenStreetMap)
L . tileLayer ( 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png' , {
maxZoom : 19 ,
attribution : '© OpenStreetMap contributors'
}) . addTo ( map );
// Добавление маркера на выбранной точке
const marker = L . marker ([ selectedPoint . lat , selectedPoint . lng ]) . addTo ( map );
// Установка всплывающего окна на маркере
marker . bindPopup ( " <b>Выбранная точка</b> " ) . openPopup ();
</ script >
</ tr >
</ table >
</ div >
2024-07-06 08:26:29 +03:00
</ div >
< ? php } ?>
2024-07-12 00:35:52 +03:00
< ? php
2024-07-20 23:24:50 +03:00
if ( $photo -> i ( 'moderated' ) === 1 ) {
2024-07-12 00:35:52 +03:00
$comments = DB :: query ( 'SELECT * FROM photos_comments WHERE photo_id=:pid' , array ( ':pid' => $id ));
?>
2024-07-05 09:49:49 +03:00
< div class = " p0 " id = " pp-item-comments " >
2024-07-12 00:35:52 +03:00
< h4 class = " pp-item-header " > Комментарии < span style = " font-weight:normal " > < span style = " color:#aaa " >& middot ; </ span > < ? = count ( $comments ) ?> </span></h4>
2024-07-10 13:23:05 +03:00
< div id = " posts " >
< ? php
2024-07-12 00:35:52 +03:00
2024-07-10 13:23:05 +03:00
foreach ( $comments as $c ) {
$comm = new Comment ( $c );
$comm -> i ();
}
?>
</ div >
2024-07-05 09:49:49 +03:00
< div class = " cmt-write s1 " >
< h4 class = " pp-item-header " > Ваш комментарий </ h4 >
< div style = " padding:0 11px 11px " >
2024-07-05 11:51:14 +03:00
< form action = " /comment.php " method = " post " id = " f1 " >
< input type = " hidden " name = " sid " value = " hgdl6old9r9qodmvkn1r4t7d6h " >
< input type = " hidden " name = " last_comment_rand " value = " 893329610 " >
2024-07-10 13:23:05 +03:00
< input type = " hidden " name = " id " id = " id " value = " <?= $id ?> " >
2024-07-05 11:51:14 +03:00
< input type = " hidden " name = " subj " id = " subj " value = " p " >
< textarea name = " wtext " id = " wtext " ></ textarea >< br >
2024-07-20 10:45:17 +03:00
< p id = " statusSend " style = " display: none; " > Ошибка </ p >
2024-07-05 11:51:14 +03:00
< div class = " cmt-submit " >< input type = " submit " value = " Добавить комментарий " id = " sbmt " >& ensp ; & emsp ; Ctrl + Enter
</ div >
</ form >
2024-07-05 09:49:49 +03:00
</ div >
2024-07-10 13:23:05 +03:00
2024-07-04 12:36:23 +03:00
</ div >
</ div >
2024-07-19 01:01:03 +03:00
< ? php } ?>
2024-07-04 12:36:23 +03:00
</ td >
2024-07-10 13:23:05 +03:00
</ tr >
</ tbody >
2024-07-04 12:36:23 +03:00
</ table >
2024-07-10 13:23:05 +03:00
< ? php } else { ?>
< center >
< h1 > Изображение не найдено </ h1 >
< div class = " p20w " style = " margin-bottom:20px; padding:10px 30px " >
< img src = " /static/img/pnp.jpg " alt = " Пусто " width = " 400 " height = " 205 " border = " 0 " >
< p > Изображения с таким номером нет на сайте .< br /> Может быть , е г о здесь никогда и не было .< br /> Если Вы уверены , что что - то здесь всё - таки было , значит , администратор по каким - то причинам это удалил .</ p >
</ div >
</ center >
< ? php } ?>
< table width = " 100% " style = " margin-top: 30px; " >
< tbody >
< tr >
< ? php include ( $_SERVER [ 'DOCUMENT_ROOT' ] . '/views/components/Footer.php' ); ?>
</ tr >
</ tbody >
</ table >
< script >
$ ( document ) . ready ( function () {
$ ( '#f1' ) . submit ( function ( e ) {
e . preventDefault ();
$ . ajax ({
type : " POST " ,
url : '/api/photo/comment' ,
data : $ ( this ) . serialize (),
success : function ( response ) {
var jsonData = JSON . parse ( response );
if ( jsonData . errorcode == " 1 " ) {
2024-07-20 10:45:17 +03:00
$ ( '#statusSend' ) . css ({ display : 'block' , color : 'red' });
$ ( '#statusSend' ) . text ( 'Комментарий некорректен' );
//Notify.noty('danger', 'Комментарий неккоректен');
2024-07-10 13:23:05 +03:00
//$("#result").html("<div class='alert alert-dangernew container mt-5' role='alert'>Неправильная почта или пароль!</div>");
} else if ( jsonData . errorcode == " 2 " ) {
2024-07-20 10:45:17 +03:00
$ ( '#statusSend' ) . css ({ display : 'block' , color : 'yellow' });
$ ( '#statusSend' ) . text ( 'Пожалуйста, подождите...' );
//Notify.noty('warning', 'Пожалуйста, подождите...');
2024-07-10 13:23:05 +03:00
setTimeout ( function () {
window . location . replace ( jsonData . twofaurl );
}, 1000 );
} else if ( jsonData . errorcode == " 0 " ) {
$ ( '#wtext' ) . val ( '' );
2024-07-20 10:45:17 +03:00
$ ( '#statusSend' ) . css ({ display : 'block' , color : 'green' });
$ ( '#statusSend' ) . text ( 'Комментарий отправлен!' );
//Notify.noty('success', 'Комментарий отправлен!');
2024-07-10 13:23:05 +03:00
//$("#result").html("<div class='alert alert-successnew container mt-5' role='alert'>Успешный вход!</div>");
$ . ajax ({
type : " POST " ,
url : " /api/photo/getcomments/<?= $id ?> " ,
processData : false ,
async : true ,
success : function ( r ) {
$ ( '#posts' ) . html ( r )
},
error : function ( r ) {
console . log ( r )
}
});
} else {
Notify . noty ( 'danger' , 'Неизвестная ошибка' );
2024-07-05 11:51:14 +03:00
}
2024-07-04 12:36:23 +03:00
}
2024-07-10 13:23:05 +03:00
});
2024-07-05 11:51:14 +03:00
});
});
2024-07-04 12:36:23 +03:00
</ script >
2024-07-05 11:51:14 +03:00
</ div >
2024-07-04 12:36:23 +03:00
</ html >