diff options
-rw-r--r-- | conf/dokuwiki.php | 2 | ||||
-rw-r--r-- | doku.php | 2 | ||||
-rw-r--r-- | feed.php | 72 | ||||
-rw-r--r-- | inc/HTTPClient.php | 17 | ||||
-rw-r--r-- | inc/auth.php | 5 | ||||
-rw-r--r-- | inc/auth/ad.class.php | 2 | ||||
-rw-r--r-- | inc/html.php | 13 |
7 files changed, 75 insertions, 38 deletions
diff --git a/conf/dokuwiki.php b/conf/dokuwiki.php index 90fbb8174..538b9f9da 100644 --- a/conf/dokuwiki.php +++ b/conf/dokuwiki.php @@ -122,7 +122,7 @@ $conf['rss_linkto'] = 'diff'; //what page RSS entries link to: // 'page' - the revised page itself // 'rev' - page showing all revisions // 'current' - most recent revision of page -$conf['rss_content'] = 'abstract'; // what to put in the items by deafult? +$conf['rss_content'] = 'abstract'; // what to put in the items by default? // 'abstract' - plain text, first paragraph or so // 'diff' - plain text unified diff wrapped in <pre> tags // 'htmldiff' - diff as HTML table @@ -26,6 +26,7 @@ if (isset($_SERVER['HTTP_X_DOKUWIKI_DO'])){ // load and initialize the core system require_once(DOKU_INC.'inc/init.php'); +$old = error_reporting(E_ALL ^ E_NOTICE); //import variables $QUERY = trim($_REQUEST['id']); $ID = getID(); @@ -43,6 +44,7 @@ if (isset($_POST['wikitext'])) { $PRE = cleanText(substr($_POST['prefix'], 0, -1)); $SUF = cleanText($_POST['suffix']); $SUM = $_REQUEST['summary']; +error_reporting($old); //sanitize revision $REV = preg_replace('/[^0-9]/','',$REV); @@ -24,7 +24,7 @@ $cache = new cache($key, '.feed'); // prepare cache depends $depends['files'] = getConfigFiles('main'); $depends['age'] = $conf['rss_update']; -$depends['purge'] = ($_REQUEST['purge']) ? true : false; +$depends['purge'] = isset($_REQUEST['purge']); // check cacheage and deliver if nothing has changed since last // time or the update interval has not passed, also handles conditional requests @@ -55,18 +55,20 @@ $image->link = DOKU_URL; $rss->image = $image; $data = null; -if($opt['feed_mode'] == 'list'){ - $data = rssListNamespace($opt); -}elseif($opt['feed_mode'] == 'search'){ - $data = rssSearch($opt); -}else{ +$modes = array('list' => 'rssListNamespace', + 'search' => 'rssSearch', + 'recent' => 'rssRecentChanges'); +if (isset($modes[$opt['feed_mode']])) { + $data = $modes[$opt['feed_mode']]($opt); +} else { $eventData = array( 'opt' => &$opt, 'data' => &$data, ); $event = new Doku_Event('FEED_MODE_UNKNOWN', $eventData); if ($event->advise_before(true)) { - $data = rssRecentChanges($opt); + echo sprintf('<error>Unknown feed mode %s</error>', hsc($opt['feed_mode'])); + exit; } $event->advise_after(); } @@ -83,29 +85,53 @@ print $feed; // ---------------------------------------------------------------- // /** - * Get URL parameters and config options and return a initialized option array + * Get URL parameters and config options and return an initialized option array * * @author Andreas Gohr <andi@splitbrain.org> */ function rss_parseOptions(){ global $conf; - $opt['items'] = (int) $_REQUEST['num']; - $opt['feed_type'] = $_REQUEST['type']; - $opt['feed_mode'] = $_REQUEST['mode']; - $opt['show_minor'] = $_REQUEST['minor']; - $opt['namespace'] = $_REQUEST['ns']; - $opt['link_to'] = $_REQUEST['linkto']; - $opt['item_content'] = $_REQUEST['content']; - $opt['search_query'] = $_REQUEST['q']; - - if(!$opt['feed_type']) $opt['feed_type'] = $conf['rss_type']; - if(!$opt['item_content']) $opt['item_content'] = $conf['rss_content']; - if(!$opt['link_to']) $opt['link_to'] = $conf['rss_linkto']; - if(!$opt['items']) $opt['items'] = $conf['recent']; + $opt = array(); + + foreach(array( + // Basic feed properties + // Plugins may probably want to add new values to these + // properties for implementing own feeds + + // One of: list, search, recent + 'feed_mode' => array('mode', 'recent'), + // One of: diff, page, rev, current + 'link_to' => array('linkto', $conf['rss_linkto']), + // One of: abstract, diff, htmldiff, html + 'item_content' => array('content', $conf['rss_content']), + + // Special feed properties + // These are only used by certain feed_modes + + // String, used for feed title, in list and rc mode + 'namespace' => array('ns', null), + // Positive integer, only used in rc mode + 'items' => array('num', $conf['recent']), + // Boolean, only used in rc mode + 'show_minor' => array('minor', false), + // String, only used in search mode + 'search_query' => array('q', null), + + ) as $name => $val) { + $opt[$name] = (isset($_REQUEST[$val[0]]) && !empty($_REQUEST[$val[0]])) + ? $_REQUEST[$val[0]] : $val[1]; + } + + $opt['items'] = max(0, (int) $opt['items']); + $opt['show_minor'] = (bool) $opt['show_minor']; + $opt['guardmail'] = ($conf['mailguard'] != '' && $conf['mailguard'] != 'none'); - switch ($opt['feed_type']){ + $type = valid_input_set('type', array('rss','rss2','atom','atom1','rss1', + 'default' => $conf['rss_type']), + $_REQUEST); + switch ($type){ case 'rss': $opt['feed_type'] = 'RSS0.91'; $opt['mime_type'] = 'text/xml'; @@ -279,7 +305,7 @@ function rss_buildItems(&$rss,&$data,$opt){ } // add category - if($meta['subject']){ + if(isset($meta['subject'])) { $item->category = $meta['subject']; }else{ $cat = getNS($id); diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php index 7011aa9ed..1cb16714d 100644 --- a/inc/HTTPClient.php +++ b/inc/HTTPClient.php @@ -227,7 +227,7 @@ class HTTPClient { $path = $uri['path']; if(empty($path)) $path = '/'; if(!empty($uri['query'])) $path .= '?'.$uri['query']; - $port = $uri['port']; + if(isset($uri['port']) && !empty($uri['port'])) $port = $uri['port']; if(isset($uri['user'])) $this->user = $uri['user']; if(isset($uri['pass'])) $this->pass = $uri['pass']; @@ -240,7 +240,7 @@ class HTTPClient { }else{ $request_url = $path; $server = $server; - if (empty($port)) $port = ($uri['scheme'] == 'https') ? 443 : 80; + if (!isset($port)) $port = ($uri['scheme'] == 'https') ? 443 : 80; } // add SSL stream prefix if needed - needs SSL support in PHP @@ -555,12 +555,13 @@ class HTTPClient { */ function _parseHeaders($string){ $headers = array(); - $lines = explode("\n",$string); - foreach($lines as $line){ - list($key,$val) = explode(':',$line,2); - $key = strtolower(trim($key)); - $val = trim($val); - if(empty($val)) continue; + if (!preg_match_all('/^\s*([\w-]+)\s*:\s*([\S \t]+)\s*$/m', $string, + $matches, PREG_SET_ORDER)) { + return $headers; + } + foreach($matches as $match){ + list(, $key, $val) = $match; + $key = strtolower($key); if(isset($headers[$key])){ if(is_array($headers[$key])){ $headers[$key][] = $val; diff --git a/inc/auth.php b/inc/auth.php index b3c20e6b9..83d1d4159 100644 --- a/inc/auth.php +++ b/inc/auth.php @@ -194,10 +194,11 @@ function auth_login($user,$pass,$sticky=false,$silent=false){ }else{ // read cookie information list($user,$sticky,$pass) = auth_getCookie(); - // get session info - $session = $_SESSION[DOKU_COOKIE]['auth']; if($user && $pass){ // we got a cookie - see if we can trust it + + // get session info + $session = $_SESSION[DOKU_COOKIE]['auth']; if(isset($session) && $auth->useSessionCache($user) && ($session['time'] >= time()-$conf['auth_security_timeout']) && diff --git a/inc/auth/ad.class.php b/inc/auth/ad.class.php index 41e9d854b..5478d64b9 100644 --- a/inc/auth/ad.class.php +++ b/inc/auth/ad.class.php @@ -126,7 +126,7 @@ class auth_ad extends auth_basic { * at least these fields: * * name string full name of the user - * mail string email addres of the user + * mail string email address of the user * grps array list of groups the user is in * * This LDAP specific function returns the following diff --git a/inc/html.php b/inc/html.php index b6c5cc7ba..67b1c10b7 100644 --- a/inc/html.php +++ b/inc/html.php @@ -876,7 +876,7 @@ function html_diff($text='',$intro=true){ // array in rev2. $rev1 = $REV; - if(is_array($_REQUEST['rev2'])){ + if (is_array($_REQUEST['rev2'])){ $rev1 = (int) $_REQUEST['rev2'][0]; $rev2 = (int) $_REQUEST['rev2'][1]; @@ -888,6 +888,9 @@ function html_diff($text='',$intro=true){ $rev2 = (int) $_REQUEST['rev2']; } + $r_minor = ''; + $l_minor = ''; + if($text){ // compare text to the most current revision $l_rev = ''; $l_text = rawWiki($ID,''); @@ -945,8 +948,12 @@ function html_diff($text='',$intro=true){ '<br />'.$l_user.' '.$l_sum; } - if($r_rev){ - $r_info = getRevisionInfo($ID,$r_rev,true); + $_r_rev = $r_rev; + if (!$_r_rev) { + $_r_rev = @filemtime(wikiFN($ID)); + } + if($_r_rev){ + $r_info = getRevisionInfo($ID,$_r_rev,true); if($r_info['user']){ $r_user = editorinfo($r_info['user']); if(auth_ismanager()) $r_user .= ' ('.$r_info['ip'].')'; |