<?='<?xml version="1.0" ?>'?>
<rss version="2.0">
 <channel>
  <title>ImranNazar.com</title>
  <link>http://imrannazar.com/</link>
<?php
$pages = array();
foreach(sqlite_array_query($db, 'select * from Pages where PageName in ("Articles","Sub-articles","Programming","Fiction") order by mpttLeft') as $cat)
{
  foreach(sqlite_array_query($db, 'select * from Pages where mpttLeft>'.$cat['mpttLeft'].' and leafNode=1 and mpttRight<'.$cat['mpttRight'].' order by mpttLeft') as $p)
  {
    $pages[$p['PageDate']] = array(
      'Name'=>$p['PageName'],
      'Title'=>str_replace('-',' ',$p['PageName']),
      'Description'=>$p['PageDesc'],
      'Category'=>$cat['PageName'],
      'Date'=>date('D, d M Y H:i:s', $p['PageDate'])
    );
  }
}
krsort($pages);
foreach($pages as $p):
?>
  <item>
   <title><?=$p['Title']?></title>
   <link>http://imrannazar.com/<?=$p['Name']?></link>
   <description><?=htmlentities($p['Description'])?></description>
   <category><?=$p['Category']?></category>
   <pubDate><?=$p['Date']?> GMT</pubDate>
  </item>
<?php
endforeach;
?>
 </channel>
</rss>

