403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/ilovecveti.ru/bitrix/modules/socialnetwork/lib/ui/preview/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/ilovecveti.ru/bitrix/modules/socialnetwork/lib/ui/preview/post.php
<?php
namespace Bitrix\Socialnetwork\Ui\Preview;

use Bitrix\Im\User;
use Bitrix\Main\Loader;

class Post
{
	/**
	 * Returns HTML code for blog post preview.
	 * @param array $params Expected keys: postId, userId.
	 * @return string
	 */
	public static function buildPreview(array $params)
	{
		global $APPLICATION;
		if(!Loader::includeModule('blog'))
			return null;

		ob_start();
		$APPLICATION->includeComponent(
			'bitrix:socialnetwork.blog.post.preview',
			'',
			$params
		);
		return ob_get_clean();
	}

	/**
	 * Returns attach to display in the messenger.
	 * @param array $params Expected keys: postId, userId
	 * @return \CIMMessageParamAttach | false
	 */
	public static function getImAttach(array $params)
	{
		if (!Loader::includeModule('im'))
			return false;

		if (!Loader::includeModule('blog'))
			return false;

		$cursor = \CBlogPost::getList(
			array(),
			array("ID" => $params["postId"]),
			false,
			false,
			array("ID", "BLOG_ID", "PUBLISH_STATUS", "TITLE", "AUTHOR", "ENABLE_COMMENTS", "NUM_COMMENTS", "VIEWS", "CODE", "MICRO", "DETAIL_TEXT", "DATE_PUBLISH", "CATEGORY_ID", "HAS_SOCNET_ALL", "HAS_TAGS", "HAS_IMAGES", "HAS_PROPS", "HAS_COMMENT_IMAGES")
		);
		$post = $cursor->fetch();
		if(!$post)
			return false;

		// For some reason, blog stores specialchared text.
		$post['DETAIL_TEXT'] = htmlspecialcharsback($post['DETAIL_TEXT']);
		if ($post['MICRO'] === 'Y')
			$post['TITLE'] = null;

		$parser = new \blogTextParser();
		$post['PREVIEW_TEXT'] = TruncateText($parser->killAllTags($post["DETAIL_TEXT"]), 200);
		$user = User::getInstance($post['AUTHOR']);

		$attach = new \CIMMessageParamAttach(1, '#E30000');
		$attach->addUser(array(
			'NAME' => $user->getFullName(),
			'AVATAR' => $user->getAvatar(),
		));

		if($post['TITLE'] != '')
		{
			$attach->addMessage('[b]' . $post['TITLE'] . '[/b]');
		}
		$attach->addMessage($post['PREVIEW_TEXT']);

		return $attach;
	}

	public static function getImRich(array $params)
	{
		if (!Loader::includeModule('im'))
		{
			return false;
		}

		if (!Loader::includeModule('blog'))
		{
			return false;
		}

		if (!class_exists('\Bitrix\Im\V2\Entity\Url\RichData'))
		{
			return false;
		}

		$cursor = \CBlogPost::getList(
			[],
			['ID' => $params['postId']],
			false,
			false,
			['TITLE', 'MICRO', 'DETAIL_TEXT']
		);
		$post = $cursor->fetch();
		if(!$post)
		{
			return false;
		}

		// For some reason, blog stores specialchared text.
		$post['DETAIL_TEXT'] = htmlspecialcharsback($post['DETAIL_TEXT']);
		if ($post['MICRO'] === 'Y')
		{
			$post['TITLE'] = null;
		}

		$parser = new \blogTextParser();
		$post['PREVIEW_TEXT'] = TruncateText($parser->killAllTags($post['DETAIL_TEXT']), 200);

		$rich = new \Bitrix\Im\V2\Entity\Url\RichData();

		return $rich
			->setName($post['TITLE'])
			->setDescription($post['PREVIEW_TEXT'])
			->setType(\Bitrix\Im\V2\Entity\Url\RichData::POST_TYPE)
		;
	}

	/**
	 * Returns true if current user has read access to the blog post.
	 * @param array $params Allowed keys: postId, userId.
	 * @param int $userId Current user's id.
	 * @return bool
	 */
	public static function checkUserReadAccess(array $params, $userId)
	{
		if(!Loader::includeModule('blog'))
			return false;

		$permissions = \CBlogPost::getSocNetPostPerms($params['postId'], true, $userId);
		return ($permissions >= BLOG_PERMS_READ);
	}

}

Youez - 2016 - github.com/yon3zu
LinuXploit