84 lines
2.7 KiB
PHP
84 lines
2.7 KiB
PHP
<?php
|
|
date_default_timezone_set('Europe/Paris');
|
|
require '../vendor/autoload.php';
|
|
|
|
use App\FileAndDir;
|
|
use App\Cache;
|
|
use Utils\Utils;
|
|
|
|
$config = [
|
|
'templateFile' => 'board', // Template filename (must be placed in 'public/templates' folder)
|
|
'title' => 'NanoGal', // Text to be displayed in browser titlebar
|
|
'description' => 'My gallery', // Use in meta tag "description"
|
|
'author' => 'NanoGal', // Your name
|
|
'skipObjects' => ['comment.html', '.gitkeep', 'aFolder', 'aFile.ext'], //Those files and folders will not be displayed (affects the page and the RSS feed)
|
|
'imageCaptionPosition' => 'right', // Position of caption in lightbox
|
|
'sortBy' => 'name', // Sort by name or date
|
|
'orderBy' => 'desc', // Order by asc or desc
|
|
'thumbSize' => 250, // Thumbnail height/width (square thumbs)
|
|
'displayExifInfo' => false, // Display Exif info in caption
|
|
'disableCache' => false, // Enable or disable cache
|
|
'showShareLink' => false, // Show link for thumb, full, markdown link (thumb + link to full)
|
|
'nbItemsAtom' => 25 // Number of item in atom feed
|
|
];
|
|
|
|
if (file_exists('../datas/config.php')) {
|
|
include '../datas/config.php';
|
|
$config = array_merge($config, $userConfig);
|
|
}
|
|
|
|
header('Content-Type: text/xml');
|
|
|
|
if ($config['disableCache'] === false) {
|
|
$cachedFeed = Cache::getAtomFeed();
|
|
if ($cachedFeed) {
|
|
echo $cachedFeed;
|
|
exit();
|
|
}
|
|
} else {
|
|
Cache::clearAtomFeed();
|
|
}
|
|
|
|
$gallery_link = $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'];
|
|
|
|
$fileList = new FileAndDir('', '/', $config);
|
|
$filterList = $fileList->makeMoreRecentFile();
|
|
|
|
$date = date_create();
|
|
$updated = $date->format(DateTimeInterface::ATOM);
|
|
|
|
$atom = '<?xml version="1.0" encoding="UTF-8" ?>
|
|
<feed xmlns="http://www.w3.org/2005/Atom">
|
|
<title>' . $config['title'] . '</title>
|
|
<link href="' . $gallery_link . '/feed.php" rel="self" />
|
|
<link href="' . $gallery_link . '" />
|
|
<id>' . $gallery_link . '</id>
|
|
<icon>assets/favicons/favicon-96x96.png</icon>
|
|
<logo>assets/favicons/favicon-310x310.png</logo>
|
|
<generator>NanoGal</generator>
|
|
<author>
|
|
<name>' . $config['author'] . '</name>
|
|
</author>
|
|
<updated>' . $updated . '</updated>';
|
|
|
|
foreach ($filterList as $value) {
|
|
|
|
$atom .= '
|
|
<entry>
|
|
<title>' . basename($value['url']) . '</title>
|
|
<link href="' . $value['url'] . '"/>
|
|
<id>' . $value['url'] . '</id>
|
|
<updated>' . date(DATE_ATOM, $value['tdate']) . '</updated>
|
|
<published>' . date(DATE_ATOM, $value['tdate']) . '</published>
|
|
<content type="html" xml:lang="en">
|
|
<![CDATA[
|
|
<a href="' . $value['url'] . '"><img src="' . $value['thumb'] . '"></a>
|
|
]]>
|
|
</content>
|
|
</entry>';
|
|
}
|
|
$atom .= "</feed>";
|
|
if ($config['disableCache'] === false) {
|
|
Cache::setAtomFeed($atom);
|
|
}
|
|
echo $atom;
|