a poorly-written personal website
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

42 lines
1.4 KiB

<?php
header("Content-Type: application/rss+xml; charset=UTF-8");
date_default_timezone_set('UTC');
$entries = array_map('basename', array_filter(glob('html/*')) );
$sliced = array_slice(array_reverse($entries, true), 0, 20, true);
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<rss version="2.0" ';
echo 'xmlns:content="http://purl.org/rss/1.0/modules/content/"';
echo '>';
echo '<channel>';
echo '<title>紀行無常 - katherine\'s blog</title>';
echo '<link>https://airen-no-jikken.icu/blog/</link>';
echo '<description>pointless blathering</description>';
echo '<language>en-gb</language>';
foreach($sliced as $key => $value) {
preg_match("/-.*$/", $value, $matches);
$title = substr($matches[0], 1);
preg_match("/^.*-/", $value, $matches);
$date = str_replace(".", "-", substr($matches[0], 0, -1));
$link = 'https://airen-no-jikken.icu/blog/?p=' . $key;
$content = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/blog/html/$value");
echo '<item>';
echo '<title>' . htmlspecialchars($title) . '</title>';
echo '<link>' . $link . '</link>';
echo '<guid isPermaLink="false">' . $date . htmlspecialchars($title) . '</guid>';
echo '<pubDate>' . date("D, d M Y H:i:s O", strtotime($date)) . '</pubDate>';
echo '<content:encoded><![CDATA[' . $content . ']]></content:encoded>';
echo '</item>';
}
echo '</channel>';
echo '</rss>';
?>