Parser: just wont work
Posted: Sun Oct 04, 2009 8:16 am
OK maybe someone can take a look what im doing wrong
Code: Select all
<?php
//#### Parser
function rss_parser($feedurl,$notmore)
{
include "inc/config.php";
//get the simplepie library
require_once('simplepie.inc');
$dahtmlheader ="Content-Type: text/html\r\nContent-Transfer-Encoding: 8bit\r\n";
//grab the feed
$feed = new SimplePie();
//enable caching
$feed->enable_cache(false);
//init the process
$feed->init();
//let simplepie handle the content type (atom, RSS...)
$feed->handle_content_type();
$i=0;
if ($feed->error)
{
echo $feed->error;
};
$feedurlcheck = preg_replace("/[^0-9a-zA-Z]/","",$feedurl);
if (strlen($feedurl) > 50) {$feedurlcheck = substr($feedurlcheck, 0, 50);};
foreach ($feed->get_items(0, 1) as $item)
{
if($notmore < $i +1){break;};
$title = $item->get_title();
$description = $item->get_content();
$url = $item->get_link();
if(file_exists("save/".$feedurlcheck.".txt"))
{
$lastpost = file_get_contents("save/".$feedurlcheck.".txt");
if($lastpost == $title){break;};
};
echo $output;
echo "<div class='topicheader'><h3>".$title."</h3></div>";
echo "<div class='topicbody'>".$url."<div class='clear'></div></div>";
if($i == 0)
{
$newlastpostitle = $title;
};
$i++;
};
if($lastpost != $title)
{
$fh = fopen("save/".$feedurlcheck.".txt", "w");
fputs($fh, $newlastpostitle);
fclose($fh);
};
}
?>