0 ? true : false;
/* js stuff */
$ht_js = 'var comm_sec = "' . VHref::getKey("watch") . '";';
$ht_js .= 'var comm_url = "' . $cfg['main_url'] . '/"+comm_sec+"?' . $type[0] . '=' . $f_key . '"; var m_loading = "";';
/* remove response button on shorts */
$ht_js .= '$(document).ready(function(){
if($("#wrapper").hasClass("tpl_shorts")){
var aspectRatio=9/16;
var h=$("body").height()-100;
var th=$("body").hasClass("dark")?"scroll-dark":"scroll-light";
var sh=!$("#view-player").hasClass("bottom-comments")?$(".video-js").height():360;
var ct=sh - ($("#comment-load .file-views-nr").height() + $("#comment-load #comm-post-response").height() + $("#comment-load #comm-post-form").height() + 20);
var tw=$(window).outerWidth();
var w;if(h<=560){h=560;w=315}else{w=h*aspectRatio;}
var odw = tw >= 1320 ? 360 : $(".video-js").width()-20;
odw = odw <= 748 ? (w <= 576 ? 210 : w) : odw;
var odp = tw <= 1320 ? "50%" : "15%";
// alert(ct);
$(".posted-comments").addClass("scroll " + th).css("height", ct);
// $(".posted-comments").addClass("scroll " + th).css("height", h-143);
$(".post-response-button").detach();
$(".comm-cancel-action").css("margin-right", "10px");
$(".posted-comments").on("mouseenter",function(e){
//$(this).addClass("scroll " + th).css("overflow-y", "scroll");
$(this).addClass("scroll " + th);
}).on("mouseleave",function(e){
//$(this).removeClass("scroll").removeClass(th).css("overflow-y", "hidden");
//$(this).removeClass("scroll").removeClass(th);
});
$(".comments-close i").on("click",function(e){
var ww=$(".video-js").width();
$(".overlay-buttons").removeAttr("style");
$(".overlay-data").css("width", odw);
$(".overlay-data").removeAttr("style").css("width", odw);
$(".overlay-comments").hide();
$("#view-player").removeClass("with-comments");
});
$("#main-comments-actions .comm-cancel-action").on("click",function(e){
// $(".posted-comments").css("height", h-143);
var sh=!$("#view-player").hasClass("bottom-comments")?$(".video-js").height():360;
var ct=sh - ($("#comment-load .file-views-nr").height() + $("#comment-load #comm-post-response").height() + $("#comment-load #comm-post-form").height() + 20);
$(".posted-comments").css("height", ct);
});
}
});
';
/* pagination links */
$page_nr = (int) $_GET['page'] > 1 ? (int) $_GET['page'] : 1;
/* mouse over comments */
$ht_js .= '$(document).on({mouseover: function(e){var c_key = $(this).find(".comm-actions-hkey:first").text();if(typeof $(".ce-"+c_key).html()!=="undefined"){$(this).find("#comm-actions2-over"+c_key).addClass("no-display");return}$(this).find("#comm-actions2-over"+c_key).removeClass("no-display"); $(this).addClass("comment-bg-on");}},".comment_h");';
$ht_js .= '$(document).on({mouseout: function(e){var c_key = $(this).find(".comm-actions-hkey:first").text();if(typeof $(".ce-"+c_key).html()!=="undefined"){$(this).find("#comm-actions2-over"+c_key).addClass("no-display");return}$(this).find("#comm-actions2-over"+c_key).addClass("no-display");$(this).removeClass("comment-bg-on");}},".comment_h");';
//done
/* click to sort comments */
$ht_js .= '$(".sort-comments").click(function(e){';
$ht_js .= 'e.preventDefault();var t=$(this);var v=t.attr("href").replace("#", "");$("#comm-sort").val(v);var frm=$("#comm-post-form").serialize();';
$ht_js .= '$("#comment-load").mask("");';
$ht_js .= '$.post(comm_url+"&do=comm-sort", frm, function(data){';
$ht_js .= '$("#comment-load").html(data);'; // $(".comm-input-action").val("");';
$ht_js .= 'if(v=="top-comments"){$(".response_holder .c-pinned").each(function(){c=$(this).parent().parent().parent().clone(true);c.insertAfter($(".comments_activity:first")).removeClass("response");});}'; //////////////////////
$ht_js .= '$("#comment-load").unmask();';
$ht_js .= '});';
$ht_js .= '});';
/* if logged in */
if ($islogged) {
$ht_js .= '$(".comm-cancel-action").click(function(){$(this).closest("form").find("textarea").attr("style", "height:auto");$(".comm-switch2").addClass("comm-hide");$("#comm-char-remaining").html("' . $cfg['file_comment_max_length'] . '");});';
/* update comment limit */
//$ht_js .= '$(".comm-input-action").keyup(function(){var rem = ' . $cfg['file_comment_max_length'] . '-$(this).val().length; $("#comm-char-remaining").html(rem > 0 ? rem : 0); if(rem < 1){$("#comm-char-remaining").parent().addClass("err-red");}else{$("#comm-char-remaining").parent().removeClass("err-red");}});';
//$ht_js .= '$(document).on("keyup", ".comm-reply-action", function (){var rid = $(this).attr("id").substr(2); var rem = ' . $cfg['file_comment_max_length'] . '-$(this).val().length; $("#comm-char-remaining"+rid).html(rem > 0 ? rem : 0); if(rem < 1){$("#comm-char-remaining"+rid).parent().addClass("err-red");}else{$("#comm-char-remaining"+rid).parent().removeClass("err-red");}});';
/* click to post comment */
$ht_js .= '$(".post-comment-button").click(function(){';
$ht_js .= 'if($(".comm-input-action").val() != ""){';
$ht_js .= 'var t = $(this); t.find("i").addClass("spinner icon-spinner");';
$ht_js .= '$.post(comm_url+"&do=comm-post", $("#comm-post-form").serialize(), function(data){';
$ht_js .= '$("#comment-load").html(data);$(".comm-input-action").val(""); t.find("i").removeClass("spinner icon-spinner");';
// $ht_js .= 'var ct=$(".video-js").height() - ($("#comment-load .file-views-nr").height() + $("#comment-load #comm-post-response").outerHeight() + $("#comment-load #comm-post-form").height() + 20);setTimeout(() => {$(".posted-comments-OFFFFFF").css("height", ct-13);}, "100");';
$ht_js .= '});}});';
$ht_js .= 'var pag="&page=' . $page_nr . '";';
/* click on comment actions menu */
$ht_js .= '$(".single-comm-action").click(function(){if($(this).next().next().hasClass("no-display")){$(this).addClass("topnav-button-active");$(this).next().next().removeClass("no-display");}else{$(this).removeClass("topnav-button-active");$(this).next().next().addClass("no-display");}});';
/* reply to comm */
$ht_js .= '$(document).on({click: function(e){';
$ht_js .= 'var f1 = $(this).parent().next().text();';
$ht_js .= 'var ct = "' . $cfg['file_comment_max_length'] . '";
var ht = \'
\';';
$ht_js .= 'if(!$(".cr-"+f1).html()){$(ht).insertAfter($(this).parent().parent().parent().next())} $("#c-menu"+f1+".single-comm-action").click();';
$ht_js .= '
const textarea = document.getElementById("r-"+f1);
textarea.addEventListener("focus", () => {
const currentValue = textarea.value;
textarea.value = "";
textarea.value = currentValue;
textarea.selectionStart = textarea.selectionEnd = textarea.value.length;
});
textarea.addEventListener("input", () => {
textarea.style.height = "auto";
textarea.style.height = (textarea.scrollHeight+1) + "px";
});
textarea.focus();
';
/* reply emoji */
if ($cfg['comment_emoji'] == 1) {
$ht_js .= '
const pickerOptions = {
theme: $("body").hasClass("dark") ? "dark" : "light", emojiButtonSize:30, emojiSize:20, perLine:12, skinTonePosition:"search", previewPosition:"none", autoFocus:true, dynamicWidth: true, onEmojiSelect: function(emoji){
const textarea = document.getElementById("r-"+f1)
const cursorPosition = textarea.selectionEnd
const start = textarea.value.substring(0, textarea.selectionStart)
const end = textarea.value.substring(textarea.selectionStart)
const text = start + emoji.native + end
textarea.value = text
textarea.focus()
textarea.selectionEnd = cursorPosition + emoji.native.length
}
}
const picker = new EmojiMart.Picker(pickerOptions);
$("#comment-emotes"+f1).append(picker);
if(window.innerWidth<500){
$("#comment-emotes"+f1+" em-emoji-picker").css("min-width", window.innerWidth-20).css("left", (window.innerWidth-(window.innerWidth+21)));
$(".posted-comments > .comments_activity > .response_holder #comment-emotes"+f1+" em-emoji-picker").css("min-width", window.innerWidth-20).css("left", (window.innerWidth-(window.innerWidth+21)));
} else {
$("#comment-emotes"+f1+" em-emoji-picker").css("left", "39px");
$(".posted-comments > .comments_activity > .response_holder#comment-emotes"+f1+" em-emoji-picker").css("left", "39px");
}
window.addEventListener("resize",function(){
if(window.innerWidth<500){
$("#comment-emotes"+f1+" em-emoji-picker").css("min-width", window.innerWidth-20).css("left", (window.innerWidth-(window.innerWidth+21)));
$(".posted-comments > .comments_activity > .response_holder #comment-emotes"+f1+" em-emoji-picker").css("min-width", window.innerWidth-20).css("left", (window.innerWidth-(window.innerWidth+21)));
} else {
$("#comment-emotes"+f1+" em-emoji-picker").css("left", "39px");
$(".posted-comments > .comments_activity > .response_holder#comment-emotes"+f1+" em-emoji-picker").css("left", "39px");
}
});
$(document).on({click: function(e){
var $div = $("#comment-emotes"+f1+" em-emoji-picker");var $targetElement = $(e.target);var excludedDivIds = ["comment-emotes"+f1]; var excludedTextareaId = "r-"+f1;
var isClickInsideDiv = $div.find($targetElement).length > 0;
var isExcludedDiv = excludedDivIds.some(function(excludedId) {return $("#" + excludedId).find($targetElement).length > 0;});
var isExcludedTextarea = $targetElement.is("#" + excludedTextareaId);
if (!isClickInsideDiv && !isExcludedDiv && !isExcludedTextarea){$("#comment-emotes"+f1+" em-emoji-picker").css("display", "none");$("#comment-emotes"+f1+" i").removeClass("icon-smiley2").addClass("icon-smiley")}
}});
';
}
$ht_js .= '}},".comm-reply");'; //recheck
/* edit comm */
$ht_js .= '$(document).on({click: function(e){';
$ht_js .= 'var f1 = $(this).parent().parent().next().text();';
$ht_js .= 'var ct = "' . $cfg['file_comment_max_length'] . '";
var ht = \'\';';
$ht_js .= 'if(!$(".ce-"+f1).html()){$(".cr-"+f1).replaceWith("");$(".comm-own"+f1+", #' . $type . '-comment"+f1+" .comm-body, #comm-actions-main"+f1+", #comm-actions2-over"+f1+", .comment-rating"+f1).hide();$(ht).insertAfter("#comm-actions2-over"+f1);} $("#c-menu"+f1+".single-comm-action").click();';
$ht_js .= '
const textarea = document.getElementById("e-"+f1);
textarea.addEventListener("focus", () => {
const currentValue = textarea.value;
textarea.value = "";
textarea.value = currentValue;
textarea.selectionStart = textarea.selectionEnd = textarea.value.length;
});
textarea.addEventListener("input", () => {
textarea.style.height = "auto";
textarea.style.height = (textarea.scrollHeight+1) + "px";
});
textarea.focus();
';
/* reply emoji */
if ($cfg['comment_emoji'] == 1) {
$ht_js .= '
const pickerOptions = {
theme: $("body").hasClass("dark") ? "dark" : "light", emojiButtonSize:30, emojiSize:20, perLine:12, skinTonePosition:"search", previewPosition:"none", autoFocus:true, dynamicWidth: true, onEmojiSelect: function(emoji){
const textarea = document.getElementById("e-"+f1)
const cursorPosition = textarea.selectionEnd
const start = textarea.value.substring(0, textarea.selectionStart)
const end = textarea.value.substring(textarea.selectionStart)
const text = start + emoji.native + end
textarea.value = text
textarea.focus()
textarea.selectionEnd = cursorPosition + emoji.native.length
}
}
const picker = new EmojiMart.Picker(pickerOptions);
$("#ecomment-emotes"+f1).append(picker);
if(window.innerWidth<500){
$("#ecomment-emotes"+f1+" em-emoji-picker").css("min-width", window.innerWidth-20).css("left", (window.innerWidth-(window.innerWidth+21)));
$(".posted-comments > .comments_activity > .response_holder #ecomment-emotes"+f1+" em-emoji-picker").css("min-width", window.innerWidth-20).css("left", (window.innerWidth-(window.innerWidth+21)));
} else {
$("#ecomment-emotes"+f1+" em-emoji-picker").css("left", "39px");
$(".posted-comments > .comments_activity > .response_holder#ecomment-emotes"+f1+" em-emoji-picker").css("left", "39px");
}
window.addEventListener("resize",function(){
if(window.innerWidth<500){
$("#ecomment-emotes"+f1+" em-emoji-picker").css("min-width", window.innerWidth-20).css("left", (window.innerWidth-(window.innerWidth+21)));
$(".posted-comments > .comments_activity > .response_holder #ecomment-emotes"+f1+" em-emoji-picker").css("min-width", window.innerWidth-20).css("left", (window.innerWidth-(window.innerWidth+21)));
} else {
$("#ecomment-emotes"+f1+" em-emoji-picker").css("left", "39px");
$(".posted-comments > .comments_activity > .response_holder#ecomment-emotes"+f1+" em-emoji-picker").css("left", "39px");
}
});
$(document).on({click: function(e){
var $div = $("#ecomment-emotes"+f1+" em-emoji-picker");var $targetElement = $(e.target);var excludedDivIds = ["ecomment-emotes"+f1]; var excludedTextareaId = "e-"+f1;
var isClickInsideDiv = $div.find($targetElement).length > 0;
var isExcludedDiv = excludedDivIds.some(function(excludedId) {return $("#" + excludedId).find($targetElement).length > 0;});
var isExcludedTextarea = $targetElement.is("#" + excludedTextareaId);
if (!isClickInsideDiv && !isExcludedDiv && !isExcludedTextarea){$("#ecomment-emotes"+f1+" em-emoji-picker").css("display", "none");$("#ecomment-emotes"+f1+" i").removeClass("icon-smiley2").addClass("icon-smiley")}
}});
';
}
$ht_js .= '
textarea.style.height = "auto";
textarea.style.height = (textarea.scrollHeight+1) + "px";
const currentValue = textarea.value;
textarea.value = "";
textarea.value = currentValue;
textarea.selectionStart = textarea.selectionEnd = textarea.value.length;
textarea.focus();
';
$ht_js .= '}},".comm-edit");'; //recheck
/* click outside of emoji picker */
$ht_js .= '$(document).on({click: function(e){';
$ht_js .= 'var $div = $("#ntm em-emoji-picker");var $targetElement = $(e.target);var excludedDivIds = ["comment-emotes","main-comments-actions"]; var excludedTextareaId = "textarea-content";';
$ht_js .= 'var isClickInsideDiv = $div.find($targetElement).length > 0;';
$ht_js .= 'var isExcludedDiv = excludedDivIds.some(function(excludedId) {return $("#" + excludedId).find($targetElement).length > 0;});';
$ht_js .= 'var isExcludedTextarea = $targetElement.is("#" + excludedTextareaId);';
$ht_js .= 'if (!isClickInsideDiv && !isExcludedDiv && !isExcludedTextarea){if(!$("#ntm em-emoji-picker").is(":hidden")){$("#ntm em-emoji-picker").css("display", "none");$("#comment-emotes i").removeClass("icon-smiley2").addClass("icon-smiley")}}';
$ht_js .= '}});'; //done
/* changing emoji picker theme light/dark */
$ht_js .= '$(document).on({click: function(e){';
$ht_js .= 'if(!$("body").hasClass("dark")){
setTimeout(function(){
$("em-emoji-picker").each(function(){
const emojiPicker = this;//document.querySelector("em-emoji-picker");
const shadowRoot = emojiPicker.shadowRoot || emojiPicker.attachShadow({ mode: "open" });
const sectionElement = shadowRoot.querySelector("section");
sectionElement.setAttribute("data-theme", "dark");
});
},1000);
}else{
setTimeout(function(){
$("em-emoji-picker").each(function(){
const emojiPicker = this;//document.querySelector("em-emoji-picker");
const shadowRoot = emojiPicker.shadowRoot || emojiPicker.attachShadow({ mode: "open" });
const sectionElement = shadowRoot.querySelector("section");sectionElement.setAttribute("data-theme", "light");
});
},1000);
}';
$ht_js .= '}},"#theme-switch-input1, #theme-switch-input2");'; //done
/* size event listener */
$ht_js .= '$(function(){if(window.innerWidth<500){$("em-emoji-picker").css("min-width", window.innerWidth-20).css("left", (window.innerWidth-(window.innerWidth+21))) }else{$("em-emoji-picker").css("left", "39px")}});';
$ht_js .= 'window.addEventListener("resize",function(){if(window.innerWidth<500){$("em-emoji-picker").css("min-width", window.innerWidth-20).css("left", (window.innerWidth-(window.innerWidth+21)))}else{$("em-emoji-picker").css("left", "39px")}});';
}
$ht_js .= '$(".comm-toggle-replies").each(function(){var t = $(this); var _id = t.attr("id").substr(3); if (typeof($("#"+_id+" .response_holder").html()) == "undefined"){t.detach();}});';
/* linkify comments */
$ht_js .= '$(".comment_h p").linkify({defaultProtocol: "https", validate: {email: function(value){return false}}, ignoreTags: ["script","style"]});';
/* sort comments */
$ht_js .= '$(function(){$("#entry-action-buttons").dlmenu({animationClasses:{classin:"dl-animate-in-5",classout:"dl-animate-out-5"}})});';
/* show/hide comments */
$ht_js .= '$(".showComments-eye").on("click", function(){$(\'#list-' . $type . '-comments, .comment_left_char\').toggle();$(\'#comm-post-form\').stop().slideToggle(\'fast\')});';
/* comm post response */
$file_resp = $islogged ? $class_database->singleFieldValue('db_' . $type . 'files', 'responding', 'file_key', $f_key) : null;
$comm_btn = ($cfg['file_comments'] == 1 ? '' : null);
$comm_all = $section == $href['watch'] ? '
' . $comm_all . $language['view.files.comm.all'] . '
' . $comm_btn . '
' . ($section == $href['see_comments'] ? VGenerate::advHTML(21) : null) . '
' . VGenerate::simpleDivWrap('', 'comm-post-response', VGenerate::noticeTpl('', $msg_arr[1], $msg_arr[0])) . '
' . VGenerate::simpleDivWrap('posted-comments', 'list-' . $type . '-comments', self::listFileComments($type, $vuid)) . '
' . ($section == $href['see_comments'] ? VGenerate::advHTML(22) : null) . '
';
$html .= VGenerate::declareJS('$(document).ready(function(){' . $ht_js . '});
' . ($_SESSION['USER_ID'] > 0 ? '
var textarea = document.getElementById("textarea-content");
textarea.addEventListener("input", () => {
textarea.style.height = "auto";
textarea.style.height = (textarea.scrollHeight+1) + "px";
if ($("#wrapper").hasClass("tpl_shorts")) {
var pch=$("#comm-post-form").height() + 92;
var h=$("body").height()-100;
// $(".posted-comments").css("height",(h-pch));
var sh=!$("#view-player").hasClass("bottom-comments")?$(".video-js").height():360;
var ct=sh - ($("#comment-load .file-views-nr").height() + $("#comment-load #comm-post-response").height() + $("#comment-load #comm-post-form").height() + 20);
$(".posted-comments").css("height", ct);
}
});
textarea.addEventListener("focus", () => {
$("#main-comments-actions").show();
if ($("#wrapper").hasClass("tpl_shorts")) {
var pch=$("#comm-post-form").height() + 92;
var h=$("body").height()-100;
// $(".posted-comments").css("height",(h-pch));
var sh=!$("#view-player").hasClass("bottom-comments")?$(".video-js").height():360;
var ct=sh - ($("#comment-load .file-views-nr").height() + $("#comment-load #comm-post-response").height() + $("#comment-load #comm-post-form").height() + 20);
$(".posted-comments").css("height", ct);
}
});
var pickerOptions = {
theme: $("body").hasClass("dark") ? "dark" : "light", emojiButtonSize:30, emojiSize:20, perLine:12, skinTonePosition:"search", previewPosition:"none", autoFocus:true, dynamicWidth: true, onEmojiSelect: function(emoji){
const textarea = document.getElementById("textarea-content")
const cursorPosition = textarea.selectionEnd
const start = textarea.value.substring(0, textarea.selectionStart)
const end = textarea.value.substring(textarea.selectionStart)
const text = start + emoji.native + end
textarea.value = text
textarea.focus()
textarea.selectionEnd = cursorPosition + emoji.native.length
}
}
var picker = new EmojiMart.Picker(pickerOptions);
$("#comment-emotes").append(picker);
' : null) . '
function opencheck(k){$(".comments_activity").each(function(){var t = $(this); var _id = t.attr("id"); if (t){ if (typeof(t.find("#"+k).html()) != "undefined") {setTimeout(function () {$("#"+_id+" > .response_holder").css("display", "block"); $("#"+_id+" .comm-toggle-replies").find("i").removeClass("iconBe-chevron-down").addClass("iconBe-chevron-up"); }, 1);} } });}
');
return $html;
}
/* listing comments */
public function listFileComments(string $type, int $vuid, $getReplies = false)
{
$db = self::$db;
$class_filter = self::$filter;
$cfg = self::$cfg;
$language = self::$language;
$section = self::$section;
$href = self::$href;
$file_key = (int) self::$file_key;
if ($type == '' or $vuid == '' or $file_key == '') {
return;
}
$ch_cfg['ch_comm_spam'] = 1;
/* get blocked users */
$c_blocked = $db->execute(sprintf("SELECT
A.`ct_id`, A.`usr_id`, B.`usr_id` AS `blocked_usr_id`
FROM `db_usercontacts` A, `db_accountuser` B
WHERE
A.`usr_id`='%s' AND A.`ct_blocked`='1' AND A.`ct_active`='1' AND A.`ct_username`=B.`usr_user`;",
$vuid));
if ($c_blocked->fields['ct_id']) {
$u_blocked = array();
while (!$c_blocked->EOF) {
$u_blocked[] = $c_blocked->fields['blocked_usr_id'];
$c_blocked->MoveNext();
}
}
/* owner details */
$u_info = VUserinfo::getUserInfo($vuid);
$u_name = VNotify::displayName($u_info);
/* is owner */
$edit = $vuid == (int) $_SESSION['USER_ID'] ? 1 : 0;
/* paging */
$cpp = $section != $href['see_comments'] ? 15 : 50; //paging limit
$page_nr = $_GET['page'] > 1 ? intval($_GET['page']) : 1;
//$page_nr = isset($_GET['page']) ? intval($_GET['page'])+1 : 1;
$s_from = !$getReplies ? ($page_nr - 1) * $cpp : 0;
$reply_t = !$getReplies ? "`c_replyto`=''" : sprintf("`c_replyto`='%s'", $getReplies['replyto']);
$reply_s = !$getReplies ? "A.`c_replyto`=''" : sprintf("A.`c_replyto`='%s'", $getReplies['replyto']);
/* sort by */
$sort_by = isset($_POST['file_comm_sort']) ? $class_filter->clr_str($_POST['file_comm_sort']) : (isset($_POST['comm_sort']) ? $class_filter->clr_str($_POST['comm_sort']) : 'top-comments');
$sort_approved = "AND A.`c_approved`='1'";
$sort_total = "AND `c_approved`='1'";
$sort_spam = null;
$sort_spam_total = null;
switch ($sort_by) {
default:
case "top-comments":
$sort_sql = 'c_rating_value';
break;
case "new-comments":
$sort_sql = 'c_id';
break;
case "new-replies":
$interval = 72;
$sort_approved = $edit == 1 ? "AND A.`c_approved`>='0' AND A.`c_datetime` > NOW() - INTERVAL $interval HOUR" : "AND A.`c_approved`='1' AND A.`c_datetime` > NOW() - INTERVAL $interval HOUR";
$sort_total = $edit == 1 ? "AND `c_approved`>='0' AND `c_datetime` > NOW() - INTERVAL $interval HOUR" : "AND `c_approved`='1' AND `c_datetime` > NOW() - INTERVAL $interval HOUR";
$sort_sql = 'c_id';
$reply_t = "`c_replyto`!=''";
$reply_s = "A.`c_replyto`!=''";
$getReplies = false;
break;
case "not-approved":
if ($edit == 1) {
$sort_approved = "AND A.`c_approved`='0'";
$sort_total = "AND `c_approved`='0'";
$sort_sql = 'c_approved';
$reply_t = "`c_replyto`=''";
$reply_s = "A.`c_replyto`=''";
$getReplies = false;
}
break;
case "spam-reports":
if ($edit == 1) {
$sort_approved = "AND A.`c_approved`>='0'";
$sort_total = "AND `c_approved`>='0'";
$sort_spam = "AND A.`c_spam`!=''";
$sort_spam_total = "AND `c_spam`!=''";
$sort_sql = 'c_spam';
$reply_t = "`c_replyto`=''";
$reply_s = "A.`c_replyto`=''";
$getReplies = false;
}
break;
}
$ttotal_sql = sprintf("SELECT COUNT(*) AS `total` FROM `db_%scomments` WHERE %s `file_key`='%s' %s %s", $type, (isset($u_blocked[0]) ? sprintf("`c_usr_id` NOT IN(%s) AND", implode(",", $u_blocked)) : null), $file_key, ($edit == 1 ? $sort_spam_total : null), $sort_total);
$total_sql = sprintf("SELECT COUNT(*) AS `total` FROM `db_%scomments` WHERE %s %s AND `file_key`='%s' %s %s", $type, (isset($u_blocked[0]) ? sprintf("`c_usr_id` NOT IN(%s) AND", implode(",", $u_blocked)) : null), $reply_t, $file_key, ($edit == 1 ? $sort_spam_total : null), $sort_total);
if ((($edit == 1 and ($sort_by == 'not-approved' or $sort_by == 'spam-reports' or $sort_by == 'new-replies-off')) or ($edit == 0 and $sort_by == 'new-replies-off')) and !$getReplies) {
$total_sql = str_replace($reply_t . " AND", "", $total_sql);
}
$ex_id = array();
if (!$getReplies and $page_nr == 1) {
$comm_sql = sprintf("SELECT
A.`c_id`, A.`c_usr_id`, A.`c_key`, A.`c_body`, A.`c_datetime`,
A.`c_approved`, A.`c_rating`, A.`c_replyto`, A.`c_edited`, A.`c_pinned`,
B.`usr_user`, B.`usr_id`, B.`usr_key`, B.`usr_partner`, B.`usr_affiliate`,
B.`affiliate_badge`, B.`usr_dname`, B.`ch_title`, C.`comment_spam`, C.`comment_votes`
FROM `db_%scomments` A
JOIN `db_accountuser` B ON A.`c_usr_id`=B.`usr_id`
JOIN `db_%sfiles` C ON A.`file_key`=C.`file_key`
WHERE %s A.`file_key`='%s' %s %s
AND A.`c_pinned`='1'
AND A.`c_active`='1'
ORDER BY `%s` DESC;
", $type, $type, (isset($u_blocked[0]) ? sprintf("`c_usr_id` NOT IN(%s) AND", implode(",", $u_blocked)) : null), $file_key, $sort_approved, $sort_spam, $sort_sql);
$comm_db = self::$db_cache ? $db->CacheExecute($cfg['cache_view_comments'], $comm_sql) : $db->execute($comm_sql);
$comm_rs1 = $comm_db->getrows();
if (isset($comm_rs1[0])) {
foreach ($comm_rs1 as $key => $val) {
$ex_id[] = (int) $val['c_id'];
}
}
// var_dump($ex_id);
}
$comm_sql = sprintf("SELECT
A.`c_id`, A.`c_usr_id`, A.`c_key`, A.`c_body`, A.`c_datetime`,
A.`c_approved`, A.`c_rating`, A.`c_replyto`, A.`c_edited`, A.`c_pinned`,
B.`usr_user`, B.`usr_id`, B.`usr_key`, B.`usr_partner`, B.`usr_affiliate`,
B.`affiliate_badge`, B.`usr_dname`, B.`ch_title`, C.`comment_spam`, C.`comment_votes`
FROM `db_%scomments` A
JOIN `db_accountuser` B ON A.`c_usr_id`=B.`usr_id`
JOIN `db_%sfiles` C ON A.`file_key`=C.`file_key`
WHERE %s %s %s AND A.`file_key`='%s' %s %s
AND A.`c_active`='1'
ORDER BY
CASE WHEN A.`c_pinned`='1' THEN 0 ELSE 1 END, `%s` DESC
LIMIT %s, %s;
", $type, $type, (isset($ex_id[0]) ? sprintf("A.`c_id` NOT IN (%s) AND ", implode(",", $ex_id)) : null), (isset($u_blocked[0]) ? sprintf("`c_usr_id` NOT IN(%s) AND", implode(",", $u_blocked)) : null), $reply_s, $file_key, $sort_approved, $sort_spam, $sort_sql, $s_from, $cpp);
if ((($edit == 1 and ($sort_by == 'not-approved' or $sort_by == 'spam-reports' or $sort_by == 'new-replies-off')) or ($edit == 0 and $sort_by == 'new-replies-off')) and !$getReplies) {
$comm_sql = str_replace($reply_s . " AND", "", $comm_sql);
}
if ($sort_by == 'top-comments') {
$comm_sql = str_replace("`c_rating_value`", "A.`c_rating_value` DESC, A.`c_id`", $comm_sql);
}
$comm_db = self::$db_cache ? $db->CacheExecute($cfg['cache_view_comments'], $comm_sql) : $db->execute($comm_sql);
$ttotal_db = self::$db_cache ? $db->CacheExecute($cfg['cache_view_comments'], $ttotal_sql) : $db->execute($ttotal_sql);
$total_db = self::$db_cache ? $db->CacheExecute($cfg['cache_view_comments'], $total_sql) : $db->execute($total_sql);
$total_nr = (int) $total_db->fields['total'];
$ttotal_nr = (int) $ttotal_db->fields['total'];
$comm_rs = $comm_db->getrows();
if (!$getReplies and $page_nr == 1) {
foreach ($comm_rs1 as $v => $val) {
array_unshift($comm_rs, $val);
// exit;
}
}
$pages = ceil($total_nr / $cpp);
if ($total_nr > 0) {
$html = null;
foreach ($comm_rs as $key => $val) {
$c_key = $val['c_key'];
$c_body = $val['c_body'];
$c_usr_name = $val['usr_user'];
$c_usr_key = $val['usr_key'];
$c_dusr = $val['usr_dname'];
$ch_usr = $val['ch_title'];
$c_usr = $c_dusr != '' ? $c_dusr : ($ch_usr != '' ? $ch_usr : $c_usr_name);
$c_replyto = $val['c_replyto'];
$c_edited = $val['c_edited'];
$c_pinned = $val['c_pinned'];
$c_date = VUserinfo::timeRange($val['c_datetime']);
$c_date = $c_date != '' ? $c_date : $language['frontend.global.now'];
$usr_lnk = VHref::channelURL(["username" => $c_usr_name]);
$add = 0;
/* comment html */
if ($val['comment_votes'] == 1 and $cfg['file_comment_votes'] == 1) {
$c_rate = $val['c_rating'] != '' ? unserialize($val['c_rating']) : '';
if ($c_rate != '') {
$votes = array();
foreach ($c_rate as $k => $v) {
$add .= $v;
if ($k == $_SESSION['USER_ID']) {
$votes[$c_key] = (int) $v;
}
}
$t_rate = self::calculateString($add);
} else {
$t_rate = 0;
}
}
/* user thumbnail */
$cfg['file_comments_avatar'] = 1;
$more_menu = false;
$more_ht = '' . $c_key . '
';
/* all actions */
$comm_actions = $_SESSION['USER_ID'] > 0 ? VGenerate::simpleDivWrap('ucls-links', '', '' . $vote_ht . '
' . $ckey_ht) : null;
$more_actions = $_SESSION['USER_ID'] > 0 ? VGenerate::simpleDivWrap('ucls-links', '', $more_ht . $ckey_ht) : null;
$more_actions .= $_SESSION['USER_ID'] > 0 ? VGenerate::simpleDivWrap('yy-bg spam-rep-list', 'spam-rep-' . $c_key, $spam_rep, 'display: none;') : null;
/* @username regex */
$pattern = '/@(\w+)/';
preg_match_all($pattern, $c_body, $matches);
if (isset($matches[1])) {
$usernames = $matches[1];
foreach ($usernames as $username) {
$c_usr_key = self::$dbc->singleFieldValue('db_accountuser', 'usr_key', 'usr_user', $username);
if ($c_usr_key == '') {
$c_usr_key = self::$dbc->singleFieldValue('db_accountuser', 'usr_key', 'usr_dname', $username);
}
if ($c_usr_key == '') {
$c_usr_key = self::$dbc->singleFieldValue('db_accountuser', 'usr_key', 'ch_dname', $username);
}
if ($c_usr_key != '') {
$c_body = str_replace('@' . $username, '' : null)) . '
' . ((($c_replyto > 0 and $sort_by != 'not-approved' and $sort_by != 'spam-reports' and $sort_by != 'new-replies' and $getReplies) ? '
' : null)) . '
';
echo ((isset($_POST['c_key']) and $class_filter->clr_str($_POST['c_key']) == $c_key) ? VGenerate::declareJS('opencheck("' . $c_key . '");') : null);
if (($key + 1) == $cpp) {
break;
}
}
/* pagination links */
//if ($pages > 1 and !$getReplies) {
if ($page_nr == 1 and !$getReplies) {
$p = 10; //number of page links to show
$j = ($page_nr >= $p) ? (floor($page_nr / $p) * $p) : 1;
$j_gt = ($page_nr >= $p) ? ((floor($page_nr / $p) * $p) + ($p - 1)) : ($p - 1);
$pag = '
\'+(ct-($(".comm-own"+f1+">a").html().length+3))+\' ' . $language['view.files.comm.char'] . '