1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
webservice.php
См. документацию.
1<?php
3
5{
6 private $debug = false;
7 private $timeout = 0;
8 private $server = /*.(Bitrix\Main\Web\HttpClient).*/ null;
9
17 protected abstract function getActionURL($arParams = /*.(array[string]string).*/ []);
18
26 protected function action($action)
27 {
28 $url = $this->getActionURL([
29 'action' => $action,
30 'debug' => ($this->debug ? 'y' : 'n'),
31 ]);
32
33 $this->server = new Bitrix\Main\Web\HttpClient([
34 'redirect' => true,
35 ]);
36 if ($this->timeout > 0)
37 {
38 $this->server->setTimeout($this->timeout);
39 }
40
41 $strXML = $this->server->get($url);
42 if ($strXML === false || !$this->server->getStatus())
43 {
44 $errors = $this->server->getError();
45 throw new CBitrixCloudException(GetMessage('BCL_CDN_WS_SERVER', [
46 '#STATUS#' => $errors ? implode(' ', $errors) : '-1',
47 ]), '');
48 }
49
50 if ($this->server->getStatus() != 200)
51 {
52 throw new CBitrixCloudException(GetMessage('BCL_CDN_WS_SERVER', [
53 '#STATUS#' => (string)$this->server->getStatus(),
54 ]), '');
55 }
56
57 $obXML = new CDataXML;
58 if (!$obXML->LoadString($strXML))
59 {
60 throw new CBitrixCloudException(GetMessage('BCL_CDN_WS_XML_PARSE', [
61 '#CODE#' => '1',
62 ]), '');
63 }
64
65 /* @var CDataXMLNode $node */
66 $node = $obXML->SelectNodes('/error/code');
67 if (is_object($node))
68 {
69 $error_code = $node->textContent();
70 $message_id = 'BCL_CDN_WS_' . $error_code;
71 /*
72 GetMessage("BCL_CDN_WS_LICENSE_EXPIRE");
73 GetMessage("BCL_CDN_WS_LICENSE_NOT_FOUND");
74 GetMessage("BCL_CDN_WS_QUOTA_EXCEEDED");
75 GetMessage("BCL_CDN_WS_CMS_LICENSE_NOT_FOUND");
76 GetMessage("BCL_CDN_WS_DOMAIN_NOT_REACHABLE");
77 GetMessage("BCL_CDN_WS_LICENSE_DEMO");
78 GetMessage("BCL_CDN_WS_LICENSE_NOT_ACTIVE");
79 GetMessage("BCL_CDN_WS_NOT_POWERED_BY_BITRIX_CMS");
80 GetMessage("BCL_CDN_WS_WRONG_DOMAIN_SPECIFIED");
81 */
82
83 $debug_content = '';
84 $node = $obXML->SelectNodes('/error/debug');
85 if (is_object($node))
86 {
87 $debug_content = $node->textContent();
88 }
89
90 if (HasMessage($message_id))
91 {
92 throw new CBitrixCloudException(GetMessage($message_id), $error_code, $debug_content);
93 }
94 else
95 {
96 throw new CBitrixCloudException(GetMessage('BCL_CDN_WS_SERVER', [
97 '#STATUS#' => $error_code,
98 ]), $error_code, $debug_content);
99 }
100 }
101
102 return $obXML;
103 }
104
113 public function setDebug($bActive)
114 {
115 $result = $this->debug;
116 $this->debug = ($bActive === true);
117 return $result;
118 }
119
126 public function setTimeout($timeout)
127 {
128 $this->timeout = $timeout > 0 ? intval($timeout) : 0;
129 return $this->timeout;
130 }
131
139 public function getServerStatus()
140 {
141 return isset($this->server) ? $this->server->getStatus() : null;
142 }
143
151 public function getServerResult()
152 {
153 return isset($this->server) ? $this->server->getResult() : null;
154 }
155}
$arParams
Определения access_dialog.php:21
getServerStatus()
Определения webservice.php:139
setTimeout($timeout)
Определения webservice.php:126
setDebug($bActive)
Определения webservice.php:113
getServerResult()
Определения webservice.php:151
getActionURL($arParams=[])
action($action)
Определения webservice.php:26
Определения xml.php:396
SelectNodes($strNode)
Определения xml.php:472
$result
Определения get_property_values.php:14
$errors
Определения iblock_catalog_edit.php:74
$GLOBALS[ 'DB'] debug
Определения start.php:56
HasMessage($name)
Определения tools.php:3418
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
GetMessage($name, $aReplace=null)
Определения tools.php:3397
$action
Определения file_dialog.php:21
$url
Определения iframe.php:7