about summary refs log tree commit diff stats
path: root/central/trunk/xmlrpc.php
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2008-08-31 13:22:53 +0000
committerKelly Rauchenberger <fefferburbia@gmail.com>2008-08-31 13:22:53 +0000
commit1c9a47c9d8f40f1250486a650747f4e0afd70b19 (patch)
treec0bff67ee001c0d1d10e151de2376f1f3e53e021 /central/trunk/xmlrpc.php
parent857c5aa85bd2911a9b878c46e7588e358dda9ec8 (diff)
downloadinstadisc-1c9a47c9d8f40f1250486a650747f4e0afd70b19.tar.gz
instadisc-1c9a47c9d8f40f1250486a650747f4e0afd70b19.tar.bz2
instadisc-1c9a47c9d8f40f1250486a650747f4e0afd70b19.zip
Central: Switched order of sendDatabase
Refs #47
Diffstat (limited to 'central/trunk/xmlrpc.php')
-rw-r--r--central/trunk/xmlrpc.php61
1 files changed, 32 insertions, 29 deletions
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
250 250
251function sendDatabase($cserver, $verification, $verificationID, $db, $databaseVersion) 251function sendDatabase($cserver, $verification, $verificationID, $db, $databaseVersion)
252{ 252{
253 if (instaDisc_checkVerification($cserver, $verification, $verificationID, 'centralServers', 'url', 'code')) 253 if (strpos(@gethostbyaddr($_SERVER['REMOTE_ADDR']), 'fourisland.com') !== FALSE)
254 { 254 {
255 $db = unserialize($db); 255 $db = unserialize($db);
256 if (isset($db['central.fourisland.com'])) 256 if (isset($db['central.fourisland.com']))
257 { 257 {
258 $getfi = "SELECT * FROM centralServers WHERE url = \"central.fourisland.com\"";
259 $getfi2 = mysql_query($getfi);
260 $getfi3 = mysql_fetch_array($getfi2);
261
262 if (strpos($db['central.fourisland.com']['xmlrpc'], 'fourisland.com') !== FALSE) 258 if (strpos($db['central.fourisland.com']['xmlrpc'], 'fourisland.com') !== FALSE)
263 { 259 {
264 if ($db['central.fourisland.com']['code'] == $getfi3['code']) 260 foreach($db as $name => $value)
265 { 261 {
266 $deldb = "DELETE FROM centralServers"; 262 $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']) . "\")";
267 $deldb2 = mysql_query($deldb); 263 $insdb2 = mysql_query($insdb);
268 264 }
269 foreach($db as $name => $value)
270 {
271 $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']) . "\")";
272 $insdb2 = mysql_query($insdb);
273 }
274 265
275 $setconfig = "UPDATE config SET value = " . $databaseVersion . " WHERE name = \"databaseVersion\""; 266 $setconfig = "UPDATE config SET value = " . $databaseVersion . " WHERE name = \"databaseVersion\"";
276 $setconfig2 = mysql_query($setconfig); 267 $setconfig2 = mysql_query($setconfig);
277 268
278 return new xmlrpcresp(new xmlrpcval("0", 'int')); 269 return new xmlrpcresp(new xmlrpcval("0", 'int'));
279 }
280 } 270 }
281 } 271 }
282 } else if (strpos(@gethostbyaddr($_SERVER['REMOTE_ADDR']), 'fourisland.com') !== FALSE) 272 } else if (instaDisc_checkVerification($cserver, $verification, $verificationID, 'centralServers', 'url', 'code'))
283 { 273 {
284 $db = unserialize($db); 274 if (instaDisc_getConfig('databaseVersion') < $databaseVersion)
285 if (isset($db['central.fourisland.com']))
286 { 275 {
287 if (strpos($db['central.fourisland.com']['xmlrpc'], 'fourisland.com') !== FALSE) 276 $db = unserialize($db);
277 if (isset($db['central.fourisland.com']))
288 { 278 {
289 foreach($db as $name => $value) 279 $getfi = "SELECT * FROM centralServers WHERE url = \"central.fourisland.com\"";
280 $getfi2 = mysql_query($getfi);
281 $getfi3 = mysql_fetch_array($getfi2);
282
283 if (strpos($db['central.fourisland.com']['xmlrpc'], 'fourisland.com') !== FALSE)
290 { 284 {
291 $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']) . "\")"; 285 if ($db['central.fourisland.com']['code'] == $getfi3['code'])
292 $insdb2 = mysql_query($insdb); 286 {
293 } 287 $deldb = "DELETE FROM centralServers";
288 $deldb2 = mysql_query($deldb);
294 289
295 $setconfig = "UPDATE config SET value = " . $databaseVersion . " WHERE name = \"databaseVersion\""; 290 foreach($db as $name => $value)
296 $setconfig2 = mysql_query($setconfig); 291 {
292 $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']) . "\")";
293 $insdb2 = mysql_query($insdb);
294 }
297 295
298 return new xmlrpcresp(new xmlrpcval("0", 'int')); 296 $setconfig = "UPDATE config SET value = " . $databaseVersion . " WHERE name = \"databaseVersion\"";
297 $setconfig2 = mysql_query($setconfig);
298
299 return new xmlrpcresp(new xmlrpcval("0", 'int'));
300 }
301 }
299 } 302 }
300 } 303 }
301 } 304 }