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\Comments; use Burlakastudio\Realcommenter\DEBUGGER; use Burlakastudio\Realcommenter\GRANT_AND_ACCESS; use Burlakastudio\Realcommenter\HTML_TEMPLATER; use Burlakastudio\Realcommenter\OPTIONS; use Burlakastudio\Realcommenter\RECAPTCHA2; use Burlakastudio\Realcommenter\RECAPTCHA3; use Burlakastudio\Realcommenter\RequestInfo; 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 - * ����: * 0 - ������� ������ * !0 - ����, �� ������ ����������� ����� * * � form_data * ������ � �����: * TEXT - ���������� ������ ����� � ������������ (����� � �� ��!!!) * * (??? ���� �� ������, ��� ���� ����� �����������) * ADDI[#additional_fld_id#]:��� ��� ����������� ������� * ADDI[#additional_fld_id#]:� ����� � �������� * = ������������ ��� */ /** * ������ � �������������� (����) * � �� �����������, � �� ���� ��� � ��������� ���������� �������� ������������� ��������������� * � (?! ������ ������������� ������ ��������) * � ��������� ���������� ������ ����������� �����, � ���������� �� �������� �� � ����� �� �� * � ���� ��: * .. ����� ��������/ * .. ��������� ��������� ��������/ * .. ����� ������� (��� ���������� � ��������� ����������) * .. ��������� ������� (��� ���������� � ��������� ����������) * ...�: * - ���������� ���������� * - ���������� �� ������� * * ������ � �������������� (������) * - ������� �������� ������� �������������� * - ������ ������� ������ �� ��������� ����������� * - ������ ������� ������ �� ����������� ���������� * * �� ��������� �� ����������, ����: * � ��� ������� (��) * � ��� ������ �������� �����, �� ��� �� �������� * (����������, ������, ��� ������, ���.���� �� ��������...) * � �������� ����-����� � �� �������� �� ����� * � ���������� � ���� * * �������� ���������, ����: * � ������� ���������� ���� ������� ����� * � �������� ����-����� � ������� �������� �� ������� � ������������: * - ������� * - ������ ����-��� */ /** * @var array $arParams */ // ��� ������, �� ������� ����������� $urlOptions = [ 'url' => $posts['talk_url'], 'groupId' => $arParams['TALK_GROUP_ID'], 'createIfNotFound' => true, ]; $urlInfo = URL::getInfo($urlOptions); if (!$urlInfo['UF_PAGE_TITLE'] || OPTIONS::get('keep_actual')) { $titles = [ 'browserTitle' => $posts['browserTitle'], 'h1Title' => $posts['h1Title'], ]; $titleOptions = [ 'id' => $urlInfo['ID'], 'titles' => $titles ]; URL::pageTitleCheckAndSync($titleOptions); } // ��� ����, � �������� ��������� ���� ����������� $URL_ID = $urlInfo['ID']; /** * ���� ����� ������� ��� ����� �� �����������, * ����� �� ������� target_node == ��� ����������, �� ������ � �������� ����� * * ���� �� �� ������� (����� ��������� �� ������� ������), * target_node ����� ����� ���, * �� ��� ���� ������ �� ���������� �������� target_position (top | bottom) */ $targetNodeId = (int)htmlspecialchars($posts['target_node']); $targetInfo = Comments::getCommentInfo($targetNodeId, $urlInfo); $targetPosition = htmlspecialchars($posts['target_position']); if ($targetPosition) { $targetPosition = ($targetPosition === 'bottom') ?: 'top'; } // ������� ����������� ������ ���������� if ($targetInfo) { $commentDepthLevel = (int)$targetInfo['UF_DEPTH_LEVEL'] + 1; } else { $commentDepthLevel = 1; } if ( empty($urlInfo) || ($targetNodeId && empty($targetInfo) && !$targetPosition) || !GRANT_AND_ACCESS::may_comment($arParams) || !GRANT_AND_ACCESS::have_access_by_special_case_of_comment( $targetNodeId, $arParams ) || // �������� �� �� ���� ������� ������ �����������, � ����� ������ ������������� GRANT_AND_ACCESS::restrictedDepth( $arParams, $commentDepthLevel - 1) ) { DEBUGGER::error( Loc::getMessage('OPERATION_ACCESS_DENIED') ); $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 ($smthWrongWithText = STOP_FILTER::text_must_be_stopped($value, 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 (!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 ( !isset($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 ( !isset($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 (!isset($json_return['ERROR']) && $URL_ID) { /** * 2019.10.18 * �������. * * � ������� ��� ����� ������������ ��, �� ����� �������� ��� � * ��� ��������� ��������� ��������� * 1\n2\n3 * �������� � 1<br>2<br>3 * ...� ��� �� ������� */ if ($formData['UF_COMMENT'] && $formData['editor_type'] === 'html') { STOP_FILTER::trim_html($formData['UF_COMMENT']); } // TODO: � ������ - ������� �������� �������� � UF_PROOF_AWAITING // TODO: UF_SMILES_ACTIVE - ������ �� ����� // TODO: �������� ������� - UF_RATE_VALUE // TODO: ������� ������������ �� ���������� - UF_PROOF_AWAITING /** * ��������� ���������� ������� ��: * - ���� ��� ��������� ��� � �����-�� �� �� ������ ��������� �� ������� * - ���� ����� ��� ������� ���������� * * �� ������ ���, � ����� �� ��������� * (� ��������� �������� �� ��������� ����) * ����� ���� ����������� �������� ��� �������. * * �� ��� ��������� � ����������, �� ���� ������� � ����� ���� */ $commentActivity = Comments::calculateActive($arParams); if ( $commentActivity && $formData['ADDI'] && !GRANT_AND_ACCESS::is_any_moder($arParams) ) { $moderableFields = AdditionalFields::getModerableFields($urlInfo['UF_GROUP_ID']); $commentActivity = (int)(empty($moderableFields)); } $userInfo = USER::get_info(); $commentInfo = [ 'UF_ACTIVE' => $commentActivity, 'UF_COMMENT' => $formData['UF_COMMENT'], 'UF_SIGNATURE' => $formData['UF_SIGNATURE'], 'UF_EMAIL' => $formData['UF_EMAIL'] ?: $userInfo['EMAIL'], 'UF_UPLOADS' => (!empty($formData['UF_UPLOADS']) ? serialize($formData['UF_UPLOADS']) : ''), 'UF_USER_ID' => $userInfo['ID'], // ��� ���������� //'UF_SMILES_ACTIVE' => $COMMENT_SMILES_ACTIVE, //'UF_RATE_VALUE' => $COMMENT_RATE_VALUE, //'UF_PROOF_AWAITING' => $COMMENT_PROOF_AWAITING, 'UF_URL_ID' => $URL_ID, 'UF_PARENT_ID' => $targetNodeId, // ����������� ����������� (��� ������� ������) 'UF_DEPTH_LEVEL' => $commentDepthLevel, 'UF_CREATED_DATE' => new \Bitrix\Main\Type\DateTime(), ]; try { /** * ��� ���������� ���������� ��������� �����. * ������ ������ ��������� ��� ���� ��� */ $commentInfo['ADDI'] = $formData['ADDI'] ?? null; $commentId = Comments::new_comment($commentInfo, $arParams); /** * ���� ���� ����������� ���������, * ����� �� ���� ������ ������������ */ if (!$commentInfo['UF_ACTIVE']) { $json_return['MSG_OF_RESULT'] = str_replace( '#MSG#', Loc::getMessage('ITAPE_SET_AS_UNACTIVE'), HTML_TEMPLATER::get('sent_to_moderation', $arParams) ); } else { $json_return['RESULT'] = $commentId; } /** * ��������� ����� ������� */ RequestInfo::saveRequestFor($commentId); } catch (Exception $e) { $json_return['ERROR'][] = Loc::getMessage($e->getMessage()) ?: $e->getMessage(); } }