xref: /dokuwiki/lib/exe/xmlrpc.php (revision e62b9ea586eb7763bfb64c8c4dc440a2819e1aa9)
1797c0d11SAndreas Gohr<?php
27aec69d1SGuy Brandif(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../');
3797c0d11SAndreas Gohr
4797c0d11SAndreas Gohr// fix when '<?xml' isn't on the very first line
5797c0d11SAndreas Gohrif(isset($HTTP_RAW_POST_DATA)) $HTTP_RAW_POST_DATA = trim($HTTP_RAW_POST_DATA);
6797c0d11SAndreas Gohr
7797c0d11SAndreas Gohr
8797c0d11SAndreas Gohrrequire_once(DOKU_INC.'inc/init.php');
9fdd2e9d6SMichael Klier
10fdd2e9d6SMichael Klierif(!$conf['xmlrpc']) {
11fdd2e9d6SMichael Klier    die('XML-RPC server not enabled.');
12fdd2e9d6SMichael Klier}
13fdd2e9d6SMichael Klier
14797c0d11SAndreas Gohrrequire_once(DOKU_INC.'inc/common.php');
15797c0d11SAndreas Gohrrequire_once(DOKU_INC.'inc/auth.php');
16797c0d11SAndreas Gohrsession_write_close();  //close session
17797c0d11SAndreas Gohrrequire_once(DOKU_INC.'inc/IXR_Library.php');
18797c0d11SAndreas Gohr
19797c0d11SAndreas Gohr
20797c0d11SAndreas Gohr/**
21797c0d11SAndreas Gohr * Contains needed wrapper functions and registers all available
22797c0d11SAndreas Gohr * XMLRPC functions.
23797c0d11SAndreas Gohr */
24797c0d11SAndreas Gohrclass dokuwiki_xmlrpc_server extends IXR_IntrospectionServer {
25797c0d11SAndreas Gohr    var $methods = array();
26797c0d11SAndreas Gohr
27797c0d11SAndreas Gohr    /**
28797c0d11SAndreas Gohr     * Constructor. Register methods and run Server
29797c0d11SAndreas Gohr     */
30797c0d11SAndreas Gohr    function dokuwiki_xmlrpc_server(){
31797c0d11SAndreas Gohr        $this->IXR_IntrospectionServer();
32797c0d11SAndreas Gohr
33797c0d11SAndreas Gohr        /* DokuWiki's own methods */
34797c0d11SAndreas Gohr        $this->addCallback(
35797c0d11SAndreas Gohr            'dokuwiki.getVersion',
36797c0d11SAndreas Gohr            'getVersion',
37797c0d11SAndreas Gohr            array('string'),
38fdd2e9d6SMichael Klier            'Returns the running DokuWiki version.'
39797c0d11SAndreas Gohr        );
40797c0d11SAndreas Gohr
41797c0d11SAndreas Gohr        /* Wiki API v2 http://www.jspwiki.org/wiki/WikiRPCInterface2 */
42797c0d11SAndreas Gohr        $this->addCallback(
43797c0d11SAndreas Gohr            'wiki.getRPCVersionSupported',
44797c0d11SAndreas Gohr            'this:wiki_RPCVersion',
45797c0d11SAndreas Gohr            array('int'),
46fdd2e9d6SMichael Klier            'Returns 2 with the supported RPC API version.'
47797c0d11SAndreas Gohr        );
48797c0d11SAndreas Gohr        $this->addCallback(
49797c0d11SAndreas Gohr            'wiki.getPage',
50797c0d11SAndreas Gohr            'this:rawPage',
51797c0d11SAndreas Gohr            array('string','string'),
52797c0d11SAndreas Gohr            'Get the raw Wiki text of page, latest version.'
53797c0d11SAndreas Gohr        );
54797c0d11SAndreas Gohr        $this->addCallback(
55797c0d11SAndreas Gohr            'wiki.getPageVersion',
56797c0d11SAndreas Gohr            'this:rawPage',
57797c0d11SAndreas Gohr            array('string','string','int'),
58797c0d11SAndreas Gohr            'Get the raw Wiki text of page.'
59797c0d11SAndreas Gohr        );
60797c0d11SAndreas Gohr        $this->addCallback(
61797c0d11SAndreas Gohr            'wiki.getPageHTML',
62797c0d11SAndreas Gohr            'this:htmlPage',
63797c0d11SAndreas Gohr            array('string','string'),
64797c0d11SAndreas Gohr            'Return page in rendered HTML, latest version.'
65797c0d11SAndreas Gohr        );
66797c0d11SAndreas Gohr        $this->addCallback(
67797c0d11SAndreas Gohr            'wiki.getPageHTMLVersion',
68797c0d11SAndreas Gohr            'this:htmlPage',
69797c0d11SAndreas Gohr            array('string','string','int'),
70797c0d11SAndreas Gohr            'Return page in rendered HTML.'
71797c0d11SAndreas Gohr        );
72797c0d11SAndreas Gohr        $this->addCallback(
73797c0d11SAndreas Gohr            'wiki.getAllPages',
74797c0d11SAndreas Gohr            'this:listPages',
75797c0d11SAndreas Gohr            array('struct'),
76797c0d11SAndreas Gohr            'Returns a list of all pages. The result is an array of utf8 pagenames.'
77797c0d11SAndreas Gohr        );
78797c0d11SAndreas Gohr        $this->addCallback(
79797c0d11SAndreas Gohr            'wiki.getBackLinks',
80797c0d11SAndreas Gohr            'this:listBackLinks',
81797c0d11SAndreas Gohr            array('struct','string'),
82797c0d11SAndreas Gohr            'Returns the pages that link to this page.'
83797c0d11SAndreas Gohr        );
84797c0d11SAndreas Gohr        $this->addCallback(
85797c0d11SAndreas Gohr            'wiki.getPageInfo',
86797c0d11SAndreas Gohr            'this:pageInfo',
87797c0d11SAndreas Gohr            array('struct','string'),
88797c0d11SAndreas Gohr            'Returns a struct with infos about the page.'
89797c0d11SAndreas Gohr        );
90797c0d11SAndreas Gohr        $this->addCallback(
91797c0d11SAndreas Gohr            'wiki.getPageInfoVersion',
92797c0d11SAndreas Gohr            'this:pageInfo',
93797c0d11SAndreas Gohr            array('struct','string','int'),
94797c0d11SAndreas Gohr            'Returns a struct with infos about the page.'
95797c0d11SAndreas Gohr        );
963a1dad2dSDennis Ploeger        $this->addCallback(
9773056168SMichael Klier            'wiki.getPageVersions',
9873056168SMichael Klier            'this:pageVersions',
9973056168SMichael Klier            array('struct','string','int'),
10073056168SMichael Klier            'Returns the available revisions of the page.'
10173056168SMichael Klier        );
10273056168SMichael Klier        $this->addCallback(
1033a1dad2dSDennis Ploeger            'wiki.putPage',
1043a1dad2dSDennis Ploeger            'this:putPage',
105222572bfSMichael Klier            array('int', 'string', 'string', 'struct'),
106fdd2e9d6SMichael Klier            'Saves a wiki page.'
1073a1dad2dSDennis Ploeger        );
108beccd742SMichael Klier        $this->addCallback(
109beccd742SMichael Klier            'wiki.listLinks',
110beccd742SMichael Klier            'this:listLinks',
111beccd742SMichael Klier            array('struct','string'),
112fdd2e9d6SMichael Klier            'Lists all links contained in a wiki page.'
113beccd742SMichael Klier        );
11463dd0d58SMichael Klier        $this->addCallback(
11563dd0d58SMichael Klier            'wiki.getRecentChanges',
11663dd0d58SMichael Klier            'this:getRecentChanges',
11763dd0d58SMichael Klier            array('struct','int'),
11863dd0d58SMichael Klier            'Returns a strukt about all recent changes since given timestamp.'
11963dd0d58SMichael Klier        );
120*e62b9ea5SMichael Klier		$this->addCallback(
121*e62b9ea5SMichael Klier			'wiki.aclCheck',
122*e62b9ea5SMichael Klier			'this:aclCheck',
123*e62b9ea5SMichael Klier			array('struct', 'string'),
124*e62b9ea5SMichael Klier			'Returns the permissions of a given wiki page.'
125*e62b9ea5SMichael Klier		);
126797c0d11SAndreas Gohr
127797c0d11SAndreas Gohr        $this->serve();
128797c0d11SAndreas Gohr    }
129797c0d11SAndreas Gohr
130797c0d11SAndreas Gohr    /**
131797c0d11SAndreas Gohr     * Return a raw wiki page
132797c0d11SAndreas Gohr     */
133797c0d11SAndreas Gohr    function rawPage($id,$rev=''){
134797c0d11SAndreas Gohr        if(auth_quickaclcheck($id) < AUTH_READ){
135797c0d11SAndreas Gohr            return new IXR_Error(1, 'You are not allowed to read this page');
136797c0d11SAndreas Gohr        }
1372c176304SMichael Klier        $text = rawWiki($id,$rev);
1382c176304SMichael Klier        if(!$text) {
1392c176304SMichael Klier            $data = array($id);
1402c176304SMichael Klier            return trigger_event('HTML_PAGE_FROMTEMPLATE',$data,'pageTemplate',true);
1412c176304SMichael Klier        } else {
1422c176304SMichael Klier            return $text;
1432c176304SMichael Klier        }
144797c0d11SAndreas Gohr    }
145797c0d11SAndreas Gohr
146797c0d11SAndreas Gohr    /**
147797c0d11SAndreas Gohr     * Return a wiki page rendered to html
148797c0d11SAndreas Gohr     */
149797c0d11SAndreas Gohr    function htmlPage($id,$rev=''){
150797c0d11SAndreas Gohr        if(auth_quickaclcheck($id) < AUTH_READ){
151797c0d11SAndreas Gohr            return new IXR_Error(1, 'You are not allowed to read this page');
152797c0d11SAndreas Gohr        }
153797c0d11SAndreas Gohr        return p_wiki_xhtml($id,$rev,false);
154797c0d11SAndreas Gohr    }
155797c0d11SAndreas Gohr
156797c0d11SAndreas Gohr    /**
157797c0d11SAndreas Gohr     * List all pages - we use the indexer list here
158797c0d11SAndreas Gohr     */
159797c0d11SAndreas Gohr    function listPages(){
160797c0d11SAndreas Gohr        require_once(DOKU_INC.'inc/fulltext.php');
161797c0d11SAndreas Gohr        return ft_pageLookup('');
162797c0d11SAndreas Gohr    }
163797c0d11SAndreas Gohr
164797c0d11SAndreas Gohr    /**
165797c0d11SAndreas Gohr     * Return a list of backlinks
166797c0d11SAndreas Gohr     */
167beccd742SMichael Klier    function listBackLinks($id){
168797c0d11SAndreas Gohr        require_once(DOKU_INC.'inc/fulltext.php');
169797c0d11SAndreas Gohr        return ft_backlinks($id);
170797c0d11SAndreas Gohr    }
171797c0d11SAndreas Gohr
172797c0d11SAndreas Gohr    /**
17363dd0d58SMichael Klier     * Return some basic data about a page
174797c0d11SAndreas Gohr     */
175797c0d11SAndreas Gohr    function pageInfo($id,$rev=''){
176797c0d11SAndreas Gohr        if(auth_quickaclcheck($id) < AUTH_READ){
177797c0d11SAndreas Gohr            return new IXR_Error(1, 'You are not allowed to read this page');
178797c0d11SAndreas Gohr        }
179797c0d11SAndreas Gohr        $file = wikiFN($id,$rev);
180797c0d11SAndreas Gohr        $time = @filemtime($file);
181797c0d11SAndreas Gohr        if(!$time){
182797c0d11SAndreas Gohr            return new IXR_Error(10, 'The requested page does not exist');
183797c0d11SAndreas Gohr        }
184797c0d11SAndreas Gohr
185797c0d11SAndreas Gohr        $info = getRevisionInfo($id, $time, 1024);
186797c0d11SAndreas Gohr
187797c0d11SAndreas Gohr        $data = array(
188797c0d11SAndreas Gohr            'name'         => $id,
189797c0d11SAndreas Gohr            'lastModified' => new IXR_Date($time),
190797c0d11SAndreas Gohr            'author'       => (($info['user']) ? $info['user'] : $info['ip']),
191797c0d11SAndreas Gohr            'version'      => $time
192797c0d11SAndreas Gohr        );
19363dd0d58SMichael Klier
19463dd0d58SMichael Klier        return ($data);
195797c0d11SAndreas Gohr    }
196797c0d11SAndreas Gohr
197797c0d11SAndreas Gohr    /**
1983a1dad2dSDennis Ploeger     * Save a wiki page
199222572bfSMichael Klier     *
200222572bfSMichael Klier     * @author Michael Klier <chi@chimeric.de>
2013a1dad2dSDennis Ploeger     */
202222572bfSMichael Klier    function putPage($id, $text, $params) {
2033a1dad2dSDennis Ploeger        global $TEXT;
204a6a229ceSMichael Klier        global $lang;
2053a1dad2dSDennis Ploeger
206222572bfSMichael Klier        $id    = cleanID($id);
207222572bfSMichael Klier        $TEXT  = trim($text);
208222572bfSMichael Klier        $sum   = $params['sum'];
209222572bfSMichael Klier        $minor = $params['minor'];
210222572bfSMichael Klier
211222572bfSMichael Klier        if(empty($id))
212fdd2e9d6SMichael Klier            return new IXR_Error(1, 'Empty page ID');
213222572bfSMichael Klier
21451597811SMichael Klier        if(!page_exists($id) && empty($TEXT)) {
21551597811SMichael Klier            return new IXR_ERROR(1, 'Refusing to write an empty new wiki page');
21651597811SMichael Klier        }
21751597811SMichael Klier
218055b0144SChris Smith        if(auth_quickaclcheck($id) < AUTH_EDIT)
219222572bfSMichael Klier            return new IXR_Error(1, 'You are not allowed to edit this page');
2203a1dad2dSDennis Ploeger
2213a1dad2dSDennis Ploeger        // Check, if page is locked
222222572bfSMichael Klier        if(checklock($id))
223222572bfSMichael Klier            return new IXR_Error(1, 'The page is currently locked');
224222572bfSMichael Klier
225a6a229ceSMichael Klier        // SPAM check
2263a1dad2dSDennis Ploeger        if(checkwordblock())
227222572bfSMichael Klier            return new IXR_Error(1, 'Positive wordblock check');
2283a1dad2dSDennis Ploeger
229a6a229ceSMichael Klier        // autoset summary on new pages
230a6a229ceSMichael Klier        if(!page_exists($id) && empty($sum)) {
231a6a229ceSMichael Klier            $sum = $lang['created'];
232a6a229ceSMichael Klier        }
233a6a229ceSMichael Klier
234a6a229ceSMichael Klier        // autoset summary on deleted pages
235a6a229ceSMichael Klier        if(page_exists($id) && empty($TEXT) && empty($sum)) {
236a6a229ceSMichael Klier            $sum = $lang['deleted'];
237a6a229ceSMichael Klier        }
238a6a229ceSMichael Klier
239222572bfSMichael Klier        lock($id);
2403a1dad2dSDennis Ploeger
241222572bfSMichael Klier        saveWikiText($id,$TEXT,$sum,$minor);
2423a1dad2dSDennis Ploeger
243222572bfSMichael Klier        unlock($id);
2443a1dad2dSDennis Ploeger
2453a1dad2dSDennis Ploeger        return 0;
246beccd742SMichael Klier    }
2473a1dad2dSDennis Ploeger
248beccd742SMichael Klier	/**
249*e62b9ea5SMichael Klier	 * Returns the permissions of a given wiki page
250*e62b9ea5SMichael Klier	 */
251*e62b9ea5SMichael Klier	function aclCheck($id) {
252*e62b9ea5SMichael Klier		return auth_quickaclcheck($id);
253*e62b9ea5SMichael Klier	}
254*e62b9ea5SMichael Klier
255*e62b9ea5SMichael Klier    /**
256beccd742SMichael Klier     * Lists all links contained in a wiki page
25763dd0d58SMichael Klier     *
25863dd0d58SMichael Klier     * @author Michael Klier <chi@chimeric.de>
259beccd742SMichael Klier     */
260beccd742SMichael Klier    function listLinks($id) {
261beccd742SMichael Klier        if(auth_quickaclcheck($id) < AUTH_READ){
262beccd742SMichael Klier            return new IXR_Error(1, 'You are not allowed to read this page');
263beccd742SMichael Klier        }
264beccd742SMichael Klier        $links = array();
265beccd742SMichael Klier
266beccd742SMichael Klier        // resolve page instructions
267beccd742SMichael Klier        $ins   = p_cached_instructions(wikiFN(cleanID($id)));
268beccd742SMichael Klier
269beccd742SMichael Klier        // instantiate new Renderer - needed for interwiki links
270beccd742SMichael Klier        include(DOKU_INC.'inc/parser/xhtml.php');
271beccd742SMichael Klier        $Renderer = new Doku_Renderer_xhtml();
272beccd742SMichael Klier        $Renderer->interwiki = getInterwiki();
273beccd742SMichael Klier
274beccd742SMichael Klier        // parse parse instructions
275beccd742SMichael Klier        foreach($ins as $in) {
276beccd742SMichael Klier            $link = array();
277beccd742SMichael Klier            switch($in[0]) {
278beccd742SMichael Klier                case 'internallink':
279beccd742SMichael Klier                    $link['type'] = 'local';
280beccd742SMichael Klier                    $link['page'] = $in[1][0];
281beccd742SMichael Klier                    $link['href'] = wl($in[1][0]);
282beccd742SMichael Klier                    array_push($links,$link);
283beccd742SMichael Klier                    break;
284beccd742SMichael Klier                case 'externallink':
285beccd742SMichael Klier                    $link['type'] = 'extern';
286beccd742SMichael Klier                    $link['page'] = $in[1][0];
287beccd742SMichael Klier                    $link['href'] = $in[1][0];
288beccd742SMichael Klier                    array_push($links,$link);
289beccd742SMichael Klier                    break;
290beccd742SMichael Klier                case 'interwikilink':
291beccd742SMichael Klier                    $url = $Renderer->_resolveInterWiki($in[1][2],$in[1][3]);
292beccd742SMichael Klier                    $link['type'] = 'extern';
293beccd742SMichael Klier                    $link['page'] = $url;
294beccd742SMichael Klier                    $link['href'] = $url;
295beccd742SMichael Klier                    array_push($links,$link);
296beccd742SMichael Klier                    break;
297beccd742SMichael Klier            }
298beccd742SMichael Klier        }
299beccd742SMichael Klier
30063dd0d58SMichael Klier        return ($links);
30163dd0d58SMichael Klier    }
30263dd0d58SMichael Klier
30363dd0d58SMichael Klier    /**
30463dd0d58SMichael Klier     * Returns a list of recent changes since give timestamp
30563dd0d58SMichael Klier     *
30663dd0d58SMichael Klier     * @author Michael Klier <chi@chimeric.de>
30763dd0d58SMichael Klier     */
30863dd0d58SMichael Klier    function getRecentChanges($timestamp) {
30963dd0d58SMichael Klier        global $conf;
31063dd0d58SMichael Klier
31163dd0d58SMichael Klier        if(strlen($timestamp) != 10)
31263dd0d58SMichael Klier            return new IXR_Error(20, 'The provided value is not a valid timestamp');
31363dd0d58SMichael Klier
31463dd0d58SMichael Klier        $changes = array();
31563dd0d58SMichael Klier
31663dd0d58SMichael Klier        require_once(DOKU_INC.'inc/changelog.php');
31763dd0d58SMichael Klier        require_once(DOKU_INC.'inc/pageutils.php');
31863dd0d58SMichael Klier
31963dd0d58SMichael Klier        // read changes
32063dd0d58SMichael Klier        $lines = @file($conf['changelog']);
32163dd0d58SMichael Klier
32263dd0d58SMichael Klier        if(empty($lines))
32363dd0d58SMichael Klier            return new IXR_Error(10, 'The changelog could not be read');
32463dd0d58SMichael Klier
32563dd0d58SMichael Klier        // we start searching at the end of the list
32663dd0d58SMichael Klier        $lines = array_reverse($lines);
32763dd0d58SMichael Klier
32863dd0d58SMichael Klier        // cache seen pages and skip them
32963dd0d58SMichael Klier        $seen = array();
33063dd0d58SMichael Klier
33163dd0d58SMichael Klier        foreach($lines as $line) {
33263dd0d58SMichael Klier
33363dd0d58SMichael Klier            if(empty($line)) continue; // skip empty lines
33463dd0d58SMichael Klier
33563dd0d58SMichael Klier            $logline = parseChangelogLine($line);
33663dd0d58SMichael Klier
33763dd0d58SMichael Klier            if($logline === false) continue;
33863dd0d58SMichael Klier
33963dd0d58SMichael Klier            // skip seen ones
34063dd0d58SMichael Klier            if(isset($seen[$logline['id']])) continue;
34163dd0d58SMichael Klier
34263dd0d58SMichael Klier            // skip minors
34363dd0d58SMichael Klier            if($logline['type'] === DOKU_CHANGE_TYPE_MINOR_EDIT && ($flags & RECENTS_SKIP_MINORS)) continue;
34463dd0d58SMichael Klier
34563dd0d58SMichael Klier            // remember in seen to skip additional sights
34663dd0d58SMichael Klier            $seen[$logline['id']] = 1;
34763dd0d58SMichael Klier
34863dd0d58SMichael Klier            // check if it's a hidden page
34963dd0d58SMichael Klier            if(isHiddenPage($logline['id'])) continue;
35063dd0d58SMichael Klier
35163dd0d58SMichael Klier            // check ACL
35263dd0d58SMichael Klier            if(auth_quickaclcheck($logline['id']) < AUTH_READ) continue;
35363dd0d58SMichael Klier
35463dd0d58SMichael Klier            // check existance
35563dd0d58SMichael Klier            if((!@file_exists(wikiFN($logline['id']))) && ($flags & RECENTS_SKIP_DELETED)) continue;
35663dd0d58SMichael Klier
35763dd0d58SMichael Klier            // check if logline is still in the queried time frame
35863dd0d58SMichael Klier            if($logline['date'] >= $timestamp) {
35963dd0d58SMichael Klier                $change['name']         = $logline['id'];
360610b2ab1SMichael Klier                $change['lastModified'] = new IXR_Date($logline['date']);
36163dd0d58SMichael Klier                $change['author']       = $logline['user'];
36263dd0d58SMichael Klier                $change['version']      = $logline['date'];
36363dd0d58SMichael Klier                array_push($changes, $change);
36463dd0d58SMichael Klier            } else {
36563dd0d58SMichael Klier                $changes = array_reverse($changes);
36663dd0d58SMichael Klier                return ($changes);
36763dd0d58SMichael Klier            }
36863dd0d58SMichael Klier        }
36963dd0d58SMichael Klier        // in case we still have nothing at this point
37063dd0d58SMichael Klier        return new IXR_Error(30, 'There are no changes in the specified timeframe');
3713a1dad2dSDennis Ploeger    }
3723a1dad2dSDennis Ploeger
3733a1dad2dSDennis Ploeger    /**
37473056168SMichael Klier     * Returns a list of available revisions of a given wiki page
37573056168SMichael Klier     *
37673056168SMichael Klier     * @author Michael Klier <chi@chimeric.de>
37773056168SMichael Klier     */
37873056168SMichael Klier    function pageVersions($id, $first) {
37973056168SMichael Klier        global $conf;
38073056168SMichael Klier
38173056168SMichael Klier        $versions = array();
38273056168SMichael Klier
38373056168SMichael Klier        if(empty($id))
38473056168SMichael Klier            return new IXR_Error(1, 'Empty page ID');
38573056168SMichael Klier
38673056168SMichael Klier        require_once(DOKU_INC.'inc/changelog.php');
38773056168SMichael Klier
38873056168SMichael Klier        $revisions = getRevisions($id, $first, $conf['recent']+1);
38973056168SMichael Klier
39073056168SMichael Klier        if(count($revisions)==0 && $first!=0) {
39173056168SMichael Klier            $first=0;
39273056168SMichael Klier            $revisions = getRevisions($id, $first, $conf['recent']+1);
39373056168SMichael Klier        }
39473056168SMichael Klier
39545c63471SMichael Klier        if(count($revisions)>0 && $first==0) {
39645c63471SMichael Klier            array_unshift($revisions, '');  // include current revision
39745c63471SMichael Klier            array_pop($revisions);          // remove extra log entry
39845c63471SMichael Klier        }
39945c63471SMichael Klier
40073056168SMichael Klier        $hasNext = false;
40173056168SMichael Klier        if(count($revisions)>$conf['recent']) {
40273056168SMichael Klier            $hasNext = true;
40373056168SMichael Klier            array_pop($revisions); // remove extra log entry
40473056168SMichael Klier        }
40573056168SMichael Klier
40673056168SMichael Klier        if(!empty($revisions)) {
40773056168SMichael Klier            foreach($revisions as $rev) {
40873056168SMichael Klier                $file = wikiFN($id,$rev);
40973056168SMichael Klier                $time = @filemtime($file);
41045c63471SMichael Klier                // we check if the page actually exists, if this is not the
41145c63471SMichael Klier                // case this can lead to less pages being returned than
41245c63471SMichael Klier                // specified via $conf['recent']
41373056168SMichael Klier                if($time){
41473056168SMichael Klier                    $info = getRevisionInfo($id, $time, 1024);
41573056168SMichael Klier                    if(!empty($info)) {
41673056168SMichael Klier                        $data['user'] = $info['user'];
41773056168SMichael Klier                        $data['ip']   = $info['ip'];
41873056168SMichael Klier                        $data['type'] = $info['type'];
41973056168SMichael Klier                        $data['sum']  = $info['sum'];
42073056168SMichael Klier                        $data['modified'] = new IXR_Date($info['date']);
42173056168SMichael Klier                        $data['version'] = $info['date'];
42273056168SMichael Klier                        array_push($versions, $data);
42373056168SMichael Klier                    }
42473056168SMichael Klier                }
42573056168SMichael Klier            }
42673056168SMichael Klier            return $versions;
42773056168SMichael Klier        } else {
42873056168SMichael Klier            return array();
42973056168SMichael Klier        }
43073056168SMichael Klier    }
43173056168SMichael Klier
43273056168SMichael Klier    /**
433797c0d11SAndreas Gohr     * The version of Wiki RPC API supported
434797c0d11SAndreas Gohr     */
435797c0d11SAndreas Gohr    function wiki_RPCVersion(){
436797c0d11SAndreas Gohr        return 2;
437797c0d11SAndreas Gohr    }
438797c0d11SAndreas Gohr}
439797c0d11SAndreas Gohr
440797c0d11SAndreas Gohr$server = new dokuwiki_xmlrpc_server();
441797c0d11SAndreas Gohr
44263dd0d58SMichael Klier// vim:ts=4:sw=4:enc=utf-8:
443