diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2008-08-01 19:05:03 +0000 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2008-08-01 19:05:03 +0000 |
commit | 1f3ccdbb990204d5238c78f0990496011ccb9902 (patch) | |
tree | 8a21f2838d82300ebdae61afdd2fabdabc119962 /central | |
parent | edc9d436c4e4f9fa3cb00256652190359a4ddc20 (diff) | |
download | instadisc-1f3ccdbb990204d5238c78f0990496011ccb9902.tar.gz instadisc-1f3ccdbb990204d5238c78f0990496011ccb9902.tar.bz2 instadisc-1f3ccdbb990204d5238c78f0990496011ccb9902.zip |
Central: Added sendDatabase functions
Completed the instaDisc_sendDatabase() library function and the InstaDisc.sendDatabase() XML-RPC function.
Diffstat (limited to 'central')
-rw-r--r-- | central/trunk/instadisc.php | 22 | ||||
-rw-r--r-- | central/trunk/xmlrpc.php | 36 |
2 files changed, 55 insertions, 3 deletions
diff --git a/central/trunk/instadisc.php b/central/trunk/instadisc.php index d32d2d7..9920e51 100644 --- a/central/trunk/instadisc.php +++ b/central/trunk/instadisc.php | |||
@@ -37,6 +37,28 @@ function instaDisc_sendUpdateNotice($softwareVersion) | |||
37 | 37 | ||
38 | function instaDisc_sendDatabase($cserver) | 38 | function instaDisc_sendDatabase($cserver) |
39 | { | 39 | { |
40 | $getdb = "SELECT * FROM centralServers"; | ||
41 | $getdb2 = mysql_query($getdb); | ||
42 | $i=0; | ||
43 | while ($getdb3[$i] = mysql_fetch_array($getdb2)) | ||
44 | { | ||
45 | $db[$getdb3[$i]['url']] = $getdb3[$i]['key']; | ||
46 | $i++; | ||
47 | } | ||
48 | |||
49 | $cserver2 = $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; | ||
50 | $getuk = "SELECT * FROM centralServers WHERE url = \"" . mysql_escape_string($cserver2) . "\""; | ||
51 | $getuk2 = mysql_query($getuk); | ||
52 | $getuk3 = mysql_fetch_array($getuk2); | ||
53 | |||
54 | $verID = rand(1,65536); | ||
55 | |||
56 | $client = new xmlrpc_client($cserver); | ||
57 | $msg = new xmlrpcmsg("InstaDisc.sendDatabase", array( new xmlrpcval($cserver2, 'string'), | ||
58 | new xmlrpcval(md5($cserver2 + ":" + $getuk3['key'] + ":" + $verID), 'string'), | ||
59 | new xmlrpcval($verID, 'int'), | ||
60 | new xmlrpcval($db, 'array'))); | ||
61 | $client->send($msg); | ||
40 | } | 62 | } |
41 | 63 | ||
42 | function instaDisc_addItem($username, $subscription, $title, $author, $url, $semantics) | 64 | function instaDisc_addItem($username, $subscription, $title, $author, $url, $semantics) |
diff --git a/central/trunk/xmlrpc.php b/central/trunk/xmlrpc.php index 68ff92d..c10002a 100644 --- a/central/trunk/xmlrpc.php +++ b/central/trunk/xmlrpc.php | |||
@@ -26,7 +26,7 @@ function deleteItem($username, $verification, $verificationID, $id) | |||
26 | $getitem3 = mysql_fetch_array($getitem2); | 26 | $getitem3 = mysql_fetch_array($getitem2); |
27 | if ($getitem3['id'] == $id) | 27 | if ($getitem3['id'] == $id) |
28 | { | 28 | { |
29 | $delitem = "DELETE inbox WHERE username = \"" . mysql_escape_string($username) . "\" AND itemID = " . $id; | 29 | $delitem = "DELETE FROM inbox WHERE username = \"" . mysql_escape_string($username) . "\" AND itemID = " . $id; |
30 | $delitem2 = mysql_query($delitem); | 30 | $delitem2 = mysql_query($delitem); |
31 | 31 | ||
32 | return new xmlrpcresp(new xmlrpcval(0, "int")); | 32 | return new xmlrpcresp(new xmlrpcval(0, "int")); |
@@ -195,7 +195,7 @@ function deleteSubscription($username, $verification, $verificationID, $subscrip | |||
195 | $getsub3 = mysql_fetch_array($getsub2); | 195 | $getsub3 = mysql_fetch_array($getsub2); |
196 | if ($getsub3['url'] == $subscription) | 196 | if ($getsub3['url'] == $subscription) |
197 | { | 197 | { |
198 | $delsub = "DELETE subscriptions WHERE url = \"" . mysql_escape_string($subscription) . "\" AND username = \"" . mysql_escape_string($username . "\" AND owner = \"false\""; | 198 | $delsub = "DELETE FROM subscriptions WHERE url = \"" . mysql_escape_string($subscription) . "\" AND username = \"" . mysql_escape_string($username) . "\" AND owner = \"false\""; |
199 | $delsub2 = mysql_query($delsub); | 199 | $delsub2 = mysql_query($delsub); |
200 | 200 | ||
201 | return new xmlrpcresp(new xmlrpcval(0, "int")); | 201 | return new xmlrpcresp(new xmlrpcval(0, "int")); |
@@ -218,6 +218,35 @@ function addSubscription($username, $verification, $verificationID, $subscriptio | |||
218 | return new xmlrpcresp(new xmlrpcval(1, "int")); | 218 | return new xmlrpcresp(new xmlrpcval(1, "int")); |
219 | } | 219 | } |
220 | 220 | ||
221 | function sendDatabase($cserver, $verification, $verificationID, $db) | ||
222 | { | ||
223 | if (instaDisc_checkVerification($cserver, $verification, $verificationID, 'centralServers', 'url', 'key')) | ||
224 | { | ||
225 | if (isset($db['central.fourisland.com'])) | ||
226 | { | ||
227 | $getfi = "SELECT * FROM centralServers WHERE url = \"central.fourisland.com\""; | ||
228 | $getfi2 = mysql_query($getfi); | ||
229 | $getfi3 = mysql_fetch_array($getfi2); | ||
230 | |||
231 | if ($db['central.fourisland.com'] == $getfi3['key']) | ||
232 | { | ||
233 | $deldb = "TRUNCATE TABLE centralServers"; | ||
234 | $deldb2 = mysql_query($deldb); | ||
235 | |||
236 | foreach($db as $name => $value) | ||
237 | { | ||
238 | $insdb = "INSERT INTO centralServers (url, key) VALUES (\"" . mysql_escape_string($name) . "\", \"" . mysql_escape_string($value) . "\")"; | ||
239 | $insdb2 = mysql_query($insdb); | ||
240 | } | ||
241 | |||
242 | return new xmlrpcresp(new xmlrpcval("0", 'int')); | ||
243 | } | ||
244 | } | ||
245 | } | ||
246 | |||
247 | return new xmlrpcresp(new xmlrpcval(1, "int")); | ||
248 | } | ||
249 | |||
221 | $s = new xmlrpc_server( array( "InstaDisc.checkRegistration" => array("function" => "checkRegistration"), | 250 | $s = new xmlrpc_server( array( "InstaDisc.checkRegistration" => array("function" => "checkRegistration"), |
222 | "InstaDisc.deleteItem" => array("function" => "deleteItem"), | 251 | "InstaDisc.deleteItem" => array("function" => "deleteItem"), |
223 | "InstaDisc.resendItem" => array("function" => "resendItem"), | 252 | "InstaDisc.resendItem" => array("function" => "resendItem"), |
@@ -227,7 +256,8 @@ $s = new xmlrpc_server( array( "InstaDisc.checkRegistration" => array("function" | |||
227 | "InstaDisc.sendUpdateNotice" => array("function" => "sendUpdateNotice"), | 256 | "InstaDisc.sendUpdateNotice" => array("function" => "sendUpdateNotice"), |
228 | "InstaDisc.askForDatabase" => array("function" => "askForDatabase"), | 257 | "InstaDisc.askForDatabase" => array("function" => "askForDatabase"), |
229 | "InstaDisc.deleteSubscription" => array("function" => "deleteSubscription"), | 258 | "InstaDisc.deleteSubscription" => array("function" => "deleteSubscription"), |
230 | "InstaDisc.addSubscription" => array("function" => "addSubscription") | 259 | "InstaDisc.addSubscription" => array("function" => "addSubscription"), |
260 | "InstaDisc.sendDatabase" => array("function" => "sendDatabase") | ||
231 | ),0); | 261 | ),0); |
232 | $s->functions_parameters_type = 'phpvals'; | 262 | $s->functions_parameters_type = 'phpvals'; |
233 | $s->service(); | 263 | $s->service(); |