Exemplo n.º 1
0
				}
			}
			if (!empty($addr))
			{
				$arIPs[] = $addr;
			}
			COption::SetOptionString("prmedia.treelikecomments", "ban", implode(", ", $arIPs));

			$addr = $arComment['REMOTE_ADDR'];
			if ($action == 'ban_delete')
			{
				// delete all comments for ip
				$arFilter = array(
					"REMOTE_ADDR" => $addr
				);
				$rsComment = $obComment->GetList(false, $arFilter);
				while ($arComment = $rsComment->Fetch())
				{
					$objectId = $obComment->GetObjectData($arComment['ID']);
					$obComment->Delete($arComment['ID']);
					@$CACHE_MANAGER->ClearByTag("prmedia_treelike_comments_" . $objectId);
				}
				LocalRedirect('/bitrix/admin/tc_comment_list.php?result=ban_delete');
				return;
			}
			LocalRedirect('/bitrix/admin/tc_comment_list.php?result=ban');
		}
	}
}
else
{
Exemplo n.º 2
0
Arquivo: index.php Projeto: ASDAFF/mp
	$obComment = new CTreelikeComments;

	$rsComment = $obComment->GetByID($commentId);
	if ($arComment = $rsComment->Fetch())
	{
		$obComment->Delete($commentId);
		$CACHE_MANAGER->ClearByTag("prmedia_treelike_comments_" . $arComment['OBJECT_ID']);
	}

	LocalRedirect($APPLICATION->GetCurPageParam("", array("delete-comment-id")));
}


