<?php
error_reporting(E_ALL&(~E_NOTICE));
function cut($start,$end,$word,$testvar=0)
{
$word=substr($word,strpos($word,$start)+strlen($start));
$word=substr($word,0,strpos($word,$end));
if($testvar) die($start." ".$end."<br>".$word);
return $word;
}
//make resume from description
function resume($text,$limit=7)
{
$words=@explode(" ",$text);
$words=@array_splice($words,0,$limit);
$retstr=@implode(" ",$words);
return $retstr."... ";
}
function easyfeeder($configs)
{
//go thru the feeds array
$content=file_get_contents($configs[feed]);
$items=explode("<item>",$content);
array_shift($items); //strip the general feed description
$retstr="";
foreach($items as $cnt=>$item)
{
if($configs[maxitems]>0 and $cnt+1>$configs[maxitems]) break;
//extract tags
$title=cut("<title>","</title>",$item);
$link=cut("<link>","</link>",$item);
if(strstr($item,"<![CDATA["))
{
$description=cut("<description>","</description>",$item);
$description=cut("<![CDATA[","]]",$description);
}
else
{
$description=cut("<description>","</description>",$item);
}
$language=cut("<language>","</language>",$item);
$copyright=cut("<copyright>","</copyright>",$item);
$managingEditor=cut("<managingEditor>","</managingEditor>",$item);
$webMaster=cut("<webMaster>","</webMaster>",$item);
$pubDate=cut("<pubDate>","</pubDate>",$item);
$lastBuildDate=cut("<lastBuildDate>","</lastBuildDate>",$item);
$category=cut("<category>","</category>",$item);
//now replace tags
$tpl=file_get_contents($configs[template]);
$tpl=str_replace("{title}",$title,$tpl);
$tpl=str_replace("{link}",$link,$tpl);
$tpl=str_replace("{description}",$description,$tpl);
$tpl=str_replace("{language}",$language,$tpl);
$tpl=str_replace("{copyright}",$copyright,$tpl);
$tpl=str_replace("{managingEditor}",$managingEditor,$tpl);
$tpl=str_replace("{webMaster}",$webMaster,$tpl);
$tpl=str_replace("{pubDate}",$pubDate,$tpl);
$tpl=str_replace("{lastBuildDate}",$lastBuildDate,$tpl);
$tpl=str_replace("{category}",$category,$tpl);
$retstr.=$tpl;
}
return $retstr;
}
?>