d83b2a64672aa19303ca2a70c6d9f28e69fef201
[atutor.git] / mods / wiki / z.php
1 <?php
2 /*
3    RemoteProcedureCalls for ewiki
4    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
5    - allows for XmlRpcToWiki (v2)
6    - provides OpenSearch API (v0)
7    - access wrapper for WikiSync (v0.1)
8    - allows WebDAV directory browsing
9    - can be used for ?binary= transfer
10    
11    All write-access features in the individual modules are already
12    restricted by calling "fragments/funcs/auth.php" separately. This
13    whole interface is however disabled for _PROTECTED_MODE setups.
14 */
15
16 #-- load libs and server interface code
17 define("EWIKI_SCRIPT_BINARY", "z.php?binary=");
18 include_once("config.php");
19 include_once("plugins/lib/upgrade.php");
20
21 #-- surpress errors (slightly)
22 include_once("plugins/debug/xerror.php");
23 error_reporting(E_ALL^E_NOTICE);
24
25
26 #-- REQUIRE authentication for now
27 #   (TOO dangerous currently else - no full security review made yet)
28 require("fragments/funcs/auth.php");
29
30
31 #-- interfaces and protocols
32 if (true) {
33   include_once("plugins/lib/wikiapi.php");
34 }
35 if (!function_exists("ewiki_opensearch_api")) {
36   include_once("plugins/lib/opensearch.php");
37 }
38 if (!function_exists("xmlrpc")) {
39   include_once("plugins/lib/xmlrpc.php");
40 }
41 if (!function_exists("phprpc")) {
42   include_once("plugins/lib/phprpc.php");
43 }
44 if (!function_exists("atom_server")) {
45   // include_once("plugins/lib/atom-server.php");
46 }
47 if (!class_exists("wikidav")) {
48   include_once("plugins/lib/xml.php");
49   include_once("plugins/lib/minidav.php");
50   include_once("plugins/lib/webdav.php");
51 }
52
53 #-- prepare *-RPC
54 $xmlrpc_methods = &$wikiapi;
55 $phprpc_methods = &$wikiapi;
56
57 #-- fail for:
58 if (EWIKI_PROTECTED_MODE) {
59    die("The API is disabled, because it doesn't yet respect the _PROTECTED_MODE restrictions.");
60 }
61
62
63 #-- WebDAV
64 if (defined("EWIKI_SCRIPT_WEBDAV") && $_SERVER["PATH_INFO"]) {
65 #error_reporting(E_ALL);
66    $wds = new WikiDav();
67    $wds->ServeRequest();
68    exit;
69 }
70
71
72 #-- what kind of request
73 $rt = strtolower(trim(strtok(@$_SERVER["CONTENT_TYPE"], ",;")));
74 switch ($rt) {
75
76    #-- WikiApi
77    case XMLRPC_MIME_OLD:
78    case XMLRPC_MIME_NEW:
79       xmlrpc_server();
80       exit;
81
82    #-- Atom
83    case "application/atom+xml":
84       // atom_server();
85       header("501 Not Implemented");
86       exit;
87
88    #-- WikiSync or PHP-RPC
89    case "application/vnd.php.serialized":
90       phprpc_server();
91       include("tools/t_sync.php");
92       exit;
93       
94    default:
95 }
96
97 #-- other detection mechanism?
98 //...
99
100
101 #-- else complain
102 header("Content-Type: text/html");
103 header("Status: 401 Method Not Implemented");
104 die('<html><head><link rel="stylesheet" type="text/css" href="tools/t_config.css"></head><body>This is the interface for XML-RPC, OpenSearch, WikiSync, PHP-RPC, <a href="z.php/">WebDAV</a> and Atom requests. Go away already!</body></html>');
105
106 ?>