$arResult = array();
$rsComment = CTreelikeComments::GetList(array(), array(), intval($arGadgetParams['COUNT']));
$count = CTreelikeComments::GetList(array(), array(), intval($arGadgetParams['COUNT']), true);
if ($count > $arGadgetParams['COUNT'])
{
	$count = $arGadgetParams['COUNT'];
}
while ($arComment = $rsComment->GetNext())
{
	$arItem = array();
	$rsElement = CIBlockElement::GetByID($arComment['OBJECT_ID']);
	$arElement = $rsElement->GetNext();
	if (empty($arComment['LOGIN']))
	{
		$arItem['LOGIN'] = '******' . $arComment['AUTHOR_NAME'] . '</strong>';
	} else
	{
		$arItem['LOGIN'] = '******' . $arComment['USER_ID'] . '" style="font-weight: bold;">' . $arComment['LOGIN'] . '</a>';
Exemplo n.º 3
0
 /**
  * Checking treelike comment for spam
  * @param &array Comment fields to check
  * @return null|boolean NULL when success or FALSE when spam detected
  */
 function OnBeforePrmediaCommentAddHandler(&$arFields)
 {
     global $APPLICATION, $USER;
     $ct_status = COption::GetOptionString('cleantalk.antispam', 'status', '0');
     $ct_comment_treelike = COption::GetOptionString('cleantalk.antispam', 'form_comment_treelike', '0');
     if ($ct_status == 1 && $ct_comment_treelike == 1) {
         if ($USER->IsAdmin()) {
             return;
         }
         // Skip authorized user with more than 5 approved comments
         if ($USER->IsAuthorized()) {
             $approved_comments = CTreelikeComments::GetList(array('ID' => 'ASC'), array('USER_ID' => $arFields['USER_ID'], 'ACTIVATED' => 1), '', TRUE);
             if (intval($approved_comments) > 5) {
                 return;
             }
         }
         $aComment = array();
         $aComment['type'] = 'comment';
         $aComment['sender_email'] = isset($arFields['EMAIL']) ? $arFields['EMAIL'] : '';
         $aComment['sender_nickname'] = isset($arFields['AUTHOR_NAME']) ? $arFields['AUTHOR_NAME'] : '';
         $aComment['message_title'] = '';
         $aComment['message_body'] = isset($arFields['COMMENT']) ? $arFields['COMMENT'] : '';
         $aComment['example_title'] = '';
         $aComment['example_body'] = '';
         $aComment['example_comments'] = '';
         if (COption::GetOptionString('cleantalk.antispam', 'form_send_example', '0') == 1) {
             // Find last 10 approved comments
             $db_res = CTreelikeComments::GetList(array('DATE' => 'DESC'), array('OBJECT_ID_NUMBER' => $arFields['OBJECT_ID'], 'ACTIVATED' => 1), 10);
             while ($ar_res = $db_res->Fetch()) {
                 $aComment['example_comments'] .= $ar_res['COMMENT'] . "\n\n";
             }
         }
         $aResult = self::CheckAllBefore($aComment, TRUE);
         if (isset($aResult) && is_array($aResult)) {
             if ($aResult['errno'] == 0) {
                 if ($aResult['allow'] == 1) {
                     // Not spammer - just return;
                     return;
                 } else {
                     if ($aResult['stop_queue'] == 1) {
                         // Spammer and stop_queue - return false and throw
                         if (preg_match('//u', $aResult['ct_result_comment'])) {
                             $err_str = preg_replace('/^[^\\*]*?\\*\\*\\*|\\*\\*\\*[^\\*]*?$/iu', '', $aResult['ct_result_comment']);
                             $err_str = preg_replace('/<[^<>]*>/iu', '', $err_str);
                         } else {
                             $err_str = preg_replace('/^[^\\*]*?\\*\\*\\*|\\*\\*\\*[^\\*]*?$/i', '', $aResult['ct_result_comment']);
                             $err_str = preg_replace('/<[^<>]*>/i', '', $err_str);
                         }
                         $APPLICATION->ThrowException($err_str);
                         return FALSE;
                     } else {
                         // Spammer and NOT stop_queue - to manual approvement
                         // ACTIVATED = 0
                         /*            
                                                     // doesn't work - TreeLike Comments uses
                                                     // deprecated ExecuteModuleEvent
                                                     // instead of ExecuteModuleEventEx
                                                     // $arFields are not passwd by ref
                                                     // (See source - $args[] = func_get_arg($i))
                                                     // so I cannot change 'ACTIVATED'
                                                     $arFields['ACTIVATED'] = 0;
                                                     return;
                         */
                         if (preg_match('//u', $aResult['ct_result_comment'])) {
                             $err_str = preg_replace('/^[^\\*]*?\\*\\*\\*|\\*\\*\\*[^\\*]*?$/iu', '', $aResult['ct_result_comment']);
                             $err_str = preg_replace('/<[^<>]*>/iu', '', $err_str);
                         } else {
                             $err_str = preg_replace('/^[^\\*]*?\\*\\*\\*|\\*\\*\\*[^\\*]*?$/i', '', $aResult['ct_result_comment']);
                             $err_str = preg_replace('/<[^<>]*>/i', '', $err_str);
                         }
                         $APPLICATION->ThrowException($err_str);
                         return FALSE;
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 4
0
function getComments($PARENT_ID, $DEPTH_LEVEL, &$comments, &$left_margin, $date_format, $userlink, $commentLink, $max_depth_level, $asName, &$arIDs, $templateFolder, $canModify)
{
  $arFilter = array("OBJECT_ID_NUMBER" => OBJECT_ID, "PARENT_ID" => $PARENT_ID);
	$res = CTreelikeComments::GetList(array("ID" => "DESC"), $arFilter);

	while ($ob = $res->GetNext())
	{
		if ($ob['USER_ID'] != NULL)
		{
			$link = $userlink;

			if (preg_match('/USER_LOGIN/i', $link))
			{
				$userlogin_before = "#USER_LOGIN#";
				$userlogin_after = $ob['LOGIN'];

				$link = str_replace($userlogin_before, $userlogin_after, $link);
			}
			if (preg_match('/USER_ID/i', $link))
			{
				$id_before = "#USER_ID#";
				$id_after = $ob['USER_ID'];

				$link = str_replace($id_before, $id_after, $link);
			}
			if (preg_match('/PERSONAL_WWW/i', $link))
			{
				$id_before = "#PERSONAL_WWW#";
				$id_after = "";
				$arFilter = array(
					"ID" => $ob['USER_ID']
				);
				$arSelectParams = array(
					"FIELDS" => array(
						"ID", "PERSONAL_WWW"
					)
				);
				$rsUser = CUser::GetList($by = "ID", $order = "DESC", $arFilter, $arSelectParams);
				if ($arUser = $rsUser->Fetch())
				{
					$id_after = $arUser['PERSONAL_WWW'];
				}

				$link = str_replace($id_before, $id_after, $link);
			}
		}

		$user = array(
			"ID" => $ob['USER_ID'],
			"LOGIN" => $ob['LOGIN'],
			"NAME" => $ob['NAME'],
			"LAST_NAME" => $ob['LAST_NAME'],
			"PERSONAL_PHOTO" => CFile::GetPath($ob['PERSONAL_PHOTO']),
			"USERLINK" => $link
		);

		switch ($asName)
		{
			case "name_lastname":
				if ($user['NAME'] != "" && $user['LAST_NAME'] != "")
					$user['LOGIN'] = $user['NAME'] . " " . $user['LAST_NAME'];
				break;

			case "name":
				if ($user['NAME'] != "")
					$user['LOGIN'] = $user['NAME'];
				break;
		}

		if ($DEPTH_LEVEL > $max_depth_level - 1)
			$DEPTH_LEVEL = $max_depth_level - 1;

		if ($commentLink == "Y")
			$cLink = "comment_" . $ob["ID"];
		else
			$cLink = "N";

		$arIDs[] = $ob['ID'];

		// add modification date
		$commentText = $ob['~COMMENT'];
		$commentModify = "";

		if (!empty($ob['DATE_MODIFY']) && $canModify == "Y")
		{
			$commentModify = GetMessage('CHANGE_COMMENT_MSG');
			$commentDateTime = explode(" ", $ob['DATE_MODIFY']);
			$commentModify = str_replace("#DATE#", $commentDateTime[0], $commentModify);
			$commentModify = str_replace("#TIME#", $commentDateTime[1], $commentModify);
		}

		// if user is author add modification link
		$canEdit = "N";
		if (!empty($ob['USER_ID']) && $ob['USER_ID'] == CUser::GetID() && $canModify == "Y")
		{
			$canEdit = "Y";
		}

		$commentHiddenContent = TreelikeCommentsGetSmiles($ob['~COMMENT'],
			array(
				":)" => "smile.png",
				":D" => "xd.png",
				":(" => "sad.png",
				"x_x" => "x_x.png",
				"0_0" => "0_0.png",
			),
			array("FOLDER" => $templateFolder)
		);
		$commentHiddenContent = CTreelikeComments::ParseTextBack($commentHiddenContent);
		$commentHiddenContent = strip_tags($commentHiddenContent);


		$comments[$ob['ID']] = array(
			"ID" => $ob['ID'],
			"DEPTH_LEVEL" => $DEPTH_LEVEL,
			"PARENT_ID" => $ob['PARENT_ID'],
			"LEFT_MARGIN" => $DEPTH_LEVEL * $left_margin,
			"USER" => $user,
			"COMMENT_LINK" => $cLink,
			"COMMENT" => $commentText,
			"AUTHOR_NAME" => $ob['AUTHOR_NAME'],
			"DATE_CREATE" => FormatDate($date_format, strtotime($ob['NEW_DATE'])),
			"ACTIVATED" => $ob['ACTIVATED'],
			"VoteUp" => 0,
			"VoteDown" => 0,
			"TOTAL_VOTE" => 0,
			"COMMENT_HIDDEN_CONTENT" => $commentHiddenContent,
			"MODIFY_STRING" => $commentModify,
			"DATE_MODIFY" => $ob['DATE_MODIFY'],
			"CAN_EDIT" => $canEdit
		);

		getComments($ob['ID'], $DEPTH_LEVEL + 1, $comments, $left_margin, $date_format, $userlink, $commentLink, $max_depth_level, $asName, $arIDs, $templateFolder, $canModify);
	}

}
Exemplo n.º 5
0
<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();?>	
<?
$arResult['FANCYBOX'] = false;
if (is_array($arResult['PROPERTIES']['MORE_PHOTO']['VALUE'])) {
	foreach ($arResult['PROPERTIES']['MORE_PHOTO']['VALUE'] as $photo) {
		$arResult['FANCYBOX'][] = array(
			'thumb' => CFile::ResizeImageGet($photo, array('width' => 100, 'height' => 100), BX_RESIZE_IMAGE_PROPORTIONAL, true),
			'normal' => CFile::ResizeImageGet($photo, array('width' => 800, 'height' => 800), BX_RESIZE_IMAGE_PROPORTIONAL, true)
			);
	}
}

CModule::IncludeModule('prmedia.treelikecomments');
$arFilter = array("OBJECT_ID_NUMBER" => $arResult['ID']);
$commentsCounter = CTreelikeComments::GetList(array("ID" => "DESC"), $arFilter)->SelectedRowsCount();

$showComments = false;
if ($_SESSION['COMMENTS']['ADD'] == 'Y') {
	$showComments = true;
	unset($_SESSION['COMMENTS']['ADD']);
}
?>
<script>
	$(document).ready(function () {
		<?if (true === $showComments) : ?>
			$('.comments-tab').click();
		<?endif;?>
	});
</script>
<style>
	.play-btn {width: 160px; opacity: 0.9; display: block; line-height: 0.7em; padding: 19px 0 19px 0; margin: 0 0 21px 0; background: #bfbfbf url(/src/icons/play48.png) no-repeat left; background-origin: content-box; text-align: center; color: #fff;  font-weight: 400; font-size: 24px; font-family: 'Open Sans', sans-serif; text-decoration: none; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px;position: absolute; top: 181px; left: 391px; padding-left: 12px;}
Exemplo n.º 6
0
	$row->AddViewField("IP", $myrow["REMOTE_ADDR"]);
	$row->AddViewField("COMMENT", HTMLToTxt($myrow['COMMENT']));
	$row->AddViewField("OBJECT_ID", $iblock_element_name. '<a style="padding-left: 3px;" href="iblock_element_edit.php?WF=Y&ID='.$myrow['OBJECT_ID'].'&type='.$iblock_element_type.'&lang='.LANG.'&IBLOCK_ID='.$iblock_element_iblock_id.'&find_section_section=-1" />['.$myrow['OBJECT_ID'].']</a>');
	$row->AddViewField("SITE_ID", $myrow['SITE_ID']);
	$row->AddViewField("ACTIVATED", $myrow['ACTIVATED']);
	$row->AddViewField("DATE_MODIFY", $myrow['DATE_MODIFY']);

	$result_user = '';

	$remoteAddr = CTreelikeComments::GetIP();
	$arFilter = array(
		"REMOTE_ADDR" => $remoteAddr

	);
	$obComment = new CTreelikeComments;
	$commentsCount = $obComment->GetList(false, $arFilter, false, true);
	$banDeleteConfirm = str_replace("#COMMENTS_COUNT#", $commentsCount, GetMessage('TC_BAN_DELETE_CONFIRM'));
	$banDeleteConfirm = str_replace("#REMOTE_ADDR#", $remoteAddr, $banDeleteConfirm);
	$arWordEndings = explode(",", GetMessage('TC_BAN_DELETE_WORD_ENDS'));
	$banDeleteConfirm = str_replace("#WORD_END#", getNumericSuffix($arWordEndings, $commentsCount), $banDeleteConfirm);

	// row actions
	$arActions = Array();
	$arActions[] = array(
		"TEXT" => GetMessage("TC_ACTIVATE"),
		"ACTION" => $lAdmin->ActionRedirect("tc_comment_actions.php?action=activate&id=" . $myrow['ID'])
	);
	$arActions[] = array(
		"TEXT" => GetMessage("TC_DEACTIVATE"),
		"ACTION" => $lAdmin->ActionRedirect("tc_comment_actions.php?action=deactivate&id=" . $myrow['ID'])
	);
Exemplo n.º 7
0
	if (PrmediaLastCommentsCheckRestrictions($arParams['IBLOCK_RESTRICTIONS']))
	{
		$arRestrictons = $arParams['IBLOCK_RESTRICTIONS'];
	}
	$restrictions = implode(',', $arRestrictons);

	// getlist
	$order = array(
		'ID' => 'DESC'
	);
	$filter = array(
		'SITE_ID' => SITE_ID,
		'ACTIVATED' => 1,
		'IBLOCK_ID' => $restrictions
	);
	$rsComment = CTreelikeComments::GetList($order, $filter, intval($arParams['COUNT']));
	while ($arComment = $rsComment->GetNext())
	{
		$element = CIBlockElement::GetByID($arComment['OBJECT_ID']);
		$arIblockElement = $element->GetNext();
		if (!strlen($arComment['LOGIN']))
		{
			$username = $arComment['AUTHOR_NAME'];
			$isRegistered = 'N';
			$profileURL = '';
		}
		else
		{
			$username = $arComment['LOGIN'];
			if (strlen($arParams['PROFILE_URL']))
			{
Exemplo n.º 8
0
	$arResult['ALLOW_RATING'] = $arParams['ALLOW_RATING'];
	$arResult['SHOW_USERPIC'] = $arParams['SHOW_USERPIC'];
	$arResult['SHOW_DATE'] = $arParams['SHOW_DATE'];
	$arResult['GROUPS'] = CTreelikeComments::IsModerator();
	$arResult['CURRENT_USER'] = $USER->IsAuthorized() ? $USER->GetID() : 0;

	$arItems = array();
	$arIDs = array();

	// Getting comments List
	$arFilter = array(
		"OBJECT_ID_NUMBER" => $arParams["OBJECT_ID"],
		"SITE_ID" => SITE_ID,
	);

	$resComm = CTreelikeComments::GetList(array(), $arFilter);
	while($arComm = $resComm->GetNext()):
		$arIDs[] = $arComm["ID"];
		$arItems[$arComm["ID"]] = $arComm;
		$arItems[$arComm["ID"]]["COMMENT"] = $arComm["~COMMENT"];
	endwhile;

	// Count votes
	if(!empty($arIDs))
	{
		$resVoteIDs = CTreelikeComments::GetVotedIDs($arIDs);
		$allbestCommentsCount = 0; // corresponding to the condition

		while($arIDs = $resVoteIDs->GetNext()):
			if($arIDs["VOTE_TYPE"] == "UP")
			{