private function QueryOrderData($arFilter, $arOptions = null) { if (!is_array($arOptions)) { $arOptions = array(); } $requestMethod = isset($arOptions["REQUEST_METHOD"]) && is_string($arOptions["REQUEST_METHOD"]) ? strtoupper($arOptions["REQUEST_METHOD"]) : ""; if ($requestMethod === "") { $requestMethod = "GET"; } $siteUrl = !empty($_SERVER["HTTP_HOST"]) ? ($GLOBALS["APPLICATION"]->IsHTTPS() ? "https" : "http") . "://" . $_SERVER["HTTP_HOST"] : ""; if ($requestMethod === "GET") { if ($siteUrl !== "") { $arFilter["CRM_SITE_URL"] = $siteUrl; } $request = array("METHOD" => "GET", "PATH" => CHTTP::urlAddParams($this->path, $arFilter), "HEADERS" => array()); } else { $request = array("METHOD" => "POST", "PATH" => $this->path, "HEADERS" => array(), "BODY" => array()); foreach ($arFilter as $key => $val) { $request["BODY"][$key] = $val; } if ($siteUrl !== "") { $request["BODY"]["CRM_SITE_URL"] = $siteUrl; } } $response = $this->proxy->Send($request); if (is_array($response) && isset($response["BODY"])) { return $response["BODY"]; } $errors = array(); foreach ($this->proxy->GetErrors() as $error) { $errors[] = sprintf("[%s] %s", $error[0], $error[1]); } $status = implode(" ", $errors); $this->AddError("GD1", $status); CCrmExternalSale::Update($this->externalSaleId, array("LAST_STATUS" => $status)); return null; }
if (isset($_REQUEST["__BX_CRM_QUERY_STRING_PREFIX"])) { $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; }
$arParams["PATH_TO_SYNC"] = trim($arParams["PATH_TO_SYNC"]); if (strlen($arParams["PATH_TO_SYNC"]) <= 0) { $arParams["PATH_TO_SYNC"] = $APPLICATION->GetCurPage() . "?" . $arParams["PAGE_VAR"] . "=sync&" . $arParams["ID_VAR"] . "=#id#"; } $arResult["FatalErrorMessage"] = ""; $arResult["ErrorMessage"] = ""; $arResult["PATH_TO_INDEX"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_INDEX"], array()); $arResult["PATH_TO_EDIT"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_EDIT"], array("id" => 0)); if (strlen($arResult["FatalErrorMessage"]) <= 0) { if ($_SERVER["REQUEST_METHOD"] == "GET" && strlen($_REQUEST["delete_id"]) > 0 && check_bitrix_sessid()) { CCrmExternalSale::Delete($_REQUEST["delete_id"]); CAgent::RemoveAgent("CCrmExternalSaleImport::DataSync(" . intval($_REQUEST["delete_id"]) . ");", "crm"); LocalRedirect($APPLICATION->GetCurPageParam("", array("sessid", "delete_id", "check_id", "sync_id"))); } elseif ($_SERVER["REQUEST_METHOD"] == "GET" && strlen($_REQUEST["check_id"]) > 0) { $errorMessage = ""; $proxy = new CCrmExternalSaleProxy($_REQUEST["check_id"]); if (!$proxy->IsInitialized()) { $errorMessage .= GetMessage("CRM_EXT_SALE_C1NO_CONNECT") . "<br>"; } else { $request = array("METHOD" => "GET", "PATH" => "/bitrix/admin/sale_order_new.php", "HEADERS" => array(), "BODY" => array()); $response = $proxy->Send($request); if ($response == null) { $errorMessage .= GetMessage("CRM_EXT_SALE_C1ERROR_CONNECT") . "<br>"; $arErr = $proxy->GetErrors(); foreach ($arErr as $err) { $errorMessage .= sprintf("[%s] %s<br>", $err[0], htmlspecialcharsbx($err[1])); } } elseif ($response["STATUS"]["CODE"] != 200) { $errorMessage .= sprintf(GetMessage("CRM_EXT_SALE_C1STATUS") . "<br>", $response["STATUS"]["CODE"], $response["STATUS"]["PHRASE"]); } elseif (strpos($response["BODY"], "form_auth") !== false) { $errorMessage .= GetMessage("CRM_EXT_SALE_C1NO_AUTH") . "<br>";