diff options
author | 53hornet <atc@53hor.net> | 2021-12-10 23:17:42 -0500 |
---|---|---|
committer | 53hornet <atc@53hor.net> | 2021-12-10 23:17:42 -0500 |
commit | de9bbfdb8f0d3b366e76a5cc775690f7315c740f (patch) | |
tree | ce5dd65c507ce5db6382665d824ef163e47e8d0f /feed.php | |
parent | e68127a6ff2428657b8dab0b90cd16bf1dd99dad (diff) | |
download | 53hor-de9bbfdb8f0d3b366e76a5cc775690f7315c740f.tar.xz 53hor-de9bbfdb8f0d3b366e76a5cc775690f7315c740f.zip |
feat: custom routing, no required php in posts
Diffstat (limited to 'feed.php')
-rw-r--r-- | feed.php | 16 |
1 files changed, 7 insertions, 9 deletions
@@ -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> |