7 return array(
"title",
"link",
"description",
"enclosure",
"enclosure_length",
"enclosure_type",
"category",
"pubDate");
14 $DB->Query(
"DELETE FROM b_iblock_rss WHERE IBLOCK_ID = ".(
int)
$IBLOCK_ID);
21 $arCurNodesRSS =
array();
23 "SELECT NODE, NODE_VALUE ".
26 while ($db_res_arr =
$db_res->Fetch())
28 $arCurNodesRSS[$db_res_arr[
"NODE"]] = $db_res_arr[
"NODE_VALUE"];
30 return $arCurNodesRSS;
33 public static function GetNewsEx($SITE, $PORT, $PATH, $QUERY_STR, $bOutChannel = False)
37 $cacheKey = md5($SITE.$PORT.$PATH.$QUERY_STR);
44 if ($db_res_arr[
"CACHE"] <>
'')
46 if ($db_res_arr[
"VALID"]==
"Y")
49 $text = $db_res_arr[
"CACHE"];
56 $http = new \Bitrix\Main\Web\HttpClient(
array(
57 "socketTimeout" => 120,
59 $http->setHeader(
"User-Agent",
"BitrixSMRSS");
60 $text = $http->get($SITE.
":".$PORT.$PATH.($QUERY_STR <>
''?
"?".$QUERY_STR:
""));
64 $rss_charset =
"windows-1251";
65 if (preg_match(
"/<".
"\?XML[^>]{1,}encoding=[\"']([^>\"']{1,})[\"'][^>]{0,}\?".
">/i",
$text,
$matches))
71 $headers = $http->getHeaders();
72 $ct = $headers->get(
"Content-Type");
73 if (preg_match(
"#charset=([a-zA-Z0-9-]+)#m", $ct, $match))
74 $rss_charset = $match[1];
77 $text = preg_replace(
"/<!DOCTYPE.*?>/i",
"",
$text);
78 $text = preg_replace(
"/<".
"\\?XML.*?\\?".
">/i",
"",
$text);
89 $ar = $objXML->GetArray();
93 is_array(
$ar) && isset(
$ar[
"rss"])
94 && is_array(
$ar[
"rss"]) && isset(
$ar[
"rss"][
"#"])
95 && is_array(
$ar[
"rss"][
"#"]) && isset(
$ar[
"rss"][
"#"][
"channel"])
96 && is_array(
$ar[
"rss"][
"#"][
"channel"]) && isset(
$ar[
"rss"][
"#"][
"channel"][0])
97 && is_array(
$ar[
"rss"][
"#"][
"channel"][0]) && isset(
$ar[
"rss"][
"#"][
"channel"][0][
"#"])
99 $arRes =
$ar[
"rss"][
"#"][
"channel"][0][
"#"];
106 is_array(
$ar) && isset(
$ar[
"rss"])
107 && is_array(
$ar[
"rss"]) && isset(
$ar[
"rss"][
"#"])
118 $ttl = (
$arRes[
"ttl"][0][
"#"] <>
'')? intval(
$arRes[
"ttl"][0][
"#"]): 60;
151 if(is_array(
$arRes[
"title"][0][
"#"]))
152 $arRes[
"title"][0][
"#"] =
$arRes[
"title"][0][
"#"][
"cdata-section"][0][
"#"];
153 if(is_array(
$arRes[
"link"][0][
"#"]))
154 $arRes[
"link"][0][
"#"] =
$arRes[
"link"][0][
"#"][
"cdata-section"][0][
"#"];
155 if(is_array(
$arRes[
"description"][0][
"#"]))
156 $arRes[
"description"][0][
"#"] =
$arRes[
"description"][0][
"#"][
"cdata-section"][0][
"#"];
159 "title" =>
$arRes[
"title"][0][
"#"],
160 "link" =>
$arRes[
"link"][0][
"#"],
161 "description" =>
$arRes[
"description"][0][
"#"],
162 "lastBuildDate" =>
$arRes[
"lastBuildDate"][0][
"#"],
163 "ttl" =>
$arRes[
"ttl"][0][
"#"],
168 if(is_array(
$arRes[
"image"][0][
"#"]))
170 $arResult[
"image"][
"title"] =
$arRes[
"image"][0][
"#"][
"title"][0][
"#"];
173 $arResult[
"image"][
"width"] =
$arRes[
"image"][0][
"#"][
"width"][0][
"#"];
174 $arResult[
"image"][
"height"] =
$arRes[
"image"][0][
"#"][
"height"][0][
"#"];
188 foreach (
$arRes[
"item"] as
$i => $arItem)
190 if (!is_array($arItem) || !is_array($arItem[
"#"]))
193 if (is_array($arItem[
"#"][
"title"][0][
"#"]))
194 $arItem[
"#"][
"title"][0][
"#"] = $arItem[
"#"][
"title"][0][
"#"][
"cdata-section"][0][
"#"];
196 if (is_array($arItem[
"#"][
"description"][0][
"#"]))
197 $arItem[
"#"][
"description"][0][
"#"] = $arItem[
"#"][
"description"][0][
"#"][
"cdata-section"][0][
"#"];
198 elseif (is_array($arItem[
"#"][
"encoded"][0][
"#"]))
199 $arItem[
"#"][
"description"][0][
"#"] = $arItem[
"#"][
"encoded"][0][
"#"][
"cdata-section"][0][
"#"];
200 $arResult[
"item"][
$i][
"description"] = $arItem[
"#"][
"description"][0][
"#"];
202 if (is_array($arItem[
"#"][
"title"][0][
"#"]))
203 $arItem[
"#"][
"title"][0][
"#"] = $arItem[
"#"][
"title"][0][
"#"][
"cdata-section"][0][
"#"];
204 $arResult[
"item"][
$i][
"title"] = $arItem[
"#"][
"title"][0][
"#"];
206 if (is_array($arItem[
"#"][
"link"][0][
"#"]))
207 $arItem[
"#"][
"link"][0][
"#"] = $arItem[
"#"][
"link"][0][
"#"][
"cdata-section"][0][
"#"];
208 $arResult[
"item"][
$i][
"link"] = $arItem[
"#"][
"link"][0][
"#"];
210 if ($arItem[
"#"][
"enclosure"])
212 $arResult[
"item"][
$i][
"enclosure"][
"url"] = $arItem[
"#"][
"enclosure"][0][
"@"][
"url"];
213 $arResult[
"item"][
$i][
"enclosure"][
"length"] = $arItem[
"#"][
"enclosure"][0][
"@"][
"length"];
214 $arResult[
"item"][
$i][
"enclosure"][
"type"] = $arItem[
"#"][
"enclosure"][0][
"@"][
"type"];
215 if ($arItem[
"#"][
"enclosure"][0][
"@"][
"width"])
217 $arResult[
"item"][
$i][
"enclosure"][
"width"] = $arItem[
"#"][
"enclosure"][0][
"@"][
"width"];
219 if ($arItem[
"#"][
"enclosure"][0][
"@"][
"height"])
221 $arResult[
"item"][
$i][
"enclosure"][
"height"] = $arItem[
"#"][
"enclosure"][0][
"@"][
"height"];
224 $arResult[
"item"][
$i][
"category"] = $arItem[
"#"][
"category"][0][
"#"];
225 $arResult[
"item"][
$i][
"pubDate"] = $arItem[
"#"][
"pubDate"][0][
"#"];
234 "title" =>
$arRes[
"channel"][0][
"#"][
"title"][0][
"#"],
235 "link" =>
$arRes[
"channel"][0][
"#"][
"link"][0][
"#"],
236 "description" =>
$arRes[
"channel"][0][
"#"][
"description"][0][
"#"],
237 "lastBuildDate" =>
$arRes[
"channel"][0][
"#"][
"lastBuildDate"][0][
"#"],
238 "ttl" =>
$arRes[
"channel"][0][
"#"][
"ttl"][0][
"#"],
243 $arResult[
"image"][
"title"] =
$arRes[
"image"][0][
"#"][
"title"][0][
"#"];
246 $arResult[
"image"][
"width"] =
$arRes[
"image"][0][
"#"][
"width"][0][
"#"];
247 $arResult[
"image"][
"height"] =
$arRes[
"image"][0][
"#"][
"height"][0][
"#"];
252 foreach (
$arRes[
"item"] as
$i => $arItem)
254 if (!is_array($arItem) || !is_array($arItem[
"#"]))
257 if (is_array($arItem[
"#"][
"title"][0][
"#"]))
258 $arItem[
"#"][
"title"][0][
"#"] = $arItem[
"#"][
"title"][0][
"#"][
"cdata-section"][0][
"#"];
260 if (is_array($arItem[
"#"][
"description"][0][
"#"]))
261 $arItem[
"#"][
"description"][0][
"#"] = $arItem[
"#"][
"description"][0][
"#"][
"cdata-section"][0][
"#"];
262 elseif (is_array($arItem[
"#"][
"encoded"][0][
"#"]))
263 $arItem[
"#"][
"description"][0][
"#"] = $arItem[
"#"][
"encoded"][0][
"#"][
"cdata-section"][0][
"#"];
264 $arResult[
"item"][
$i][
"description"] = $arItem[
"#"][
"description"][0][
"#"];
266 $arResult[
"item"][
$i][
"title"] = $arItem[
"#"][
"title"][0][
"#"];
267 $arResult[
"item"][
$i][
"link"] = $arItem[
"#"][
"link"][0][
"#"];
268 if ($arItem[
"#"][
"enclosure"])
270 $arResult[
"item"][
$i][
"enclosure"][
"url"] = $arItem[
"#"][
"enclosure"][0][
"@"][
"url"];
271 $arResult[
"item"][
$i][
"enclosure"][
"length"] = $arItem[
"#"][
"enclosure"][0][
"@"][
"length"];
272 $arResult[
"item"][
$i][
"enclosure"][
"type"] = $arItem[
"#"][
"enclosure"][0][
"@"][
"type"];
273 if ($arItem[
"#"][
"enclosure"][0][
"@"][
"width"])
275 $arResult[
"item"][
$i][
"enclosure"][
"width"] = $arItem[
"#"][
"enclosure"][0][
"@"][
"width"];
277 if ($arItem[
"#"][
"enclosure"][0][
"@"][
"height"])
279 $arResult[
"item"][
$i][
"enclosure"][
"height"] = $arItem[
"#"][
"enclosure"][0][
"@"][
"height"];
282 $arResult[
"item"][
$i][
"category"] = $arItem[
"#"][
"category"][0][
"#"];
283 $arResult[
"item"][
$i][
"pubDate"] = $arItem[
"#"][
"pubDate"][0][
"#"];
292 public static function XMLDate2Dec($date_XML, $dateFormat =
"DD.MM.YYYY")
294 static $MonthChar2Num = Array(
"",
"jan",
"feb",
"mar",
"apr",
"may",
"jun",
"jul",
"aug",
"sep",
"oct",
"nov",
"dec");
296 if(preg_match(
"/(\\d+)\\s+(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\\s+(\\d+)/i", $date_XML, $match))
297 $timestamp = mktime(0, 0, 0, array_search(mb_strtolower($match[2]), $MonthChar2Num), $match[1], $match[3]);
301 return date(CDatabase::DateFormatToPHP($dateFormat), $timestamp);
317 echo
"<".
"?xml version=\"1.0\" encoding=\"".
LANG_CHARSET.
"\"?".
">\n";
318 echo
"<rss version=\"2.0\"";
324 $arType = $dbr->Fetch();
325 if ($arType && ($arType[
"IN_RSS"] ==
"Y"))
static convertEncoding($data, $charsetFrom, $charsetTo)
static XMLDate2Dec($date_XML, $dateFormat="DD.MM.YYYY")
static GetNodeList($IBLOCK_ID)
static GetNewsEx($SITE, $PORT, $PATH, $QUERY_STR, $bOutChannel=False)
static GetNews($ID, $LANG, $TYPE, $SITE, $PORT, $PATH, $LIMIT=0)
static Delete($IBLOCK_ID)
static GetRSS($ID, $LANG, $TYPE, $LIMIT_NUM=false, $LIMIT_DAY=false, $yandex=false)
static FormatArray(&$arRes, $bOutChannel=false)
static ExtractProperties($str, &$arProps, &$arItem)
static GetRSSText($arIBLOCK, $LIMIT_NUM=false, $LIMIT_DAY=false, $yandex=false)
static UpdateCache($cacheKey, $CACHE, $HOURS_CACHE, $bCACHED)
static GetCache($cacheKey)
static GetList($arOrder=array("SORT"=> "ASC"), $arFilter=array())
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
if(empty($signedUserToken)) $key