1<?php 2/** 3 * DokuWiki Plugin feedauth (Action Component) 4 * 5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 6 * @author Andreas Gohr <andi@splitbrain.org> 7 */ 8 9// must be run within Dokuwiki 10if (!defined('DOKU_INC')) die(); 11 12if (!defined('DOKU_LF')) define('DOKU_LF', "\n"); 13if (!defined('DOKU_TAB')) define('DOKU_TAB', "\t"); 14if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 15 16require_once DOKU_PLUGIN.'action.php'; 17 18class action_plugin_feedauth extends DokuWiki_Action_Plugin { 19 20 function register(Doku_Event_Handler $controller) { 21 22 $controller->register_hook('FEED_OPTS_POSTPROCESS', 'BEFORE', $this, 'handle_feed_opts_postprocess'); 23 24 } 25 26 function handle_feed_opts_postprocess(&$event, $param) { 27 if(!$_SERVER['REMOTE_USER']){ 28 if($this->getConf('always') || isset($_REQUEST['feedauth'])){ 29 header('WWW-Authenticate: Basic realm="Feed"'); 30 header('HTTP/1.0 401 Unauthorized'); 31 echo 'Authorization required'; 32 exit; 33 } 34 } 35 } 36 37} 38 39// vim:ts=4:sw=4:et:enc=utf-8: 40