2024-01-18 17:09:45 +00:00
|
|
|
<?php
|
2024-01-18 22:09:17 +00:00
|
|
|
|
2024-01-18 17:09:45 +00:00
|
|
|
// Bounce if not logged in
|
2024-01-18 22:09:17 +00:00
|
|
|
include_once( 'logcheck.php' );
|
2024-01-18 17:09:45 +00:00
|
|
|
|
|
|
|
include_once( 'common.php' );
|
|
|
|
include_once( 'config.php' );
|
|
|
|
|
|
|
|
function build_feed() {
|
|
|
|
$files = array_values( array_diff( scandir( "./posts" ), array('..', '.')));
|
|
|
|
if ( !count( $files ) ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$siteName = SITE_NAME;
|
|
|
|
$siteLang = SITE_LANG;
|
|
|
|
$siteRoot = $root = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . '/';
|
|
|
|
$buildDate = date( DATE_RSS );
|
|
|
|
|
|
|
|
$header = <<<XML
|
2024-01-23 07:02:50 +00:00
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
2024-01-18 17:09:45 +00:00
|
|
|
<rss version="2.0">
|
|
|
|
<channel>
|
|
|
|
<title>$siteName</title>
|
|
|
|
<link>$siteRoot</link>
|
|
|
|
<description>$siteName RSS Feed</description>
|
|
|
|
<lastBuildDate>$buildDate</lastBuildDate>
|
|
|
|
<language>$siteLang</language>
|
|
|
|
|
2024-01-18 17:43:13 +00:00
|
|
|
XML;
|
2024-01-18 17:09:45 +00:00
|
|
|
|
|
|
|
$item = <<<'XML'
|
|
|
|
<item>
|
|
|
|
<title>%s</title>
|
|
|
|
<guid>%s</guid>
|
|
|
|
<link>%s</link>
|
|
|
|
<pubDate>%s</pubDate>
|
|
|
|
</item>
|
|
|
|
|
2024-01-18 17:43:13 +00:00
|
|
|
XML;
|
2024-01-18 17:09:45 +00:00
|
|
|
|
|
|
|
foreach ( array_reverse( $files ) as $f ) {
|
|
|
|
$fn = split_filename( $f, DATE_RSS );
|
|
|
|
$root = $siteRoot . 'post.php?f=';
|
|
|
|
$t = title_from_filename( $f );
|
|
|
|
$header .= sprintf( $item, $fn['title'], $fn['encoded'], $root . $fn['encoded'], $fn['time'] );
|
|
|
|
}
|
|
|
|
|
|
|
|
$header .= " </channel>\n</rss>";
|
|
|
|
file_put_contents( "./rssFeed.xml", $header );
|
|
|
|
}
|