$feedPath = "../feed_ua.xml"; // The path/name of your .xml file from this one.
// Feed settings
$rssTitle = "Kaniv"; // The title of your rss feed.
$rssLink = "http://www.Kaniv.ck.ua"; // A link to your website.
$rssDesc = "Новини Канева"; // A description of your feed.
$rssCopy = "© www.kaniv.ck.ua"; // Copyright for your feed.
// Table settings
$tableName = "news"; // The name of the table to feed.
$tableKey = "cid"; // The name of the field that holds primary keys
$tableTitle = ""; // The name of the field that holds the title
$tableDate = "time"; // The name of the field that holds the formatted date
$tableDesc = "message"; // The name of the field that holds the description
$sql = "SELECT * FROM " . $tableName . ' WHERE lang="ua" ORDER BY ' . $tableKey . ' DESC LIMIT 15';
$result = mysql_query($sql);
$num = mysql_num_rows($result);
// Cycle through last 15 news articles and add them to the item block array.
$itemBlock = array("");
for($i=0; $i<$num; $i++) {
$newsID = mysql_result($result, $i, $tableKey);
$newsTitle = 'Новини Канева';
$newsDate = mysql_result($result, $i, $tableDate);
$newsDesc = mysql_result($result, $i, $tableDesc);
$newsLink = $rssLink;
$newsDesc = htmlspecialchars($newsDesc);
$buildDate = date("r");
$startBlock = '<?xml version="1.0" encoding="windows-1251" ?>';
$startBlock .= '';
$startBlock .= '<rss version="2.0"><channel>';
$startBlock .= '<title>' . $rssTitle. '</title>';
$startBlock .= '<link>' . $rssLink . '</link>';
$startBlock .= '<description>' . $rssDesc . '</description>';
$startBlock .= '<language>en-gb</language>';
$startBlock .= '<lastBuildDate>' . $buildDate . '</lastBuildDate>';
$startBlock .= '';
$startBlock .= '<copyright>' . $rssCopy . '</copyright>';
$startBlock .= '<ttl>15</ttl>';
// Create the end block.
$endBlock = '</channel>';
$endBlock .= '</rss>';
$title = '<title>' . $newsTitle .' '.$newsDate. '</title>';
$desc = '<description>' . $newsDesc . '</description>';
$link = '<link>' . $newsLink . '</link>';
$guid = '<guid isPermaLink="false">' . $newsLink . '/?id=' . $newsID . '</guid>';
$pubDate = '<pubDate>' . $newsDate . '</pubDate>';
array_push($itemBlock, '<item>');
array_push($itemBlock, $title);
array_push($itemBlock, $desc);
array_push($itemBlock, $link);
array_push($itemBlock, '');
array_push($itemBlock, '');
array_push($itemBlock, $guid);
array_push($itemBlock, $pubDate);
array_push($itemBlock, '</item>');
}
// Write the three blocks to file
$file = $feedPath;
$file = fopen($file, "w");
fwrite($file, $startBlock);
$length = count($itemBlock);
for($i = 0; $i < $length; $i++) {
fwrite($file, $itemBlock[$i]);
}
fwrite($file, $endBlock);
fclose($file);
Короче, стандартная фишка
