xref: /dokuwiki/lib/exe/xmlrpc.php (revision 224122cf976599e1fc256224095d84c4e0827e1a)
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');
9797c0d11SAndreas Gohrrequire_once(DOKU_INC.'inc/common.php');
10797c0d11SAndreas Gohrrequire_once(DOKU_INC.'inc/auth.php');
11797c0d11SAndreas Gohrsession_write_close();  //close session
12593bf8f6SMichael Klier
13593bf8f6SMichael Klierif(!$conf['xmlrpc']) {
14593bf8f6SMichael Klier    die('XML-RPC server not enabled.');
15593bf8f6SMichael Klier    // FIXME check for groups allowed
16593bf8f6SMichael Klier}
17593bf8f6SMichael Klier
18797c0d11SAndreas Gohrrequire_once(DOKU_INC.'inc/IXR_Library.php');
19797c0d11SAndreas Gohr
20797c0d11SAndreas Gohr
21797c0d11SAndreas Gohr/**
22797c0d11SAndreas Gohr * Contains needed wrapper functions and registers all available
23797c0d11SAndreas Gohr * XMLRPC functions.
24797c0d11SAndreas Gohr */
25797c0d11SAndreas Gohrclass dokuwiki_xmlrpc_server extends IXR_IntrospectionServer {
26797c0d11SAndreas Gohr    var $methods = array();
27797c0d11SAndreas Gohr
28797c0d11SAndreas Gohr    /**
29797c0d11SAndreas Gohr     * Constructor. Register methods and run Server
30797c0d11SAndreas Gohr     */
31797c0d11SAndreas Gohr    function dokuwiki_xmlrpc_server(){
32797c0d11SAndreas Gohr        $this->IXR_IntrospectionServer();
33797c0d11SAndreas Gohr
34797c0d11SAndreas Gohr        /* DokuWiki's own methods */
35797c0d11SAndreas Gohr        $this->addCallback(
36797c0d11SAndreas Gohr            'dokuwiki.getVersion',
37797c0d11SAndreas Gohr            'getVersion',
38797c0d11SAndreas Gohr            array('string'),
39fdd2e9d6SMichael Klier            'Returns the running DokuWiki version.'
40797c0d11SAndreas Gohr        );
41797c0d11SAndreas Gohr
421b11c097SAndreas Gohr        $this->addCallback(
431b11c097SAndreas Gohr            'dokuwiki.getPagelist',
441b11c097SAndreas Gohr            'this:readNamespace',
451b11c097SAndreas Gohr            array('struct','string','struct'),
461b11c097SAndreas Gohr            'List all pages within the given namespace.'
471b11c097SAndreas Gohr        );
481b11c097SAndreas Gohr
491b11c097SAndreas Gohr        $this->addCallback(
501b11c097SAndreas Gohr            'dokuwiki.getTime',
511b11c097SAndreas Gohr            'time',
521b11c097SAndreas Gohr            array('int'),
531b11c097SAndreas Gohr            'Return the current time at the wiki server.'
541b11c097SAndreas Gohr        );
551b11c097SAndreas Gohr
5628ec3c76SAndreas Gohr        $this->addCallback(
5728ec3c76SAndreas Gohr            'dokuwiki.setLocks',
5828ec3c76SAndreas Gohr            'this:setLocks',
5928ec3c76SAndreas Gohr            array('struct','struct'),
6028ec3c76SAndreas Gohr            'Lock or unlock pages.'
6128ec3c76SAndreas Gohr        );
6228ec3c76SAndreas Gohr
63797c0d11SAndreas Gohr        /* Wiki API v2 http://www.jspwiki.org/wiki/WikiRPCInterface2 */
64797c0d11SAndreas Gohr        $this->addCallback(
65797c0d11SAndreas Gohr            'wiki.getRPCVersionSupported',
66797c0d11SAndreas Gohr            'this:wiki_RPCVersion',
67797c0d11SAndreas Gohr            array('int'),
68fdd2e9d6SMichael Klier            'Returns 2 with the supported RPC API version.'
69797c0d11SAndreas Gohr        );
70797c0d11SAndreas Gohr        $this->addCallback(
71797c0d11SAndreas Gohr            'wiki.getPage',
72797c0d11SAndreas Gohr            'this:rawPage',
73797c0d11SAndreas Gohr            array('string','string'),
74797c0d11SAndreas Gohr            'Get the raw Wiki text of page, latest version.'
75797c0d11SAndreas Gohr        );
76797c0d11SAndreas Gohr        $this->addCallback(
77797c0d11SAndreas Gohr            'wiki.getPageVersion',
78797c0d11SAndreas Gohr            'this:rawPage',
79797c0d11SAndreas Gohr            array('string','string','int'),
80797c0d11SAndreas Gohr            'Get the raw Wiki text of page.'
81797c0d11SAndreas Gohr        );
82797c0d11SAndreas Gohr        $this->addCallback(
83797c0d11SAndreas Gohr            'wiki.getPageHTML',
84797c0d11SAndreas Gohr            'this:htmlPage',
85797c0d11SAndreas Gohr            array('string','string'),
86797c0d11SAndreas Gohr            'Return page in rendered HTML, latest version.'
87797c0d11SAndreas Gohr        );
88797c0d11SAndreas Gohr        $this->addCallback(
89797c0d11SAndreas Gohr            'wiki.getPageHTMLVersion',
90797c0d11SAndreas Gohr            'this:htmlPage',
91797c0d11SAndreas Gohr            array('string','string','int'),
92797c0d11SAndreas Gohr            'Return page in rendered HTML.'
93797c0d11SAndreas Gohr        );
94797c0d11SAndreas Gohr        $this->addCallback(
95797c0d11SAndreas Gohr            'wiki.getAllPages',
96797c0d11SAndreas Gohr            'this:listPages',
97797c0d11SAndreas Gohr            array('struct'),
98797c0d11SAndreas Gohr            'Returns a list of all pages. The result is an array of utf8 pagenames.'
99797c0d11SAndreas Gohr        );
100797c0d11SAndreas Gohr        $this->addCallback(
10126bec61eSMichael Klier            'wiki.getAttachments',
10226bec61eSMichael Klier            'this:listAttachments',
103c63d1645SGina Haeussge            array('struct', 'string', 'struct'),
10426bec61eSMichael Klier            'Returns a list of all media files.'
10526bec61eSMichael Klier        );
10626bec61eSMichael Klier        $this->addCallback(
107797c0d11SAndreas Gohr            'wiki.getBackLinks',
108797c0d11SAndreas Gohr            'this:listBackLinks',
109797c0d11SAndreas Gohr            array('struct','string'),
110797c0d11SAndreas Gohr            'Returns the pages that link to this page.'
111797c0d11SAndreas Gohr        );
112797c0d11SAndreas Gohr        $this->addCallback(
113797c0d11SAndreas Gohr            'wiki.getPageInfo',
114797c0d11SAndreas Gohr            'this:pageInfo',
115797c0d11SAndreas Gohr            array('struct','string'),
116797c0d11SAndreas Gohr            'Returns a struct with infos about the page.'
117797c0d11SAndreas Gohr        );
118797c0d11SAndreas Gohr        $this->addCallback(
119797c0d11SAndreas Gohr            'wiki.getPageInfoVersion',
120797c0d11SAndreas Gohr            'this:pageInfo',
121797c0d11SAndreas Gohr            array('struct','string','int'),
122797c0d11SAndreas Gohr            'Returns a struct with infos about the page.'
123797c0d11SAndreas Gohr        );
1243a1dad2dSDennis Ploeger        $this->addCallback(
12573056168SMichael Klier            'wiki.getPageVersions',
12673056168SMichael Klier            'this:pageVersions',
12773056168SMichael Klier            array('struct','string','int'),
12873056168SMichael Klier            'Returns the available revisions of the page.'
12973056168SMichael Klier        );
13073056168SMichael Klier        $this->addCallback(
1313a1dad2dSDennis Ploeger            'wiki.putPage',
1323a1dad2dSDennis Ploeger            'this:putPage',
133222572bfSMichael Klier            array('int', 'string', 'string', 'struct'),
134fdd2e9d6SMichael Klier            'Saves a wiki page.'
1353a1dad2dSDennis Ploeger        );
136beccd742SMichael Klier        $this->addCallback(
137beccd742SMichael Klier            'wiki.listLinks',
138beccd742SMichael Klier            'this:listLinks',
139beccd742SMichael Klier            array('struct','string'),
140fdd2e9d6SMichael Klier            'Lists all links contained in a wiki page.'
141beccd742SMichael Klier        );
14263dd0d58SMichael Klier        $this->addCallback(
14363dd0d58SMichael Klier            'wiki.getRecentChanges',
14463dd0d58SMichael Klier            'this:getRecentChanges',
14563dd0d58SMichael Klier            array('struct','int'),
14699c8d7f2Smichael            'Returns a struct about all recent changes since given timestamp.'
14799c8d7f2Smichael        );
14899c8d7f2Smichael        $this->addCallback(
14999c8d7f2Smichael            'wiki.getRecentMediaChanges',
15099c8d7f2Smichael            'this:getRecentMediaChanges',
15199c8d7f2Smichael            array('struct','int'),
15299c8d7f2Smichael            'Returns a struct about all recent media changes since given timestamp.'
15363dd0d58SMichael Klier        );
154e62b9ea5SMichael Klier        $this->addCallback(
155e62b9ea5SMichael Klier            'wiki.aclCheck',
156e62b9ea5SMichael Klier            'this:aclCheck',
157c63d1645SGina Haeussge            array('int', 'string'),
158e62b9ea5SMichael Klier            'Returns the permissions of a given wiki page.'
159e62b9ea5SMichael Klier        );
1602aca132fSMichael Klier        $this->addCallback(
1612aca132fSMichael Klier            'wiki.putAttachment',
1622aca132fSMichael Klier            'this:putAttachment',
1632aca132fSMichael Klier            array('struct', 'string', 'base64', 'struct'),
1642aca132fSMichael Klier            'Upload a file to the wiki.'
1652aca132fSMichael Klier        );
166cfef3001SGina Haeussge        $this->addCallback(
167f01ff8c1SGina Haeussge            'wiki.deleteAttachment',
168f01ff8c1SGina Haeussge            'this:deleteAttachment',
169f01ff8c1SGina Haeussge            array('int', 'string'),
170f01ff8c1SGina Haeussge            'Delete a file from the wiki.'
171f01ff8c1SGina Haeussge        );
172f01ff8c1SGina Haeussge        $this->addCallback(
173cfef3001SGina Haeussge            'wiki.getAttachment',
174cfef3001SGina Haeussge            'this:getAttachment',
175c63d1645SGina Haeussge            array('base64', 'string'),
176cfef3001SGina Haeussge            'Download a file from the wiki.'
177cfef3001SGina Haeussge        );
1785672e868SGina Haeussge        $this->addCallback(
1795672e868SGina Haeussge            'wiki.getAttachmentInfo',
1805672e868SGina Haeussge            'this:getAttachmentInfo',
181c63d1645SGina Haeussge            array('struct', 'string'),
1825672e868SGina Haeussge            'Returns a struct with infos about the attachment.'
1835672e868SGina Haeussge        );
184797c0d11SAndreas Gohr
185bb32615dSMichael Klier        /**
186bb32615dSMichael Klier         * Trigger XMLRPC_CALLBACK_REGISTER, action plugins can use this event
187bb32615dSMichael Klier         * to extend the XMLRPC interface and register their own callbacks.
188bb32615dSMichael Klier         *
189bb32615dSMichael Klier         * Event data:
190bb32615dSMichael Klier         *  The XMLRPC server object:
191bb32615dSMichael Klier         *
192bb32615dSMichael Klier         *  $event->data->addCallback() - register a callback, the second
193bb32615dSMichael Klier         *  paramter has to be of the form "plugin:<pluginname>:<plugin
194bb32615dSMichael Klier         *  method>"
195bb32615dSMichael Klier         *
196bb32615dSMichael Klier         *  $event->data->callbacks - an array which holds all awaylable
197bb32615dSMichael Klier         *  callbacks
198bb32615dSMichael Klier         */
199bb32615dSMichael Klier        trigger_event('XMLRPC_CALLBACK_REGISTER', $this);
200bb32615dSMichael Klier
201797c0d11SAndreas Gohr        $this->serve();
202797c0d11SAndreas Gohr    }
203797c0d11SAndreas Gohr
204797c0d11SAndreas Gohr    /**
205797c0d11SAndreas Gohr     * Return a raw wiki page
206797c0d11SAndreas Gohr     */
207797c0d11SAndreas Gohr    function rawPage($id,$rev=''){
208797c0d11SAndreas Gohr        if(auth_quickaclcheck($id) < AUTH_READ){
209797c0d11SAndreas Gohr            return new IXR_Error(1, 'You are not allowed to read this page');
210797c0d11SAndreas Gohr        }
2112c176304SMichael Klier        $text = rawWiki($id,$rev);
2122c176304SMichael Klier        if(!$text) {
2132c176304SMichael Klier            $data = array($id);
2142c176304SMichael Klier            return trigger_event('HTML_PAGE_FROMTEMPLATE',$data,'pageTemplate',true);
2152c176304SMichael Klier        } else {
2162c176304SMichael Klier            return $text;
2172c176304SMichael Klier        }
218797c0d11SAndreas Gohr    }
219797c0d11SAndreas Gohr
220797c0d11SAndreas Gohr    /**
221cfef3001SGina Haeussge     * Return a media file encoded in base64
222c63d1645SGina Haeussge     *
223c63d1645SGina Haeussge     * @author Gina Haeussge <osd@foosel.net>
224cfef3001SGina Haeussge     */
225cfef3001SGina Haeussge    function getAttachment($id){
226c63d1645SGina Haeussge        $id = cleanID($id);
227cfef3001SGina Haeussge        if (auth_quickaclcheck(getNS($id).':*') < AUTH_READ)
228cfef3001SGina Haeussge            return new IXR_Error(1, 'You are not allowed to read this file');
229cfef3001SGina Haeussge
230cfef3001SGina Haeussge        $file = mediaFN($id);
231cfef3001SGina Haeussge        if (!@ file_exists($file))
232cfef3001SGina Haeussge            return new IXR_Error(1, 'The requested file does not exist');
233cfef3001SGina Haeussge
234cfef3001SGina Haeussge        $data = io_readFile($file, false);
235cfef3001SGina Haeussge        $base64 = base64_encode($data);
236cfef3001SGina Haeussge        return $base64;
237cfef3001SGina Haeussge    }
238cfef3001SGina Haeussge
239cfef3001SGina Haeussge    /**
2405672e868SGina Haeussge     * Return info about a media file
2415672e868SGina Haeussge     *
2425672e868SGina Haeussge     * @author Gina Haeussge <osd@foosel.net>
2435672e868SGina Haeussge     */
2445672e868SGina Haeussge    function getAttachmentInfo($id){
2455672e868SGina Haeussge        $id = cleanID($id);
2465672e868SGina Haeussge        $info = array(
2475672e868SGina Haeussge            'lastModified' => 0,
2485672e868SGina Haeussge            'size' => 0,
2495672e868SGina Haeussge        );
2505672e868SGina Haeussge
2515672e868SGina Haeussge        $file = mediaFN($id);
2525672e868SGina Haeussge        if ((auth_quickaclcheck(getNS($id).':*') >= AUTH_READ) && file_exists($file)){
2535672e868SGina Haeussge            $info['lastModified'] = new IXR_Date(filemtime($file));
2545672e868SGina Haeussge            $info['size'] = filesize($file);
2555672e868SGina Haeussge        }
2565672e868SGina Haeussge
2575672e868SGina Haeussge        return $info;
2585672e868SGina Haeussge    }
2595672e868SGina Haeussge
2605672e868SGina Haeussge    /**
261797c0d11SAndreas Gohr     * Return a wiki page rendered to html
262797c0d11SAndreas Gohr     */
263797c0d11SAndreas Gohr    function htmlPage($id,$rev=''){
264797c0d11SAndreas Gohr        if(auth_quickaclcheck($id) < AUTH_READ){
265797c0d11SAndreas Gohr            return new IXR_Error(1, 'You are not allowed to read this page');
266797c0d11SAndreas Gohr        }
267797c0d11SAndreas Gohr        return p_wiki_xhtml($id,$rev,false);
268797c0d11SAndreas Gohr    }
269797c0d11SAndreas Gohr
270797c0d11SAndreas Gohr    /**
271797c0d11SAndreas Gohr     * List all pages - we use the indexer list here
272797c0d11SAndreas Gohr     */
273797c0d11SAndreas Gohr    function listPages(){
274dfd13e55SMichael Klier        global $conf;
275dfd13e55SMichael Klier
276dfd13e55SMichael Klier        $list  = array();
277dfd13e55SMichael Klier        $pages = file($conf['indexdir'] . '/page.idx');
278dfd13e55SMichael Klier        $pages = array_filter($pages, 'isVisiblePage');
279dfd13e55SMichael Klier
280dfd13e55SMichael Klier        foreach(array_keys($pages) as $idx) {
281dfd13e55SMichael Klier            if(page_exists($pages[$idx])) {
282dfd13e55SMichael Klier                $perm = auth_quickaclcheck($pages[$idx]);
283dfd13e55SMichael Klier                if($perm >= AUTH_READ) {
284dfd13e55SMichael Klier                    $page = array();
285dfd13e55SMichael Klier                    $page['id'] = trim($pages[$idx]);
286dfd13e55SMichael Klier                    $page['perms'] = $perm;
287dfd13e55SMichael Klier                    $page['size'] = @filesize(wikiFN($pages[$idx]));
288e070c6f3SGina Haeussge                    $page['lastModified'] = new IXR_Date(@filemtime(wikiFN($pages[$idx])));
289dfd13e55SMichael Klier                    $list[] = $page;
290dfd13e55SMichael Klier                }
291dfd13e55SMichael Klier            }
292dfd13e55SMichael Klier        }
293dfd13e55SMichael Klier
294dfd13e55SMichael Klier        return $list;
295797c0d11SAndreas Gohr    }
296797c0d11SAndreas Gohr
297797c0d11SAndreas Gohr    /**
2981b11c097SAndreas Gohr     * List all pages in the given namespace (and below)
2991b11c097SAndreas Gohr     */
3001b11c097SAndreas Gohr    function readNamespace($ns,$opts){
3011b11c097SAndreas Gohr        global $conf;
3021b11c097SAndreas Gohr
3031b11c097SAndreas Gohr        if(!is_array($opts)) $opts=array();
3041b11c097SAndreas Gohr
3051b11c097SAndreas Gohr        $ns = cleanID($ns);
3061b11c097SAndreas Gohr        $dir = utf8_encodeFN(str_replace(':', '/', $ns));
3071b11c097SAndreas Gohrdbglog('ggg');
3081b11c097SAndreas Gohr        $data = array();
3091b11c097SAndreas Gohr        require_once(DOKU_INC.'inc/search.php');
3101b11c097SAndreas Gohr        search($data, $conf['datadir'], 'search_allpages', $opts, $dir);
3111b11c097SAndreas Gohrdbglog($data);
3121b11c097SAndreas Gohr        return $data;
3131b11c097SAndreas Gohr    }
3141b11c097SAndreas Gohr
3151b11c097SAndreas Gohr    /**
31626bec61eSMichael Klier     * List all media files.
3173275953aSGina Haeussge     *
3183275953aSGina Haeussge     * Available options are 'recursive' for also including the subnamespaces
3193275953aSGina Haeussge     * in the listing, and 'pattern' for filtering the returned files against
3203275953aSGina Haeussge     * a regular expression matching their name.
3213275953aSGina Haeussge     *
3223275953aSGina Haeussge     * @author Gina Haeussge <osd@foosel.net>
32326bec61eSMichael Klier     */
3243275953aSGina Haeussge    function listAttachments($ns, $options = array()) {
32526bec61eSMichael Klier        global $conf;
32626bec61eSMichael Klier        global $lang;
32726bec61eSMichael Klier
32826bec61eSMichael Klier        $ns = cleanID($ns);
32926bec61eSMichael Klier
3303275953aSGina Haeussge        if (!is_array($options))
3313275953aSGina Haeussge            $options = array();
3323275953aSGina Haeussge
3333275953aSGina Haeussge
33426bec61eSMichael Klier        if(auth_quickaclcheck($ns.':*') >= AUTH_READ) {
33526bec61eSMichael Klier            $dir = utf8_encodeFN(str_replace(':', '/', $ns));
33626bec61eSMichael Klier
33726bec61eSMichael Klier            $data = array();
33826bec61eSMichael Klier            require_once(DOKU_INC.'inc/search.php');
339*224122cfSAndreas Gohr            search($data, $conf['mediadir'], 'search_media', $options, $dir);
340*224122cfSAndreas Gohr            $len = count($data);
341*224122cfSAndreas Gohr            if(!$len) return array();
34226bec61eSMichael Klier
343*224122cfSAndreas Gohr            for($i=0; $i<$len; $i++) {
344*224122cfSAndreas Gohr                unset($data[$i]['meta']);
345*224122cfSAndreas Gohr                $data[$i]['lastModified'] = new IXR_Date($data[$i]['mtime']);
34626bec61eSMichael Klier            }
347*224122cfSAndreas Gohr            return $data;
34826bec61eSMichael Klier        } else {
34926bec61eSMichael Klier            return new IXR_Error(1, 'You are not allowed to list media files.');
35026bec61eSMichael Klier        }
35126bec61eSMichael Klier    }
35226bec61eSMichael Klier
35326bec61eSMichael Klier    /**
354797c0d11SAndreas Gohr     * Return a list of backlinks
355797c0d11SAndreas Gohr     */
356beccd742SMichael Klier    function listBackLinks($id){
357797c0d11SAndreas Gohr        require_once(DOKU_INC.'inc/fulltext.php');
358797c0d11SAndreas Gohr        return ft_backlinks($id);
359797c0d11SAndreas Gohr    }
360797c0d11SAndreas Gohr
361797c0d11SAndreas Gohr    /**
36263dd0d58SMichael Klier     * Return some basic data about a page
363797c0d11SAndreas Gohr     */
364797c0d11SAndreas Gohr    function pageInfo($id,$rev=''){
365797c0d11SAndreas Gohr        if(auth_quickaclcheck($id) < AUTH_READ){
366797c0d11SAndreas Gohr            return new IXR_Error(1, 'You are not allowed to read this page');
367797c0d11SAndreas Gohr        }
368797c0d11SAndreas Gohr        $file = wikiFN($id,$rev);
369797c0d11SAndreas Gohr        $time = @filemtime($file);
370797c0d11SAndreas Gohr        if(!$time){
371797c0d11SAndreas Gohr            return new IXR_Error(10, 'The requested page does not exist');
372797c0d11SAndreas Gohr        }
373797c0d11SAndreas Gohr
374797c0d11SAndreas Gohr        $info = getRevisionInfo($id, $time, 1024);
375797c0d11SAndreas Gohr
376797c0d11SAndreas Gohr        $data = array(
377797c0d11SAndreas Gohr            'name'         => $id,
378797c0d11SAndreas Gohr            'lastModified' => new IXR_Date($time),
379797c0d11SAndreas Gohr            'author'       => (($info['user']) ? $info['user'] : $info['ip']),
380797c0d11SAndreas Gohr            'version'      => $time
381797c0d11SAndreas Gohr        );
38263dd0d58SMichael Klier
38363dd0d58SMichael Klier        return ($data);
384797c0d11SAndreas Gohr    }
385797c0d11SAndreas Gohr
386797c0d11SAndreas Gohr    /**
3873a1dad2dSDennis Ploeger     * Save a wiki page
388222572bfSMichael Klier     *
389222572bfSMichael Klier     * @author Michael Klier <chi@chimeric.de>
3903a1dad2dSDennis Ploeger     */
391222572bfSMichael Klier    function putPage($id, $text, $params) {
3923a1dad2dSDennis Ploeger        global $TEXT;
393a6a229ceSMichael Klier        global $lang;
394593bf8f6SMichael Klier        global $conf;
3953a1dad2dSDennis Ploeger
396222572bfSMichael Klier        $id    = cleanID($id);
397222572bfSMichael Klier        $TEXT  = trim($text);
398222572bfSMichael Klier        $sum   = $params['sum'];
399222572bfSMichael Klier        $minor = $params['minor'];
400222572bfSMichael Klier
401222572bfSMichael Klier        if(empty($id))
402fdd2e9d6SMichael Klier            return new IXR_Error(1, 'Empty page ID');
403222572bfSMichael Klier
40451597811SMichael Klier        if(!page_exists($id) && empty($TEXT)) {
40551597811SMichael Klier            return new IXR_ERROR(1, 'Refusing to write an empty new wiki page');
40651597811SMichael Klier        }
40751597811SMichael Klier
408055b0144SChris Smith        if(auth_quickaclcheck($id) < AUTH_EDIT)
409222572bfSMichael Klier            return new IXR_Error(1, 'You are not allowed to edit this page');
4103a1dad2dSDennis Ploeger
4113a1dad2dSDennis Ploeger        // Check, if page is locked
412222572bfSMichael Klier        if(checklock($id))
413222572bfSMichael Klier            return new IXR_Error(1, 'The page is currently locked');
414222572bfSMichael Klier
415a6a229ceSMichael Klier        // SPAM check
4163a1dad2dSDennis Ploeger        if(checkwordblock())
417222572bfSMichael Klier            return new IXR_Error(1, 'Positive wordblock check');
4183a1dad2dSDennis Ploeger
419a6a229ceSMichael Klier        // autoset summary on new pages
420a6a229ceSMichael Klier        if(!page_exists($id) && empty($sum)) {
421a6a229ceSMichael Klier            $sum = $lang['created'];
422a6a229ceSMichael Klier        }
423a6a229ceSMichael Klier
424a6a229ceSMichael Klier        // autoset summary on deleted pages
425a6a229ceSMichael Klier        if(page_exists($id) && empty($TEXT) && empty($sum)) {
426a6a229ceSMichael Klier            $sum = $lang['deleted'];
427a6a229ceSMichael Klier        }
428a6a229ceSMichael Klier
429222572bfSMichael Klier        lock($id);
4303a1dad2dSDennis Ploeger
431222572bfSMichael Klier        saveWikiText($id,$TEXT,$sum,$minor);
4323a1dad2dSDennis Ploeger
433222572bfSMichael Klier        unlock($id);
4343a1dad2dSDennis Ploeger
435593bf8f6SMichael Klier        // run the indexer if page wasn't indexed yet
436593bf8f6SMichael Klier        if(!@file_exists(metaFN($id, '.indexed'))) {
437593bf8f6SMichael Klier            // try to aquire a lock
438593bf8f6SMichael Klier            $lock = $conf['lockdir'].'/_indexer.lock';
439593bf8f6SMichael Klier            while(!@mkdir($lock,$conf['dmode'])){
440593bf8f6SMichael Klier                usleep(50);
441593bf8f6SMichael Klier                if(time()-@filemtime($lock) > 60*5){
442593bf8f6SMichael Klier                    // looks like a stale lock - remove it
443593bf8f6SMichael Klier                    @rmdir($lock);
444593bf8f6SMichael Klier                }else{
445593bf8f6SMichael Klier                    return false;
446593bf8f6SMichael Klier                }
447593bf8f6SMichael Klier            }
448593bf8f6SMichael Klier            if($conf['dperm']) chmod($lock, $conf['dperm']);
449593bf8f6SMichael Klier
450593bf8f6SMichael Klier            require_once(DOKU_INC.'inc/indexer.php');
451593bf8f6SMichael Klier
452593bf8f6SMichael Klier            // do the work
453593bf8f6SMichael Klier            idx_addPage($id);
454593bf8f6SMichael Klier
455593bf8f6SMichael Klier            // we're finished - save and free lock
456593bf8f6SMichael Klier            io_saveFile(metaFN($id,'.indexed'),INDEXER_VERSION);
457593bf8f6SMichael Klier            @rmdir($lock);
458593bf8f6SMichael Klier        }
459593bf8f6SMichael Klier
4603a1dad2dSDennis Ploeger        return 0;
461beccd742SMichael Klier    }
4623a1dad2dSDennis Ploeger
463beccd742SMichael Klier    /**
4642aca132fSMichael Klier     * Uploads a file to the wiki.
4652aca132fSMichael Klier     *
4662aca132fSMichael Klier     * Michael Klier <chi@chimeric.de>
4672aca132fSMichael Klier     */
468f01ff8c1SGina Haeussge    function putAttachment($id, $file, $params) {
4692aca132fSMichael Klier        global $conf;
4702aca132fSMichael Klier        global $lang;
4712aca132fSMichael Klier
472f01ff8c1SGina Haeussge        $auth = auth_quickaclcheck(getNS($id).':*');
4732aca132fSMichael Klier        if($auth >= AUTH_UPLOAD) {
474f01ff8c1SGina Haeussge            if(!isset($id)) {
4752aca132fSMichael Klier                return new IXR_ERROR(1, 'Filename not given.');
4762aca132fSMichael Klier            }
4772aca132fSMichael Klier
478f01ff8c1SGina Haeussge            $ftmp = $conf['tmpdir'] . '/' . $id;
4792aca132fSMichael Klier
4802aca132fSMichael Klier            // save temporary file
4812aca132fSMichael Klier            @unlink($ftmp);
4822aca132fSMichael Klier            $buff = base64_decode($file);
4832aca132fSMichael Klier            io_saveFile($ftmp, $buff);
4842aca132fSMichael Klier
4852aca132fSMichael Klier            // get filename
486ecebf3a8SAndreas Gohr            list($iext, $imime,$dl) = mimetype($id);
487f01ff8c1SGina Haeussge            $id = cleanID($id);
4882aca132fSMichael Klier            $fn = mediaFN($id);
4892aca132fSMichael Klier
4902aca132fSMichael Klier            // get filetype regexp
4912aca132fSMichael Klier            $types = array_keys(getMimeTypes());
4922aca132fSMichael Klier            $types = array_map(create_function('$q','return preg_quote($q,"/");'),$types);
4932aca132fSMichael Klier            $regex = join('|',$types);
4942aca132fSMichael Klier
4952aca132fSMichael Klier            // because a temp file was created already
4962aca132fSMichael Klier            if(preg_match('/\.('.$regex.')$/i',$fn)) {
4972aca132fSMichael Klier                //check for overwrite
49899c8d7f2Smichael                $overwrite = @file_exists($fn);
49999c8d7f2Smichael                if($overwrite && (!$params['ow'] || $auth < AUTH_DELETE)) {
500*224122cfSAndreas Gohr                    return new IXR_ERROR(1, $lang['uploadexist'].'1');
5012aca132fSMichael Klier                }
5022aca132fSMichael Klier                // check for valid content
5032aca132fSMichael Klier                @require_once(DOKU_INC.'inc/media.php');
5042aca132fSMichael Klier                $ok = media_contentcheck($ftmp, $imime);
5052aca132fSMichael Klier                if($ok == -1) {
506*224122cfSAndreas Gohr                    return new IXR_ERROR(1, sprintf($lang['uploadexist'].'2', ".$iext"));
5072aca132fSMichael Klier                } elseif($ok == -2) {
5082aca132fSMichael Klier                    return new IXR_ERROR(1, $lang['uploadspam']);
5092aca132fSMichael Klier                } elseif($ok == -3) {
5102aca132fSMichael Klier                    return new IXR_ERROR(1, $lang['uploadxss']);
5112aca132fSMichael Klier                }
5122aca132fSMichael Klier
5132aca132fSMichael Klier                // prepare event data
5142aca132fSMichael Klier                $data[0] = $ftmp;
5152aca132fSMichael Klier                $data[1] = $fn;
5162aca132fSMichael Klier                $data[2] = $id;
5172aca132fSMichael Klier                $data[3] = $imime;
51899c8d7f2Smichael                $data[4] = $overwrite;
5192aca132fSMichael Klier
5202aca132fSMichael Klier                // trigger event
5212aca132fSMichael Klier                require_once(DOKU_INC.'inc/events.php');
5222aca132fSMichael Klier                return trigger_event('MEDIA_UPLOAD_FINISH', $data, array($this, '_media_upload_action'), true);
5232aca132fSMichael Klier
5242aca132fSMichael Klier            } else {
5252aca132fSMichael Klier                return new IXR_ERROR(1, $lang['uploadwrong']);
5262aca132fSMichael Klier            }
5272aca132fSMichael Klier        } else {
5282aca132fSMichael Klier            return new IXR_ERROR(1, "You don't have permissions to upload files.");
5292aca132fSMichael Klier        }
5302aca132fSMichael Klier    }
5312aca132fSMichael Klier
5322aca132fSMichael Klier    /**
533f01ff8c1SGina Haeussge     * Deletes a file from the wiki.
534f01ff8c1SGina Haeussge     *
535f01ff8c1SGina Haeussge     * @author Gina Haeussge <osd@foosel.net>
536f01ff8c1SGina Haeussge     */
537f01ff8c1SGina Haeussge    function deleteAttachment($id){
538f01ff8c1SGina Haeussge        $auth = auth_quickaclcheck(getNS($id).':*');
539f01ff8c1SGina Haeussge        if($auth < AUTH_DELETE) return new IXR_ERROR(1, "You don't have permissions to delete files.");
540f01ff8c1SGina Haeussge        global $conf;
541f01ff8c1SGina Haeussge        global $lang;
542f01ff8c1SGina Haeussge
543f01ff8c1SGina Haeussge        // check for references if needed
544f01ff8c1SGina Haeussge        $mediareferences = array();
545f01ff8c1SGina Haeussge        if($conf['refcheck']){
546f01ff8c1SGina Haeussge            require_once(DOKU_INC.'inc/fulltext.php');
547f01ff8c1SGina Haeussge            $mediareferences = ft_mediause($id,$conf['refshow']);
548f01ff8c1SGina Haeussge        }
549f01ff8c1SGina Haeussge
550f01ff8c1SGina Haeussge        if(!count($mediareferences)){
551f01ff8c1SGina Haeussge            $file = mediaFN($id);
552f01ff8c1SGina Haeussge            if(@unlink($file)){
55399c8d7f2Smichael                require_once(DOKU_INC.'inc/changelog.php');
55499c8d7f2Smichael                addMediaLogEntry(time(), $id, DOKU_CHANGE_TYPE_DELETE);
555f01ff8c1SGina Haeussge                io_sweepNS($id,'mediadir');
556f01ff8c1SGina Haeussge                return 0;
557f01ff8c1SGina Haeussge            }
558f01ff8c1SGina Haeussge            //something went wrong
559f01ff8c1SGina Haeussge               return new IXR_ERROR(1, 'Could not delete file');
560f01ff8c1SGina Haeussge        } else {
561f01ff8c1SGina Haeussge            return new IXR_ERROR(1, 'File is still referenced');
562f01ff8c1SGina Haeussge        }
563f01ff8c1SGina Haeussge    }
564f01ff8c1SGina Haeussge
565f01ff8c1SGina Haeussge    /**
5662aca132fSMichael Klier     * Moves the temporary file to its final destination.
5672aca132fSMichael Klier     *
5682aca132fSMichael Klier     * Michael Klier <chi@chimeric.de>
5692aca132fSMichael Klier     */
5702aca132fSMichael Klier    function _media_upload_action($data) {
5712aca132fSMichael Klier        global $conf;
5722aca132fSMichael Klier
57399c8d7f2Smichael        if(is_array($data) && count($data)===5) {
5742aca132fSMichael Klier            io_createNamespace($data[2], 'media');
5752aca132fSMichael Klier            if(rename($data[0], $data[1])) {
5762aca132fSMichael Klier                chmod($data[1], $conf['fmode']);
5772aca132fSMichael Klier                media_notify($data[2], $data[1], $data[3]);
57899c8d7f2Smichael                // add a log entry to the media changelog
57999c8d7f2Smichael                require_once(DOKU_INC.'inc/changelog.php');
58099c8d7f2Smichael                if ($data[4]) {
58199c8d7f2Smichael                    addMediaLogEntry(time(), $data[2], DOKU_CHANGE_TYPE_EDIT);
58299c8d7f2Smichael                } else {
58399c8d7f2Smichael                    addMediaLogEntry(time(), $data[2], DOKU_CHANGE_TYPE_CREATE);
58499c8d7f2Smichael                }
5852aca132fSMichael Klier                return $data[2];
5862aca132fSMichael Klier            } else {
5872aca132fSMichael Klier                return new IXR_ERROR(1, 'Upload failed.');
5882aca132fSMichael Klier            }
5892aca132fSMichael Klier        } else {
5902aca132fSMichael Klier            return new IXR_ERROR(1, 'Upload failed.');
5912aca132fSMichael Klier        }
5922aca132fSMichael Klier    }
5932aca132fSMichael Klier
5942aca132fSMichael Klier    /**
595e62b9ea5SMichael Klier    * Returns the permissions of a given wiki page
596e62b9ea5SMichael Klier    */
597e62b9ea5SMichael Klier    function aclCheck($id) {
598e62b9ea5SMichael Klier        return auth_quickaclcheck($id);
599e62b9ea5SMichael Klier    }
600e62b9ea5SMichael Klier
601e62b9ea5SMichael Klier    /**
602beccd742SMichael Klier     * Lists all links contained in a wiki page
60363dd0d58SMichael Klier     *
60463dd0d58SMichael Klier     * @author Michael Klier <chi@chimeric.de>
605beccd742SMichael Klier     */
606beccd742SMichael Klier    function listLinks($id) {
607beccd742SMichael Klier        if(auth_quickaclcheck($id) < AUTH_READ){
608beccd742SMichael Klier            return new IXR_Error(1, 'You are not allowed to read this page');
609beccd742SMichael Klier        }
610beccd742SMichael Klier        $links = array();
611beccd742SMichael Klier
612beccd742SMichael Klier        // resolve page instructions
613beccd742SMichael Klier        $ins   = p_cached_instructions(wikiFN(cleanID($id)));
614beccd742SMichael Klier
615beccd742SMichael Klier        // instantiate new Renderer - needed for interwiki links
616beccd742SMichael Klier        include(DOKU_INC.'inc/parser/xhtml.php');
617beccd742SMichael Klier        $Renderer = new Doku_Renderer_xhtml();
618beccd742SMichael Klier        $Renderer->interwiki = getInterwiki();
619beccd742SMichael Klier
620beccd742SMichael Klier        // parse parse instructions
621beccd742SMichael Klier        foreach($ins as $in) {
622beccd742SMichael Klier            $link = array();
623beccd742SMichael Klier            switch($in[0]) {
624beccd742SMichael Klier                case 'internallink':
625beccd742SMichael Klier                    $link['type'] = 'local';
626beccd742SMichael Klier                    $link['page'] = $in[1][0];
627beccd742SMichael Klier                    $link['href'] = wl($in[1][0]);
628beccd742SMichael Klier                    array_push($links,$link);
629beccd742SMichael Klier                    break;
630beccd742SMichael Klier                case 'externallink':
631beccd742SMichael Klier                    $link['type'] = 'extern';
632beccd742SMichael Klier                    $link['page'] = $in[1][0];
633beccd742SMichael Klier                    $link['href'] = $in[1][0];
634beccd742SMichael Klier                    array_push($links,$link);
635beccd742SMichael Klier                    break;
636beccd742SMichael Klier                case 'interwikilink':
637beccd742SMichael Klier                    $url = $Renderer->_resolveInterWiki($in[1][2],$in[1][3]);
638beccd742SMichael Klier                    $link['type'] = 'extern';
639beccd742SMichael Klier                    $link['page'] = $url;
640beccd742SMichael Klier                    $link['href'] = $url;
641beccd742SMichael Klier                    array_push($links,$link);
642beccd742SMichael Klier                    break;
643beccd742SMichael Klier            }
644beccd742SMichael Klier        }
645beccd742SMichael Klier
64663dd0d58SMichael Klier        return ($links);
64763dd0d58SMichael Klier    }
64863dd0d58SMichael Klier
64963dd0d58SMichael Klier    /**
65063dd0d58SMichael Klier     * Returns a list of recent changes since give timestamp
65163dd0d58SMichael Klier     *
65299c8d7f2Smichael     * @author Michael Hamann <michael@content-space.de>
65363dd0d58SMichael Klier     * @author Michael Klier <chi@chimeric.de>
65463dd0d58SMichael Klier     */
65563dd0d58SMichael Klier    function getRecentChanges($timestamp) {
65663dd0d58SMichael Klier        if(strlen($timestamp) != 10)
65763dd0d58SMichael Klier            return new IXR_Error(20, 'The provided value is not a valid timestamp');
65863dd0d58SMichael Klier
65963dd0d58SMichael Klier        require_once(DOKU_INC.'inc/changelog.php');
66063dd0d58SMichael Klier        require_once(DOKU_INC.'inc/pageutils.php');
66163dd0d58SMichael Klier
66299c8d7f2Smichael        $recents = getRecentsSince($timestamp);
66363dd0d58SMichael Klier
66499c8d7f2Smichael        $changes = array();
66563dd0d58SMichael Klier
66699c8d7f2Smichael        foreach ($recents as $recent) {
66799c8d7f2Smichael            $change = array();
66899c8d7f2Smichael            $change['name']         = $recent['id'];
66999c8d7f2Smichael            $change['lastModified'] = new IXR_Date($recent['date']);
67099c8d7f2Smichael            $change['author']       = $recent['user'];
67199c8d7f2Smichael            $change['version']      = $recent['date'];
67299c8d7f2Smichael            $change['perms']        = $recent['perms'];
67399c8d7f2Smichael            $change['size']         = @filesize(wikiFN($recent['id']));
67463dd0d58SMichael Klier            array_push($changes, $change);
67599c8d7f2Smichael        }
67699c8d7f2Smichael
67799c8d7f2Smichael        if (!empty($changes)) {
67899c8d7f2Smichael            return $changes;
67963dd0d58SMichael Klier        } else {
68063dd0d58SMichael Klier            // in case we still have nothing at this point
68163dd0d58SMichael Klier            return new IXR_Error(30, 'There are no changes in the specified timeframe');
6823a1dad2dSDennis Ploeger        }
68399c8d7f2Smichael    }
68499c8d7f2Smichael
68599c8d7f2Smichael    /**
68699c8d7f2Smichael     * Returns a list of recent media changes since give timestamp
68799c8d7f2Smichael     *
68899c8d7f2Smichael     * @author Michael Hamann <michael@content-space.de>
68999c8d7f2Smichael     * @author Michael Klier <chi@chimeric.de>
69099c8d7f2Smichael     */
69199c8d7f2Smichael    function getRecentMediaChanges($timestamp) {
69299c8d7f2Smichael        if(strlen($timestamp) != 10)
69399c8d7f2Smichael            return new IXR_Error(20, 'The provided value is not a valid timestamp');
69499c8d7f2Smichael
69599c8d7f2Smichael        require_once(DOKU_INC.'inc/changelog.php');
69699c8d7f2Smichael        require_once(DOKU_INC.'inc/pageutils.php');
69799c8d7f2Smichael
69899c8d7f2Smichael        $recents = getRecentsSince($timestamp, null, '', RECENTS_MEDIA_CHANGES);
69999c8d7f2Smichael
70099c8d7f2Smichael        $changes = array();
70199c8d7f2Smichael
70299c8d7f2Smichael        foreach ($recents as $recent) {
70399c8d7f2Smichael            $change = array();
70499c8d7f2Smichael            $change['name']         = $recent['id'];
70599c8d7f2Smichael            $change['lastModified'] = new IXR_Date($recent['date']);
70699c8d7f2Smichael            $change['author']       = $recent['user'];
70799c8d7f2Smichael            $change['version']      = $recent['date'];
70899c8d7f2Smichael            $change['perms']        = $recent['perms'];
70999c8d7f2Smichael            $change['size']         = @filesize(wikiFN($recent['id']));
71099c8d7f2Smichael            array_push($changes, $change);
71199c8d7f2Smichael        }
71299c8d7f2Smichael
71399c8d7f2Smichael        if (!empty($changes)) {
71499c8d7f2Smichael            return $changes;
71599c8d7f2Smichael        } else {
71699c8d7f2Smichael            // in case we still have nothing at this point
71799c8d7f2Smichael            return new IXR_Error(30, 'There are no changes in the specified timeframe');
71899c8d7f2Smichael        }
71999c8d7f2Smichael    }
7203a1dad2dSDennis Ploeger
7213a1dad2dSDennis Ploeger    /**
72273056168SMichael Klier     * Returns a list of available revisions of a given wiki page
72373056168SMichael Klier     *
72473056168SMichael Klier     * @author Michael Klier <chi@chimeric.de>
72573056168SMichael Klier     */
72673056168SMichael Klier    function pageVersions($id, $first) {
72773056168SMichael Klier        global $conf;
72873056168SMichael Klier
72973056168SMichael Klier        $versions = array();
73073056168SMichael Klier
73173056168SMichael Klier        if(empty($id))
73273056168SMichael Klier            return new IXR_Error(1, 'Empty page ID');
73373056168SMichael Klier
73473056168SMichael Klier        require_once(DOKU_INC.'inc/changelog.php');
73573056168SMichael Klier
73673056168SMichael Klier        $revisions = getRevisions($id, $first, $conf['recent']+1);
73773056168SMichael Klier
73873056168SMichael Klier        if(count($revisions)==0 && $first!=0) {
73973056168SMichael Klier            $first=0;
74073056168SMichael Klier            $revisions = getRevisions($id, $first, $conf['recent']+1);
74173056168SMichael Klier        }
74273056168SMichael Klier
74345c63471SMichael Klier        if(count($revisions)>0 && $first==0) {
74445c63471SMichael Klier            array_unshift($revisions, '');  // include current revision
74545c63471SMichael Klier            array_pop($revisions);          // remove extra log entry
74645c63471SMichael Klier        }
74745c63471SMichael Klier
74873056168SMichael Klier        $hasNext = false;
74973056168SMichael Klier        if(count($revisions)>$conf['recent']) {
75073056168SMichael Klier            $hasNext = true;
75173056168SMichael Klier            array_pop($revisions); // remove extra log entry
75273056168SMichael Klier        }
75373056168SMichael Klier
75473056168SMichael Klier        if(!empty($revisions)) {
75573056168SMichael Klier            foreach($revisions as $rev) {
75673056168SMichael Klier                $file = wikiFN($id,$rev);
75773056168SMichael Klier                $time = @filemtime($file);
75845c63471SMichael Klier                // we check if the page actually exists, if this is not the
75945c63471SMichael Klier                // case this can lead to less pages being returned than
76045c63471SMichael Klier                // specified via $conf['recent']
76173056168SMichael Klier                if($time){
76273056168SMichael Klier                    $info = getRevisionInfo($id, $time, 1024);
76373056168SMichael Klier                    if(!empty($info)) {
76473056168SMichael Klier                        $data['user'] = $info['user'];
76573056168SMichael Klier                        $data['ip']   = $info['ip'];
76673056168SMichael Klier                        $data['type'] = $info['type'];
76773056168SMichael Klier                        $data['sum']  = $info['sum'];
76873056168SMichael Klier                        $data['modified'] = new IXR_Date($info['date']);
76973056168SMichael Klier                        $data['version'] = $info['date'];
77073056168SMichael Klier                        array_push($versions, $data);
77173056168SMichael Klier                    }
77273056168SMichael Klier                }
77373056168SMichael Klier            }
77473056168SMichael Klier            return $versions;
77573056168SMichael Klier        } else {
77673056168SMichael Klier            return array();
77773056168SMichael Klier        }
77873056168SMichael Klier    }
77973056168SMichael Klier
78073056168SMichael Klier    /**
781797c0d11SAndreas Gohr     * The version of Wiki RPC API supported
782797c0d11SAndreas Gohr     */
783797c0d11SAndreas Gohr    function wiki_RPCVersion(){
784797c0d11SAndreas Gohr        return 2;
785797c0d11SAndreas Gohr    }
7861b11c097SAndreas Gohr
78728ec3c76SAndreas Gohr
78828ec3c76SAndreas Gohr    /**
78928ec3c76SAndreas Gohr     * Locks or unlocks a given batch of pages
79028ec3c76SAndreas Gohr     *
79128ec3c76SAndreas Gohr     * Give an associative array with two keys: lock and unlock. Both should contain a
79228ec3c76SAndreas Gohr     * list of pages to lock or unlock
79328ec3c76SAndreas Gohr     *
79428ec3c76SAndreas Gohr     * Returns an associative array with the keys locked, lockfail, unlocked and
79528ec3c76SAndreas Gohr     * unlockfail, each containing lists of pages.
79628ec3c76SAndreas Gohr     */
79728ec3c76SAndreas Gohr    function setLocks($set){
79828ec3c76SAndreas Gohr        $locked     = array();
79928ec3c76SAndreas Gohr        $lockfail   = array();
80028ec3c76SAndreas Gohr        $unlocked   = array();
80128ec3c76SAndreas Gohr        $unlockfail = array();
80228ec3c76SAndreas Gohr
80328ec3c76SAndreas Gohr        foreach((array) $set['lock'] as $id){
80428ec3c76SAndreas Gohr            if(checklock($id)){
80528ec3c76SAndreas Gohr                $lockfail[] = $id;
80628ec3c76SAndreas Gohr            }else{
80728ec3c76SAndreas Gohr                lock($id);
80828ec3c76SAndreas Gohr                $locked[] = $id;
80928ec3c76SAndreas Gohr            }
81028ec3c76SAndreas Gohr        }
81128ec3c76SAndreas Gohr
81228ec3c76SAndreas Gohr        foreach((array) $set['unlock'] as $id){
81328ec3c76SAndreas Gohr            if(unlock($id)){
81428ec3c76SAndreas Gohr                $unlocked[] = $id;
81528ec3c76SAndreas Gohr            }else{
81628ec3c76SAndreas Gohr                $unlockfail[] = $id;
81728ec3c76SAndreas Gohr            }
81828ec3c76SAndreas Gohr        }
81928ec3c76SAndreas Gohr
82028ec3c76SAndreas Gohr        return array(
82128ec3c76SAndreas Gohr            'locked'     => $locked,
82228ec3c76SAndreas Gohr            'lockfail'   => $lockfail,
82328ec3c76SAndreas Gohr            'unlocked'   => $unlocked,
82428ec3c76SAndreas Gohr            'unlockfail' => $unlockfail,
82528ec3c76SAndreas Gohr        );
82628ec3c76SAndreas Gohr    }
82728ec3c76SAndreas Gohr
828797c0d11SAndreas Gohr}
829797c0d11SAndreas Gohr
830797c0d11SAndreas Gohr$server = new dokuwiki_xmlrpc_server();
831797c0d11SAndreas Gohr
8322aca132fSMichael Klier// vim:ts=4:sw=4:et:enc=utf-8:
833