6 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
7 * @author Andreas Gohr <andi@splitbrain.org>
10 * @global Input $INPUT
13 use dokuwiki\Feed\FeedCreator
;
14 use dokuwiki\Feed\FeedCreatorOptions
;
15 use dokuwiki\Cache\Cache
;
16 use dokuwiki\ChangeLog\MediaChangeLog
;
17 use dokuwiki\ChangeLog\PageChangeLog
;
18 use dokuwiki\Extension\AuthPlugin
;
19 use dokuwiki\Extension\Event
;
21 if (!defined('DOKU_INC')) define('DOKU_INC', __DIR__
. '/');
22 require_once(DOKU_INC
. 'inc/init.php');
25 session_write_close();
28 if (!actionOK('rss')) {
30 echo '<error>RSS feed is disabled.</error>';
34 $options = new FeedCreatorOptions();
36 // the feed is dynamic - we need a cache for each combo
37 // (but most people just use the default feed so it's still effective)
39 $options->getCacheKey(),
40 $INPUT->server
->str('REMOTE_USER'),
41 $INPUT->server
->str('HTTP_HOST'),
42 $INPUT->server
->str('SERVER_PORT')
44 $cache = new Cache($key, '.feed');
46 // prepare cache depends
47 $depends['files'] = getConfigFiles('main');
48 $depends['age'] = $conf['rss_update'];
49 $depends['purge'] = $INPUT->bool('purge');
51 // check cacheage and deliver if nothing has changed since last
52 // time or the update interval has not passed, also handles conditional requests
53 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
54 header('Pragma: public');
55 header('Content-Type: ' . $options->getMimeType());
56 header('X-Robots-Tag: noindex');
57 if ($cache->useCache($depends)) {
58 http_conditionalRequest($cache->getTime());
59 if ($conf['allowdebug']) header("X-CacheUsed: $cache->cache");
60 echo $cache->retrieveCache();
63 http_conditionalRequest(time());
68 $feed = (new FeedCreator($options))->build();
69 $cache->storeCache($feed);
71 } catch (Exception
$e) {
73 echo '<error>' . hsc($e->getMessage()) . '</error>';