PHP:
<?php
$filename = 'rss.xml';
// convert the format to UTF-8
function makeUTF($desc)
{
$desc = UTF8_encode($desc);
$desc = stripslashes($desc);
return $desc;
}
function seoname($seoit) {
$seoit = strip_tags($seoit);
$seoit = str_replace("'", "", $seoit);
$seoit = str_replace(" ", " ", $seoit);
$seoit = preg_replace("#[\W_]+#", "-", $seoit);
$seoit = trim($seoit);
$seoit = strtolower($seoit);
return $seoit;
}
if(file_exists($filename) && filesize($filename) >= 10 && time() - filemtime($filename) <= 43200) //43200
{
readfile($filename);
}
else {
include "funcs.php";
$rss = '';
$rss .= '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">'."\n";
$rss .= '<channel>'."\n";
$rss .= '<atom:link href="'.$core->siteurl.'/rss.php" rel="self" type="application/rss+xml" />'."\n";
$rss .= '<title>'. $core->sitename .'</title>'."\n";
$rss .= '<link>'. $core->siteurl .'</link>'."\n";
$rss .= '<description>The Ultimate Source of Latest Direct Downloads</description>'."\n";
$rss .= '<copyright>Copyright 2010 '.$core->sitename.' - '.$core->siteurl.'</copyright>'."\n";
$rss .= '<language>en</language>'."\n";
//IF YOU HAVE AN IMAGE USE BELOW
$rss .= '<image>'."\n";
$rss .= ' <title>'.$core->sitename.'</title>'."\n";
$rss .= ' <url>'.$core->site_button.'</url>'."\n";
$rss .= ' <link>'.$core->siteurl.'</link>'."\n";
$rss .= '</image>'."\n";
$today = date("D, d M Y H:i:s +0100");
$rss .= "<pubDate>$today</pubDate>\n";
$items = mysql_query("SELECT * FROM wcddl_downloads WHERE type !='xxx' ORDER BY id DESC limit 0,200") or die(mysql_error());
while($article = mysql_fetch_assoc($items))
{
$title = makeUTF($article["title"]);
$url = '/latest-warez-download-'.$article["id"].'-'.seoname($article["title"]).'.html';
$desc = seoname($title);
$desc = makeUTF($desc);
$rss .= "<item>\n";
$rss .= "<title>$title</title>\n";
$rss .= "<link>". $core->siteurl . $url ."</link>\n";
$rss .= "<guid>". $core->siteurl . $url ."</guid>\n";
$rss .= "<pubDate>$today</pubDate>\n";
$rss .= "<description>Download ".$title." and much more ".$article["type"]."s only at ".$core->sitename."</description>\n";
$rss .= "</item>\n";
}
$rss .= "</channel>\n";
$rss .= "</rss>\n";
if(file_exists($filename) && is_writable($filename)) {
$fp = fopen($filename, "w");
fputs($fp, $rss);
fclose($fp);
}
else
{
echo 'Error: '.$filename.' or CHMOD';
die();
}
header('Content-type: text/xml');
echo $rss;
}
?>
Last edited: