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/rospirotorg.ru/bitrix/modules/burlakastudio.realcommenter/lib/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/burlakastudio.realcommenter/lib/COUNTER.php
<?php
/**
 * ����� "��������� ����������� D7" ��� �������
 * �������� ���� �����: www.realcommenter.com
 * �������� ���� �����������: burlaka.studio
 * ����� � ����������: ������� ������� (AlexeyGfi) -> alexeygfi@gmail.com
 */

namespace Burlakastudio\Realcommenter;

class COUNTER {
	
	public static function OnRecalculateReferenceEvent( \Bitrix\Main\Event $e ) {
		
		/**
		 * ����� ��������� ��������� ������������ � ��������� �����.
		 *
		 * ����� ������ ������� ������:
		 *      - �������/����� ����:
		 *              ���� � ���� ��� � ���� ����� ������ ������
		 *              ����� - ������ �������� ������� �� ������
		 *              ����������� ���� � ������� ������� ����������
		 *              ...���� ��� �������� �� ������ � ��
		 *      - �������/����� ����:
		 *              ��� ���� �� �������� ������������ ����,
		 *              ������ ������ �� ������ �� ��
		 *              � �������� ����������
		 *              ...���� ��� �������� �� ������ � ��
		 */
		
		$comment_info= $e->getParameter( 'comment_info' );
		$arParams= $e->getParameter( 'arParams' );
		
		/**
		 * ID ����� ������ �� � $comment_info (��������, ����� �������������),
		 * � � comment_id
		 */
		if( !$comment_info[ 'ID' ] ) {
			$comment_id= intval( $e->getParameter( 'comment_id' ) );
			if( $comment_id ) {
				$comment_info= COMMENTS::getCommentInfo( $comment_id );
			}
			
		}
		
		if( empty( $comment_info ) || !$comment_info[ 'UF_URL_ID' ] ) {
			return;
		}
		
		// ���� �� ������ ������ � ���� ���
		$arParams[ 'SKIP_CACHE' ]= true;
		$tree= [];
		$moderator= false;
		
		COMMENTS::getStructureOfUrlComments( $comment_info[ 'UF_URL_ID' ], $arParams, $moderator, $tree );
		
		$url_info= URL::get_info( $comment_info[ 'UF_URL_ID' ] );
		if( !$url_info ) {
			return;
		}
		
		/**
		 * � ��� ���� ������� ����� ��������� ������,
		 * ��������� �� �������� �����, ��� ��� ���������� �����������
		 * ����������� ����� ����� ��������� ������������ ������ ������ �����.
		 *
		 * ��� �� ...[ 'INFO' ][ 'COMM_STAT' ]
		 * ���� �� �� �����, � ������ ��� ������������
		 *
		 * ��, ��� ����� ������ ����� ������� ������ - �������� �������,
		 * ������ �������� ��� ��� � ���� ���� ������������ (UF_COMMENTS_INSIDE)
		 * �� ��������� � ��������� - ������� ���
		 *
		 */
		
		try{
			self::scan_and_check_comment_counters( $tree );
		} catch( \Exception $e ) {
			ErrorNotificator::sendError($e->getMessage());
		}
		
		/**
		 * �� � ����� ������� ���������, ����� �� ������� ���� ������ ����
		 */
		
		$comments_in_url= 0;
		
		foreach ( $tree as &$node ) {
			
			/**
			 * ���� ����� ���� ���������� ������ �����.
			 * �� � ����� �� ��.
			 * ��� ��� ����, � ���������� ����� ���� � ������ ���� (+1)
			 */
			
			if( !COMMENTS::in_special_case( 0, $arParams, $node[ 'INFO' ] ) ) {
				$comments_in_url++;
			}
			
			
			if( !$node[ 'INFO' ][ 'COMM_STAT' ] ) {
				continue;
			}
			
			$comments_in_url+= $node[ 'INFO' ][ 'COMM_STAT' ];
			
		}
		
		if( $url_info[ 'UF_COMMENTS_INSIDE' ] != $comments_in_url ) {
			$update_result= URL::set_counter( $url_info[ 'ID' ], $comments_in_url, $arParams );
			
			if( !$update_result->isSuccess() ) {
				ErrorNotificator::sendError(implode(', ', $update_result->getErrorMessages()));
			}
		}
		
	}
	
	/**
	 * @param array $inside_tree
	 *
	 * @throws \Exception
	 */
	private static function scan_and_check_comment_counters( &$inside_tree= [] ) {
		
		if( empty( $inside_tree ) ) {
			return;
		}
		
		foreach( $inside_tree as $node ) {
			
			if( $node[ 'CHILD' ] ) {
				self::scan_and_check_comment_counters( $node[ 'CHILD' ] );
			}
			
			if( !$node[ 'INFO' ][ 'COMM_STAT' ] ) {
				$node[ 'INFO' ][ 'COMM_STAT' ]= 0;
			}
			
			if( $node[ 'INFO' ][ 'UF_COMMENTS_INSIDE' ] != $node[ 'INFO' ][ 'COMM_STAT' ] ) {
				
				/**
				 * �������� ���� ����
				 */
				
				$update_result= COMMENTS::update(
					$node[ 'INFO' ][ 'ID' ],
					[ 'UF_COMMENTS_INSIDE' => intval( $node[ 'INFO' ][ 'COMM_STAT' ] ) ]
				);
				
				if( !$update_result->isSuccess() ) {
					
					throw new \Exception(
						'Comment Counter update error: '
						. implode( ', ', $update_result->getErrorMessages() )
					);
					
				}
			}
			
		}
		
	}
	
}

Youez - 2016 - github.com/yon3zu
LinuXploit