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;
 }
Ejemplo n.º 2
0
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    foreach ($_POST as $key => $val) {
        $request["BODY"][$key] = $val;
    }
    $request["BODY"]["CRM_MANAGER_USER_ID"] = intval($USER->GetID());
    $request["BODY"]["bxpublic"] = "Y";
    $request["BODY"]["nocdn"] = "Y";
    $request["BODY"]["externalcontext"] = "crm";
    if (isset($request["BODY"]["AlreadyUTF8Request"]) && $request["BODY"]["AlreadyUTF8Request"] == "Y") {
        $request["UTF"] = true;
        unset($request["BODY"]["AlreadyUTF8Request"]);
    }
} else {
    $request["PATH"] .= (strpos($request["PATH"], "?") !== false ? "&" : "?") . "CRM_MANAGER_USER_ID=" . intval($USER->GetID()) . "&bxpublic=Y&nocdn=Y&externalcontext=crm";
}
$response = $proxy->Send($request);
if ($response == null) {
    die("Communication error");
}
$body = $response["BODY"];
if (isset($response["CONTENT"]["ENCODING"]) && in_array($response["CONTENT"]["TYPE"], array("text/xml", "application/xml", "text/html"))) {
    $utf8Encoding = strtoupper($response["CONTENT"]["ENCODING"]) == "UTF-8";
    if (!$utf8Encoding && defined("BX_UTF")) {
        $body = CharsetConverter::ConvertCharset($body, $response["CONTENT"]["ENCODING"], "UTF-8");
    } elseif ($utf8Encoding && !defined("BX_UTF")) {
        $body = CharsetConverter::ConvertCharset($body, "UTF-8", SITE_CHARSET);
    }
}
$body = preg_replace("#(\"|')(/bitrix/([a-z0-9_.-]+/)*?([a-z0-9_.-]+?\\.(gif|png)))#i", "\$1" . $proxy->GetUrl() . "\$2", $body);
$body = preg_replace("#(\"|')(/bitrix/([a-z0-9_.-]+/)*?(sale\\.css))#i", "\$1" . $proxy->GetUrl() . "\$2", $body);
$body = preg_replace("#(\"|')(/upload/([%a-z0-9_.-]+/)*?([%a-z0-9_.-]+?\\.([a-z0-9]+)))#i", "\$1" . $proxy->GetUrl() . "\$2", $body);