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 * Increased whenever the API is changed 9 */ 10define('DOKU_XMLRPC_API_VERSION', 6); 11 12require_once(DOKU_INC.'inc/init.php'); 13session_write_close(); //close session 14 15if(!$conf['xmlrpc']) die('XML-RPC server not enabled.'); 16 17/** 18 * Contains needed wrapper functions and registers all available 19 * XMLRPC functions. 20 */ 21class dokuwiki_xmlrpc_server extends IXR_IntrospectionServer { 22 var $methods = array(); 23 var $public_methods = array(); 24 var $remote; 25 26 /** 27 * Checks if the current user is allowed to execute non anonymous methods 28 */ 29 function checkAuth(){ 30 global $conf; 31 global $USERINFO; 32 33 if(!$conf['useacl']) return true; //no ACL - then no checks 34 if(trim($conf['xmlrpcuser']) == '') return true; //no restrictions 35 36 return auth_isMember($conf['xmlrpcuser'],$_SERVER['REMOTE_USER'],(array) $USERINFO['grps']); 37 } 38 39 /** 40 * Adds a callback, extends parent method 41 * 42 * add another parameter to define if anonymous access to 43 * this method should be granted. 44 */ 45 function addCallback($method, $callback, $args, $help, $public=false){ 46 if($public) $this->public_methods[] = $method; 47 return parent::addCallback($method, $callback, $args, $help); 48 } 49 50 /** 51 * Execute a call, extends parent method 52 * 53 * Checks for authentication first 54 */ 55 function call($methodname, $args){ 56 if(!in_array($methodname,$this->public_methods) && !$this->checkAuth()){ 57 if (!isset($_SERVER['REMOTE_USER'])) { 58 header('HTTP/1.1 401 Unauthorized'); 59 } else { 60 header('HTTP/1.1 403 Forbidden'); 61 } 62 return new IXR_Error(-32603, 'server error. not authorized to call method "'.$methodname.'".'); 63 } 64 return parent::call($methodname, $args); 65 } 66 67 /** 68 * Constructor. Register methods and run Server 69 */ 70 function dokuwiki_xmlrpc_server(){ 71 $this->remote = new RemoteAPI(); 72 $this->IXR_IntrospectionServer(); 73 74 /* DokuWiki's own methods */ 75 $this->addCallback( 76 'dokuwiki.getXMLRPCAPIVersion', 77 'this:getAPIVersion', 78 array('integer'), 79 'Returns the XMLRPC API version.', 80 true 81 ); 82 83 $this->addCallback( 84 'dokuwiki.getVersion', 85 'getVersion', 86 array('string'), 87 'Returns the running DokuWiki version.', 88 true 89 ); 90 91 $this->addCallback( 92 'dokuwiki.login', 93 'this:login', 94 array('integer','string','string'), 95 'Tries to login with the given credentials and sets auth cookies.', 96 true 97 ); 98 99 $this->addCallback( 100 'dokuwiki.getPagelist', 101 'this:readNamespace', 102 array('struct','string','struct'), 103 'List all pages within the given namespace.' 104 ); 105 106 $this->addCallback( 107 'dokuwiki.search', 108 'this:search', 109 array('struct','string'), 110 'Perform a fulltext search and return a list of matching pages' 111 ); 112 113 $this->addCallback( 114 'dokuwiki.getTime', 115 'time', 116 array('int'), 117 'Return the current time at the wiki server.' 118 ); 119 120 $this->addCallback( 121 'dokuwiki.setLocks', 122 'this:setLocks', 123 array('struct','struct'), 124 'Lock or unlock pages.' 125 ); 126 127 128 $this->addCallback( 129 'dokuwiki.getTitle', 130 'this:getTitle', 131 array('string'), 132 'Returns the wiki title.', 133 true 134 ); 135 136 $this->addCallback( 137 'dokuwiki.appendPage', 138 'this:appendPage', 139 array('int', 'string', 'string', 'struct'), 140 'Append text to a wiki page.' 141 ); 142 143 /* Wiki API v2 http://www.jspwiki.org/wiki/WikiRPCInterface2 */ 144 $this->addCallback( 145 'wiki.getRPCVersionSupported', 146 'this:wiki_RPCVersion', 147 array('int'), 148 'Returns 2 with the supported RPC API version.', 149 true 150 ); 151 $this->addCallback( 152 'wiki.getPage', 153 'this:rawPage', 154 array('string','string'), 155 'Get the raw Wiki text of page, latest version.' 156 ); 157 $this->addCallback( 158 'wiki.getPageVersion', 159 'this:rawPage', 160 array('string','string','int'), 161 'Get the raw Wiki text of page.' 162 ); 163 $this->addCallback( 164 'wiki.getPageHTML', 165 'this:htmlPage', 166 array('string','string'), 167 'Return page in rendered HTML, latest version.' 168 ); 169 $this->addCallback( 170 'wiki.getPageHTMLVersion', 171 'this:htmlPage', 172 array('string','string','int'), 173 'Return page in rendered HTML.' 174 ); 175 $this->addCallback( 176 'wiki.getAllPages', 177 'this:listPages', 178 array('struct'), 179 'Returns a list of all pages. The result is an array of utf8 pagenames.' 180 ); 181 $this->addCallback( 182 'wiki.getAttachments', 183 'this:listAttachments', 184 array('struct', 'string', 'struct'), 185 'Returns a list of all media files.' 186 ); 187 $this->addCallback( 188 'wiki.getBackLinks', 189 'this:listBackLinks', 190 array('struct','string'), 191 'Returns the pages that link to this page.' 192 ); 193 $this->addCallback( 194 'wiki.getPageInfo', 195 'this:pageInfo', 196 array('struct','string'), 197 'Returns a struct with infos about the page.' 198 ); 199 $this->addCallback( 200 'wiki.getPageInfoVersion', 201 'this:pageInfo', 202 array('struct','string','int'), 203 'Returns a struct with infos about the page.' 204 ); 205 $this->addCallback( 206 'wiki.getPageVersions', 207 'this:pageVersions', 208 array('struct','string','int'), 209 'Returns the available revisions of the page.' 210 ); 211 $this->addCallback( 212 'wiki.putPage', 213 'this:putPage', 214 array('int', 'string', 'string', 'struct'), 215 'Saves a wiki page.' 216 ); 217 $this->addCallback( 218 'wiki.listLinks', 219 'this:listLinks', 220 array('struct','string'), 221 'Lists all links contained in a wiki page.' 222 ); 223 $this->addCallback( 224 'wiki.getRecentChanges', 225 'this:getRecentChanges', 226 array('struct','int'), 227 'Returns a struct about all recent changes since given timestamp.' 228 ); 229 $this->addCallback( 230 'wiki.getRecentMediaChanges', 231 'this:getRecentMediaChanges', 232 array('struct','int'), 233 'Returns a struct about all recent media changes since given timestamp.' 234 ); 235 $this->addCallback( 236 'wiki.aclCheck', 237 'this:aclCheck', 238 array('int', 'string'), 239 'Returns the permissions of a given wiki page.' 240 ); 241 $this->addCallback( 242 'wiki.putAttachment', 243 'this:putAttachment', 244 array('struct', 'string', 'base64', 'struct'), 245 'Upload a file to the wiki.' 246 ); 247 $this->addCallback( 248 'wiki.deleteAttachment', 249 'this:deleteAttachment', 250 array('int', 'string'), 251 'Delete a file from the wiki.' 252 ); 253 $this->addCallback( 254 'wiki.getAttachment', 255 'this:getAttachment', 256 array('base64', 'string'), 257 'Download a file from the wiki.' 258 ); 259 $this->addCallback( 260 'wiki.getAttachmentInfo', 261 'this:getAttachmentInfo', 262 array('struct', 'string'), 263 'Returns a struct with infos about the attachment.' 264 ); 265 266 /** 267 * Trigger XMLRPC_CALLBACK_REGISTER, action plugins can use this event 268 * to extend the XMLRPC interface and register their own callbacks. 269 * 270 * Event data: 271 * The XMLRPC server object: 272 * 273 * $event->data->addCallback() - register a callback, the second 274 * paramter has to be of the form "plugin:<pluginname>:<plugin 275 * method>" 276 * 277 * $event->data->callbacks - an array which holds all awaylable 278 * callbacks 279 */ 280 trigger_event('XMLRPC_CALLBACK_REGISTER', $this); 281 282 $this->serve(); 283 } 284 285 /** 286 * Return a raw wiki page 287 */ 288 function rawPage($id,$rev=''){ 289 try { 290 return $this->remote->rawPage($id, $rev); 291 } catch(RemoteAccessDenied $e) { 292 return new IXR_Error(1, 'You are not allowed to read this page'); 293 } 294 } 295 296 /** 297 * Return a media file encoded in base64 298 * 299 * @author Gina Haeussge <osd@foosel.net> 300 */ 301 function getAttachment($id){ 302 try { 303 try { 304 return $this->remote->getAttachment($id); 305 } catch (RemoteAccessDenied $e) { 306 return new IXR_Error(1, 'You are not allowed to read this file'); 307 } 308 } 309 catch (RemoteException $e) { 310 return new IXR_Error(1, $e->getMessage()); 311 } 312 } 313 314 /** 315 * Return info about a media file 316 * 317 * @author Gina Haeussge <osd@foosel.net> 318 */ 319 function getAttachmentInfo($id){ 320 $info = $this->remote->getAttachmentInfo($id); 321 $info['lastModified'] = new IXR_Date($info['lastModified']); 322 return $info; 323 } 324 325 /** 326 * Return a wiki page rendered to html 327 */ 328 function htmlPage($id,$rev=''){ 329 $id = cleanID($id); 330 if(auth_quickaclcheck($id) < AUTH_READ){ 331 return new IXR_Error(1, 'You are not allowed to read this page'); 332 } 333 return p_wiki_xhtml($id,$rev,false); 334 } 335 336 /** 337 * List all pages - we use the indexer list here 338 */ 339 function listPages(){ 340 $list = array(); 341 $pages = idx_get_indexer()->getPages(); 342 $pages = array_filter(array_filter($pages,'isVisiblePage'),'page_exists'); 343 344 foreach(array_keys($pages) as $idx) { 345 $perm = auth_quickaclcheck($pages[$idx]); 346 if($perm < AUTH_READ) { 347 continue; 348 } 349 $page = array(); 350 $page['id'] = trim($pages[$idx]); 351 $page['perms'] = $perm; 352 $page['size'] = @filesize(wikiFN($pages[$idx])); 353 $page['lastModified'] = new IXR_Date(@filemtime(wikiFN($pages[$idx]))); 354 $list[] = $page; 355 } 356 357 return $list; 358 } 359 360 /** 361 * List all pages in the given namespace (and below) 362 */ 363 function readNamespace($ns,$opts){ 364 global $conf; 365 366 if(!is_array($opts)) $opts=array(); 367 368 $ns = cleanID($ns); 369 $dir = utf8_encodeFN(str_replace(':', '/', $ns)); 370 $data = array(); 371 $opts['skipacl'] = 0; // no ACL skipping for XMLRPC 372 search($data, $conf['datadir'], 'search_allpages', $opts, $dir); 373 return $data; 374 } 375 376 /** 377 * List all pages in the given namespace (and below) 378 */ 379 function search($query){ 380 require_once(DOKU_INC.'inc/fulltext.php'); 381 382 $regex = ''; 383 $data = ft_pageSearch($query,$regex); 384 $pages = array(); 385 386 // prepare additional data 387 $idx = 0; 388 foreach($data as $id => $score){ 389 $file = wikiFN($id); 390 391 if($idx < FT_SNIPPET_NUMBER){ 392 $snippet = ft_snippet($id,$regex); 393 $idx++; 394 }else{ 395 $snippet = ''; 396 } 397 398 $pages[] = array( 399 'id' => $id, 400 'score' => $score, 401 'rev' => filemtime($file), 402 'mtime' => filemtime($file), 403 'size' => filesize($file), 404 'snippet' => $snippet, 405 ); 406 } 407 return $pages; 408 } 409 410 /** 411 * Returns the wiki title. 412 */ 413 function getTitle(){ 414 global $conf; 415 return $conf['title']; 416 } 417 418 /** 419 * List all media files. 420 * 421 * Available options are 'recursive' for also including the subnamespaces 422 * in the listing, and 'pattern' for filtering the returned files against 423 * a regular expression matching their name. 424 * 425 * @author Gina Haeussge <osd@foosel.net> 426 */ 427 function listAttachments($ns, $options = array()) { 428 global $conf; 429 global $lang; 430 431 $ns = cleanID($ns); 432 433 if (!is_array($options)) $options = array(); 434 $options['skipacl'] = 0; // no ACL skipping for XMLRPC 435 436 437 if(auth_quickaclcheck($ns.':*') >= AUTH_READ) { 438 $dir = utf8_encodeFN(str_replace(':', '/', $ns)); 439 440 $data = array(); 441 search($data, $conf['mediadir'], 'search_media', $options, $dir); 442 $len = count($data); 443 if(!$len) return array(); 444 445 for($i=0; $i<$len; $i++) { 446 unset($data[$i]['meta']); 447 $data[$i]['lastModified'] = new IXR_Date($data[$i]['mtime']); 448 } 449 return $data; 450 } else { 451 return new IXR_Error(1, 'You are not allowed to list media files.'); 452 } 453 } 454 455 /** 456 * Return a list of backlinks 457 */ 458 function listBackLinks($id){ 459 return ft_backlinks(cleanID($id)); 460 } 461 462 /** 463 * Return some basic data about a page 464 */ 465 function pageInfo($id,$rev=''){ 466 $id = cleanID($id); 467 if(auth_quickaclcheck($id) < AUTH_READ){ 468 return new IXR_Error(1, 'You are not allowed to read this page'); 469 } 470 $file = wikiFN($id,$rev); 471 $time = @filemtime($file); 472 if(!$time){ 473 return new IXR_Error(10, 'The requested page does not exist'); 474 } 475 476 $info = getRevisionInfo($id, $time, 1024); 477 478 $data = array( 479 'name' => $id, 480 'lastModified' => new IXR_Date($time), 481 'author' => (($info['user']) ? $info['user'] : $info['ip']), 482 'version' => $time 483 ); 484 485 return ($data); 486 } 487 488 /** 489 * Save a wiki page 490 * 491 * @author Michael Klier <chi@chimeric.de> 492 */ 493 function putPage($id, $text, $params) { 494 global $TEXT; 495 global $lang; 496 global $conf; 497 498 $id = cleanID($id); 499 $TEXT = cleanText($text); 500 $sum = $params['sum']; 501 $minor = $params['minor']; 502 503 if(empty($id)) 504 return new IXR_Error(1, 'Empty page ID'); 505 506 if(!page_exists($id) && trim($TEXT) == '' ) { 507 return new IXR_ERROR(1, 'Refusing to write an empty new wiki page'); 508 } 509 510 if(auth_quickaclcheck($id) < AUTH_EDIT) 511 return new IXR_Error(1, 'You are not allowed to edit this page'); 512 513 // Check, if page is locked 514 if(checklock($id)) 515 return new IXR_Error(1, 'The page is currently locked'); 516 517 // SPAM check 518 if(checkwordblock()) 519 return new IXR_Error(1, 'Positive wordblock check'); 520 521 // autoset summary on new pages 522 if(!page_exists($id) && empty($sum)) { 523 $sum = $lang['created']; 524 } 525 526 // autoset summary on deleted pages 527 if(page_exists($id) && empty($TEXT) && empty($sum)) { 528 $sum = $lang['deleted']; 529 } 530 531 lock($id); 532 533 saveWikiText($id,$TEXT,$sum,$minor); 534 535 unlock($id); 536 537 // run the indexer if page wasn't indexed yet 538 idx_addPage($id); 539 540 return 0; 541 } 542 543 /** 544 * Appends text to a wiki page. 545 */ 546 function appendPage($id, $text, $params) { 547 $currentpage = $this->rawPage($id); 548 if (!is_string($currentpage)) { 549 return $currentpage; 550 } 551 return $this->putPage($id, $currentpage.$text, $params); 552 } 553 554 /** 555 * Uploads a file to the wiki. 556 * 557 * Michael Klier <chi@chimeric.de> 558 */ 559 function putAttachment($id, $file, $params) { 560 $id = cleanID($id); 561 $auth = auth_quickaclcheck(getNS($id).':*'); 562 563 if(!isset($id)) { 564 return new IXR_ERROR(1, 'Filename not given.'); 565 } 566 567 global $conf; 568 569 $ftmp = $conf['tmpdir'] . '/' . md5($id.clientIP()); 570 571 // save temporary file 572 @unlink($ftmp); 573 if (preg_match('/^[A-Za-z0-9\+\/]*={0,2}$/', $file) === 1) { 574 // DEPRECATED: Double-decode file if it still looks like base64 575 // after first decoding (which is done by the library) 576 $file = base64_decode($file); 577 } 578 io_saveFile($ftmp, $file); 579 580 $res = media_save(array('name' => $ftmp), $id, $params['ow'], $auth, 'rename'); 581 if (is_array($res)) { 582 return new IXR_ERROR(-$res[1], $res[0]); 583 } else { 584 return $res; 585 } 586 } 587 588 /** 589 * Deletes a file from the wiki. 590 * 591 * @author Gina Haeussge <osd@foosel.net> 592 */ 593 function deleteAttachment($id){ 594 $id = cleanID($id); 595 $auth = auth_quickaclcheck(getNS($id).':*'); 596 $res = media_delete($id, $auth); 597 if ($res & DOKU_MEDIA_DELETED) { 598 return 0; 599 } elseif ($res & DOKU_MEDIA_NOT_AUTH) { 600 return new IXR_ERROR(1, "You don't have permissions to delete files."); 601 } elseif ($res & DOKU_MEDIA_INUSE) { 602 return new IXR_ERROR(1, 'File is still referenced'); 603 } else { 604 return new IXR_ERROR(1, 'Could not delete file'); 605 } 606 } 607 608 /** 609 * Returns the permissions of a given wiki page 610 */ 611 function aclCheck($id) { 612 $id = cleanID($id); 613 return auth_quickaclcheck($id); 614 } 615 616 /** 617 * Lists all links contained in a wiki page 618 * 619 * @author Michael Klier <chi@chimeric.de> 620 */ 621 function listLinks($id) { 622 $id = cleanID($id); 623 if(auth_quickaclcheck($id) < AUTH_READ){ 624 return new IXR_Error(1, 'You are not allowed to read this page'); 625 } 626 $links = array(); 627 628 // resolve page instructions 629 $ins = p_cached_instructions(wikiFN($id)); 630 631 // instantiate new Renderer - needed for interwiki links 632 include(DOKU_INC.'inc/parser/xhtml.php'); 633 $Renderer = new Doku_Renderer_xhtml(); 634 $Renderer->interwiki = getInterwiki(); 635 636 // parse parse instructions 637 foreach($ins as $in) { 638 $link = array(); 639 switch($in[0]) { 640 case 'internallink': 641 $link['type'] = 'local'; 642 $link['page'] = $in[1][0]; 643 $link['href'] = wl($in[1][0]); 644 array_push($links,$link); 645 break; 646 case 'externallink': 647 $link['type'] = 'extern'; 648 $link['page'] = $in[1][0]; 649 $link['href'] = $in[1][0]; 650 array_push($links,$link); 651 break; 652 case 'interwikilink': 653 $url = $Renderer->_resolveInterWiki($in[1][2],$in[1][3]); 654 $link['type'] = 'extern'; 655 $link['page'] = $url; 656 $link['href'] = $url; 657 array_push($links,$link); 658 break; 659 } 660 } 661 662 return ($links); 663 } 664 665 /** 666 * Returns a list of recent changes since give timestamp 667 * 668 * @author Michael Hamann <michael@content-space.de> 669 * @author Michael Klier <chi@chimeric.de> 670 */ 671 function getRecentChanges($timestamp) { 672 if(strlen($timestamp) != 10) 673 return new IXR_Error(20, 'The provided value is not a valid timestamp'); 674 675 $recents = getRecentsSince($timestamp); 676 677 $changes = array(); 678 679 foreach ($recents as $recent) { 680 $change = array(); 681 $change['name'] = $recent['id']; 682 $change['lastModified'] = new IXR_Date($recent['date']); 683 $change['author'] = $recent['user']; 684 $change['version'] = $recent['date']; 685 $change['perms'] = $recent['perms']; 686 $change['size'] = @filesize(wikiFN($recent['id'])); 687 array_push($changes, $change); 688 } 689 690 if (!empty($changes)) { 691 return $changes; 692 } else { 693 // in case we still have nothing at this point 694 return new IXR_Error(30, 'There are no changes in the specified timeframe'); 695 } 696 } 697 698 /** 699 * Returns a list of recent media changes since give timestamp 700 * 701 * @author Michael Hamann <michael@content-space.de> 702 * @author Michael Klier <chi@chimeric.de> 703 */ 704 function getRecentMediaChanges($timestamp) { 705 if(strlen($timestamp) != 10) 706 return new IXR_Error(20, 'The provided value is not a valid timestamp'); 707 708 $recents = getRecentsSince($timestamp, null, '', RECENTS_MEDIA_CHANGES); 709 710 $changes = array(); 711 712 foreach ($recents as $recent) { 713 $change = array(); 714 $change['name'] = $recent['id']; 715 $change['lastModified'] = new IXR_Date($recent['date']); 716 $change['author'] = $recent['user']; 717 $change['version'] = $recent['date']; 718 $change['perms'] = $recent['perms']; 719 $change['size'] = @filesize(mediaFN($recent['id'])); 720 array_push($changes, $change); 721 } 722 723 if (!empty($changes)) { 724 return $changes; 725 } else { 726 // in case we still have nothing at this point 727 return new IXR_Error(30, 'There are no changes in the specified timeframe'); 728 } 729 } 730 731 /** 732 * Returns a list of available revisions of a given wiki page 733 * 734 * @author Michael Klier <chi@chimeric.de> 735 */ 736 function pageVersions($id, $first) { 737 $id = cleanID($id); 738 if(auth_quickaclcheck($id) < AUTH_READ){ 739 return new IXR_Error(1, 'You are not allowed to read this page'); 740 } 741 global $conf; 742 743 $versions = array(); 744 745 if(empty($id)) 746 return new IXR_Error(1, 'Empty page ID'); 747 748 $revisions = getRevisions($id, $first, $conf['recent']+1); 749 750 if(count($revisions)==0 && $first!=0) { 751 $first=0; 752 $revisions = getRevisions($id, $first, $conf['recent']+1); 753 } 754 755 if(count($revisions)>0 && $first==0) { 756 array_unshift($revisions, ''); // include current revision 757 array_pop($revisions); // remove extra log entry 758 } 759 760 $hasNext = false; 761 if(count($revisions)>$conf['recent']) { 762 $hasNext = true; 763 array_pop($revisions); // remove extra log entry 764 } 765 766 if(!empty($revisions)) { 767 foreach($revisions as $rev) { 768 $file = wikiFN($id,$rev); 769 $time = @filemtime($file); 770 // we check if the page actually exists, if this is not the 771 // case this can lead to less pages being returned than 772 // specified via $conf['recent'] 773 if($time){ 774 $info = getRevisionInfo($id, $time, 1024); 775 if(!empty($info)) { 776 $data['user'] = $info['user']; 777 $data['ip'] = $info['ip']; 778 $data['type'] = $info['type']; 779 $data['sum'] = $info['sum']; 780 $data['modified'] = new IXR_Date($info['date']); 781 $data['version'] = $info['date']; 782 array_push($versions, $data); 783 } 784 } 785 } 786 return $versions; 787 } else { 788 return array(); 789 } 790 } 791 792 /** 793 * The version of Wiki RPC API supported 794 */ 795 function wiki_RPCVersion(){ 796 return 2; 797 } 798 799 800 /** 801 * Locks or unlocks a given batch of pages 802 * 803 * Give an associative array with two keys: lock and unlock. Both should contain a 804 * list of pages to lock or unlock 805 * 806 * Returns an associative array with the keys locked, lockfail, unlocked and 807 * unlockfail, each containing lists of pages. 808 */ 809 function setLocks($set){ 810 $locked = array(); 811 $lockfail = array(); 812 $unlocked = array(); 813 $unlockfail = array(); 814 815 foreach((array) $set['lock'] as $id){ 816 $id = cleanID($id); 817 if(auth_quickaclcheck($id) < AUTH_EDIT || checklock($id)){ 818 $lockfail[] = $id; 819 }else{ 820 lock($id); 821 $locked[] = $id; 822 } 823 } 824 825 foreach((array) $set['unlock'] as $id){ 826 $id = cleanID($id); 827 if(auth_quickaclcheck($id) < AUTH_EDIT || !unlock($id)){ 828 $unlockfail[] = $id; 829 }else{ 830 $unlocked[] = $id; 831 } 832 } 833 834 return array( 835 'locked' => $locked, 836 'lockfail' => $lockfail, 837 'unlocked' => $unlocked, 838 'unlockfail' => $unlockfail, 839 ); 840 } 841 842 function getAPIVersion(){ 843 return DOKU_XMLRPC_API_VERSION; 844 } 845 846 function login($user,$pass){ 847 global $conf; 848 global $auth; 849 if(!$conf['useacl']) return 0; 850 if(!$auth) return 0; 851 852 @session_start(); // reopen session for login 853 if($auth->canDo('external')){ 854 $ok = $auth->trustExternal($user,$pass,false); 855 }else{ 856 $evdata = array( 857 'user' => $user, 858 'password' => $pass, 859 'sticky' => false, 860 'silent' => true, 861 ); 862 $ok = trigger_event('AUTH_LOGIN_CHECK', $evdata, 'auth_login_wrapper'); 863 } 864 session_write_close(); // we're done with the session 865 866 return $ok; 867 } 868 869 870} 871 872$server = new dokuwiki_xmlrpc_server(); 873 874// vim:ts=4:sw=4:et: 875