Skip to content

Instantly share code, notes, and snippets.

@fluffy-critter
Last active August 21, 2019 22:43
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 fluffy-critter/528a42d474284f3ad112e7a3fc541f62 to your computer and use it in GitHub Desktop.
Save fluffy-critter/528a42d474284f3ad112e7a3fc541f62 to your computer and use it in GitHub Desktop.
puppy space pirates rss feed example
<?php
/*
To use this, put it in your site root directory, and add the following to
the <head> section of your index.php:
<link rel="alternate" type="application/rss+xml" title="RSS" href="rss.php">
*/
header('Content-Type: application/rss+xml');
echo '<?xml version="1.0" encoding="UTF-8" ?>';
?><rss version="2.0">
<channel>
<title>Puppy Space Pirates</title>
<description>The offical comic adaptation of the movie</description>
<link>http://puppyspacepirates.com/</link>
<?php
$comics = scandir('comics', SCANDIR_SORT_DESCENDING);
foreach ($comics as $filename) {
$pathinfo = pathinfo($filename);
if ($pathinfo['extension'] == 'png' || $pathinfo['extension'] == 'jpg') {
$page = $pathinfo['filename'];
$link = "http://puppyspacepirates.com/?id=$page";
?>
<item><title>Page <?=$page?></title>
<link><?=$link?></link>
<description><![CDATA[<a href="<?=$link?>"><img src="http://puppyspacepirates.com/comics/<?=$filename?>"></a>]]></description>
<guid isPermaLink="true"><?=$link?></guid>
<pubDate><?=date('r', filemtime("comics/$filename"))?></pubDate>
</item>
<?php
}
}
?>
</channel></rss>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment