2024-02-25 21:11:08 +01:00
|
|
|
<?php
|
|
|
|
header('Content-type: text/xml');
|
|
|
|
/*
|
|
|
|
Runs from a directory containing files to provide an
|
|
|
|
RSS 2.0 feed that contains the list and modification times for all the
|
|
|
|
files. Thanks to vsoch on GitHub!
|
|
|
|
*/
|
|
|
|
$feedName = "dym's random audio finds";
|
|
|
|
$feedDesc = "feed of audio files";
|
|
|
|
$feedURL = "https://web.dym.sh/audio/rss.xml";
|
|
|
|
$feedBaseURL = "https://web.dym.sh/audio/"; // must end in trailing forward slash (/).
|
|
|
|
|
2024-04-30 21:16:11 +02:00
|
|
|
// $allowed_ext = ".mp4,.mp3,.webm,.ogg,.flac,.opus";
|
2024-02-25 21:11:08 +01:00
|
|
|
|
|
|
|
echo '<?xml version="1.0" ?>';
|
|
|
|
?>
|
|
|
|
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
|
|
|
<channel>
|
|
|
|
<title><?= $feedName ?></title>
|
|
|
|
<link><?= $feedURL ?></link>
|
|
|
|
<description><?= $feedDesc ?></description>
|
|
|
|
<?php
|
|
|
|
$items = [];
|
|
|
|
$sub = "";
|
|
|
|
$dir = opendir("./");
|
|
|
|
|
|
|
|
while( $file = readdir($dir) )
|
|
|
|
{
|
|
|
|
$ext = strtolower( pathinfo($sub.$file, PATHINFO_EXTENSION) );
|
|
|
|
if( '.' !== $file
|
|
|
|
&& '..' !== $file
|
|
|
|
&& 'index.php' !== $file
|
|
|
|
&& 'index.html' !== $file
|
|
|
|
&& !is_dir($file)
|
|
|
|
// && 0 < strpos($allowed_ext, $ext)
|
2024-04-30 21:16:11 +02:00
|
|
|
) {
|
2024-02-25 21:11:08 +01:00
|
|
|
$item['name'] = $sub.$file;
|
|
|
|
$item['timestamp'] = filectime($sub.$file);
|
|
|
|
$item['size'] = filesize($sub.$file);
|
|
|
|
$items[] = $item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
closedir($dir);
|
|
|
|
// natcasesort($items);
|
|
|
|
|
|
|
|
foreach($items as $item) {
|
|
|
|
if (!empty($item['name'])) {
|
|
|
|
$title = $item['name'];
|
|
|
|
$link = $feedBaseURL . urlencode( $item['name'] );
|
|
|
|
$dt = date( DATE_RSS, $item['timestamp'] );
|
|
|
|
echo <<<__item__
|
|
|
|
<item>
|
|
|
|
<title><![CDATA[$title]]></title>
|
|
|
|
<link>$link</link>
|
|
|
|
<guid>$link</guid>
|
|
|
|
<pubDate>$dt</pubDate>
|
|
|
|
</item>
|
|
|
|
__item__;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</channel>
|
2024-04-30 21:16:11 +02:00
|
|
|
</rss>
|