Code:<?php
require_once("config.php");
require_once("db/db.php");
$row = $db->sql_fetchrow($db->sql_query("SELECT * FROM ".$prefix."_config"));
$sitename = superhtmlentities($row[sitename]);
$nukeurl = $row[nukeurl];
$backend_title = superhtmlentities($row[backend_title]);
$backend_language = $row[backend_language];
function superhtmlentities($text) {
// Thanks to mirrorball_girl for this
$entities = array(128 => 'euro', 130 => 'sbquo', 131 => 'fnof', 132 => 'bdquo', 133 => 'hellip', 134 => 'dagger', 135 => 'Dagger', 136 => 'circ', 137 => 'permil', 138 => 'Scaron', 139 => 'lsaquo', 140 => 'OElig', 145 => 'lsquo', 146 => 'rsquo', 147 => 'ldquo', 148 => 'rdquo', 149 => 'bull', 150 => '#45', 151 => 'mdash', 152 => 'tilde', 153 => 'trade', 154 => 'scaron', 155 => 'rsaquo', 156 => 'oelig', 159 => 'Yuml');
$new_text = '';
for($i = 0; $i < strlen($text); $i++) {
$num = ord($text {
$i }
);
if (array_key_exists($num, $entities)) {
switch ($num) {
case 150:
$new_text .= '-';
break;
case 153:
$new_text .= '(tm)';
break;
default:
$new_text .= "&".$entities[$num].';';
}
}
else
if ($num < 127 || $num > 159) {
$new_text .= htmlentities($text {
$i }
);
}
}
$new_text = ereg_replace(" +", " ", $new_text);
## remove double spaces.
return $new_text;
}
header("Content-Type: application/rss+xml");
echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n\n";
echo "<!DOCTYPE rss PUBLIC \"-//Netscape Communications//DTD RSS 0.91//EN\"\n";
echo " \"http://my.netscape.com/publish/formats/rss-0.91.dtd\">\n\n";
echo "<rss version=\"0.91\">\n\n";
echo "<channel>\n";
echo "<title>".htmlspecialchars($sitename)." - Forums</title>\n";
echo "<link>$nukeurl</link>\n";
echo "<description>".htmlspecialchars($backend_title)."</description>\n";
echo "<language>$backend_language</language>\n\n";
$result = mysql_query("SELECT topic_id, forum_id, topic_last_post_id, topic_title FROM ".$prefix."_bbtopics ORDER BY topic_last_post_id DESC");
$amount = 15;
$counter = 0;
while(list($topic_id, $forum_id, $topic_last_post_id, $topic_title) = mysql_fetch_row($result)) {
$result1 = mysql_query( "SELECT auth_view, auth_read, forum_name, cat_id FROM ".$prefix."_bbforums where forum_id = '$forum_id'");
list( $auth_view, $auth_read, $forum_name, $cat_id ) = mysql_fetch_row($result1);
if( ( $auth_view != 0 ) or ( $auth_read != 0 ) ) continue;
if( $topic_moved_id != 0 ) continue;
++$counter;
$result3 = mysql_query("SELECT topic_id, FROM_UNIXTIME(post_time,'%b %d, %Y at %T') as post_time, username, user_id FROM ".$prefix."_bbposts," .$prefix."_users where post_id='$topic_last_post_id' AND user_id=poster_id Limit 1");
list($topic_id, $post_time, $username, $user_id)=mysql_fetch_row($result3);
$rtitle = superhtmlentities($topic_title);
$rtitle = str_replace('_',' ',$rtitle); //added 9/1/2004
echo "<item>\n";
echo "<title>".htmlspecialchars($rtitle)."</title>\n";
echo "<link>$nukeurl/postp$topic_last_post_id#$topic_last_post_id</link>\n";
echo "</item>\n\n";
if ($counter==$amount) break;
}
echo "</channel>\n";
echo "</rss>";
?>
|