本文整理汇总了PHP中CDataXML::GetArray方法的典型用法代码示例。如果您正苦于以下问题:PHP CDataXML::GetArray方法的具体用法?PHP CDataXML::GetArray怎么用?PHP CDataXML::GetArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDataXML
的用法示例。
在下文中一共展示了CDataXML::GetArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getData
public function getData()
{
$xml_str = file_get_contents($this->file);
$xml = new \CDataXML();
$xml->LoadString($xml_str);
$arXml = $xml->GetArray();
unset($xml_str);
return $this->toTmp($arXml);
}
示例2: Request
function Request($server, $page, $port, $params, $uri = false)
{
if ($uri && strlen($uri) > 0) {
$strURI = $uri;
} else {
$strURI = "http://" . $server . (strlen($port) > 0 && intval($port) > 0 ? ":" . intval($port) : "") . (strlen($page) ? $page : "/") . (strlen($params) > 0 ? "?" . $params : "");
}
$http = new \Bitrix\Main\Web\HttpClient(array("version" => "1.0", "socketTimeout" => 30, "streamTimeout" => 30, "redirect" => true, "redirectMax" => 5));
$strData = $http->get($strURI);
$errors = $http->getError();
$arRSSResult = array();
if (!$strData && !empty($errors)) {
$strError = "";
foreach ($errors as $errorCode => $errMes) {
$strError .= $errorCode . ": " . $errMes;
}
\CEventLog::Add(array("SEVERITY" => "ERROR", "AUDIT_TYPE_ID" => "XDIMPORT_HTTP", "MODULE_ID" => "xdimport", "ITEM_ID" => "RSS_REQUEST", "DESCRIPTION" => $strError));
}
if ($strData) {
$rss_charset = "windows-1251";
if (preg_match("/<" . "\\?XML[^>]{1,}encoding=[\"']([^>\"']{1,})[\"'][^>]{0,}\\?" . ">/i", $strData, $matches)) {
$rss_charset = Trim($matches[1]);
}
$strData = preg_replace("/<" . "\\?XML.*?\\?" . ">/i", "", $strData);
$strData = $GLOBALS["APPLICATION"]->ConvertCharset($strData, $rss_charset, SITE_CHARSET);
}
if (strlen($strData) > 0) {
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/xml.php";
$objXML = new CDataXML();
$res = $objXML->LoadString($strData);
if ($res !== false) {
$ar = $objXML->GetArray();
if (is_array($ar) && isset($ar["rss"]) && is_array($ar["rss"]) && isset($ar["rss"]["#"]) && is_array($ar["rss"]["#"]) && isset($ar["rss"]["#"]["channel"]) && is_array($ar["rss"]["#"]["channel"]) && isset($ar["rss"]["#"]["channel"][0]) && is_array($ar["rss"]["#"]["channel"][0]) && isset($ar["rss"]["#"]["channel"][0]["#"])) {
$arRSSResult = $ar["rss"]["#"]["channel"][0]["#"];
} else {
$arRSSResult = array();
}
$arRSSResult["rss_charset"] = strtolower(SITE_CHARSET);
}
}
if (is_array($arRSSResult) && !empty($arRSSResult)) {
$arRSSResult = CXDILFSchemeRSS::FormatArray($arRSSResult);
if (!empty($arRSSResult) && array_key_exists("item", $arRSSResult) && is_array($arRSSResult["item"]) && !empty($arRSSResult["item"])) {
$arRSSResult["item"] = array_reverse($arRSSResult["item"]);
}
}
return $arRSSResult;
}
示例3: GetMessage
} else {
$strError = GetMessage("ERROR_EMPTY_ANSWER");
}
} else {
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/xml.php";
$charset = "windows-1251";
if (preg_match("/<" . "\\?XML[^>]{1,}encoding=[\"']([^>\"']{1,})[\"'][^>]{0,}\\?" . ">/i", $strQueryText, $matches)) {
$charset = trim($matches[1]);
}
$strQueryText = preg_replace("#<!DOCTYPE[^>]+?>#i", "", $strQueryText);
$strQueryText = preg_replace("#<" . "\\?XML[^>]+?\\?" . ">#i", "", $strQueryText);
$strQueryText = $APPLICATION->ConvertCharset($strQueryText, $charset, SITE_CHARSET);
$objXML = new CDataXML();
$res = $objXML->LoadString($strQueryText);
if ($res !== false) {
$arData = $objXML->GetArray();
} else {
$arData = false;
}
if ($currantCurrancy == "UAH") {
//ukraina
if (is_array($arData) && count($arData["ValCurs"]["#"]["Valute"]) > 0) {
for ($j1 = 0, $intCount = count($arData["ValCurs"]["#"]["Valute"]); $j1 < $intCount; $j1++) {
if ($arData["ValCurs"]["#"]["Valute"][$j1]["#"]["CharCode"][0]["#"] == $CURRENCY) {
$RATE_CNT = IntVal($arData["ValCurs"]["#"]["Valute"][$j1]["#"]["Nominal"][0]["#"]);
$arCurrValue = str_replace(",", ".", $arData["ValCurs"]["#"]["Valute"][$j1]["#"]["Value"][0]["#"]);
$RATE = DoubleVal($arCurrValue);
break;
}
}
}
示例4: GetNewsEx
function GetNewsEx($SITE, $PORT, $PATH, $QUERY_STR, $bOutChannel = False)
{
global $APPLICATION;
$cacheKey = md5($SITE.$PORT.$PATH.$QUERY_STR);
$bValid = False;
$bUpdate = False;
if ($db_res_arr = CIBlockRSS::GetCache($cacheKey))
{
$bUpdate = True;
if (strlen($db_res_arr["CACHE"])>0)
{
if ($db_res_arr["VALID"]=="Y")
{
$bValid = True;
$text = $db_res_arr["CACHE"];
}
}
}
if (!$bValid)
{
$FP = fsockopen($SITE, $PORT, $errno, $errstr, 120);
if ($FP)
{
$strVars = $QUERY_STR;
$strRequest = "GET ".$PATH.(strlen($strVars) > 0? "?".$strVars: "")." HTTP/1.0\r\n";
$strRequest.= "User-Agent: BitrixSMRSS\r\n";
$strRequest.= "Accept: */*\r\n";
$strRequest.= "Host: $SITE\r\n";
$strRequest.= "Accept-Language: en\r\n";
$strRequest.= "\r\n";
fputs($FP, $strRequest);
$headers = "";
while(!feof($FP))
{
$line = fgets($FP, 4096);
if($line == "\r\n")
break;
$headers .= $line;
}
$text = "";
while(!feof($FP))
$text .= fread($FP, 4096);
$rss_charset = "windows-1251";
if (preg_match("/<"."\?XML[^>]{1,}encoding=[\"']([^>\"']{1,})[\"'][^>]{0,}\?".">/i", $text, $matches))
{
$rss_charset = Trim($matches[1]);
}
elseif($headers)
{
if(preg_match("#^Content-Type:.*?charset=([a-zA-Z0-9-]+)#m", $headers, $match))
$rss_charset = $match[1];
}
$text = preg_replace("/<!DOCTYPE.*?>/i", "", $text);
$text = preg_replace("/<"."\\?XML.*?\\?".">/i", "", $text);
$text = $APPLICATION->ConvertCharset($text, $rss_charset, SITE_CHARSET);
fclose($FP);
}
else
{
$text = "";
}
}
if (strlen($text) > 0)
{
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/classes/general/xml.php");
$objXML = new CDataXML();
$res = $objXML->LoadString($text);
if($res !== false)
{
$ar = $objXML->GetArray();
//$ar = xmlize_rss($text1);
if (!$bOutChannel)
{
$arRes = $ar["rss"]["#"]["channel"][0]["#"];
}
else
{
$arRes = $ar["rss"]["#"];
}
$arRes["rss_charset"] = strtolower(SITE_CHARSET);
if (!$bValid)
{
$ttl = (strlen($arRes["ttl"][0]["#"]) > 0)? IntVal($arRes["ttl"][0]["#"]): 60;
CIBlockRSS::UpdateCache($cacheKey, $text, array("minutes" => $ttl), $bUpdate);
}
}
return $arRes;
//.........这里部分代码省略.........
示例5: ParseOrderData
private function ParseOrderData($orderData, &$modificationLabel, &$arErrors)
{
if (empty($orderData)) {
$arErrors[] = array("PD1", GetMessage("CRM_EXT_SALE_IMPORT_EMPTY_ANSW"));
return null;
}
if (substr(ltrim($orderData), 0, strlen('<?xml')) != '<?xml') {
$orderDataTmp = @gzuncompress($orderData);
if (substr(ltrim($orderDataTmp), 0, strlen('<?xml')) != '<?xml') {
if (strpos($orderDataTmp, "You haven't rights for exchange") !== false) {
$arErrors[] = array("PD2", GetMessage("CRM_EXT_SALE_IMPORT_UNKNOWN_ANSW_PERMS"));
} elseif (strpos($orderDataTmp, "failure") !== false) {
$arErrors[] = array("PD2", GetMessage("CRM_EXT_SALE_IMPORT_UNKNOWN_ANSW_F"));
$arErrors[] = array("PD2", preg_replace("/\\s*failure\n/", "", $orderDataTmp));
} elseif (strpos($orderData, "Authorization") !== false || strpos($orderData, "Access denied") !== false) {
$arErrors[] = array("PD2", GetMessage("CRM_EXT_SALE_IMPORT_UNKNOWN_ANSW_PERMS1"));
} else {
$arErrors[] = array("PD2", GetMessage("CRM_EXT_SALE_IMPORT_UNKNOWN_ANSW") . substr($orderData, 0, 100));
}
return null;
}
$orderData = $orderDataTmp;
unset($orderDataTmp);
}
$charset = "";
if (preg_match("/^<" . "\\?xml[^>]+?encoding=[\"']([^>\"']+)[\"'][^>]*\\?" . ">/i", $orderData, $matches)) {
$charset = trim($matches[1]);
}
if (!empty($charset) && strtoupper($charset) != strtoupper(SITE_CHARSET)) {
$orderData = CharsetConverter::ConvertCharset($orderData, $charset, SITE_CHARSET);
}
$objXML = new CDataXML();
if ($objXML->LoadString($orderData)) {
$arOrderData = $objXML->GetArray();
} else {
$arErrors[] = array("XL1", GetMessage("CRM_EXT_SALE_IMPORT_ERROR_XML"));
return null;
}
$arSettings = array();
foreach ($arOrderData["CommerceInformation"]["@"] as $key => $value) {
$arSettings[$key] = array();
$ar1 = explode(";", $value);
foreach ($ar1 as $v1) {
$ar2 = explode("=", $v1);
if (count($ar2) == 2) {
$arSettings[$key][trim($ar2[0])] = $ar2[1];
}
}
if (count($arSettings[$key]) <= 0) {
$arSettings[$key] = $value;
}
}
if (!isset($arSettings["SumFormat"]["CRD"])) {
$arSettings["SumFormat"]["CRD"] = '.';
}
if (!isset($arSettings["QuantityFormat"]["CRD"])) {
$arSettings["QuantityFormat"]["CRD"] = '.';
}
if (!isset($arSettings["DateFormat"]["DF"])) {
$arSettings["DateFormat"]["DF"] = 'yyyy-MM-dd';
}
$arSettings["DateFormat"]["DF"] = strtoupper($arSettings["DateFormat"]["DF"]);
if (!isset($arSettings["TimeFormat"]["DF"])) {
$arSettings["TimeFormat"]["DF"] = 'HH:MM:SS';
}
$arSettings["TimeFormat"]["DF"] = str_replace("MM", "MI", $arSettings["TimeFormat"]["DF"]);
$arOrders = array();
if (is_array($arOrderData["CommerceInformation"]["#"]) && is_array($arOrderData["CommerceInformation"]["#"]["Document"])) {
foreach ($arOrderData["CommerceInformation"]["#"]["Document"] as $arDocument) {
if ($arDocument["#"]["BusinessTransaction"][0]["#"] == "ItemOrder") {
$v = $this->ParseOrderDataOrder($arDocument, $arSettings);
if (is_array($v)) {
$arOrders[] = $v;
if (isset($v["DATE_UPDATE"])) {
$modificationLabelTmp = MakeTimeStamp($v["DATE_UPDATE"]);
if ($modificationLabelTmp > $modificationLabel) {
$modificationLabel = $modificationLabelTmp;
}
}
}
}
}
}
return $arOrders;
}
示例6: SendRequest
function SendRequest($access_key, $secret_key, $verb, $bucket, $file_name = '/', $params = '')
{
global $APPLICATION;
$this->status = 0;
$RequestMethod = $verb;
$RequestHost = "sts.amazonaws.com";
$RequestURI = "/";
$RequestParams = "";
$params['SignatureVersion'] = 2;
$params['SignatureMethod'] = 'HmacSHA1';
$params['AWSAccessKeyId'] = $access_key;
$params['Timestamp'] = gmdate('Y-m-d') . 'T' . gmdate('H:i:s');
//.preg_replace("/(\d\d)\$/", ":\\1", date("O"));
$params['Version'] = '2011-06-15';
ksort($params);
foreach ($params as $name => $value) {
if ($RequestParams != '') {
$RequestParams .= '&';
}
$RequestParams .= urlencode($name) . "=" . urlencode($value);
}
$StringToSign = "{$RequestMethod}\n" . "{$RequestHost}\n" . "{$RequestURI}\n" . "{$RequestParams}";
$Signature = urlencode(base64_encode($this->hmacsha1($StringToSign, $secret_key)));
$obRequest = new CHTTP();
$obRequest->Query($RequestMethod, $RequestHost, 443, $RequestURI . "?{$RequestParams}&Signature={$Signature}", false, 'ssl://');
$this->status = $obRequest->status;
$this->headers = $obRequest->headers;
$this->errno = $obRequest->errno;
$this->errstr = $obRequest->errstr;
$this->result = $obRequest->result;
if ($obRequest->status == 200) {
if ($obRequest->result) {
$obXML = new CDataXML();
$text = preg_replace("/<" . "\\?XML.*?\\?" . ">/i", "", $obRequest->result);
if ($obXML->LoadString($text)) {
$arXML = $obXML->GetArray();
if (is_array($arXML)) {
return $arXML;
}
}
//XML parse error
$APPLICATION->ThrowException(GetMessage('CLO_SECSERV_S3_XML_PARSE_ERROR', array('#errno#' => 1)));
return false;
} else {
//Empty success result
return array();
}
} elseif ($obRequest->status > 0) {
if ($obRequest->result) {
$APPLICATION->ThrowException(GetMessage('CLO_SECSERV_S3_XML_ERROR', array('#errmsg#' => $obRequest->result)));
return false;
}
$APPLICATION->ThrowException(GetMessage('CLO_SECSERV_S3_XML_PARSE_ERROR', array('#errno#' => 2)));
return false;
} else {
$APPLICATION->ThrowException(GetMessage('CLO_SECSERV_S3_XML_PARSE_ERROR', array('#errno#' => 3)));
return false;
}
}
示例7: HttpClient
break;
}
$http = new HttpClient();
$data = $http->get($url);
$charset = 'windows-1251';
$matches = array();
if (preg_match("/<" . "\\?XML[^>]{1,}encoding=[\"']([^>\"']{1,})[\"'][^>]{0,}\\?" . ">/i", $data, $matches)) {
$charset = trim($matches[1]);
}
$data = preg_replace("#<!DOCTYPE[^>]+?>#i", '', $data);
$data = preg_replace("#<" . "\\?XML[^>]+?\\?" . ">#i", '', $data);
$data = $APPLICATION->ConvertCharset($data, $charset, SITE_CHARSET);
$objXML = new CDataXML();
$res = $objXML->LoadString($data);
if ($res !== false) {
$data = $objXML->GetArray();
} else {
$data = false;
}
switch ($baseCurrency) {
case 'UAH':
if (is_array($data) && count($data["exchange"]["#"]['currency']) > 0) {
$currencyList = $data['exchange']['#']['currency'];
foreach ($currencyList as &$currencyRate) {
if ($currencyRate['#']['cc'][0]['#'] == $currency) {
$result['STATUS'] = 'OK';
$result['RATE_CNT'] = 1;
$result['RATE'] = (double) str_replace(",", ".", $currencyRate['#']['rate'][0]['#']);
break;
}
}
示例8: SendRequest
function SendRequest($access_key, $secret_key, $verb, $bucket, $file_name = '/', $params = '', $content = '', $additional_headers = array())
{
global $APPLICATION;
$this->status = 0;
if (isset($additional_headers["Content-Type"])) {
$ContentType = $additional_headers["Content-Type"];
unset($additional_headers["Content-Type"]);
} else {
$ContentType = $content ? 'text/plain' : '';
}
if (!array_key_exists("x-goog-api-version", $additional_headers)) {
$additional_headers["x-goog-api-version"] = "1";
}
$RequestMethod = $verb;
$RequestURI = $file_name;
$RequestDATE = gmdate('D, d M Y H:i:s', time()) . ' GMT';
//Prepare Signature
$CanonicalizedAmzHeaders = "";
ksort($additional_headers);
foreach ($additional_headers as $key => $value) {
if (preg_match("/^x-goog-/", $key)) {
$CanonicalizedAmzHeaders .= $key . ":" . $value . "\n";
}
}
$CanonicalizedResource = "/" . $bucket . $RequestURI;
$StringToSign = "{$RequestMethod}\n\n{$ContentType}\n{$RequestDATE}\n{$CanonicalizedAmzHeaders}{$CanonicalizedResource}";
//$utf = $APPLICATION->ConvertCharset($StringToSign, LANG_CHARSET, "UTF-8");
$Signature = base64_encode($this->hmacsha1($StringToSign, $secret_key));
$Authorization = "GOOG1 " . $access_key . ":" . $Signature;
$obRequest = new CHTTP();
$obRequest->additional_headers["Date"] = $RequestDATE;
$obRequest->additional_headers["Authorization"] = $Authorization;
foreach ($additional_headers as $key => $value) {
if (!preg_match("/^option-/", $key)) {
$obRequest->additional_headers[$key] = $value;
}
}
if ($this->new_end_point && preg_match('#^(http|https)://' . preg_quote($bucket, '#') . '(.+)/#', $this->new_end_point, $match)) {
$host = $match[2];
} else {
$host = $bucket . ".commondatastorage.googleapis.com";
}
$was_end_point = $this->new_end_point;
$this->new_end_point = '';
$obRequest->Query($RequestMethod, $host, 80, $RequestURI . $params, $content, '', $ContentType);
$this->status = $obRequest->status;
$this->headers = $obRequest->headers;
$this->errno = $obRequest->errno;
$this->errstr = $obRequest->errstr;
$this->result = $obRequest->result;
if ($obRequest->status == 200) {
if (isset($additional_headers["option-raw-result"])) {
return $obRequest->result;
} elseif ($obRequest->result) {
$obXML = new CDataXML();
$text = preg_replace("/<" . "\\?XML.*?\\?" . ">/i", "", $obRequest->result);
if ($obXML->LoadString($text)) {
$arXML = $obXML->GetArray();
if (is_array($arXML)) {
return $arXML;
}
}
//XML parse error
$APPLICATION->ThrowException(GetMessage('CLO_STORAGE_GOOGLE_XML_PARSE_ERROR', array('#errno#' => 1)));
return false;
} else {
//Empty success result
return array();
}
} elseif ($obRequest->status == 307 && isset($obRequest->headers["Location"]) && !$was_end_point) {
$this->new_end_point = $obRequest->headers["Location"];
return $this->SendRequest($access_key, $secret_key, $verb, $bucket, $file_name, $params, $content, $additional_headers);
} elseif ($obRequest->status > 0) {
if ($obRequest->result) {
$obXML = new CDataXML();
if ($obXML->LoadString($obRequest->result)) {
$arXML = $obXML->GetArray();
if (is_array($arXML) && is_string($arXML["Error"]["#"]["Message"][0]["#"])) {
$APPLICATION->ThrowException(GetMessage('CLO_STORAGE_GOOGLE_XML_ERROR', array('#errmsg#' => trim($arXML["Error"]["#"]["Message"][0]["#"], '.'))));
return false;
}
}
}
$APPLICATION->ThrowException(GetMessage('CLO_STORAGE_GOOGLE_XML_PARSE_ERROR', array('#errno#' => 2)));
return false;
} else {
$APPLICATION->ThrowException(GetMessage('CLO_STORAGE_GOOGLE_XML_PARSE_ERROR', array('#errno#' => 3)));
return false;
}
}
示例9: CPHPCache
if ($adminMenu->IsSectionActive("menu_marketplace")) {
$CACHE = 60 * 60 * 24;
$obCache = new CPHPCache();
$cache_id = "main_menu_marketplace_" . LANGUAGE_ID;
if ($obCache->InitCache($CACHE, $cache_id, "/")) {
$vars = $obCache->GetVars();
$arMarket = $vars["arMarket"];
} else {
$ht = new Bitrix\Main\Web\HttpClient(array("socketTimeout" => 30));
if ($res = $ht->get("http://marketplace.1c-bitrix.ru/data_export.php")) {
if ($ht->getStatus() == "200") {
$res = $APPLICATION->ConvertCharset($res, "windows-1251", SITE_CHARSET);
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/xml.php";
$objXML = new CDataXML();
$objXML->LoadString($res);
$arResult = $objXML->GetArray();
if (!empty($arResult) && is_array($arResult)) {
if (!empty($arResult["categories"]["#"]["category"])) {
foreach ($arResult["categories"]["#"]["category"] as $category) {
$arCategory = array();
$arUrls = array();
if (!empty($category["#"]["items"][0]["#"]["item"])) {
foreach ($category["#"]["items"][0]["#"]["item"] as $catIn) {
$url = "update_system_market.php?category=" . $catIn["#"]["id"][0]["#"];
$arCategory[] = array("text" => $catIn["#"]["name"][0]["#"] . " (" . $catIn["#"]["count"][0]["#"] . ")", "title" => GetMessage("MAIN_MENU_MP_CATEGORY") . " " . $catIn["#"]["name"][0]["#"], "url" => $url . "&lang=" . LANGUAGE_ID);
$arUrls[] = $url;
}
}
if (IntVal($category["#"]["id"][0]["#"]) > 0) {
$url = "update_system_market.php?category=" . $category["#"]["id"][0]["#"];
$arUrls[] = $url;
示例10: Calculate
function Calculate($profile, $arConfig, $arOrder, $STEP)
{
if ($STEP >= 3) {
return array("RESULT" => "ERROR", "TEXT" => GetMessage('SALE_DH_CPCR_ERROR_CONNECT'));
}
$arOrder["WEIGHT"] = CSaleMeasure::Convert($arOrder["WEIGHT"], "G", "KG");
if ($arOrder["WEIGHT"] <= 0) {
$arOrder["WEIGHT"] = 1;
}
// weight must not be null - let it be 1 kg
$arLocationFrom = CDeliveryCPCR::__GetLocation($arOrder["LOCATION_FROM"]);
$arLocationTo = CDeliveryCPCR::__GetLocation($arOrder["LOCATION_TO"]);
// caching is dependent from category, locations "from" & "to" and from weight interval
$cache_id = "sale3|9.5.0|cpcr|" . $arConfig["category"]['VALUE'] . "|" . $arLocationFrom["ORIGINAL"]["COUNTRY_ID"] . "|" . $arLocationFrom["ORIGINAL"]["CITY_ID"] . "|" . $arLocationTo["ORIGINAL"]["COUNTRY_ID"] . "|" . $arLocationTo["ORIGINAL"]["CITY_ID"];
if ($arOrder["WEIGHT"] <= 0.5) {
$cache_id .= "|0";
} elseif ($arOrder["WEIGHT"] <= 1) {
$cache_id .= "|1";
} else {
$cache_id .= "|" . ceil($arOrder["WEIGHT"]);
}
// other intervals - up to next natural number
$obCache = new CPHPCache();
if ($obCache->InitCache(DELIVERY_CPCR_CACHE_LIFETIME, $cache_id, "/")) {
// cache found
$vars = $obCache->GetVars();
$arResult = $vars["RESULT"];
} else {
// format HTTP query request data
$arQuery = array();
$arQuery[] = DELIVERY_CPCR_SERVER_POST_FROM_COUNTRY . "=" . urlencode($arLocationFrom["COUNTRY"]);
if (is_set($arLocationFrom["CITY_ID"])) {
$arQuery[] = DELIVERY_CPCR_SERVER_POST_FROM_CITY . "=" . urlencode($arLocationFrom["CITY_ID"]);
} else {
$arQuery[] = DELIVERY_CPCR_SERVER_POST_FROM_CITY_NAME . "=" . urlencode($GLOBALS['APPLICATION']->ConvertCharset($arLocationFrom["CITY"], LANG_CHARSET, 'windows-1251'));
}
$arQuery[] = DELIVERY_CPCR_SERVER_POST_WEIGHT . "=" . urlencode($arOrder["WEIGHT"]);
$arQuery[] = DELIVERY_CPCR_SERVER_POST_CATEGORY . "=" . "1";
//urlencode($arConfig["category"]["VALUE"]);
// price coefficient will be added later - to make caching independent from price
$arQuery[] = DELIVERY_CPCR_SERVER_POST_PRICE . "=0";
$arQuery[] = DELIVERY_CPCR_SERVER_POST_TO_COUNTRY . "=" . urlencode($arLocationTo["COUNTRY"]);
/*
if (is_set($arLocationTo["REGION"]))
$arQuery[] = DELIVERY_CPCR_SERVER_POST_TO_REGION."=".urlencode($arLocationTo["REGION"]);
else
$arQuery[] = DELIVERY_CPCR_SERVER_POST_TO_REGION."=".urlencode(DELIVERY_CPCR_CITY_DEFAULT);
*/
if (is_set($arLocationTo["CITY_ID"])) {
$arQuery[] = DELIVERY_CPCR_SERVER_POST_TO_CITY . "=" . urlencode($arLocationTo["CITY_ID"]);
} else {
$arQuery[] = DELIVERY_CPCR_SERVER_POST_TO_CITY_NAME . "=" . urlencode($GLOBALS['APPLICATION']->ConvertCharset($arLocationTo["CITY"], LANG_CHARSET, 'windows-1251'));
}
CDeliveryCPCR::__Write2Log(print_r($arLocationTo, true));
$arQuery[] = DELIVERY_CPCR_SERVER_POST_ADDITIONAL;
$query_string = implode("&", $arQuery);
$query_page = DELIVERY_CPCR_SERVER_PAGE;
// get data from server
$ob = new CHTTP();
$ob->http_timeout = 50;
$data = $ob->Query(DELIVERY_CPCR_SERVER_METHOD, DELIVERY_CPCR_SERVER, DELIVERY_CPCR_SERVER_PORT, $query_page . (DELIVERY_CPCR_SERVER_METHOD == 'GET' ? (strpos($query_page, '?') === false ? '?' : '&') . $query_string : ''), DELIVERY_CPCR_SERVER_METHOD == 'POST' ? $query_string : false);
if ($data) {
$data = $GLOBALS["APPLICATION"]->ConvertCharset($ob->result, 'windows-1251', LANG_CHARSET);
}
CDeliveryCPCR::__Write2Log($query_page);
CDeliveryCPCR::__Write2Log($query_string);
CDeliveryCPCR::__Write2Log($error_number . ": " . $error_text);
CDeliveryCPCR::__Write2Log($data);
if (strpos($data, "<?xml") === false) {
return array("RESULT" => "ERROR", "TEXT" => GetMessage('SALE_DH_CPCR_ERROR_CONNECT'));
}
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/xml.php";
$objXML = new CDataXML();
$objXML->LoadString($data);
$arResult = $objXML->GetArray();
$arProfiles = array('SIMPLE' => '"цеоюпд-щйяопеяя"', 'ECONOM' => '"оекхйюм-ярюмдюпр"', 'SIMPLE13' => '"цеоюпд-щйяопеяя 13"', 'SIMPLE18' => '"цеоюпд-щйяопеяя 18"', 'BIZON' => '"ахгнм-йюпцн"', 'COLIBRI' => '"йнкхапх-днйслемр"', 'PELICAN' => '"оекхйюм-нмкюим"', 'FRAXT' => '"тпюур"');
$arTmpResult = array();
if (isset($arResult["root"]["#"]["Error"]) and is_array($arResult["root"]["#"]["Error"])) {
return array("RESULT" => "ERROR", "TEXT" => GetMessage('SALE_DH_CPCR_ERROR_CONNECT') . ' (' . htmlspecialcharsbx(strip_tags($arResult["root"]["#"]["Tariff"][0]["#"]["TariffType"][0]["#"])) . ')');
} else {
if (!empty($arResult["root"]["#"]["Tariff"])) {
foreach ($arResult["root"]["#"]["Tariff"] as $key => $val) {
foreach ($val["#"] as $k => $v) {
foreach ($arProfiles as $prof => $title) {
if (ToUpper($v[0]["#"]) == ToUpper($title)) {
$arTmpResult[ToLower($prof)] = array('VALUE' => $val["#"]["Total_Dost"][0]["#"], 'TRANSIT' => $val["#"]["DP"][0]["#"]);
unset($arProfiles[$prof]);
break;
}
}
}
}
}
$arResult = $arTmpResult;
if (count($arTmpResult) > 0) {
$obCache->StartDataCache();
$obCache->EndDataCache(array("RESULT" => $arResult));
} else {
return array("RESULT" => "ERROR", "TEXT" => GetMessage('SALE_DH_CPCR_ERROR_CONNECT'));
}
//.........这里部分代码省略.........
示例11: LoadFromStr
function LoadFromStr($strXML)
{
if (strlen($strXML) <= 0) {
$this->props = 'all';
return true;
}
$objXML = new CDataXML();
$objXML->delete_ns = false;
if (!$objXML->LoadString($strXML)) {
$this->success = false;
return false;
}
$this->_array = $objXML->GetArray();
$this->parse_array($this->_array);
return $this->success;
}
示例12: ListFiles
public function ListFiles($arBucket, $filePath, $bRecursive = false)
{
global $APPLICATION;
$result = array(
"dir" => array(),
"file" => array(),
"file_size" => array(),
);
$filePath = trim($filePath, '/');
if(strlen($filePath))
$filePath .= '/';
if($arBucket["PREFIX"])
{
if(substr($filePath, 0, strlen($arBucket["PREFIX"])+2) != "/".$arBucket["PREFIX"]."/")
$filePath = $arBucket["PREFIX"]."/".ltrim($filePath, "/");
}
$filePath = $APPLICATION->ConvertCharset($filePath, LANG_CHARSET, "UTF-8");
$marker = '';
$new_marker = false;
while(true)
{
$obRequest = $this->SendRequest(
$arBucket["SETTINGS"],
"GET",
$arBucket["BUCKET"],
'/',
$s='?format=xml&'.($bRecursive? '': '&delimiter=/').'&prefix='.urlencode($filePath).'&marker='.urlencode($marker)
);
$bFound = false;
if(is_object($obRequest) && $obRequest->result && $this->status == 200)
{
$obXML = new CDataXML;
$text = preg_replace("/<"."\\?XML.*?\\?".">/i", "", $obRequest->result);
if($obXML->LoadString($text))
{
$arXML = $obXML->GetArray();
if(
isset($arXML["container"])
&& is_array($arXML["container"])
&& isset($arXML["container"]["#"])
&& is_array($arXML["container"]["#"])
&& !empty($arXML["container"]["#"])
)
{
if(
isset($arXML["container"]["#"]["object"])
&& is_array($arXML["container"]["#"]["object"])
&& !empty($arXML["container"]["#"]["object"])
)
{
$bFound = true;
foreach($arXML["container"]["#"]["object"] as $a)
{
$new_marker = $a["#"]["name"][0]["#"];
if($a["#"]["content_type"][0]["#"] === "application/directory")
{
$dir_name = trim(substr($a["#"]["name"][0]["#"], strlen($filePath)), "/");
$result["dir"][$APPLICATION->ConvertCharset(urldecode($dir_name), "UTF-8", LANG_CHARSET)] = true;
}
else
{
$file_name = substr($a["#"]["name"][0]["#"], strlen($filePath));
$file_name = $APPLICATION->ConvertCharset(urldecode($file_name), "UTF-8", LANG_CHARSET);
if (!in_array($file_name, $result["file"]))
{
$result["file"][] = $file_name;
$result["file_size"][] = $a["#"]["bytes"][0]["#"];
}
}
}
}
if(
isset($arXML["container"]["#"]["subdir"])
&& is_array($arXML["container"]["#"]["subdir"])
&& !empty($arXML["container"]["#"]["subdir"])
)
{
$bFound = true;
foreach($arXML["container"]["#"]["subdir"] as $a)
{
$new_marker = $a["@"]["name"];
$dir_name = trim(substr($a["@"]["name"], strlen($filePath)), "/");
$result["dir"][$APPLICATION->ConvertCharset(urldecode($dir_name), "UTF-8", LANG_CHARSET)] = true;
}
}
}
}
}
else
{
return false;
}
if($new_marker === $marker)
break;
//.........这里部分代码省略.........
示例13: SendRequest
/**
* @param array[string]string $arSettings
* @param string $verb
* @param string $bucket
* @param string $file_name
* @param string $params
* @param string $content
* @param array[string]string $additional_headers
* @return mixed
*/
public function SendRequest($arSettings, $verb, $bucket, $file_name = '/', $params = '', $content = '', $additional_headers = array())
{
global $APPLICATION;
$this->status = 0;
if (isset($additional_headers["Content-Type"])) {
$ContentType = $additional_headers["Content-Type"];
unset($additional_headers["Content-Type"]);
} else {
$ContentType = $content != "" ? 'text/plain' : '';
}
foreach ($this->set_headers as $key => $value) {
$additional_headers[$key] = $value;
}
if (array_key_exists("SESSION_TOKEN", $arSettings)) {
$additional_headers["x-amz-security-token"] = $arSettings["SESSION_TOKEN"];
}
ksort($additional_headers);
$RequestURI = $file_name;
$obRequest = new CHTTP();
if (isset($additional_headers["option-file-result"])) {
$obRequest->fp = $additional_headers["option-file-result"];
}
foreach ($this->SignRequest($arSettings, $verb, $bucket, $file_name, $ContentType, $additional_headers) as $key => $value) {
$obRequest->additional_headers[$key] = $value;
}
foreach ($additional_headers as $key => $value) {
if (preg_match("/^option-/", $key) == 0) {
$obRequest->additional_headers[$key] = $value;
}
}
if ($this->new_end_point != "" && preg_match('#^(http|https)://' . preg_quote($bucket, '#') . '(.+?)/#', $this->new_end_point, $match) > 0) {
$host = $bucket . $match[2];
} elseif ($this->location) {
$host = $bucket . "." . $this->location . ".amazonaws.com";
} else {
$host = $bucket . ".s3.amazonaws.com";
}
$was_end_point = $this->new_end_point;
$this->new_end_point = '';
$obRequest->Query($verb, $host, 80, $RequestURI . $params, $content, '', $ContentType);
$this->status = $obRequest->status;
$this->host = $host;
$this->verb = $verb;
$this->url = $RequestURI . $params;
$this->headers = $obRequest->headers;
$this->errno = $obRequest->errno;
$this->errstr = $obRequest->errstr;
$this->result = $obRequest->result;
if ($obRequest->status == 200) {
if (isset($additional_headers["option-raw-result"]) || isset($additional_headers["option--result"])) {
return $obRequest->result;
} elseif ($obRequest->result != "") {
$obXML = new CDataXML();
$text = preg_replace("/<" . "\\?XML.*?\\?" . ">/i", "", $obRequest->result);
if ($obXML->LoadString($text)) {
$arXML = $obXML->GetArray();
if (is_array($arXML)) {
return $arXML;
}
}
//XML parse error
$e = new CApplicationException(GetMessage('CLO_STORAGE_S3_XML_PARSE_ERROR', array('#errno#' => '1')));
$APPLICATION->ThrowException($e);
return false;
} else {
//Empty success result
return array();
}
} elseif ($obRequest->status == 307 && isset($obRequest->headers["Location"]) && $was_end_point === "") {
$this->new_end_point = $obRequest->headers["Location"];
return $this->SendRequest($arSettings, $verb, $bucket, $file_name, $params, $content, $additional_headers);
} elseif ($obRequest->status > 0) {
if ($obRequest->result != "") {
$obXML = new CDataXML();
if ($obXML->LoadString($obRequest->result)) {
$node = $obXML->SelectNodes("/Error/Message");
if (is_object($node)) {
$errmsg = trim($node->textContent(), '.');
$e = new CApplicationException(GetMessage('CLO_STORAGE_S3_XML_ERROR', array('#errmsg#' => $errmsg)));
$APPLICATION->ThrowException($e);
return false;
}
}
}
$e = new CApplicationException(GetMessage('CLO_STORAGE_S3_XML_PARSE_ERROR', array('#errno#' => '2')));
$APPLICATION->ThrowException($e);
return false;
} else {
$e = new CApplicationException(GetMessage('CLO_STORAGE_S3_XML_PARSE_ERROR', array('#errno#' => '3')));
$APPLICATION->ThrowException($e);
//.........这里部分代码省略.........
示例14: LoadCurrencyRates
public static function LoadCurrencyRates($bank = array())
{
$arResult = array();
$DATA = array("CBRF" => array("URL" => "www.cbr.ru", "LINK" => "/scripts/XML_daily.asp", "PORT" => "80", "ITEMS" => array("ValCurs", "#", "Valute"), "CURRENCY" => array("#", "CharCode", 0, "#"), "RATE" => array("#", "Nominal", 0, "#"), "VALUE" => array("#", "Value", 0, "#")), "NBU" => array("URL" => "bank-ua.com", "LINK" => "/export/currrate.xml", "PORT" => "80", "ITEMS" => array("chapter", "#", "item"), "CURRENCY" => array("#", "char3", 0, "#"), "RATE" => array("#", "size", 0, "#"), "VALUE" => array("#", "rate", 0, "#")), "NBK" => array("URL" => "www.nationalbank.kz", "LINK" => "/rss/rates_all.xml", "PORT" => "80", "ITEMS" => array("rss", "#", "channel", 0, "#", "item"), "CURRENCY" => array("#", "title", 0, "#"), "RATE" => array("#", "quant", 0, "#"), "VALUE" => array("#", "description", 0, "#")), "NBB" => array("URL" => "www.nbrb.by", "LINK" => "/Services/XmlExRates.aspx", "PORT" => "80", "ITEMS" => array("DailyExRates", "#", "Currency"), "CURRENCY" => array("#", "CharCode", 0, "#"), "RATE" => array("#", "Scale", 0, "#"), "VALUE" => array("#", "Rate", 0, "#")));
if (sizeof($bank) <= 0) {
$bank = array_keys($DATA);
}
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/classes/general/xml.php";
foreach ($bank as $bnk) {
$strQueryText = QueryGetData($DATA[$bnk]["URL"], $DATA[$bnk]["PORT"], $DATA[$bnk]["LINK"], "", $error_number, $error_text);
if (strlen($strQueryText) > 0) {
$objXML = new CDataXML();
$objXML->LoadString($strQueryText);
$arData = $objXML->GetArray();
for ($i = 0; $i < sizeof($DATA[$bnk]["ITEMS"]); $i++) {
$arData = $arData[$DATA[$bnk]["ITEMS"][$i]];
}
if (is_array($arData) && count($arData) > 0) {
for ($j1 = 0; $j1 < count($arData); $j1++) {
for ($i = 0; $i < sizeof($DATA[$bnk]["VALUE"]); $i++) {
if ($i == 0) {
$q1 = $arData[$j1][$DATA[$bnk]["VALUE"][$i]];
} elseif ($i > 0) {
$q1 = $q1[$DATA[$bnk]["VALUE"][$i]];
}
}
$arCurrValue = str_replace(",", ".", $q1);
for ($i = 0; $i < sizeof($DATA[$bnk]["CURRENCY"]); $i++) {
if ($i == 0) {
$currency1 = $arData[$j1][$DATA[$bnk]["CURRENCY"][$i]];
} elseif ($i > 0) {
$currency1 = $currency1[$DATA[$bnk]["CURRENCY"][$i]];
}
}
for ($i = 0; $i < sizeof($DATA[$bnk]["RATE"]); $i++) {
if ($i == 0) {
$rate = $arData[$j1][$DATA[$bnk]["RATE"][$i]];
} elseif ($i > 0) {
$rate = $rate[$DATA[$bnk]["RATE"][$i]];
}
}
$curr = DoubleVal($arCurrValue);
if (sizeof($currency) > 0) {
if (in_array($currency1, $currency)) {
$arResult[$bnk][] = array("RATE" => round($curr, 2), "RATE_CNT" => $rate, "CURRENCY" => $currency1);
}
} else {
$arResult[$bnk][] = array("RATE" => round($curr, 2), "RATE_CNT" => $rate, "CURRENCY" => $currency1);
}
}
}
}
}
$arResultNew = array();
foreach ($arResult as $rate => $value) {
foreach ($value as $currency) {
$arResultNew[$rate][$currency["CURRENCY"]] = $currency;
}
}
$arResult = $arResultNew;
$arResult["CBRF"]["RUB"] = array("CURRENCY" => "RUB", "RATE" => 1, "RATE_CNT" => 1);
unset($arResultNew);
return $arResult;
}
示例15: referenceValue
public function referenceValue(CDataXML $xmlObject)
{
global $APPLICATION;
if ($this->NS["HL"] <= 0) {
$this->error = GetMessage("CC_BCIH_XML_PARSE_ERROR", array("#CODE#" => 310));
return;
}
$entity_id = "HLBLOCK_" . $this->NS["HL"];
$xmlArray = $xmlObject->GetArray();
$xmlId = $xmlArray[GetMessage("CC_BCIH_XML_REFERENCE_ITEM")]["#"][GetMessage("CC_BCIH_XML_ID")][0]["#"];
$xmlVersion = $xmlArray[GetMessage("CC_BCIH_XML_REFERENCE_ITEM")]["#"][GetMessage("CC_BCIH_XML_VERSION")][0]["#"];
if (!is_string($xmlId) || $xmlId === "") {
$this->error = GetMessage("CC_BCIH_XML_PARSE_ERROR", array("#CODE#" => 320));
return;
}
$entity_data_class = $this->getDataClass($this->NS["HL"]);
$rsData = $entity_data_class::getList(array("select" => array("ID", "UF_XML_ID", "UF_VERSION"), "filter" => array("=UF_XML_ID" => $xmlId)));
$this->NS["C"]++;
$arFields = array("UF_XML_ID" => $xmlId, "UF_VERSION" => $this->NS["SESSID"] . "#" . $xmlVersion);
$xmlFields = $xmlArray[GetMessage("CC_BCIH_XML_REFERENCE_ITEM")]["#"][GetMessage("CC_BCIH_XML_FIELD_VALUES")][0]["#"][GetMessage("CC_BCIH_XML_FIELD_VALUE")];
if (!is_array($xmlFields)) {
$this->error = GetMessage("CC_BCIH_XML_PARSE_ERROR", array("#CODE#" => 330));
return;
}
foreach ($xmlFields as $xml) {
$xmlValue = $xml["#"][GetMessage("CC_BCIH_XML_VALUE")][0]["#"];
$xmlValueId = $xml["#"][GetMessage("CC_BCIH_XML_NAME")][0]["#"];
if ($xmlValueId === GetMessage("CC_BCIH_XML_NAME")) {
$xmlValueId = "NAME";
} elseif ($xmlValueId === GetMessage("CC_BCIH_XML_DESCRIPTION")) {
$xmlValueId = "DESCRIPTION";
}
$xmlValueId = $this->xml2id($xmlValueId);
$xmlValueId = substr("UF_" . strtoupper($xmlValueId), 0, 20);
switch ($this->NS["FM"][$xmlValueId]) {
case "datetime":
if ($xmlValue === "0001-01-01T00:00:00") {
$xmlValue = false;
} else {
$xmlValue = str_replace("T", " ", $xmlValue);
$xmlValue = MakeTimeStamp($xmlValue, "YYYY-MM-DD HH:MI:SS");
$xmlValue = ConvertTimeStamp($xmlValue, "FULL");
}
break;
case "boolean":
if ($xmlValue === "true") {
$xmlValue = true;
} elseif ($xmlValue === "false") {
$xmlValue = false;
} else {
$xmlValue = false;
}
break;
case "double":
$xmlValue = str_replace(" ", "", $xmlValue);
$xmlValue = str_replace(",", ".", $xmlValue);
break;
}
$arFields[$xmlValueId] = $xmlValue;
}
if ($arData = $rsData->fetch()) {
list($dbSessid, $dbVersion) = explode("#", $arData["UF_VERSION"], 2);
if ($dbVersion === $xmlVersion) {
if (!$this->NS["CHO"] && $dbSessid !== $this->NS["SESSID"]) {
$arFields = array("UF_VERSION" => $arFields["UF_VERSION"]);
} else {
return;
}
}
$entity_data_class::update($arData["ID"], $arFields);
} else {
$entity_data_class::add($arFields);
}
}