Source: bblog.phps - download
<?php
//RSS generator
if(isset($_GET['rss'])){
header('Content-Type: text/xml');
$link = 'http://'.$_SERVER['HTTP_HOST'].'/'.$_SERVER['SCRIPT_NAME'];
print '<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"><channel><title>Basic Blog</title><link>'.$link.'</link>';
$tpl = '<item><pubDate>{date}</pubDate><title>{title}</title><link>{link}</link><description>{news}</description></item>';
$all_files = glob('news-*.txt');
foreach($all_files as $file_name) {
list($title, $news) = explode("\n",file_get_contents($file_name), 2);
$link = str_replace(array('news-','.txt'),'',$link.'?n='.$file_name);
$date = date('D, d M Y h:m:i +0000',filemtime($file_name));
print str_replace(array('{link}', '{date}', '{title}','{news}'), array($link, $date, $title, $news), $tpl);
}
print '</channel></rss>';
die;
}
?>
<html dir="rtl">
<head>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type'/>
<link rel="alternate" type="application/rss+xml" title="Blog RSS" href="?rss" />
<title>Basic Blog</title>
<style type="text/css">
body {font-family:Tahoma,sans-serif;font-size:15px;background-color:#CFCFCF}
a {text-decoration:none;font-weight:bold;color:#000}
#body {margin:0 auto;width:85%;padding-top: 20px;background-color:#F1F1F1;border:2px solid #AAA;}
.title {border-bottom:1px solid #AAA;}
.blog {text-align:justify;padding-left: 20px;padding-right: 20px;}
</style>
<body>
<div id="body">
<?php
$tpl = '<div class="blog">
<div class="title"><a href="?n={link}">{title}</a></div>
<p><font color="#cccccc"><i>{date}</i></font> {news}</p>
</div>';
$all_files = ((int)$_GET['n']>0)? glob('news-'.$_GET['n'].'.txt'):glob('news-*.txt');
foreach($all_files as $file_name) {
list($title, $news) = explode("\n",file_get_contents($file_name), 2);
$link = str_replace(array('news-','.txt'),'',$file_name);
$date = date('Y-m-d',filemtime($file_name));
print str_replace(array('{link}', '{date}', '{title}','{news}'), array($link, $date, $title, $news), $tpl);
}
?>
</div>
</body>
</html>