$val) {
if(!empty($val) && htValidURL($val)){
$aFeedUrls[] = $val;
}
}
}
if (empty($aFeedUrls)) {
exit;
}
$enc = 'UTF-8';
$gTimeout = 10;
$gHCRLF = "\n";
$aFeedChanel = array();
$aFeedItems = array();
foreach ($aFeedUrls as $url) {
$run=0;
$out = true;
$return = '';
while ($out===true && $run < 5) {
$Cont = htGetPageContent($url, '', 'GET', true, 2, 2);
$return = $Cont['Content'];
$headers = htGetResponseHeaders($Cont['Header']);
/*echo '
';
echo print_r($Cont);
echo '';*/
if (isset($headers['Location']) && !empty($headers['Location'])) {
$url = trim($headers['Location']);
//echo 'Location: '.$url.'
';
continue;
}
//Check feed tag
preg_match("/\?>[\s\S]{0,10}<(rss|rdf|feed)[^>]*>/im", $return, $areg);
if (strpos($return,'/imU',$return,$aRes);
if (!empty($aRes) && !empty($aRes[0])) {
preg_match('/href=(\'|"| )+(.*)(\'|"| )+/imU',$aRes[0],$aRes);
$run++;
if (isset($aRes[2]) && !empty($aRes[2])) {
$url = $aRes[2];
continue;
}
}
break;
}else {
$out=false;
}
}
//Remove tag
$format = '';
if(preg_match("/<(rss|rdf|feed)[^>]*>/i", $return, $areg)){
if (isset($areg[1])) {
$format = $areg[1];
}
$pos=strpos($return, '<'.$format);
if($pos!==false){
$return=substr($return, $pos);
}
}
$return=preg_replace("/
]*>/i", '', $return);
list($aChannel, $aFeed) = xmParseFeedArray(basexml2array($return));
if (empty($aFeedChanel)) {
$aFeedChanel = $aChannel;
}
if (empty($aFeedItems)) {
$aFeedItems = $aFeed;
}else {
foreach ($aFeed as $fi) {
$aFeedItems[] = $fi;
}
}
}
$tData = array();
$cnt = 0;
$tArrayKeys = array_keys($aFeedItems);
if ($gNewsOrder == 1) {
shuffle($tArrayKeys);
}
$c = count($tArrayKeys);
for ($i=0; $i < $c; $i++) {
$value = $aFeedItems[$tArrayKeys[$i]];
if ($cnt > $tLimit) {
break;
}
if (!isset($value['description'])) {
$value['description'] = '';
}
if (trim(strip_tags($value['description'])) == '' && trim(strip_tags($value['title'])) == '') {
continue;
}
$tData[$cnt] = $value;
$cnt++;
}
//Check channel
$arr['rss']['channel'] = $aFeedChanel;
$arr['rss']['channel']['item'] = $tData;
$xml = array2xml($arr);
$xml = preg_replace('/[\r\n]/', '', $xml);
$xml = preg_replace('/[\s]{2,}/', ' ', $xml);
//$xml = preg_replace('/[<[\s]*br[\s\/]*>]{0,}/iU', ' ', $xml);
echo '';
echo $xml;
?>