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/ajax/ |
Upload File : |
<?php use Bitrix\Main\Localization\Loc; use Burlakastudio\Realcommenter\AdditionalFields; use Burlakastudio\Realcommenter\AdditionalFieldsValues; use Burlakastudio\Realcommenter\Comments; use Burlakastudio\Realcommenter\DEBUGGER; use Burlakastudio\Realcommenter\GRANT_AND_ACCESS; use Burlakastudio\Realcommenter\RECAPTCHA2; use Burlakastudio\Realcommenter\RECAPTCHA3; use Burlakastudio\Realcommenter\STOP_FILTER; use Burlakastudio\Realcommenter\TOOLS; use Burlakastudio\Realcommenter\URL; use Burlakastudio\Realcommenter\USER; if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true) { die(); } /** * ����� "��������� ����������� D7" ��� ������� * �������� ���� �����: www.realcommenter.com * �������� ���� �����������: burlaka.studio * ����� � ����������: ������� ������� (AlexeyGfi) -> alexeygfi@gmail.com */ /** * ���� ������ �� ���������� * * �������� � ����������: * * � talk_id - ��� ��������� * ! ������ �� ��� ������ (� � ���� �������� �� ���� � ��� ��� ������) * * � talk_url - ��� ������, �� ������� �������� ����������� * ! ��������, �� �� ������ (�� ��� ���� ����� �������� �����������) * ...� ���� ���� ������ ��� - ������ * * � target_node - �����������, ������ � ��������. ��������� ������ ���������� * * � form_data * ������ � �����: * TEXT - ���������� ������ ����� � ������������ (����� � �� ��!!!) * * (??? ���� �� ������, ��� ���� ����� �����������) * ADDITIONAL_FIELD:23 * ADDITIONAL_FIELD:25 * � ������������ ��� * */ /** * ������ � �������������� (����) * � �� �����������, � �� ���� ��� � ��������� ���������� �������� ������������� ��������������� * � (?! ������ ������������� ������ ��������) * � ��������� ���������� ������ ����������� �����, � ���������� �� �������� �� � ����� �� �� * � ���� ��: * .. ����� ��������/ * .. ��������� ��������� ��������/ * .. ����� ������� (��� ���������� � ��������� ����������) * .. ��������� ������� (��� ���������� � ��������� ����������) * ...�: * - ���������� ���������� * - ���������� �� ������� * * ������ � �������������� (������) * - ������� �������� ������� �������������� * - ������ ������� ������ �� ��������� ����������� * - ������ ������� ������ �� ����������� ���������� * * * �� ��������� �� ����������, ����: * � ��� ������� (��) * � ��� ������ �������� �����, �� ��� �� �������� * (����������, ������, ��� ������, ���.���� �� ��������...) * � �������� ����-����� � �� �������� �� ����� * * * �������� ���������, ����: * � ������� ���������� ���� ������� ����� * � �������� ����-����� � ������� �������� �� ������� � ������������: * - ������� * - ������ ����-��� */ /** * @var array $arParams */ // ��� ������, �� ������� ����������� $url = $posts['talk_url']; //$urlInfo = URL::get_info(0, $url, $arParams['TALK_GROUP_ID'], true); $urlInfo = URL::getInfo([ 'url' => $url, 'groupId' => $arParams['TALK_GROUP_ID'], 'createIfNotFound' => true ]); // ��� ����, � �������� ��������� ���� ����������� //$urlId = $urlInfo['ID']; $commentId = (int)htmlspecialchars($posts['target_node']); $currentInfo = Comments::getCommentInfo($commentId/*, $urlInfo*/); $userInfo = USER::get_info(); if ( // �� ����������� ����� empty($userInfo) // ��� ��������� �� ���� || empty($urlInfo) // ������ ��� ����������, �� ��������� �� ���� ��� || ($commentId && empty($currentInfo)) // ���� ������������� (������ �������?) || !GRANT_AND_ACCESS::may_comment($arParams) // ����������� �� �� ������� ������� ���������� (������ ���������?) || !GRANT_AND_ACCESS::have_access_by_special_case_of_comment( $commentId, $arParams) // �� ����� // ... ��� ������� ����, � ������ �������� ����� ����� ������������ ���� ����������� // � �� ��������� || ( ( $userInfo['ID'] != $currentInfo['UF_USER_ID'] || !GRANT_AND_ACCESS::may_edit_comment_like_author( $currentInfo['UF_USER_ID'], $currentInfo['UF_CREATED_DATE'] ) ) && !GRANT_AND_ACCESS::is_any_moder($arParams) ) // (!!!) ������� �������� �� ���������� ������. // ��� ����� ������������� � ����� ����� ��������������� �������� ������, // ���� ����� �� �����, �� ������������ ����� (� ����� ���������� �������) // // ����������� ������� �� �������, ������ ���������� �� ����� ������������� (� ��� ��� ����� ����� o_O?) // ...����� ���� ����������� ����� ���������� // || ( // \Burlakastudio\Realcommenter\GRANT_AND_ACCESS::restricted_depth( // $arParams, $current_info[ 'UF_DEPTH_LEVEL' ] ) // && $user_info[ 'ID' ] != $current_info[ 'UF_USER_ID' ] // ) ) { DEBUGGER::error( Loc::getMessage('OPERATION_ACCESS_DENIED'), [], false ); $json_return['ERROR'][] = Loc::getMessage('OPERATION_ACCESS_DENIED'); } /** * ������� ����� �������� ��� */ $formData = $posts['form_data']; if (!TOOLS::all_required_variables_set($formData, $arParams)) { DEBUGGER::error( Loc::getMessage('REQUIRED_DATA_NOT_COMPLETE') ); $json_return['ERROR'][] = Loc::getMessage('REQUIRED_DATA_NOT_COMPLETE'); } // ���� ��� ��������� ��� - ������� if (!empty($formData['ADDI'])) { /** * Return result of true or false and reorganize $formData['ADDI'] * If something missing, it will mark as null valued key */ if (!AdditionalFields::allRequiredSet($arParams['TALK_GROUP_ID'], $formData['ADDI'])) { DEBUGGER::error( Loc::getMessage('NOT_ALL_REQUIRED_FILLS_FILED') ); $json_return['ERROR'][] = Loc::getMessage('NOT_ALL_REQUIRED_FILLS_FILED'); } else if (!GRANT_AND_ACCESS::is_any_moder($arParams)) { $smthWrongWithText = false; foreach ($formData['ADDI'] as $key => $value) { if (STOP_FILTER::text_must_be_stopped($value, true)) { $smthWrongWithText = true; break; } } if ($smthWrongWithText) { DEBUGGER::error( Loc::getMessage('STOP_FILTER_FIRED'), [], false ); $json_return['ERROR'][] = Loc::getMessage('STOP_FILTER_FIRED'); $json_return = array_merge($json_return, $smthWrongWithText); } } } // ���� ��� �������� ����� � ��� ���������� - ���� �� �� if (empty($formData['UF_COMMENT']) && empty($formData['ADDI'])) { DEBUGGER::error( Loc::getMessage('REQUIRED_DATA_NOT_COMPLETE') ); $json_return['ERROR'][] = Loc::getMessage('REQUIRED_DATA_NOT_COMPLETE'); } if ( !$json_return['ERROR'] && $formData['UF_COMMENT'] && !GRANT_AND_ACCESS::is_any_moder($arParams) ) { $smthWrongWithText = STOP_FILTER::text_must_be_stopped($formData['UF_COMMENT'], true); if ($smthWrongWithText) { DEBUGGER::error( Loc::getMessage('STOP_FILTER_FIRED'), [], false ); $json_return['ERROR'][] = Loc::getMessage('STOP_FILTER_FIRED'); $json_return = array_merge($json_return, $smthWrongWithText); } } if ( !$json_return['ERROR'] && $formData['UF_SIGNATURE'] && !GRANT_AND_ACCESS::is_any_moder($arParams) ) { $smthWrongWithText = STOP_FILTER::text_must_be_stopped($formData['UF_SIGNATURE']); if ($smthWrongWithText) { DEBUGGER::error( Loc::getMessage('STOP_FILTER_FIRED'), [], false ); $json_return['ERROR'][] = Loc::getMessage('STOP_FILTER_FIRED'); $json_return = array_merge($json_return, $smthWrongWithText); } } if (!RECAPTCHA2::recaptcha2_response_check($formData)) { DEBUGGER::error( Loc::getMessage('RECAPTCHA_RESPONSE_NOT_VALID') ); $json_return['ERROR'][] = Loc::getMessage('RECAPTCHA_RESPONSE_NOT_VALID'); } if (!RECAPTCHA3::recaptcha3_response_check($formData)) { DEBUGGER::error( Loc::getMessage('RECAPTCHA_RESPONSE_NOT_VALID') ); $json_return['ERROR'][] = Loc::getMessage('RECAPTCHA_RESPONSE_NOT_VALID'); } if (!$json_return['ERROR']) { if ($formData['UF_COMMENT']) { $editorType = $formData['editor_type'] ?: 'html'; STOP_FILTER::trim_html($formData['UF_COMMENT'], $editorType); //���� �� ��� � ��� �� �������������� unset($formData['editor_type']); } try { if ($formData['ADDI']) { /** * !!! * We get id of literally fields, * but we need to update values for particular comment */ AdditionalFieldsValues::updateForComment( $commentId, $formData['ADDI'], $arParams ); } Comments::updateSingle($commentId, $formData); $json_return['RESULT'] = $commentId; } catch (\Exception $e) { $json_return['ERROR'][] = Loc::getMessage($e->getMessage()); } }