Skip to content

Instantly share code, notes, and snippets.

@lizheming
Created October 6, 2010 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lizheming/613578 to your computer and use it in GitHub Desktop.
Save lizheming/613578 to your computer and use it in GitHub Desktop.
<?php
ob_start();
$entry = $SQL->RunQuery("SELECT * FROM entry ORDER BY time DESC LIMIT 0, 50");
$title = SITE_NAME . ' - RSS';
echo urldecode('%3C%3Fxml+version=%221.0%22+encoding=%22utf-8%22%3F%3E');
?><rss version="2.0">
<channel>
<title><?php echo $title; ?></title>
<link><?php echo BASE_URL; ?></link>
<description>Powered by PageCookery Microblog v<?php echo $pcm_version; ?> Build <?php echo $pcm_build; ?></description>
<language>zh</language>
<?php while ($item = $SQL->FetchArray($entry)) { ?>
<item>
<title><?php echo Format::Time($item['time'], 1); ?> 来自 <?php echo $item['from']; ?></title>
<link><?php echo BASE_URL; ?>?act=view&amp;id=<?php echo $item['id']; ?></link>
<description><![CDATA[<?php echo $item['content']; ?>
<?php $item['picture'] = $SQL->QueryRowsArray("SELECT * FROM picture WHERE entryid = " . $item['id']); ?>
<?php if ($item['picture']['id']) { ?>
<p class="image"><a href="<?php echo get_picture_url($item['picture']['id'], 'o'); ?>" title="<?php echo $item['picture']['filename']; ?>"><img src="<?php echo get_picture_url($item['picture']['id'], 'm'); ?>" alt="<?php echo $item['picture']['filename']; ?>" /></a></p>
<?php } ?>]]></description>
<pubDate><?php echo Format::Date($item['time'], 'D, j M Y H:i:s' , 0); ?> +0000</pubDate>
</item>
<?php } ?>
</channel>
</rss>
<?php
$data = ob_get_contents();
ob_end_clean();
file_put_contents('rss.xml', $data);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment