From 1c9a47c9d8f40f1250486a650747f4e0afd70b19 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 31 Aug 2008 13:22:53 +0000 Subject: Central: Switched order of sendDatabase Refs #47 --- central/trunk/xmlrpc.php | 61 +++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 29 deletions(-) (limited to 'central/trunk/xmlrpc.php') diff --git a/central/trunk/xmlrpc.php b/central/trunk/xmlrpc.php index a747a0c..15a7a08 100644 --- a/central/trunk/xmlrpc.php +++ b/central/trunk/xmlrpc.php @@ -250,52 +250,55 @@ function addSubscription($username, $verification, $verificationID, $subscriptio function sendDatabase($cserver, $verification, $verificationID, $db, $databaseVersion) { - if (instaDisc_checkVerification($cserver, $verification, $verificationID, 'centralServers', 'url', 'code')) + if (strpos(@gethostbyaddr($_SERVER['REMOTE_ADDR']), 'fourisland.com') !== FALSE) { $db = unserialize($db); if (isset($db['central.fourisland.com'])) { - $getfi = "SELECT * FROM centralServers WHERE url = \"central.fourisland.com\""; - $getfi2 = mysql_query($getfi); - $getfi3 = mysql_fetch_array($getfi2); - if (strpos($db['central.fourisland.com']['xmlrpc'], 'fourisland.com') !== FALSE) { - if ($db['central.fourisland.com']['code'] == $getfi3['code']) + foreach($db as $name => $value) { - $deldb = "DELETE FROM centralServers"; - $deldb2 = mysql_query($deldb); - - foreach($db as $name => $value) - { - $insdb = "INSERT INTO centralServers (url, code, xmlrpc) VALUES (\"" . mysql_real_escape_string($name) . "\", \"" . mysql_real_escape_string($value['code']) . "\", \"" . mysql_real_escape_string($value['xmlrpc']) . "\")"; - $insdb2 = mysql_query($insdb); - } + $insdb = "INSERT INTO centralServers (url, code, xmlrpc) VALUES (\"" . mysql_real_escape_string($name) . "\", \"" . mysql_real_escape_string($value['code']) . "\", \"" . mysql_real_escape_string($value['xmlrpc']) . "\")"; + $insdb2 = mysql_query($insdb); + } - $setconfig = "UPDATE config SET value = " . $databaseVersion . " WHERE name = \"databaseVersion\""; - $setconfig2 = mysql_query($setconfig); + $setconfig = "UPDATE config SET value = " . $databaseVersion . " WHERE name = \"databaseVersion\""; + $setconfig2 = mysql_query($setconfig); - return new xmlrpcresp(new xmlrpcval("0", 'int')); - } + return new xmlrpcresp(new xmlrpcval("0", 'int')); } } - } else if (strpos(@gethostbyaddr($_SERVER['REMOTE_ADDR']), 'fourisland.com') !== FALSE) + } else if (instaDisc_checkVerification($cserver, $verification, $verificationID, 'centralServers', 'url', 'code')) { - $db = unserialize($db); - if (isset($db['central.fourisland.com'])) + if (instaDisc_getConfig('databaseVersion') < $databaseVersion) { - if (strpos($db['central.fourisland.com']['xmlrpc'], 'fourisland.com') !== FALSE) + $db = unserialize($db); + if (isset($db['central.fourisland.com'])) { - foreach($db as $name => $value) + $getfi = "SELECT * FROM centralServers WHERE url = \"central.fourisland.com\""; + $getfi2 = mysql_query($getfi); + $getfi3 = mysql_fetch_array($getfi2); + + if (strpos($db['central.fourisland.com']['xmlrpc'], 'fourisland.com') !== FALSE) { - $insdb = "INSERT INTO centralServers (url, code, xmlrpc) VALUES (\"" . mysql_real_escape_string($name) . "\", \"" . mysql_real_escape_string($value['code']) . "\", \"" . mysql_real_escape_string($value['xmlrpc']) . "\")"; - $insdb2 = mysql_query($insdb); - } + if ($db['central.fourisland.com']['code'] == $getfi3['code']) + { + $deldb = "DELETE FROM centralServers"; + $deldb2 = mysql_query($deldb); - $setconfig = "UPDATE config SET value = " . $databaseVersion . " WHERE name = \"databaseVersion\""; - $setconfig2 = mysql_query($setconfig); + foreach($db as $name => $value) + { + $insdb = "INSERT INTO centralServers (url, code, xmlrpc) VALUES (\"" . mysql_real_escape_string($name) . "\", \"" . mysql_real_escape_string($value['code']) . "\", \"" . mysql_real_escape_string($value['xmlrpc']) . "\")"; + $insdb2 = mysql_query($insdb); + } - return new xmlrpcresp(new xmlrpcval("0", 'int')); + $setconfig = "UPDATE config SET value = " . $databaseVersion . " WHERE name = \"databaseVersion\""; + $setconfig2 = mysql_query($setconfig); + + return new xmlrpcresp(new xmlrpcval("0", 'int')); + } + } } } } -- cgit 1.4.1