0) {
for($i = 0;$i ';
$title = str_replace($source[0], '', $rss_channel["ITEMS"][$i]["TITLE"]);
$link = str_replace('%3A', ':', $rss_channel["ITEMS"][$i]["LINK"]);
$postdate = date("Y-m-d H:i:s", strtotime($rss_channel["ITEMS"][$i]["PUBDATE"]));
$params['newstitle'] = trim($title);
$params['newscontent'] = ''.$source[0].' wrote:
'.$rss_channel["ITEMS"][$i]["DESCRIPTION"].'
'.$pubtime;
$params['post_date'] = $postdate;
$params['addcat'] = "rssnews";
$title = trim(addslashes($title));
// check if exists
$query = 'select count(*) as thecount from '.cms_db_prefix().'module_news where news_title = \''.$title.'\'';
echo $query;
$dbresult = $db->Execute($query);
$row = $dbresult->FetchRow();
echo $row['thecount'];
if ($row['thecount']>0)
{
$output .= $title.' already in database
';
continue;
}
$sql = "insert into newslinks (url, title, source, text, pubtime)
values (
'".$link."',
'".addslashes($title)."',
'".$source[0]."',
'".addslashes($rss_channel["ITEMS"][$i]["DESCRIPTION"])."',
".$postdate."
)";
$output .= $title.$postdate.' added
';
$tmp[$i]= new News();
$tmp[$i]->DoAction("completeadd", 0, $params);
}
}
echo $output;
mail($mailaddress, $mailsubject, $output);
?>
RSS (Yahoo) to CMS News script
RSS (Yahoo) to CMS News script
Not sure if this is useful to anyone, but just in case, I wanted to automatically pull RSS news from Yahoo into my CMS Made Simple News, so I hacked this RSS Parser script and have it running as a Cronjob. I tried to take out all the parts that were specific to my needs and debugging and hopefully I didn't break anything in the process. I use it for yahoo, but you could easily combine it with the Google to RSS script that's out there and use it with Google...or you could pull any RSS feed into your CMS news.