| [ Index ] |
PHP Cross Reference of DokuWiki |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * XML feed export 5 * 6 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 7 * @author Andreas Gohr <andi@splitbrain.org> 8 * 9 * @global array $conf 10 * @global Input $INPUT 11 */ 12 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; 20 use dokuwiki\Search\FulltextSearch; 21 22 if (!defined('DOKU_INC')) define('DOKU_INC', __DIR__ . '/'); 23 require_once (DOKU_INC . 'inc/init.php'); 24 25 //close session 26 session_write_close(); 27 28 //feed disabled? 29 if (!actionOK('rss')) { 30 http_status(404); 31 echo '<error>RSS feed is disabled.</error>'; 32 exit; 33 } 34 35 $options = new FeedCreatorOptions(); 36 37 // we only cache the recent cache, but do so based on dynamic parameters 38 // other modes are never cached and always created on the fly 39 $cache = null; 40 $cacheKey = $options->getCacheKey([ 41 $INPUT->server->str('REMOTE_USER'), 42 $INPUT->server->str('HTTP_HOST'), 43 $INPUT->server->str('SERVER_PORT'), 44 ]); 45 if ($cacheKey !== null) { 46 $cache = new Cache($cacheKey, '.feed'); 47 48 // prepare cache depends 49 $depends['files'] = getConfigFiles('main'); 50 $depends['age'] = $conf['rss_update']; 51 $depends['purge'] = $INPUT->bool('purge'); 52 } 53 54 // check cacheage and deliver if nothing has changed since last 55 // time or the update interval has not passed, also handles conditional requests 56 header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); 57 header('Pragma: public'); 58 header('Content-Type: ' . $options->getMimeType()); 59 header('X-Robots-Tag: noindex'); 60 if ($cache?->useCache($depends)) { 61 http_conditionalRequest($cache->getTime()); 62 if ($conf['allowdebug']) header("X-CacheUsed: $cache->cache"); 63 echo $cache->retrieveCache(); 64 exit; 65 } else { 66 http_conditionalRequest(time()); 67 } 68 69 // create new feed 70 try { 71 $feed = (new FeedCreator($options))->build(); 72 $cache?->storeCache($feed); 73 echo $feed; 74 } catch (Exception $e) { 75 http_status(500); 76 echo '<error>' . hsc($e->getMessage()) . '</error>'; 77 exit; 78 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body