im sure this isnt the best way to do this but heck it works
if yall want to help me clean up the code
cool but if not im considering this fixed
i recieved help and ideas from my good old friend wh1tedr4gon
here is my final code
<?
//Created by PaPPy & Wh1teDr4gon
//Created on May 14th 2006
header("Content-Type: application/xml; charset=ISO-8859-1");
function EncodeXmlEntities($str) {
return str_replace(
array ('&', '"', "'", '<', '>' ),
array ('&', '"', ''' , '<' , '>' ),
$str
);
}
define('CACHE_TIME', 5 * 60); // Cache time in seconds (5 mins)
define('CACHE_FILE', 'bf.cache'); // Where we store a local copy of the feed for caching purposes(can change)
if (time() - filemtime(CACHE_FILE) < CACHE_TIME) // Is our cache file new enough to use?
{
$result = file_get_contents(CACHE_FILE); // Use cache (html code from our $destination)
} else {
// Cache expired, download new copy, and grab its contents ($result)
$result = file_get_contents('http://board.bitefight.org/search.php?action=24h');
$fp= fopen(CACHE_FILE, 'w'); //Dump html source code to cachfile
fwrite ($fp, $result); //Dump html source code to cachfile
fclose($fp); //Dump html source code to cachfile
}
$now = date("D, d M Y H:i:s") ." EST";
$rss =
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" .
"<rss version=\"2.0\">" .
"<channel>" .
"<title>Bite Fight RSS</title>" .
"<description>Bite Fight's Forum</description>" .
"<link>http://board.bitefight.org</link>" .
"<language>en-us</language>" .
"<generator>http://www.pappyspage.com</generator>" .
"<lastBuildDate>$now</lastBuildDate>" .
"<ttl>" .(CACHE_TIME / 60) ."</ttl>";
for($i=0;$i<20;$i++)
{
//Get thred number
$thrednumb = ' <a href="thread.php?threadid=';
$thrednume = '&goto=lastpost';
if ( ( $pos1 = strpos ( $result, $thrednumb ) ) !== false)
{
$result1 = substr ( $result, ( $len1 = ( $pos1 + strlen ( $thrednumb ) ) ), ( strpos ( $result, $thrednume, $len1 ) - $len1 ) );
}
//Get thred number
//Get date
$postdateb = '<td align="right" nowrap="nowrap"><span class="smallfont"><b>';
$postdatee = '</b>';
if ( ( $pos2 = strpos ( $result, $postdateb ) ) !== false)
{
$result2 = substr ( $result, ( $len2 = ( $pos2 + strlen ( $postdateb ) ) ), ( strpos ( $result, $postdatee, $len2 ) - $len2 ) );
}
//Get date
//Get forum
$forumnameb = '<br />Forum:';
$forumnamee = '</a>';
if ( ( $pos3 = strpos ( $result, $forumnameb ) ) !== false)
{
$result3 = substr ( $result, ( $len3 = ( $pos3 + strlen ( $forumnameb ) ) ), ( strpos ( $result, $forumnamee, $len3 ) - $len3 ) );
}
//Get forum
//Get time
$posttimeb = '<span class="time">';
$posttimee = '</span>';
if ( ( $pos4 = strpos ( $result, $posttimeb ) ) !== false)
{
$result4 = substr ( $result, ( $len4 = ( $pos4 + strlen ( $posttimeb ) ) ), ( strpos ( $result, $posttimee, $len4 ) - $len4 ) );
}
//Get time
//Get poster
$posterb = 'by <b>';
$postere = '</a>';
if ( ( $pos5 = strpos ( $result, $posterb ) ) !== false)
{
$result5 = substr ( $result, ( $len5 = ( $pos5 + strlen ( $posterb ) ) ), ( strpos ( $result, $postere, $len5 ) - $len5 ) );
//Get poster
//Get subject
}
$postsubb = '</span>
<a';
$postsube = '</a>';
if ( ( $pos6 = strpos ( $result, $postsubb ) ) !== false)
{
$result6 = substr ( $result, ( $len6 = ( $pos6 + strlen ( $postsubb ) ) ), ( strpos ( $result, $postsube, $len6 ) - $len6 ) );
}
//Get subject
$result = str_replace($thrednumb . $result1 . $thrednume, '~', $result);
$result = str_replace($postdateb . $result2 . $postdatee, '~~', $result);
$result = str_replace($forumnameb . $result3 . $forumnamee, '~~~', $result);
$result = str_replace($posttimeb . $result4 . $posttimee, '~~~~', $result);
$result = str_replace($posterb . $result5 . $postere, '~~~~~', $result);
$result = str_replace($postsubb . $result6 . $postsube, '~~~~~~', $result);
$strip1 = strip_tags($result1);
$strip2 = strip_tags($result2);
$strip3 = strip_tags($result3);
$strip4 = strip_tags($result4);
$strip5 = strip_tags($result5);
$result6 = '<a' .$result6;
$strip6 = strip_tags($result6);
$strip1 = "http://board.bitefight.org/thread.php?threadid=" .$strip1. "&goto=lastpost";
$descr = $strip5 . " posted about '" . $strip6 . "' in the " . $strip3 . " forums.";
$rss .=
"<item>" .
"<title>" .EncodeXmlEntities($strip6) ."</title>" .
"<link>" .EncodeXmlEntities($strip1) ."</link>" .
"<guid>" .EncodeXmlEntities($strip1) ."</guid>" .
"<description>" .EncodeXmlEntities($descr) ."</description>" .
"<pubDate>" .EncodeXmlEntities($strip2) . " @ " . EncodeXmlEntities($strip4) . " GMT(+1)" . "</pubDate>" .
"</item>";
}
// Footer.
$rss .=
"</channel>" .
"</rss>";
echo $rss;
?>
what i did was find the values of the first line, extracted it and then replaced them with ~'s. then looped so next time it searched it would come down to the next line of data to extract from
ran into a lot of problems but worked them out
thanks for all the help