summaryrefslogtreecommitdiff
path: root/feed.php
diff options
context:
space:
mode:
author53hornet <atc@53hor.net>2021-12-10 23:17:42 -0500
committer53hornet <atc@53hor.net>2021-12-10 23:17:42 -0500
commitde9bbfdb8f0d3b366e76a5cc775690f7315c740f (patch)
treece5dd65c507ce5db6382665d824ef163e47e8d0f /feed.php
parente68127a6ff2428657b8dab0b90cd16bf1dd99dad (diff)
download53hor-de9bbfdb8f0d3b366e76a5cc775690f7315c740f.tar.xz
53hor-de9bbfdb8f0d3b366e76a5cc775690f7315c740f.zip
feat: custom routing, no required php in posts
Diffstat (limited to 'feed.php')
-rw-r--r--feed.php16
1 files changed, 7 insertions, 9 deletions
diff --git a/feed.php b/feed.php
index c8f51ef..f76377c 100644
--- a/feed.php
+++ b/feed.php
@@ -12,16 +12,14 @@
<link>https://www.53hor.net</link>
</image>
<?php
- if ($posts = glob('./posts/*.php')) {
- $early = true;
+ $posts = scandir('./posts', SCANDIR_SORT_DESCENDING);
+ $posts = array_filter($posts, fn ($post) => !empty($post) && $post != '.' && $post != '..');
- foreach (array_reverse($posts) as $post) {
- if (!empty($post) && $post != '.' && $post != '..') {
- $post_name = explode('/', $post)[2];
- include($post);
- printf('<item><link>https://www.53hor.net/posts/%s</link><title>%s</title></item>', $post_name, $title);
- }
- }
+ foreach ($posts as &$post) {
+ $title = str_replace('<h1>', '', fgets(fopen("./posts/$post", 'r')));
+ $title = str_replace('</h1>', '', $title);
+ $post = str_replace('.php', '', $post);
+ printf('<item><link>https://www.53hor.net/posts/%s</link><title>%s</title></item>', $post, $title);
}
?>
</channel>