"));
//cautam informatiile de care avem nevoie
preg_match("/
(.*?)<\/title>/",$response,$title);
preg_match("/(.*?)<\/link>/",$response,$link);
preg_match("/(.*?)<\/description>/",$response,$description);
preg_match("/(.*?)<\/lastBuildDate>/",$response,$lastBuildDate);
preg_match("/(.*?)<\/generator>/",$response,$generator);
preg_match("/(.*?)<\/language>/",$response,$language);
//procesam informatiile colectate si le validam
if(sizeof($title) >= 2) $title = $title[1]; else $title = "";
if(sizeof($link) >= 2) $link = $link[1]; else $link = "";
if(sizeof($description) >= 2) $description = $description[1]; else $description = "";
if(sizeof($lastBuildDate) >= 2) $lastBuildDate = $lastBuildDate[1]; else $lastBuildDate = "";
if(sizeof($generator) >= 2) $generator = $generator[1]; else $generator = "";
if(sizeof($language) >= 2) $language = $language[1]; else $language = "";
//returnam informatiile
return array("title" => $title,
"link" => $link,
"description" => $description,
"lastBuild" => $lastBuildDate,
"generator" => $generator,
"language" => $language
);
}
function getLastItems($url)
{
//extragem response-ul,pregatim item-urile pentru procesare
$itemsFeed = array(array());
$response = getResponsePage($url);
preg_match_all("/- (.*?)<\/item>/s",$response,$items);
//procesam fiecare item in parte
foreach($items[1] as $item)
{
$new = array();
//extragem informatiile
preg_match("/(.*?)<\/title>/",$item,$new['title']);
preg_match("/(.*?)<\/link>/",$item,$new['link']);
preg_match("/(.*?)<\/comments>/",$item,$new['commentsURL']);
preg_match("/(.*?)<\/pubDate>/",$item,$new['date']);
preg_match("/(.*?)<\/dc:creator>/",$item,$new['author']);
preg_match("/(.*?)<\/description>/s",$item,$new['description']);
preg_match("/(.*?)<\/content:encoded>/s",$item,$new['content']);
preg_match("/(.*?)<\/wfw:commentRss>/",$item,$new['commentsRSS']);
preg_match("/(.*?)<\/slash:comments>/",$item,$new['commentsCount']);
//procesam informatiile colecatate si le validam
if(sizeof($new['title']) >= 2) $new['title'] = $new['title'][1]; else $new['title'] = "";
if(sizeof($new['link']) >= 2) $new['link'] = $new['link'][1]; else $new['link'] = "";
if(sizeof($new['commentsURL']) >= 2) $new['commentsURL'] = $new['commentsURL'][1]; else $new['commentsURL'] = "";
if(sizeof($new['date']) >= 2) $new['date'] = $new['date'][1]; else $new['date'] = "";
if(sizeof($new['author']) >= 2) $new['author'] = $new['author'][1]; else $new['author'] = "";
if(sizeof($new['description']) >= 2) $new['description'] = $new['description'][1]; else $new['description'] = "";
if(sizeof($new['content']) >= 2) $new['content'] = $new['content'][1]; else $new['content'] = "";
if(sizeof($new['commentsRSS']) >= 2) $new['commentsRSS'] = $new['commentsRSS'][1]; else $new['commentsRSS'] = "";
if(sizeof($new['commentsCount']) >= 2) $new['commentsCount'] = $new['commentsCount'][1]; else $new['commentsCount'] = "";
//procesam informatii ce au nevoie de o atentie speciala
$new['description'] = str_replace(array(""),"",$new['description']);
$new['content'] = str_replace(array(""),"",$new['content']);
//adaugam informatiile la lista de cele procesate
$itemsFeed[] = $new;
}
return $itemsFeed;
}
print_r(getFeedInfo("http://www.worldit.info/feed/")); //extragem informatiile de WorldIT Feed
print_r(getLastItems("http://www.worldit.info/noutati/web-cam-from-microsoft/feed/")); //extragem ultimile comentarii din articol Webcam From Microsoft
print_r(getLastItems("http://www.worldit.info/feed/")); //extragem ultimile articole de WorldIT
?>