2005-01-12 21:24:54 +01:00
|
|
|
<?php
|
2022-01-27 00:07:01 +01:00
|
|
|
|
2005-01-14 17:40:57 +01:00
|
|
|
/**
|
|
|
|
* XML feed export
|
|
|
|
*
|
|
|
|
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
|
|
|
* @author Andreas Gohr <andi@splitbrain.org>
|
2012-06-24 14:59:43 +02:00
|
|
|
*
|
|
|
|
* @global array $conf
|
2012-06-24 15:17:38 +02:00
|
|
|
* @global Input $INPUT
|
2005-01-14 17:40:57 +01:00
|
|
|
*/
|
|
|
|
|
2024-01-30 09:44:03 +01:00
|
|
|
use dokuwiki\Feed\FeedCreator;
|
2024-01-26 15:24:41 +01:00
|
|
|
use dokuwiki\Feed\FeedCreatorOptions;
|
2019-02-02 13:05:17 +01:00
|
|
|
use dokuwiki\Cache\Cache;
|
2018-06-15 11:45:58 +02:00
|
|
|
use dokuwiki\ChangeLog\MediaChangeLog;
|
|
|
|
use dokuwiki\ChangeLog\PageChangeLog;
|
2018-06-15 17:05:16 +02:00
|
|
|
use dokuwiki\Extension\AuthPlugin;
|
|
|
|
use dokuwiki\Extension\Event;
|
2018-06-15 11:45:58 +02:00
|
|
|
|
2023-08-30 14:48:22 +02:00
|
|
|
if (!defined('DOKU_INC')) define('DOKU_INC', __DIR__ . '/');
|
2022-01-26 00:16:18 +01:00
|
|
|
require_once(DOKU_INC . 'inc/init.php');
|
2009-10-20 23:23:38 +02:00
|
|
|
|
|
|
|
//close session
|
|
|
|
session_write_close();
|
|
|
|
|
2014-03-18 13:19:05 +01:00
|
|
|
//feed disabled?
|
2022-01-27 00:07:01 +01:00
|
|
|
if (!actionOK('rss')) {
|
2014-03-18 14:02:01 +01:00
|
|
|
http_status(404);
|
2014-03-18 13:19:05 +01:00
|
|
|
echo '<error>RSS feed is disabled.</error>';
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2024-01-26 15:24:41 +01:00
|
|
|
$options = new FeedCreatorOptions();
|
2009-10-20 23:23:38 +02:00
|
|
|
|
|
|
|
// the feed is dynamic - we need a cache for each combo
|
|
|
|
// (but most people just use the default feed so it's still effective)
|
2024-01-15 16:30:56 +01:00
|
|
|
$key = implode('$', [
|
|
|
|
$options->getCacheKey(),
|
|
|
|
$INPUT->server->str('REMOTE_USER'),
|
|
|
|
$INPUT->server->str('HTTP_HOST'),
|
|
|
|
$INPUT->server->str('SERVER_PORT')
|
|
|
|
]);
|
2019-02-02 13:05:17 +01:00
|
|
|
$cache = new Cache($key, '.feed');
|
2009-11-15 15:24:50 +01:00
|
|
|
|
|
|
|
// prepare cache depends
|
|
|
|
$depends['files'] = getConfigFiles('main');
|
2023-08-31 00:55:36 +02:00
|
|
|
$depends['age'] = $conf['rss_update'];
|
2012-06-24 15:17:38 +02:00
|
|
|
$depends['purge'] = $INPUT->bool('purge');
|
2009-10-20 23:23:38 +02:00
|
|
|
|
|
|
|
// check cacheage and deliver if nothing has changed since last
|
|
|
|
// time or the update interval has not passed, also handles conditional requests
|
|
|
|
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
|
|
|
header('Pragma: public');
|
2024-02-11 10:11:45 +01:00
|
|
|
header('Content-Type: ' . $options->getMimeType());
|
2009-10-20 23:23:38 +02:00
|
|
|
header('X-Robots-Tag: noindex');
|
2022-01-27 00:07:01 +01:00
|
|
|
if ($cache->useCache($depends)) {
|
2019-02-14 23:41:13 +01:00
|
|
|
http_conditionalRequest($cache->getTime());
|
2022-01-27 00:07:01 +01:00
|
|
|
if ($conf['allowdebug']) header("X-CacheUsed: $cache->cache");
|
2023-08-31 22:00:27 +02:00
|
|
|
echo $cache->retrieveCache();
|
2006-03-03 11:20:12 +01:00
|
|
|
exit;
|
2009-10-20 23:23:38 +02:00
|
|
|
} else {
|
2006-03-24 14:33:15 +01:00
|
|
|
http_conditionalRequest(time());
|
2012-06-24 14:59:43 +02:00
|
|
|
}
|
2009-10-20 23:23:38 +02:00
|
|
|
|
|
|
|
// create new feed
|
2024-01-15 16:30:56 +01:00
|
|
|
try {
|
2024-01-30 09:44:03 +01:00
|
|
|
$feed = (new FeedCreator($options))->build();
|
2024-01-15 16:30:56 +01:00
|
|
|
$cache->storeCache($feed);
|
|
|
|
echo $feed;
|
|
|
|
} catch (Exception $e) {
|
|
|
|
http_status(500);
|
|
|
|
echo '<error>' . hsc($e->getMessage()) . '</error>';
|
|
|
|
exit;
|
2009-10-20 23:23:38 +02:00
|
|
|
}
|