e0f3b4ad09cc1fbef4010fa0446f613451718909
[atutor.git] / mods / wiki / plugins / db / rpc.php
1 <?php
2 /*
3    Remote ewiki databases can be accessed using the PHP-RPC protocol
4    (more lightweight and magnitudes faster than XML-RPC). But you must
5    first create an interface on the remote server:
6    
7       <?php
8          include("config.php");
9          include("plugins/lib/phprpc.php");
10          $passwords = array("accessname" => "password");
11          include("fragments/funcs/auth.php");
12          // define("EWIKI_DB_LOCK", 0);
13          phprpc_server(array("ewiki_db"));
14       ?>
15
16    Give this a name of "z-db.php" or so, and give its absolute URL in
17    the EWIKI_DB_RPC constant here. You must load plugins/lib/phprpc.php
18    of course.
19 */
20
21 define("EWIKI_DB_RPC", "http://name:pw@rpc.example.com/ewiki/z-db.php");
22
23
24 class ewiki_database_rpc {
25
26    function ewiki_ddatabase_rpc($url=EWIKI_DB_RPC) {
27       $this->api = $url;
28    }
29    
30
31    function GET($id, $version) {
32       return phprpc($this->url, "ewiki_db::GET", array($id, $version));
33    }
34
35    function WRITE($hash, $overwrite) {
36       return phprpc($this->url, "ewiki_db::WRITE", array($hash, $overwrite));
37    }
38
39    function HIT($id) {
40       // stub
41    }
42
43    function FIND($list) {
44       return phprpc($this->url, "ewiki_db::FIND", array($list));
45    }
46
47    function GETALL($fields, $msk, $filt) {
48       return phprpc($this->url, "ewiki_db::GETALL", array($fields, $msk, $filt));
49    }
50
51    function SEARCH($field, $content, $ci, $regex, $mask, $filter) {
52       return phprpc($this->url, "ewiki_db::SEARCH", array($field, $content, $ci, $regex, $mask, $filter));
53    }
54
55    function DELETE($id, $version) {
56       return phprpc($this->url, "ewiki_db::DELETE", array($id, $version));
57    }
58
59    function INIT() {
60       return phprpc($this->url, "ewiki_db::INIT", array());
61    }
62
63 }
64
65
66 ?>