3 Provides syncing (or simply transfering) pages with a remote Wiki
4 installation, via special RPCs or open Wiki XML-RPC interface - in
9 define("WIKISYNC_VER", 0.1);
10 #$_SERVER["SERVER_NAME"] .= " {.-prevents-readonly-test-account}";
11 include("t_config.php");
12 if (!function_exists("xmlrpc")) include("plugins/lib/xmlrpc.php");
13 if (!function_exists("phprpc")) include("plugins/lib/phprpc.php");
14 if (!function_exists("ewiki_sync_local")) include("plugins/lib/sync.php");
16 #-- serve XML-RPC and PHP-RPC requests
17 header("X-WikiSync: " . WIKISYNC_VER);
18 $ewiki_config["ua"] .= " WikiSync/".WIKISYNC_VER;
19 if ($_SERVER["REQUEST_METHOD"] != "GET") {
23 "ewiki_db" => "ewiki_db",
24 "ewiki.sync" => "ewiki_sync_local",
28 die("Request Missed.");
32 $action = $_REQUEST["action"];
33 $proto = $_REQUEST["proto"];
34 $url = $_REQUEST["url"];
35 if ($url) { // save as preference
36 setcookie("last_sync_url", $url, time() + 90*24*60*60, dirname($_SERVER["REQUEST_URI"]));
42 <title>syncing with remote wiki database</title>
43 <link rel="stylesheet" type="text/css" href="t_config.css">
45 <body bgcolor="#ffffff" text="#000000">
46 <h1>WikiSync™</h1>
50 // error_reporting(E_ALL);
51 if (!action || !$proto || !$url) {
54 This tool allows you to maintain some pages of a public Wiki in a separate
55 installation but keep both synchronized. You of course must have the sync
56 interface installed on both systems (or at least have the XML-RPC service
57 enabled on the other site).
62 There is currently no conflict resolution code built-in, so you have to
63 correct these yourself, whenever you edited a page that also was edited
64 (by someone else) on the remote WikiWikiWeb server. So this is very safe
65 as it never overwrites stuff, and quick as it typically only copies the
66 latest version of every page.
71 <form action="t_sync.php" method="GET">
72 <label for="proto">protocol</label>
73 <select id="proto" name="proto">
74 <option value="sync">WikiSync™ <?php echo WIKISYNC_VER; ?></option>
75 <option value="db">ewiki_db::RPC</option>
76 <option value="wiki">WikiXmlRpc v2</option>
79 <label for="url">interface</label>
80 <input type="text" name="url" id="url" size="48" value="<?php
81 if ($url = $_COOKIE["last_sync_url"]) {
85 echo "http://user:password@" . strtok($_SERVER["SERVER_NAME"], " ") . $_SERVER["REQUEST_URI"];
90 Must be either the URL to a remote <tt>z.php</tt> script or better
91 to a remote <tt>t_sync.php</tt>.
95 <select id="action" name="action" title="action">
96 <option value="sync">sync</option>
97 <option value="up">upload</option>
98 <option value="down">download</option>
99 <option value="exact">exact</option>
102 <input type="submit" value="transfer">
110 #-- minimal checks beforehand ------------------------------------------
111 elseif ($proto != "sync") {
113 echo "Sorry, currently only the WikiSync™ protocol is supported.";
117 #-- get list of (remotely) existing page versions
118 elseif (! ($ls_remote = ewiki_sync_remote("::LIST")) ) {
120 echo "No '$proto'-connection to '$url' could be established.";
125 #-- perform sync -------------------------------------------------------
129 set_time_limit(+2999);
130 $ls_local = ewiki_sync_local("::LIST", false);
131 $sync = ($action=="sync");
135 echo "<i>info</i>: " . count($locall) . " pages found in local Wiki database<br>\n";
136 echo " and " . count($rlist) . " are on remote server<br>\n";
142 if (in_array($action, array("upload", "sync", "exact"))) {
143 echo "<br>\n<h3>upload</h3>\n";
146 $ls_local, $ls_remote,
147 "ewiki_sync_local", "ewiki_sync_remote"
152 if (in_array($action, array("download", "sync", "exact"))) {
153 echo "<br>\n<h3>download</h3>\n";
156 $ls_remote, $ls_local,
157 "ewiki_sync_remote", "ewiki_sync_local"
161 #-- do an in-deepth analyzation of remaining files
162 if ($action == "exact") {
163 echo "<br>\n<h3>sync - exact comparison</h3>\n";
164 foreach ($ls_local as $id=>$ver) {
165 if ($ls_remote[$id] == $ver) {
167 echo htmlentities($id);
170 $L = ewiki_sync_local("::GET", array($id));
171 $R = ewiki_sync_remote("::GET", array($id));
173 if (!ewiki_sync_half_identical($L, $R)) {