use Bitrix\Sale\Result; use Bitrix\Sale\Provider; use Bitrix\Sale\Helpers\Admin; use Bitrix\Main\SystemException; use Bitrix\Main\Entity\EntityError; use Bitrix\Sale\UserMessageException; use Bitrix\Main\ArgumentNullException; define("NO_KEEP_STATISTIC", true); define("NO_AGENT_STATISTIC", true); define("NO_AGENT_CHECK", true); define("NOT_CHECK_PERMISSIONS", true); require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_before.php"; Loc::loadMessages(__FILE__); global $USER; $arResult = array(); $result = new \Bitrix\Main\Entity\Result(); $saleModulePermissions = $APPLICATION->GetGroupRight("sale"); if (!isset($_REQUEST["action"])) { $result->addError(new EntityError(Loc::getMessage("SALE_OA_ERROR_HAPPENED"))); $result->setData(array("SYSTEM_ERROR" => "REQUEST[action] not defined!")); } elseif ($saleModulePermissions == "D" || !check_bitrix_sessid()) { $result->addError(new EntityError(Loc::getMessage("SALE_OA_ERROR_HAPPENED"))); $result->setData(array("SYSTEM_ERROR" => "Access denied!")); } elseif (!\Bitrix\Main\Loader::includeModule('sale')) { $result->addError(new EntityError(Loc::getMessage("SALE_OA_ERROR_HAPPENED"))); $result->setData(array("SYSTEM_ERROR" => "Error! Can't include module \"Sale\"!")); } else { $processor = new AjaxProcessor($USER->GetID(), $_REQUEST); $result = $processor->processRequest(); } if ($result->isSuccess()) {
/** * @param $data * @return \Bitrix\Main\Entity\Result */ protected static function sendRequestData($data, $method) { $result = new \Bitrix\Main\Entity\Result(); $url = "http://" . DELIVERY_RUSSIANPOST_SERVER . DELIVERY_RUSSIANPOST_SERVER_PAGE; $reqResult = false; $httpClient = new \Bitrix\Main\Web\HttpClient(array("version" => "1.1", "socketTimeout" => 30, "streamTimeout" => 30, "redirect" => true, "redirectMax" => 5)); $method = DELIVERY_RUSSIANPOST_SERVER_METHOD == $method ? \Bitrix\Main\Web\HttpClient::HTTP_GET : \Bitrix\Main\Web\HttpClient::HTTP_POST; if ($httpClient->query($method, $url, $data)) { $reqResult = $httpClient->getResult(); } $errors = $httpClient->getError(); if (!$reqResult && !empty($errors)) { foreach ($errors as $errorCode => $errMes) { $result->addError(new \Bitrix\Main\Entity\EntityError($errorCode . ": " . $errMes)); } } else { $status = $httpClient->getStatus(); if ($status != 200) { $result->addError(new \Bitrix\Main\Entity\EntityError('HTTP error code: %d', $status)); } else { $result->setData(array("DATA" => $reqResult)); } } return $result; }