From 9c6d7136a17628ad1e087da138ef27c32ba251f9 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Thu, 7 Aug 2008 19:31:15 +0000 Subject: Central: Fixed a few errors --- central/trunk/instadisc.php | 3 ++- central/trunk/xmlrpc.php | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) (limited to 'central') diff --git a/central/trunk/instadisc.php b/central/trunk/instadisc.php index 826a830..c671316 100644 --- a/central/trunk/instadisc.php +++ b/central/trunk/instadisc.php @@ -127,7 +127,8 @@ function instaDisc_sendDatabase($cserver) $msg = new xmlrpcmsg("InstaDisc.sendDatabase", array( new xmlrpcval($cserver2, 'string'), new xmlrpcval(md5($cserver2 . ":" . $getuk3['code'] . ":" . $verID), 'string'), new xmlrpcval($verID, 'int'), - new xmlrpcval($db, 'array'))); + new xmlrpcval(serialize($db), 'string'), + new xmlrpcval(instaDisc_getConfig('databaseVersion'), 'string'))); $client->send($msg); } diff --git a/central/trunk/xmlrpc.php b/central/trunk/xmlrpc.php index 18aa6cb..c638401 100644 --- a/central/trunk/xmlrpc.php +++ b/central/trunk/xmlrpc.php @@ -231,19 +231,26 @@ function addSubscription($username, $verification, $verificationID, $subscriptio { if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password')) { - $inssub = "INSERT INTO subscriptions (url, username, owner) VALUES (\"" . mysql_real_escape_string($subscription) . "\", \"" . mysql_real_escape_string($username) . "\", \"false\")"; - $inssub2 = mysql_query($inssub); + $getsub = "SELECT * FROM subscriptions WHERE url = \"" . mysql_real_escape_string($subscription) . "\" AND username = \"" . mysql_real_escape_string($username) . "\" AND owner = \"false\""; + $getsub2 = mysql_query($getsub); + $getsub3 = mysql_fetch_array($getsub2); + if ($getsub3['url'] == $subscription) + { + $inssub = "INSERT INTO subscriptions (url, username, owner) VALUES (\"" . mysql_real_escape_string($subscription) . "\", \"" . mysql_real_escape_string($username) . "\", \"false\")"; + $inssub2 = mysql_query($inssub); - return new xmlrpcresp(new xmlrpcval(0, "int")); + return new xmlrpcresp(new xmlrpcval(0, "int")); + } } return new xmlrpcresp(new xmlrpcval(1, "int")); } -function sendDatabase($cserver, $verification, $verificationID, $db) +function sendDatabase($cserver, $verification, $verificationID, $db, $databaseVersion) { if (instaDisc_checkVerification($cserver, $verification, $verificationID, 'centralServers', 'url', 'code')) { + $db = unserialize($db); if (isset($db['central.fourisland.com'])) { $getfi = "SELECT * FROM centralServers WHERE url = \"central.fourisland.com\""; @@ -261,6 +268,9 @@ function sendDatabase($cserver, $verification, $verificationID, $db) $insdb2 = mysql_query($insdb); } + $setconfig = "UPDATE config SET value = " . $databaseVersion . " WHERE name = \"databaseVersion\""; + $setconfig2 = mysql_query($setconfig); + return new xmlrpcresp(new xmlrpcval("0", 'int')); } } -- cgit 1.4.1