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/CACHE.php
<?php
/**
 * ����� "��������� ����������� D7" ��� �������
 * �������� ���� �����: www.realcommenter.com
 * �������� ���� �����������: burlaka.studio
 * ����� � ����������: ������� ������� (AlexeyGfi) -> alexeygfi@gmail.com
 */

namespace Burlakastudio\Realcommenter;

class CACHE
{

    const HAVE_CACHE = false;

    public static function getTtl()
    {
        return 36000000;
    }

    public static function realcommenter_OnCommentEvented(\Bitrix\Main\Event $e)
    {

        $info = $e->getParameter('comment_info');

        /**
         * ID ����� ������ �� � $comment_info (��������, ����� �������������),
         * � � comment_id
         */
        if (!$info['ID']) {
            $id = (int)$e->getParameter('comment_id');
            if ($id) {
                $info = COMMENTS::getCommentInfo($id);
            }
        }

        self::commentsCacheComplexDrop($info);
    }

    public static function commentsCacheComplexDrop ($commentInfo = null)
    {
        if (!$commentInfo || !$commentInfo['UF_URL_ID']) {
            return;
        }

        $cacheObj = self::getCacheObj();
        if (!$cacheObj) {
            return;
        }

        // �� ��� ������������
        $cacheKey = self::get_url_key_for_comments($commentInfo['UF_URL_ID']);
        $cacheObj->clean($cacheKey, TOOLS::getModuleName());
        // �� ����������
        $cacheKey = self::getKeyForSingleComment($commentInfo['ID']);
        $cacheObj->clean($cacheKey, TOOLS::getModuleName());

        // ��������� �����������
        self::dropLastCommentsCache();
    }

    public static function realcommenter_OnUrlEvented(\Bitrix\Main\Event $e)
    {

        /**
         * 'record_id' => &$record_id,
         * 'record_Fields' => &$record_Fields,
         * 'arParams' => &$arParams
         */
        $url = '';

        $record_Fields = $e->getParameter('record_Fields');
        if (empty($record_Fields) || !$record_Fields['UF_URL']) {
            $record_id = $e->getParameter('record_id');
            if (!$record_id) {
                return;
            }

            $url_info = URL::get_info($record_id);
            if (!empty($url_info)) {
                $url = $url_info['UF_URL'];
            }

        } else {
            $url = $record_Fields['UF_URL'];
        }

        if (!$url) {
            return;
        }

        $cache_obj = self::getCacheObj();
        if (!$cache_obj) {
            return;
        }

        // �� ������������
        $cache_key = self::get_url_key($url);
        $cache_obj->clean($cache_key, TOOLS::getModuleName());

        // ��������� �����������
        self::dropLastCommentsCache();
    }

    /**
     * ����� ������� ���� ������ ������.
     * ������ ��������� � ������������
     *
     * @param null $_arg
     */
    public static function realcommenter_OnUserEvented($_arg = null)
    {

        $user_id = null;

        if ($_arg instanceof \Bitrix\Main\Event) {
            //$parameters= $_arg->getParameters();
        } else if (is_numeric($_arg)) {
            // ����� �������� - � �������� ����������� ��� ��������� ����������
            $user_id = $_arg;
        } else if (is_array($_arg)) {
            $user_id = $_arg['ID'];
        }

        if (!$user_id) {
            return;
        }

        self::clean_user_cache($user_id);
    }

    public static function clean_user_cache(&$user_id = null)
    {
        $cache_obj = self::getCacheObj();
        if (!$cache_obj) {
            return;
        }

        // �� ������������
        $cache_key = self::get_user_key($user_id);
        $cache_obj->clean($cache_key, TOOLS::getModuleName());
    }

    public static function realcommenter_OnVoteByUserEvented(\Bitrix\Main\Event $e)
    {

        $user_id = $e->getParameter('user_id');
        if (!$user_id) {
            $user_id = USER::get_id();
        }

        if (!$user_id) {
            return;
        }

        $cache_obj = CACHE::getCacheObj();
        $cache_key = CACHE::get_user_key_for_voting($user_id);

        $cache_obj->clean($cache_key, TOOLS::getModuleName());
    }

    public static function getCacheObj()
    {
        return \Bitrix\Main\Application::getInstance()->getCache();
    }

    public static function get_url_key(&$url_url = 0)
    {
        return TOOLS::getModuleName() . '_URL_' . $url_url;
    }

    public static function get_url_key_for_comments(&$url_id = 0)
    {
        return TOOLS::getModuleName() . '_URL2COMM_' . $url_id;
    }

    public static function getKeyForSingleComment($commentId = null)
    {
        return TOOLS::getModuleName() . '_COMMENTS_' . $commentId;
    }

    public static function getLastCommentsCacheKey()
    {
        return TOOLS::getModuleName() . '_LAST_COMMENTS';
    }

    protected static function dropLastCommentsCache()
    {
        $cacheObj = self::getCacheObj();
        if (!$cacheObj) {
            return;
        }

        // ��������� �����������
        $taggedCache = \Bitrix\Main\Application::getInstance()->getTaggedCache();
        if ($taggedCache) {
            $taggedCache->clearByTag(self::getLastCommentsCacheKey());
        }
        
        $cacheKey = self::getLastCommentsCacheKey();
        $cacheObj->clean($cacheKey, TOOLS::getModuleName());
    }

    public static function get_user_key(&$user_id = 0)
    {
        return TOOLS::getModuleName() . '_USR_' . $user_id;
    }

    public static function get_user_key_for_voting(&$user_id = 0)
    {
        return TOOLS::getModuleName() . '_USR_VOTING_' . $user_id;
    }

    public static function getTalkGroupKey(&$talk_id = 0)
    {
        return TOOLS::getModuleName() . '_GROUP_TALK_' . $talk_id;
    }

}

Youez - 2016 - github.com/yon3zu
LinuXploit