Файл: 2/3020.ru/modules/photos/plugins/comments.php
Строк: 87
<?php
IF (!ISSET($user) || $photo['PRIVATE_COMMENTS'] == 2 && $photo['USER_ID'] != $user['ID'] || $photo['PRIVATE_COMMENTS'] == 1 && DB::GET_COLUMN("SELECT COUNT(*) FROM `FRIENDS` WHERE `USER_ID` = '".$user['ID']."' AND `MY_ID` = '".$photo['USER_ID']."' AND `ACT` = '0' LIMIT 1") == 0 && $photo['USER_ID'] != $user['ID']){
ECHO "<div class='error'>".LG('Извините, для Вас комментирование недоступно')."</div>";
}ELSE{
IF (POST('ok_comm')){
DB_FILTER();
$err_data = 0;
$comment = DB::GET_STRING("SELECT `MESSAGE` FROM `PHOTOS_COMMENTS` WHERE `PHOTO_ID` = '".$photo['ID']."' AND `USER_ID` = '".$user['ID']."' ORDER BY `TIME` DESC LIMIT 1");
$message = ADSL(POST('message'));
$reply = NULL;
$reply_user_id = NULL;
IF (GET('reply')){
$reply_comment = DB::GET_STRING("SELECT `ID`,`USER_ID` FROM `PHOTOS_COMMENTS` WHERE `ID` = '".INTVAL(GET('reply'))."' AND `USER_ID` != '".$user['ID']."' LIMIT 1");
IF (ISSET($reply_comment['ID'])){
$reply = $reply_comment['ID'];
$reply_user_id = $reply_comment['USER_ID'];
}
IF ($reply_user_id != $photo['USER_ID'] && DB::GET_COLUMN("SELECT COUNT(*) FROM `NOTIFICATIONS_SETTINGS` WHERE `USER_ID` = '".$reply_user_id."' AND `PHOTOS_COMMENTS` = '1' LIMIT 1") == 1){
DB::GET_ADD("INSERT INTO `NOTIFICATIONS` (`USER_ID`, `OBJECT_ID`, `OBJECT_ID_LIST`, `TIME`, `TYPE`) VALUES ('".$reply_user_id."', '".$user['ID']."', '".$reply."', '".TIME()."', 'photos_comments2')");
}
}
IF ($message == $comment['MESSAGE']){
ERROR('Ваше сообщение повторяет предыдущее', 'session');
$err_data = 1;
}
IF (STR($message) < 1){
ERROR('Сообщение не может быть меньше 1 символа', 'session');
$err_data = 1;
}
IF (STR($message) > 3000){
ERROR('Сообщение не может быть больше 3000 символов', 'session');
$err_data = 1;
}
IF ($err_data == 1){
REDIRECT('/modules/?path=photos§ion=show&photo_id='.$photo['ID'].'');
}
$ID = DB::GET_ADD("INSERT INTO `PHOTOS_COMMENTS` (`MESSAGE`, `USER_ID`, `PHOTO_ID`, `TIME`, `REPLY`, `REPLY_USER_ID`) VALUES ('".$message."', '".$user['ID']."', '".$photo['ID']."', '".TIME()."', '".$reply."', '".$reply_user_id."')");
IF ($photo['USER_ID'] != $user['ID'] && DB::GET_COLUMN("SELECT COUNT(*) FROM `NOTIFICATIONS_SETTINGS` WHERE `USER_ID` = '".$photo['USER_ID']."' AND `PHOTOS_COMMENTS` = '1' LIMIT 1") == 1){
DB::GET_ADD("INSERT INTO `NOTIFICATIONS` (`USER_ID`, `OBJECT_ID`, `OBJECT_ID_LIST`, `TIME`, `TYPE`) VALUES ('".$photo['USER_ID']."', '".$user['ID']."', '".$photo['ID']."', '".TIME()."', 'photos_comments')");
}
DB::GET_SET("UPDATE `PHOTOS` SET `RATING` = '".($photo['RATING'] + 0.1)."' WHERE `ID` = '".$photo['ID']."' LIMIT 1");
DB::GET_SET("UPDATE `ATTACHMENTS` SET `ID_POST` = '".$ID."', `TYPE_POST` = 'photos_comments', `ACT` = '1' WHERE `USER_ID` = '".$user['ID']."' AND `ACT` = '0' AND `COMMENTS` = '1'");
//Начисление баллов
BALLS_ADD('PHOTOS_COMMENTS');
//Начисление рейтинга
RATING_ADD('PHOTOS_COMMENTS');
SUCCESS('Сообщение успешно добавлено', 'session');
REDIRECT('/modules/?path=photos§ion=show&photo_id='.$photo['ID'].'');
}
$reply = NULL;
$reply_get = NULL;
IF (GET('reply')){
$comment = DB::GET_STRING("SELECT `USER_ID`,`ID` FROM `PHOTOS_COMMENTS` WHERE `ID` = '".INTVAL(GET('reply'))."' AND `USER_ID` != '".$user['ID']."' LIMIT 1");
$us_comment = DB::GET_STRING("SELECT `LOGIN`,`ID` FROM `USERS` WHERE `ID` = '".$comment['USER_ID']."' LIMIT 1");
IF (!ISSET($comment['ID']) || !ISSET($us_comment['ID'])){
ERROR('Неизвестная ошибка', 'session');
REDIRECT('/modules/?path=photos§ion=show&photo_id='.$photo['ID'].'&page='.$page.'');
}
$reply = $us_comment['LOGIN'].", ";
$reply_get = "&reply=".$comment['ID']."";
}
HTML::COMMENT('ok_comm', '/modules/?path=photos§ion=show&photo_id='.$photo['ID'].$reply_get, $reply, 'photos');
}
$column = DB::GET_COLUMN("SELECT COUNT(`ID`) FROM `PHOTOS_COMMENTS` WHERE `PHOTO_ID` = '".$photo['ID']."'");
$spage = SPAGE($column, $page_settings);
$page = PAGE($spage);
$limit = $page_settings * $page - $page_settings;
ECHO "<div class='list-body'>";
ECHO "<div class='list-menu'>";
ECHO "<span class='icons'>".ICONS('comment', 17, 'fa-fw')."</span> <b>".LG('Комментарии')."</b> <span class='count'>".$column."</span>";
ECHO "</div>";
$data = DB::GET_STRING_ALL("SELECT * FROM `PHOTOS_COMMENTS` WHERE `PHOTO_ID` = '".$photo['ID']."' ORDER BY `TIME` DESC LIMIT ".$limit.", ".$page_settings."");
WHILE ($list = $data->FETCH()){
ECHO "<div class='list-menu'>";
ECHO "<table style='width: 100%;'><tr>";
ECHO "<td class='comments-avatar'>";
ECHO USER::AVATAR($list['USER_ID'], 50);
ECHO "</td>";
ECHO "<td class='comments-info'>";
ECHO USER::LOGIN($list['USER_ID'], 0, 1);
//Лайки для комментариев
REQUIRE (ROOT.'/modules/photos/plugins/comment_like.php');
ECHO "<br /><span class='time'>".STIME($list['TIME'])."</span>";
ECHO "</td>";
ECHO "</tr></table>";
IF ($list['REPLY'] > 0){
$comment = DB::GET_STRING("SELECT `USER_ID`,`ID`,`MESSAGE` FROM `PHOTOS_COMMENTS` WHERE `ID` = '".$list['REPLY']."' LIMIT 1");
$us_comment = DB::GET_STRING("SELECT `LOGIN`,`ID` FROM `USERS` WHERE `ID` = '".$list['REPLY_USER_ID']."' LIMIT 1");
ECHO "<div class='comments-reply'>";
ECHO "<div class='comments-reply-user'>".LG('Ответ')." <b>".$us_comment['LOGIN']."</b></div>";
IF (ISSET($comment['ID'])){
ECHO TEXT_ABSOLUTE(CROP_TEXT($comment['MESSAGE'], 0, 90));
}ELSE{
ECHO "<span class='comments-reply-no'>".LG('Комментарий удален')."</span>";
}
ECHO "</div>";
}
ECHO '<div class="comments-optimize">';
IF (STR($list['MESSAGE']) > 120){
ECHO "<div id='photo_comm".$list['ID']."' style='margin-top: 5px;'>";
ECHO TEXT(CROP_TEXT($list['MESSAGE'], 0, 120));
ECHO "</div>";
ECHO "<div id='photo_comm2".$list['ID']."' style='display: none; margin-top: 5px;'>";
ECHO TEXT($list['MESSAGE']);
ECHO "</div>";
?><a onclick="show_or_hide('photo_comm<?=$list['ID']?>', 'photo_comm2<?=$list['ID']?>', 'chevron<?=$list['ID']?>', 'opacity_message<?=$list['ID']?>')" load="none"><?
ECHO "<div id='chevron".$list['ID']."' class='chevron'><i class='fa fa-chevron-down fa-fw'></i></div>";
ECHO "</a>";
}ELSE{
ECHO TEXT($list['MESSAGE']);
}
/*
-------------------
Прикрепленные файлы
-------------------
*/
ECHO "<br />";
$f_data = DB::GET_STRING_ALL("SELECT * FROM `ATTACHMENTS` WHERE `ID_POST` = '".$list['ID']."' AND `TYPE_POST` = 'photos_comments' ORDER BY `TIME` DESC");
WHILE ($f_list = $f_data->FETCH()){
REQUIRE (ROOT.'/users/attachments/plugins/inc_files.php');
}
ECHO "</div>";
/*-----------------------*/
IF (ISSET($user)){
IF ($list['USER_ID'] != $user['ID']){
ECHO "<a href='/modules/?path=photos§ion=show&photo_id=".$photo['ID']."&page=".$page."&reply=".$list['ID']."' class='btn-o'>".ICONS('mail-forward', 12, 'fa-fw')." ".LG('Ответить')."</a>";
}
IF ($photo['USER_ID'] == $user['ID'] || MANAGEMENT == 1 || ACCESS('photos_comments_edit_and_delete', NULL, 1)){
//Редактирование комментариев
REQUIRE (ROOT.'/modules/photos/plugins/comments_edit.php');
//Удаление комментариев
REQUIRE (ROOT.'/modules/photos/plugins/comments_delete.php');
}
}
ECHO "</div>";
}
ECHO "</div>";
IF ($column == 0){
HTML::EMPTY();
}
IF ($spage > 1){ ECHO STR_PAGE('/modules/?path=photos§ion=show&photo_id='.$photo['ID'].'&', $spage, $page); }
?>