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/abricos.chatgpt/load/ |
Upload File : |
<? /** @global CDatabase $DB */ /** @global CUser $USER */ /** @global CMain $APPLICATION */ use Bitrix\Iblock, Bitrix\Currency; define("STOP_STATISTICS", true); define("BX_SECURITY_SHOW_MESSAGE", true); require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_before.php"); IncludeModuleLangFile($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/catalog/export_yandex.php'); IncludeModuleLangFile($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/abricos.chatgpt/chatgpt_detail.php'); IncludeModuleLangFile(__FILE__); if ($_SERVER['REQUEST_METHOD'] == 'GET') { require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_after.php"); require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_admin.php"); die(); } if (!check_bitrix_sessid()) { require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_after.php"); $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED")); require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_admin.php"); die(); } $APPLICATION->SetTitle(GetMessage('YANDEX_DETAIL_TITLE')); CModule::IncludeModule("abricos.chatgpt"); CModule::IncludeModule('catalog'); CModule::IncludeModule('iblock'); if (!$USER->CanDoOperation('catalog_export_edit')) { require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_after.php"); ShowError(GetMessage('YANDEX_ERR_NO_ACCESS_EXPORT')); require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_admin.php"); die(); } if ((!isset($_REQUEST['IBLOCK_ID'])) || ($_REQUEST['IBLOCK_ID'] == '')) { require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_after.php"); ShowError(GetMessage("YANDEX_ERR_NO_IBLOCK_CHOSEN")); require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_admin.php"); die(); } $intIBlockID = $_REQUEST['IBLOCK_ID']; $intIBlockIDCheck = intval($intIBlockID); if ($intIBlockIDCheck.'|' != $intIBlockID.'|' || $intIBlockIDCheck <= 0) { require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_after.php"); ShowError(GetMessage("YANDEX_ERR_NO_IBLOCK_CHOSEN")); require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_admin.php"); die(); } else { $intIBlockID = $intIBlockIDCheck; unset($intIBlockIDCheck); } $strPerm = 'D'; $rsIBlocks = CIBlock::GetByID($intIBlockID); if (($arIBlock = $rsIBlocks->Fetch())) { $bBadBlock = !CIBlockRights::UserHasRightTo($intIBlockID, $intIBlockID, "iblock_admin_display"); if ($bBadBlock) { require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_after.php"); ShowError(GetMessage('YANDEX_ERR_NO_ACCESS_IBLOCK')); require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_admin.php"); die(); } } else { require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_after.php"); ShowError(str_replace('#ID#',$intIBlockID,GetMessage("YANDEX_ERR_NO_IBLOCK_FOUND_EXT"))); require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_admin.php"); die(); } $dbRes = CIBlockProperty::GetList( array('SORT' => 'ASC'), array('IBLOCK_ID' => $intIBlockID, 'ACTIVE' => 'Y') ); $arIBlock['PROPERTY'] = array(); while ($arRes = $dbRes->Fetch()) { $arIBlock['PROPERTY'][$arRes['ID']] = $arRes; } if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (!empty($_REQUEST['save'])) { $arErrors = array(); $type='none'; $arTypeParams = array(); if (isset($_POST['XML_DATA'][$type]) && is_array($_POST['XML_DATA'][$type])) { $arTypeParams = $_POST['XML_DATA'][$type]; /* foreach ($arTypeParams as $key => $value) { if (!in_array($key,$arTypesConfig[$type])) { unset($arTypeParams[$key]); } elseif (!array_key_exists($value,$arIBlock['PROPERTY']) && !array_key_exists($value,$arIBlock['OFFERS_PROPERTY'])) { $arTypeParams[$key] = ''; } } */ } $XML_DATA = $arTypeParams; foreach ($XML_DATA as $key => $value) { if (!$value) unset($XML_DATA[$key]); } $commonFields = []; if (!empty($_POST['COMMON_FIELDS']) && is_array($_POST['COMMON_FIELDS'])) { foreach ($_POST['COMMON_FIELDS'] as $index => $value) { if (empty($value)) continue; $commonFields[$index] = $value; } unset($index, $value); } $arSKUExport = false; if (empty($arErrors)) { $arXMLData = array( 'TYPE' => $type, 'XML_DATA' => $XML_DATA, 'CHATGPT_NO_ACTIVE' => $CHATGPT_NO_ACTIVE, 'CHATGPT_DESCR' => $CHATGPT_DESCR, 'FILTER_DATA' => $FILTER_DATA, 'FILTER_INPUT' => $FILTER_INPUT, 'FILTER_PREF' => $FILTER_PREF, ); ?><script type="text/javascript"> top.BX.closeWait(); top.BX.WindowManager.Get().Close(); top.setDetailData('<?=CUtil::JSEscape(base64_encode(serialize($arXMLData)));?>'); </script> <? die(); } else { $e = new CAdminException(array(array('text' => implode("\n",$arErrors)))); $message = new CAdminMessage(GetMessage("YANDEX_SAVE_ERR"), $e); echo $message->Show(); } } else { $aTabs = array( array("DIV" => "yandex-settings-filter", "TAB" => GetMessage('CHATGPT_TAB1_TITLE'), "TITLE" => GetMessage('CHATGPT_FILTER_DESC')), ); $tabControl = new CAdminTabControl("tabControl", $aTabs, true, true); require_once ($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_after.php"); function yand_show_selector($group, $key, $IBLOCK, $value = "") { ?><select name="FILTER_DATA[<? echo htmlspecialcharsbx($key)?>]"> <option value=""<? echo ($value == "" ? ' selected' : ''); ?>><?=GetMessage('SBER_SKIP_PROP')?></option> <? foreach ($IBLOCK['PROPERTY'] as $key => $arProp) { ?><option value="<?=$arProp['ID']?>"<? echo ($value == $arProp['ID'] ? ' selected' : ''); ?>>[<?=htmlspecialcharsbx($key)?>] <?=htmlspecialcharsbx($arProp['NAME'])?></option><? } ?></select> <? } function __addParamCode() { return '<small>(param)</small>'; } function __addParamUnit(&$IBLOCK, $intCount, $value) { return '<input type="text" size="3" name="XML_DATA[PARAMS][UNIT_'.$intCount.']" value="'.htmlspecialcharsbx($value).'">'; } function __addParamRow(&$IBLOCK, $intCount, $strParam, $strUnit,$filterPref="=",$filterInput="") { return '<tr id="CHATGPT_FILTER_tbl_'.$intCount.'"> <td>'.addParamName($IBLOCK, $intCount, $strParam).'</td> <td style="text-align: center;"> <select name="FILTER_PREF['.$intCount.']"> <option value="=" '.($filterPref=="="? 'selected':'').'>'.GetMessage('FILTER_PREF_RAVNO').'</option> <option value=">" '.($filterPref==">"? 'selected':'').'>'.GetMessage('FILTER_PREF_MAX').'</option> <option value="<" '.($filterPref=="<"? 'selected':'').'>'.GetMessage('FILTER_PREF_MIN').'</option> <option value="=!" '.($filterPref=="=!"? 'selected':'').'>'.GetMessage('FILTER_PREF_NERAVNO').'</option> <option value="z" '.($filterPref=="z"? 'selected':'').'>'.GetMessage('FILTER_PREF_ZERO').'</option> <option value="nz" '.($filterPref=="nz"? 'selected':'').'>'.GetMessage('FILTER_PREF_NOTZERO').'</option> <option value="1" '.($filterPref=="1"? 'selected':'').'>'.GetMessage('FILTER_PREF_INARRAY').'</option> </select></td> <td style="text-align: center;"> <input name="FILTER_INPUT['.$intCount.']" type="text" value="'.$filterInput.'"> </td> </tr>'; } function __addPrefRow($intCount) { $strResult='<select name=\"FILTER_PREF['.$intCount.']\">\n <option value=\"=\" '.($filterPref=="="? 'selected':'').'>'.GetMessage('FILTER_PREF_RAVNO').'</option>\n <option value=\">\" '.($filterPref==">"? 'selected':'').'>'.GetMessage('FILTER_PREF_MAX').'</option>\n <option value=\"<\" '.($filterPref=="<"? 'selected':'').'>'.GetMessage('FILTER_PREF_MIN').'</option>\n <option value=\"=!\" '.($filterPref=="=!"? 'selected':'').'>'.GetMessage('FILTER_PREF_NERAVNO').'</option>\n <option value=\"z\" '.($filterPref=="z"? 'selected':'').'>'.GetMessage('FILTER_PREF_ZERO').'</option>\n <option value=\"nz\" '.($filterPref=="nz"? 'selected':'').'>'.GetMessage('FILTER_PREF_NOTZERO').'</option>\n<option value="1" '.($filterPref=="1"? 'selected':'').'>'.GetMessage('FILTER_PREF_INARRAY').'</option> </select>'; return $strResult; } function __addInputRow($intCount) { $strResult='<input name=\"FILTER_INPUT['.$intCount.']\" type=\"text\" value=\"\">'; return $strResult; } /*************************************************************************** HTML form ****************************************************************************/ $arXmlData = array(); if (!empty($_REQUEST['XML_DATA'])) { $xmlData = base64_decode($_REQUEST['XML_DATA']); if (CheckSerializedData($xmlData)) $arXmlData = unserialize($xmlData, ['allowed_classes' => false]); unset($xmlData); } if (isset($arXmlData['CHATGPT_NO_ACTIVE'])) $CHATGPT_NO_ACTIVE = $arXmlData['CHATGPT_NO_ACTIVE']; if (isset($arXmlData['CHATGPT_DESCR'])) $CHATGPT_DESCR = $arXmlData['CHATGPT_DESCR']; if (isset($arXmlData['FILTER_DATA'])) { foreach ($arXmlData['FILTER_DATA'] as $key => $value) $filter[$key] = $value; } if (isset($arXmlData['FILTER_PREF'])) { foreach ($arXmlData['FILTER_PREF'] as $key => $value) $filterPref[$key] = $value; } if (isset($arXmlData['FILTER_INPUT'])) { foreach ($arXmlData['FILTER_INPUT'] as $key => $value) $filterInput[$key] = $value; } ?> <script type="text/javascript"> var currentSelectedType = '<? echo $type; ?>'; function switchType(type) { BX('config_' + currentSelectedType).style.display = 'none'; currentSelectedType = type; BX('config_' + currentSelectedType).style.display = 'block'; } </script> <form name="yandex_form" method="POST" action="<?=$APPLICATION->GetCurPage(); ?>"> <input type="hidden" name="lang" value="<?=LANGUAGE_ID; ?>"> <input type="hidden" name="bxpublic" value="Y"> <input type="hidden" name="Update" value="Y" /> <input type="hidden" name="IBLOCK_ID" value="<? echo $intIBlockID; ?>" /> <? echo bitrix_sessid_post(); ?> <? $tabControl->Begin(); $tabControl->BeginNextTab(); ?> <? function addParamRowJs(&$IBLOCK, $intCount, $strParam, $strUnit,$filterInput="") { ob_start(); addParamRow2($IBLOCK, $intCount, $strParam, $strUnit,$filterInput); $strResult = ob_get_contents(); ob_end_clean(); return $strResult; } function addParamName(&$IBLOCK, $intCount, $value) { ob_start(); yand_show_selector('FILTER_DATA',$intCount, $IBLOCK, $value); $strResult = ob_get_contents(); ob_end_clean(); return $strResult; } ?> <tr> <td width="40%"><? echo GetMessage('CHATGPT_NO_ACTIVE'); ?></td> <td width="60%"> <select name="CHATGPT_NO_ACTIVE"> <option value=""><?=GetMessage('CHATGPT_SKIP'); ?></option> <option value="N"<? echo($CHATGPT_NO_ACTIVE == "N" ? ' selected' : ''); ?>><?=GetMessage('CHATGPT_NO_ACTIVE_Y'); ?></option> <option value="Y"<? echo($CHATGPT_NO_ACTIVE == "Y" ? ' selected' : ''); ?>><?=GetMessage('CHATGPT_NO_ACTIVE_N'); ?></option> </select> </td> </tr> <tr> <td width="40%"><? echo GetMessage('CHATGPT_DESCR'); ?></td> <td width="60%"> <select name="CHATGPT_DESCR"> <option value=""><?=GetMessage('CHATGPT_SKIP'); ?></option> <option value="Y"<? echo($CHATGPT_DESCR == "Y" ? ' selected' : ''); ?>><?=GetMessage('CHATGPT_DESCR_Y'); ?></option> <option value="N"<? echo($CHATGPT_DESCR == "N" ? ' selected' : ''); ?>><?=GetMessage('CHATGPT_DESCR_N'); ?></option> </select> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td colspan=2 align="center"> <? if($IBLOCK_ID>0) {?> <table class="inner" id="CHATGPT_FILTER_tbl" style="width: 550px; margin: auto;"> <thead> <tr><td colspan=2><b><? echo GetMessage('CHATGPT_FILTER_TITLE'); ?></b></td> </tr> </thead> <tbody> <? $intCountF = 0; if($filter) { foreach ($filter as $arParamDetail) { echo __addParamRow($arIBlock, $intCountF, $arParamDetail, '',$filterPref[$intCountF],$filterInput[$intCountF]); ?> <? $intCountF++; } } if ($intCountF == 0) { echo __addParamRow($arIBlock, $intCountF, '', '','',''); $intCountF++; } ?> </tbody> </table> <input type="hidden" name="FILTER_COUNT" id="FILTER_COUNT" value="<? echo $intCount; ?>"> <div style="width: 100%; text-align: center;"><input type="button" onclick="addYP3(); return false;" name="CHATGPT_FILTER_add" value="<? echo GetMessage('CHATGPT_FILTER_ADDITIONAL_MORE'); ?>"></div> <? }?> </td> </tr> <? if(!$intCountF) $intCountF=1; ?> <script type="text/javascript"> BX.ready(function(){ setTimeout(function(){ window.oParamSet = { pTypeTbl: BX("CHATGPT_FILTER_tbl"), curCount: <? echo ($intCountF); ?>, intCounter: BX("FILTER_COUNT") }; },50); }); function addYP3() { var id = window.oParamSet.curCount++, newRow, oCell, strContent; id = id.toString(); window.oParamSet.intCounter.value = window.oParamSet.curCount; newRow = window.oParamSet.pTypeTbl.insertRow(window.oParamSet.pTypeTbl.rows.length); newRow.id = 'CHATGPT_FILTER_tbl_'+id; oCell = newRow.insertCell(-1); <? if($IBLOCK_ID>0) { ?> strContent = '<? echo CUtil::JSEscape(addParamName($arIBlock, 'tmp_xxx', '')); ?>'; strContent = strContent.replace(/tmp_xxx/ig, id); oCell.innerHTML = strContent; <?} else { ?> strContent = document.getElementById('CHATGPT_FILTER_tbl_0').getElementsByTagName('td')[0].innerHTML; strContent = strContent.replace('FILTER_DATA[0]', 'FILTER_DATA['+id+']'); oCell.innerHTML = strContent; <? }?> oCell = newRow.insertCell(-1); strContent = '<?=__addPrefRow($intCountF)?>'; strContent = strContent.replace(/tmp_xxx/ig, id); oCell.innerHTML = strContent; oCell = newRow.insertCell(-1); strContent = '<?=__addInputRow($intCountF)?>'; strContent = strContent.replace(/tmp_xxx/ig, id); oCell.innerHTML = strContent; } </script> <? $tabControl->EndTab(); $tabControl->Buttons(array()); $tabControl->End(); require_once ($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_admin.php"); } }