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

namespace Burlakastudio\Realcommenter;

use Bitrix\Main\Context;
use Exception;

require_once 'RequestInfoTable.php';

class RequestInfo extends REALCOMMENTER_HL_GENERAL_PROVIDER
{

    protected static function getTableClass()
    {
        return '\Burlakastudio\Realcommenter\RequestInfoTable';
    }

    /**
     * @param int $comment_id
     *
     * @throws Exception
     */
    public static function saveRequestFor($comment_id = 0)
    {

        if (!$comment_id) {
            return;
        }

        $request_info = self::collectCommentRequestInfo();
        $request_info['UF_COMMENT_ID'] = $comment_id;

        $new_row = self::get_free_row([
            'UF_COMMENT_ID' => false
        ]);

        if (!$new_row['ID']) {
            throw new Exception('REQUEST_DB_ERROR');
        } else {
            self::update($new_row['ID'], $request_info);
        }

    }

    /**
     * �������� ���������� �� ���������� ��� ���� �� �������� �������
     *
     * @return array
     */
    private static function collectCommentRequestInfo()
    {
        $result = [];
        $server = Context::getCurrent()->getServer();

        $keysConformity = self::commentServerKeysToPreserve();
        foreach ($keysConformity as $gk => $serverKey) {
            $result[$gk] = $server->get($serverKey);
        }

        return $result;
    }

    /**
     * ��� �� ����� ����������
     *
     * 'REMOTE_ADDR', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_REAL_IP', 'HTTP_USER_AGENT', 'HTTP_REFERER', 'HTTP_COOKIE', 'SERVER_PORT', 'REQUEST_URI'
     *
     * @return array
     */
    private static function commentServerKeysToPreserve()
    {
        /**
         * @var RequestInfoTable $tableClass
         */
        $tableClass = self::getTableClass();

        $collectFields = $tableClass::getMap();
        $collectFields = self::normalizeCollectFields(array_keys($collectFields));

        return $collectFields;
    }

    /**
     * ��������: � ������� ��� � ������,
     * �� ������ ������ ������� ����� �� ���������� ��������� �������������
     *
     * ������ �� ���, ������ ������� �� HTTP_* ��������� �� UF_*
     *
     * �� ��� �� HTTP_X_FORWARDED_FOR ������ ��� UF_X_FORWARDED_FOR
     *
     * � �� �� ����, ��� ��� ��� ��� ������������ � ��������������,
     * ������ ��� (������ � ��, ������ �� ������� �� HTTP_) ���� ������� �� UF_
     *
     * � ��������, ��� ��� ����� �����, ��� UF_ ����� ��������, ��������:
     *      UF_REQUEST_URI �> $_SERVER[ 'REQUEST_URI' ]
     *      UF_REMOTE_ADDR �> $_SERVER[ 'REMOTE_ADDR' ]
     *
     * ... � ����� �����, ��� UF_ ����� ������� �� HTTP_:
     *      UF_X_FORWARDED_FOR �> $_SERVER[ 'HTTP_X_FORWARDED_FOR' ]
     *      UF_X_REAL_IP �> $_SERVER[ 'HTTP_X_REAL_IP' ]
     *
     * @param array $collectFields
     *
     * @return array
     */
    private static function normalizeCollectFields($collectFields = [])
    {

        $normalized = [];

        foreach ($collectFields as $cf) {

            $cfClear = str_replace('UF_', '', $cf);
            $cfHttp = str_replace('UF_', 'HTTP_', $cf);

            if ($_SERVER[$cfClear]) {
                $normalized[$cf] = $cfClear;
            } else if ($_SERVER[$cfHttp]) {
                $normalized[$cf] = $cfHttp;
            }
        }

        return $normalized;

    }

    public static function getInfoByComment($commentId = null)
    {
        return self::getListEx([
            'filter' => [
                'UF_COMMENT_ID' => $commentId
            ],
            'limit' => 1
        ]);
    }

}

Youez - 2016 - github.com/yon3zu
LinuXploit