1<?php 2if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../'); 3 4// fix when '<?xml' isn't on the very first line 5if(isset($HTTP_RAW_POST_DATA)) $HTTP_RAW_POST_DATA = trim($HTTP_RAW_POST_DATA); 6 7 8//EXPERIMENTAL CODE 9die('remove me to get it work'); 10 11require_once(DOKU_INC.'inc/init.php'); 12require_once(DOKU_INC.'inc/common.php'); 13require_once(DOKU_INC.'inc/auth.php'); 14session_write_close(); //close session 15require_once(DOKU_INC.'inc/IXR_Library.php'); 16 17 18 19/** 20 * Contains needed wrapper functions and registers all available 21 * XMLRPC functions. 22 */ 23class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { 24 var $methods = array(); 25 26 /** 27 * Constructor. Register methods and run Server 28 */ 29 function dokuwiki_xmlrpc_server(){ 30 $this->IXR_IntrospectionServer(); 31 32 /* DokuWiki's own methods */ 33 $this->addCallback( 34 'dokuwiki.getVersion', 35 'getVersion', 36 array('string'), 37 'Returns the running DokuWiki version' 38 ); 39 40 /* Wiki API v2 http://www.jspwiki.org/wiki/WikiRPCInterface2 */ 41 $this->addCallback( 42 'wiki.getRPCVersionSupported', 43 'this:wiki_RPCVersion', 44 array('int'), 45 'Returns 2 with the supported RPC API version' 46 ); 47 $this->addCallback( 48 'wiki.getPage', 49 'this:rawPage', 50 array('string','string'), 51 'Get the raw Wiki text of page, latest version.' 52 ); 53 $this->addCallback( 54 'wiki.getPageVersion', 55 'this:rawPage', 56 array('string','string','int'), 57 'Get the raw Wiki text of page.' 58 ); 59 $this->addCallback( 60 'wiki.getPageHTML', 61 'this:htmlPage', 62 array('string','string'), 63 'Return page in rendered HTML, latest version.' 64 ); 65 $this->addCallback( 66 'wiki.getPageHTMLVersion', 67 'this:htmlPage', 68 array('string','string','int'), 69 'Return page in rendered HTML.' 70 ); 71 $this->addCallback( 72 'wiki.getAllPages', 73 'this:listPages', 74 array('struct'), 75 'Returns a list of all pages. The result is an array of utf8 pagenames.' 76 ); 77 $this->addCallback( 78 'wiki.getBackLinks', 79 'this:listBackLinks', 80 array('struct','string'), 81 'Returns the pages that link to this page.' 82 ); 83 $this->addCallback( 84 'wiki.getPageInfo', 85 'this:pageInfo', 86 array('struct','string'), 87 'Returns a struct with infos about the page.' 88 ); 89 $this->addCallback( 90 'wiki.getPageInfoVersion', 91 'this:pageInfo', 92 array('struct','string','int'), 93 'Returns a struct with infos about the page.' 94 ); 95/* 96 FIXME: missing, yet 97 'wiki.getRecentChanges' 98 'wiki.listLinks' 99 'wiki.putPage' 100*/ 101 102 $this->serve(); 103 } 104 105 /** 106 * Return a raw wiki page 107 */ 108 function rawPage($id,$rev=''){ 109 if(auth_quickaclcheck($id) < AUTH_READ){ 110 return new IXR_Error(1, 'You are not allowed to read this page'); 111 } 112 return rawWiki($id,$rev); 113 } 114 115 /** 116 * Return a wiki page rendered to html 117 */ 118 function htmlPage($id,$rev=''){ 119 if(auth_quickaclcheck($id) < AUTH_READ){ 120 return new IXR_Error(1, 'You are not allowed to read this page'); 121 } 122 return p_wiki_xhtml($id,$rev,false); 123 } 124 125 /** 126 * List all pages - we use the indexer list here 127 */ 128 function listPages(){ 129 require_once(DOKU_INC.'inc/fulltext.php'); 130 return ft_pageLookup(''); 131 } 132 133 134 /** 135 * Return a list of backlinks 136 */ 137 function listBacklinks($id){ 138 require_once(DOKU_INC.'inc/fulltext.php'); 139 return ft_backlinks($id); 140 } 141 142 /** 143 * return some basic data about a page 144 */ 145 function pageInfo($id,$rev=''){ 146 if(auth_quickaclcheck($id) < AUTH_READ){ 147 return new IXR_Error(1, 'You are not allowed to read this page'); 148 } 149 $file = wikiFN($id,$rev); 150 $time = @filemtime($file); 151 if(!$time){ 152 return new IXR_Error(10, 'The requested page does not exist'); 153 } 154 155 $info = getRevisionInfo($id, $time, 1024); 156 157 $data = array( 158 'name' => $id, 159 'lastModified' => new IXR_Date($time), 160 'author' => (($info['user']) ? $info['user'] : $info['ip']), 161 'version' => $time 162 ); 163 return $data; 164 } 165 166 /** 167 * The version of Wiki RPC API supported 168 */ 169 function wiki_RPCVersion(){ 170 return 2; 171 } 172 173} 174 175$server = new dokuwiki_xmlrpc_server(); 176 177