From 24b3cb1ac0784ffa2acabf021fdd06c6d49cc7b1 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Mon, 1 Feb 2010 16:20:40 +0100 Subject: removed require's in lib/exe/* --- lib/exe/xmlrpc.php | 23 ----------------------- 1 file changed, 23 deletions(-) (limited to 'lib/exe/xmlrpc.php') diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index d3913482f..fb6b79cf3 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -10,15 +10,10 @@ if(isset($HTTP_RAW_POST_DATA)) $HTTP_RAW_POST_DATA = trim($HTTP_RAW_POST_DATA); define('DOKU_XMLRPC_API_VERSION',2); require_once(DOKU_INC.'inc/init.php'); -require_once(DOKU_INC.'inc/common.php'); -require_once(DOKU_INC.'inc/auth.php'); session_write_close(); //close session if(!$conf['xmlrpc']) die('XML-RPC server not enabled.'); -require_once(DOKU_INC.'inc/IXR_Library.php'); - - /** * Contains needed wrapper functions and registers all available * XMLRPC functions. @@ -378,7 +373,6 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { $ns = cleanID($ns); $dir = utf8_encodeFN(str_replace(':', '/', $ns)); $data = array(); - require_once(DOKU_INC.'inc/search.php'); $opts['skipacl'] = 0; // no ACL skipping for XMLRPC search($data, $conf['datadir'], 'search_allpages', $opts, $dir); return $data; @@ -407,7 +401,6 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { $dir = utf8_encodeFN(str_replace(':', '/', $ns)); $data = array(); - require_once(DOKU_INC.'inc/search.php'); search($data, $conf['mediadir'], 'search_media', $options, $dir); $len = count($data); if(!$len) return array(); @@ -426,7 +419,6 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { * Return a list of backlinks */ function listBackLinks($id){ - require_once(DOKU_INC.'inc/fulltext.php'); return ft_backlinks($id); } @@ -519,8 +511,6 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { } if($conf['dperm']) chmod($lock, $conf['dperm']); - require_once(DOKU_INC.'inc/indexer.php'); - // do the work idx_addPage($id); @@ -572,7 +562,6 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { return new IXR_ERROR(1, $lang['uploadexist'].'1'); } // check for valid content - @require_once(DOKU_INC.'inc/media.php'); $ok = media_contentcheck($ftmp, $imime); if($ok == -1) { return new IXR_ERROR(1, sprintf($lang['uploadexist'].'2', ".$iext")); @@ -590,7 +579,6 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { $data[4] = $overwrite; // trigger event - require_once(DOKU_INC.'inc/events.php'); return trigger_event('MEDIA_UPLOAD_FINISH', $data, array($this, '_media_upload_action'), true); } else { @@ -615,14 +603,12 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { // check for references if needed $mediareferences = array(); if($conf['refcheck']){ - require_once(DOKU_INC.'inc/fulltext.php'); $mediareferences = ft_mediause($id,$conf['refshow']); } if(!count($mediareferences)){ $file = mediaFN($id); if(@unlink($file)){ - require_once(DOKU_INC.'inc/changelog.php'); addMediaLogEntry(time(), $id, DOKU_CHANGE_TYPE_DELETE); io_sweepNS($id,'mediadir'); return 0; @@ -648,7 +634,6 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { chmod($data[1], $conf['fmode']); media_notify($data[2], $data[1], $data[3]); // add a log entry to the media changelog - require_once(DOKU_INC.'inc/changelog.php'); if ($data[4]) { addMediaLogEntry(time(), $data[2], DOKU_CHANGE_TYPE_EDIT); } else { @@ -728,9 +713,6 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { if(strlen($timestamp) != 10) return new IXR_Error(20, 'The provided value is not a valid timestamp'); - require_once(DOKU_INC.'inc/changelog.php'); - require_once(DOKU_INC.'inc/pageutils.php'); - $recents = getRecentsSince($timestamp); $changes = array(); @@ -764,9 +746,6 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { if(strlen($timestamp) != 10) return new IXR_Error(20, 'The provided value is not a valid timestamp'); - require_once(DOKU_INC.'inc/changelog.php'); - require_once(DOKU_INC.'inc/pageutils.php'); - $recents = getRecentsSince($timestamp, null, '', RECENTS_MEDIA_CHANGES); $changes = array(); @@ -803,8 +782,6 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { if(empty($id)) return new IXR_Error(1, 'Empty page ID'); - require_once(DOKU_INC.'inc/changelog.php'); - $revisions = getRevisions($id, $first, $conf['recent']+1); if(count($revisions)==0 && $first!=0) { -- cgit v1.2.3 From f71f4f5359fe234960829868bf22081bf1f2d947 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 28 Feb 2010 12:32:01 +0100 Subject: added dokuwiki.search XMLRPC call FS#1882 --- lib/exe/xmlrpc.php | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'lib/exe/xmlrpc.php') diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index d3913482f..a29a40612 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -7,7 +7,7 @@ if(isset($HTTP_RAW_POST_DATA)) $HTTP_RAW_POST_DATA = trim($HTTP_RAW_POST_DATA); /** * Increased whenever the API is changed */ -define('DOKU_XMLRPC_API_VERSION',2); +define('DOKU_XMLRPC_API_VERSION',3); require_once(DOKU_INC.'inc/init.php'); require_once(DOKU_INC.'inc/common.php'); @@ -118,6 +118,13 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { 'List all pages within the given namespace.' ); + $this->addCallback( + 'dokuwiki.search', + 'this:search', + array('struct','string'), + 'Perform a fulltext search and return a list of matching pages' + ); + $this->addCallback( 'dokuwiki.getTime', 'time', @@ -384,6 +391,41 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { return $data; } + /** + * List all pages in the given namespace (and below) + */ + function search($query){ + require_once(DOKU_INC.'inc/fulltext.php'); + + $regex = ''; + $data = ft_pageSearch($query,$regex); + $pages = array(); + + // prepare additional data + $idx = 0; + foreach($data as $id => $score){ + $file = wikiFN($id); + + if($idx < FT_SNIPPET_NUMBER){ + $snippet = ft_snippet($id,$regex); + $idx++; + }else{ + $snippet = ''; + } + + $pages[] = array( + 'id' => $id, + 'score' => $score, + 'rev' => filemtime($file), + 'mtime' => filemtime($file), + 'size' => filesize($file), + 'snippet' => $snippet, + ); + } + return $data; + } + + /** * List all media files. * -- cgit v1.2.3 From fe17917e7668864526ec0f0ae65dd0787831d8a4 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Wed, 10 Mar 2010 10:41:32 +0100 Subject: Move & rename HTML_PAGE_FROMTEMPLATE to common.php The new COMMON_PAGE_FROMTEMPLATE is triggered by pageTemplate AFTER the template has been read but before performing the template replacements. --- lib/exe/xmlrpc.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib/exe/xmlrpc.php') diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index a29a40612..155812d22 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -290,8 +290,7 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { } $text = rawWiki($id,$rev); if(!$text) { - $data = array($id); - return trigger_event('HTML_PAGE_FROMTEMPLATE',$data,'pageTemplate',true); + return pageTemplate($id); } else { return $text; } -- cgit v1.2.3 From c77fa67b50d49455e3b518eeb2bcbd0531d07165 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Tue, 16 Mar 2010 15:33:58 +0100 Subject: Use md5sum of id and client ip as temporary filename in XML-RPC Before this patch the temporary filename was the uncleaned id. This allowed everyone with upload-privileges (on the whole wiki) and XML-RPC privileges on a XML-RPC-enabled DokuWiki to (over)write any file PHP is allowed to write with any content he wants. If you have XML-RPC enabled and users with XML-RPC and upload privileges you don't trust in a way you would allow them to write any file PHP may write, consider this as an important security fix. By default XML-RPC is disabled, so if you don't know what I'm talking about you are probably not affected by the problem. --- lib/exe/xmlrpc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/exe/xmlrpc.php') diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index 670ab5d7e..b6b9f0e52 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -578,7 +578,7 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { return new IXR_ERROR(1, 'Filename not given.'); } - $ftmp = $conf['tmpdir'] . '/' . $id; + $ftmp = $conf['tmpdir'] . '/' . md5($id.clientIP()); // save temporary file @unlink($ftmp); -- cgit v1.2.3 From ac1ffdde2b4e44e5eb2434a5df8ef6a04bb4ff29 Mon Sep 17 00:00:00 2001 From: Georges-Etienne Legendre Date: Sat, 17 Apr 2010 21:45:21 +0800 Subject: Fix #1943: full text search XML-RPC call should return the $pages instead of $data --- lib/exe/xmlrpc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/exe/xmlrpc.php') diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index b6b9f0e52..743d3eedb 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -415,7 +415,7 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { 'snippet' => $snippet, ); } - return $data; + return $pages; } -- cgit v1.2.3 From e6f4c9d492a59d555873548a77c477870f6cdcd8 Mon Sep 17 00:00:00 2001 From: Georges-Etienne Legendre Date: Sat, 17 Apr 2010 21:58:17 +0800 Subject: Adding getTitle to the XML-RPC API --- lib/exe/xmlrpc.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'lib/exe/xmlrpc.php') diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index 743d3eedb..a4dc56f0f 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -7,7 +7,7 @@ if(isset($HTTP_RAW_POST_DATA)) $HTTP_RAW_POST_DATA = trim($HTTP_RAW_POST_DATA); /** * Increased whenever the API is changed */ -define('DOKU_XMLRPC_API_VERSION',3); +define('DOKU_XMLRPC_API_VERSION',4); require_once(DOKU_INC.'inc/init.php'); session_write_close(); //close session @@ -134,6 +134,15 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { 'Lock or unlock pages.' ); + + $this->addCallback( + 'dokuwiki.getTitle', + 'this:getTitle', + array('string'), + 'Returns the wiki title.', + true + ); + /* Wiki API v2 http://www.jspwiki.org/wiki/WikiRPCInterface2 */ $this->addCallback( 'wiki.getRPCVersionSupported', @@ -418,6 +427,13 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { return $pages; } + /** + * Returns the wiki title. + */ + function getTitle(){ + global $conf; + return $conf['title']; + } /** * List all media files. -- cgit v1.2.3 From 86228f109464404b30ea74164e855ef146c87249 Mon Sep 17 00:00:00 2001 From: Dominik Eckelmann Date: Mon, 24 May 2010 21:44:35 +0200 Subject: added cleanID to xmlrpc call wiki.getBackLinks --- lib/exe/xmlrpc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/exe/xmlrpc.php') diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index a4dc56f0f..377003cf1 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -476,7 +476,7 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { * Return a list of backlinks */ function listBackLinks($id){ - return ft_backlinks($id); + return ft_backlinks(cleanID($id)); } /** -- cgit v1.2.3 From a0070b52bbd24f6972b819fa8ff4bdbfe81b5bbc Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Wed, 16 Jun 2010 16:15:28 +0200 Subject: Add title index to the indexer files, improve indexer calls --- lib/exe/xmlrpc.php | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'lib/exe/xmlrpc.php') diff --git a/lib/exe/xmlrpc.php b/lib/exe/xmlrpc.php index 377003cf1..f06792361 100644 --- a/lib/exe/xmlrpc.php +++ b/lib/exe/xmlrpc.php @@ -354,24 +354,22 @@ class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { * List all pages - we use the indexer list here */ function listPages(){ - global $conf; - $list = array(); - $pages = file($conf['indexdir'] . '/page.idx'); - $pages = array_filter($pages, 'isVisiblePage'); + $pages = array_filter(array_filter(idx_getIndex('page', ''), + 'isVisiblePage'), + 'page_exists'); foreach(array_keys($pages) as $idx) { - if(page_exists($pages[$idx])) { - $perm = auth_quickaclcheck($pages[$idx]); - if($perm >= AUTH_READ) { - $page = array(); - $page['id'] = trim($pages[$idx]); - $page['perms'] = $perm; - $page['size'] = @filesize(wikiFN($pages[$idx])); - $page['lastModified'] = new IXR_Date(@filemtime(wikiFN($pages[$idx]))); - $list[] = $page; - } + $perm = auth_quickaclcheck($pages[$idx]); + if($perm < AUTH_READ) { + continue; } + $page = array(); + $page['id'] = trim($pages[$idx]); + $page['perms'] = $perm; + $page['size'] = @filesize(wikiFN($pages[$idx])); + $page['lastModified'] = new IXR_Date(@filemtime(wikiFN($pages[$idx]))); + $list[] = $page; } return $list; -- cgit v1.2.3