$fbCache = new CPHPCache;
$cacheID = array(SITE_ID, $arParams["RSS_URL"]);
$cacheTime = 86405; //Время кеширования - сутки и 5 секунд на всякий случай
if($fbCache->InitCache($cacheTime, $cacheID, "/")):
$vars = $fbCache->GetVars();
$arResult["RSS_INFO"] = $vars['RSS_INFO'];
unset($vars);
else:
$xml_url = "http://api.feedburner.com/awareness/1.0/GetFeedData?uri=";
$name = substr($arParams["RSS_URL"], (strrpos($arParams["RSS_URL"], '/')+1));
$xml_url .= $name;
$reader = new XMLReader();
@$reader->open($xml_url);
while (@$reader->read()) {
if ($reader->name == "entry"){
$circulation = @$reader->getAttribute("circulation");
$hits = @$reader->getAttribute("hits");
}
if ($reader->name == "entry") {
$hits = @$reader->getAttribute("hits");
}
}
@$reader->close();
$arResult["RSS_INFO"] = array(
"NAME" => $name,
"circulation" => ($circulation > 0) ? $circulation : 0,
"hits" => $hits,
"XML_URL" => $xml_url,
"URL" => $arParams["RSS_URL"],
);
endif;
if ($fbCache->StartDataCache())
$fbCache->EndDataCache(array('RSS_INFO' => $arResult["RSS_INFO"]));
unset($fbCache); |