This commit is contained in:
Dym Sohin 2024-02-25 21:11:08 +01:00
commit d7675e0b92
3 changed files with 132 additions and 0 deletions

6
LICENSE Normal file
View File

@ -0,0 +1,6 @@
Copyright (C) 2019 by Vanessa Sochat [github.com/vsoch]
Copyright (C) 2024 by Dym Sohin <re@dym.sh>
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

63
dir2pod.php Normal file
View File

@ -0,0 +1,63 @@
<?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 (/).
$allowed_ext = ".mp4,.mp3,.webm,.ogg,.flac";
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)
) {
$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 . $item['name']; //urlencode( $item['name'] );
$dt = date( DATE_RSS, $item['timestamp'] );
echo <<<__item__
<item>
<title><![CDATA[$title]]></title>
<guid isPermaLink="true">$link</guid>
<enclosure url="$link" />
<pubDate>$dt</pubDate>
</item>
__item__;
}
}
?>
</channel>
</rss>

63
dir2rss.php Normal file
View File

@ -0,0 +1,63 @@
<?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 (/).
// $allowed_ext = ".mp4,.mp3,.webm,.ogg,.flac";
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)
) {
$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>
</rss>