<?php
/**********************************************************
* ______ ______ ___ _______ ___ ___ _______ *
* | _ \ | _ \ | | | _ || Y || _ | *
* |. | \|. | \|. | |. 1___||. || 1___| *
* |. | |. | |. |___ |. |___ |. \_/ ||____ | *
* |: 1 |: 1 |: 1 ||: 1 ||: | ||: 1 | *
* |::.. . /|::.. . /|::.. . ||::.. . ||::.|:. ||::.. . | *
* `------' `------' `-------'`-------'`--- ---'`-------' *
* _______ _______ *
* .--.--. | _ | | | *
* | | | |___| | __ |___| | *
* \___/ _(__ | |__| / ___/ *
* |: 1 | |: 1 \ *
* |::.. . | |::.. . | *
* `-------' `-------' *
* *
* Script: DDLCMS v3.2 *
* Author: Little Dragon *
* Email: hide@address.com *
* Website: http://www.ddlcms.com *
* *
* Please direct bug reports, suggestions or feedback *
* to the DDLCMS forums: *
* *
* http://www.ddlcms.com/forums *
* *
* DDLCMS is a commercial grade content management *
* system for DDL site owners. It is provided free *
* of charge, provided: *
* *
* 1. You keep the linkback to http://www.ddlcms.com *
* in the footer. *
* *
* 2. You keep the sponsored links to Sharingzone.net *
* on your site. *
* *
* By using this script, you agree that you will not *
* modify, remove, or replace any encoded parts of *
* this script. All encoded parts MUST remain intact *
* for your site to remain in good standing. *
* *
**********************************************************/
// (c) xul.fr - Licence Mozilla 1.1.
function makeUTF($desc)
{
$desc = UTF8_encode($desc);
$desc = stripslashes($desc);
return($desc);
}
$rss = '<?xml version="1.0" encoding="UTF-8" ?>'."\n";
$rss .= '<rss version="2.0">'."\n";
$rss .= '<channel>'."\n";
$rss .= '<title>'.$site_name.'</title>'."\n";
$rss .= '<link>'.$site_url.'</link>'."\n";
$rss .= '<description>'.$description.'</description>'."\n";
$rss .= '<copyright>DDLCMS.com</copyright>'."\n";
$rss .= '<language>en</language>'."\n";
$rss .= '<image>'."\n";
$rss .= ' <title>'.$site_name.'</title>'."\n";
$rss .= ' <url>'.$site_url.'/images/button.gif</url>'."\n";
$rss .= ' <link>'.$site_url.'</link>'."\n";
$rss .= '</image>'."\n";
$today= date("D, d M Y H:i:s +0100");
$rss .= "<pubDate>$today</pubDate>\n";
$command="SELECT id, title, date, news, type FROM news ORDER BY date DESC LIMIT 10";
$items = mysql_query($command);
while($article = mysql_fetch_assoc($items))
{
$id = $article["id"];
$title = makeUTF($article["title"]);
$url = $site_url. "/news-".$article["id"]."-".dot($article["title"]).".html";
$date = $article["date"];
$type = $article["type"];
$desc = $article["news"];
$desc = trim(substr($desc, 0, 128));
$len = strlen($desc) -1;
$x = strpos($desc, '<');
if($x !== false && $x < $len) $len = $x;
if($desc[$len] != ".")
{
while($len > 20 && ord($desc[$len]) != 32) $len--;
}
if ($len > 1) {
$desc = trim(substr($desc, 0, $len)) . "...";
$desc = makeUTF($desc);
$desc = str_replace(' ', ' ', $desc);
$rss .= "<item>\n";
$rss .= "<title>$title</title>\n";
$rss .= "<link>$url</link>\n";
$rss .= "<guid>$id</guid>\n";
$rss .= "<pubDate>$date</pubDate>\n";
$rss .= "<description>$desc</description>\n";
$rss .= "</item>\n";
} else {
$desc = $article["news"];
$start = strpos($desc, 'http://');
$desc = substr($desc, $start, strlen($desc)-1);
$end = strpos($desc, '>');
$desc = substr($desc, 0, $end);
$desc = explode(" ",$desc);
$desc = $desc[0];
$imageurl = trim(str_replace(array("'","\""),"",$desc));
if (@fclose(@fopen($imageurl, "r"))) {
$rss .= "<image>\n";
$rss .= "<url>$imageurl</url>\n";
$rss .= "<title>$title</title>\n";
$rss .= "<link>$url</link>\n";
$rss .= "<description>Download information for the $type file: $title</description>\n";
$rss .= "<height>120</height>\n";
$rss .= "<width>90</width>\n";
$rss .= "</image>\n";
}
$desc = "<p><a href=\"$url\"
title=\"$title\">
<img src=\"$imageurl\" alt=\"$title\" height=\"120\" width=\"90\" style=\"border: 1px solid #000000;\" />
</a></p><p>Download information for the " . $type . " file: " . $title . "</p><p></p>";
$rss .= "<item>\n";
$rss .= "<title>$title</title>\n";
$rss .= "<link>$url</link>\n";
$rss .= "<guid>$id</guid>\n";
$rss .= "<pubDate>$date</pubDate>\n";
$rss .= "<description>$desc</description>\n";
$rss .= "</item>\n";
}
}
$rss .= "</channel>\n";
$rss .= "</rss>\n";
// storing the file
if( file_exists("../rss.xml") && !is_writable("../rss.xml") ) {
echo "<P>Unable to update RSS feed. The file \"$site_url/rss.xml\" is not writable. Please chmod it's permissions to 666";
die;
}
$fp = fopen('../rss.xml', 'w');
fputs($fp, $rss);
fclose($fp);
?>