/** * Creates an importer * * @param $saleId ID of the external shop (CCrmExternalSale) */ public function __construct($saleId) { $this->externalSaleId = intval($saleId); $this->proxy = new CCrmExternalSaleProxy($this->externalSaleId); if (!$this->proxy->IsInitialized()) { $this->AddError("PA1", sprintf("External site '%d' is not found", $this->externalSaleId)); $this->proxy = null; } }
$prefix = $_REQUEST["__BX_CRM_QUERY_STRING_PREFIX"]; $prefix = preg_replace("/%0D|%0A|\r|\n/i", "", $prefix); if (substr($prefix, 0, strlen("/bitrix/tools/crm_sale_proxy.php?")) == "/bitrix/tools/crm_sale_proxy.php?") { $prefix = substr($prefix, strlen("/bitrix/tools/crm_sale_proxy.php?")); } if (substr($path, 0, strlen($prefix)) != $prefix) { $path = $prefix . $path; } } $path = ltrim($path, "/"); if (($pos = strpos($path, "/")) !== false) { $externalSaleId = intval(substr($path, 0, $pos)); $path = substr($path, $pos); } $proxy = new CCrmExternalSaleProxy($externalSaleId); if (!$proxy->IsInitialized()) { die("External site is not found"); } $arPath = parse_url($path); $arAvailableUrls = array("/bitrix/admin/sale_order_edit.php", "/bitrix/components/bitrix/sale.ajax.delivery.calculator/templates/input/ajax.php", "/bitrix/admin/sale_order_new.php", "/bitrix/admin/sale_order_detail.php", "/bitrix/admin/sale_order_print.php", "/bitrix/admin/sale_print.php", "/bitrix/admin/sale_product_search.php", "/bitrix/admin/user_search.php", "/bitrix/admin/cat_product_search_dialog.php", "/bitrix/components/bitrix/sale.ajax.locations/templates/.default/ajax.php", "/bitrix/components/bitrix/sale.ajax.locations/templates/.default/proceed.js", "/bitrix/js/main/json/json2.min.js", "/bitrix/js/main/json/json2.js", "/bitrix/components/bitrix/catalog.product.search/templates/.default/style.css", "/bitrix/components/bitrix/catalog.product.search/templates/.default/script.js", "/bitrix/components/bitrix/sale.location.selector.search/get.php", "/bitrix/components/bitrix/sale.location.selector.steps/get.php", "/bitrix/components/bitrix/sale.location.selector.system/get.php", "/bitrix/components/bitrix/sale.location.import/get.php", "/bitrix/components/bitrix/sale.location.selector.search/templates/.default/script.js", "/bitrix/components/bitrix/sale.location.selector.steps/templates/.default/script.js", "/bitrix/components/bitrix/sale.location.selector.steps/templates/.default/style.css", "/bitrix/components/bitrix/sale.location.import/templates/.default/script.js", "/bitrix/components/bitrix/sale.location.import/templates/admin/script.js", "/bitrix/components/bitrix/sale.ajax.locations/templates/.default/style.css", "/bitrix/js/sale/core_iterator.js", "/bitrix/js/sale/core_ui_autocomplete.js", "/bitrix/js/sale/core_ui_chainedselectors.js", "/bitrix/js/sale/core_ui_combobox.js", "/bitrix/js/sale/core_ui_dynamiclist.js", "/bitrix/js/sale/core_ui_etc.js", "/bitrix/js/sale/core_ui_fileasyncloader.js", "/bitrix/js/sale/core_ui_itemtree.js", "/bitrix/js/sale/core_ui_pager.js", "/bitrix/js/sale/core_ui_widget.js"); if (!in_array($arPath["path"], $arAvailableUrls)) { die("Page is not found"); } $path = $arPath["path"] . "?" . $arPath["query"]; $request = array("METHOD" => $_SERVER["REQUEST_METHOD"], "PATH" => $path, "HEADERS" => array(), "BODY" => array()); $request["PATH"] = str_replace("CRM_MANAGER_USER_ID", "CMUI", $request["PATH"]); if ($_SERVER["REQUEST_METHOD"] == "POST") { foreach ($_POST as $key => $val) { $request["BODY"][$key] = $val; } $request["BODY"]["CRM_MANAGER_USER_ID"] = intval($USER->GetID());