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-09-06 22:36:16 +0000
committerKelly Rauchenberger <fefferburbia@gmail.com>2008-09-06 22:36:16 +0000
commit4419c4c44b18eda0d3a04af882e50be069fee49d (patch)
treea5a2b11fb0c81762740c4750e4cc4071ee817e6d /central/trunk/xmlrpc.php
parent2c33a04e24aefdb75d35841f976875c693893973 (diff)
downloadinstadisc-4419c4c44b18eda0d3a04af882e50be069fee49d.tar.gz
instadisc-4419c4c44b18eda0d3a04af882e50be069fee49d.tar.bz2
instadisc-4419c4c44b18eda0d3a04af882e50be069fee49d.zip
Central: Removed idea of multiple central servers
Refs #52
Diffstat (limited to 'central/trunk/xmlrpc.php')
-rw-r--r--central/trunk/xmlrpc.php202
1 files changed, 10 insertions, 192 deletions
diff --git a/central/trunk/xmlrpc.php b/central/trunk/xmlrpc.php index 48f1e5e..419cea4 100644 --- a/central/trunk/xmlrpc.php +++ b/central/trunk/xmlrpc.php
@@ -77,136 +77,19 @@ function requestRetained($username, $verification, $verificationID)
77 77
78function sendFromUpdate($username, $verification, $verificationID, $subscriptionSeriesURL, $subscriptionID, $title, $author, $url, $semantics, $encryptionID) 78function sendFromUpdate($username, $verification, $verificationID, $subscriptionSeriesURL, $subscriptionID, $title, $author, $url, $semantics, $encryptionID)
79{ 79{
80 if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password')) 80 $subscriptionURL = instaDisc_resolveSubscription($subscriptionSeriesURL, $subscriptionID);
81 { 81 if ($subscriptionURL != 'false')
82 if (instaDisc_resolveSubscription($subscriptionSeriesURL, $subscriptionID) != 'false')
83 {
84 $cserver = $_SERVER['SERVER_NAME'];
85 $getuk = "SELECT * FROM centralServers WHERE url = \"" . mysql_real_escape_string($cserver) . "\"";
86 $getuk2 = mysql_query($getuk);
87 $getuk3 = mysql_fetch_array($getuk2);
88
89 $getcs = "SELECT * FROM centralServers";
90 $getcs2 = mysql_query($getcs);
91 $i=0;
92 while ($getcs3[$i] = mysql_fetch_array($getcs2))
93 {
94 $verID = rand(1,2147483647);
95
96 $client = new xmlrpc_client($getcs3[$i]['xmlrpc']);
97 $msg = new xmlrpcmsg("InstaDisc.sendFromCentral", array( new xmlrpcval($cserver, 'string'),
98 new xmlrpcval(md5($cserver . ":" . $getuk3['code'] . ":" . $verID), 'string'),
99 new xmlrpcval($verID, 'int'),
100 new xmlrpcval($subscriptionSeriesURL, 'string'),
101 new xmlrpcval($subscriptionID, 'string'),
102 new xmlrpcval($title, 'string'),
103 new xmlrpcval($author, 'string'),
104 new xmlrpcval($url, 'string'),
105 new xmlrpcval($semantics, 'string'),
106 new xmlrpcval($encryptionID, 'int'),
107 new xmlrpcval(instaDisc_getConfig('softwareVersion'), 'int'),
108 new xmlrpcval(instaDisc_getConfig('databaseVersion'), 'int')));
109 $client->send($msg);
110 $i++;
111 }
112
113 return new xmlrpcresp(new xmlrpcval(0, "int"));
114 }
115 } else {
116 return new xmlrpcresp(new xmlrpcval(2, "int"));
117 }
118
119 return new xmlrpcresp(new xmlrpcval(1, "int"));
120}
121
122function sendFromCentral($cserver, $verification, $verificationID, $subscriptionSeriesURL, $subscriptionID, $title, $author, $url, $semantics, $encryptionID, $softwareVersion, $databaseVersion)
123{
124 if (instaDisc_checkVerification($cserver, $verification, $verificationID, 'centralServers', 'url', 'code'))
125 { 82 {
126 if ($softwareVersion > instaDisc_getConfig('softwareVersion')) 83 $getsed = "SELECT * FROM subscriptions WHERE url = \"" . mysql_real_escape_string($subscriptionSeriesURL) . "\" AND identity = \"" . mysql_real_escape_string($subscriptionID) . "\"";
127 { 84 $getsed2 = mysql_query($getsed);
128 instaDisc_sendUpdateNotice($softwareVersion); 85 $i=0;
129 } else if ($softwareVersion < instaDisc_getConfig('softwareVersion')) 86 while ($getsed3[$i] = mysql_fetch_array($getsed2))
130 {
131 $cserver2 = $_SERVER['SERVER_NAME'];
132 $getuk = "SELECT * FROM centralServers WHERE url = \"" . mysql_real_escape_string($cserver2) . "\"";
133 $getuk2 = mysql_query($getuk);
134 $getuk3 = mysql_fetch_array($getuk2);
135
136 $verID = rand(1,2147483647);
137
138 $client = new xmlrpc_client($cserver);
139 $msg = new xmlrpcmsg("InstaDisc.sendUpdateNotice", array( new xmlrpcval($cserver2, 'string'),
140 new xmlrpcval(md5($cserver2 . ':' . $getuk3['code'] . ':' . $verID), 'string'),
141 new xmlrpcval($verID, 'int'),
142 new xmlrpcval(instaDisc_getConfig('softwareVersion'), 'int')));
143 $client->send($msg);
144 }
145
146 if ($databaseVersion > instaDisc_getConfig('databaseVersion'))
147 {
148 $cserver2 = $_SERVER['SERVER_NAME'];
149 $getuk = "SELECT * FROM centralServers WHERE url = \"" . mysql_real_escape_string($cserver2) . "\"";
150 $getuk2 = mysql_query($getuk);
151 $getuk3 = mysql_fetch_array($getuk2);
152
153 $verID = rand(1,2147483647);
154
155 $client = new xmlrpc_client($cserver);
156 $msg = new xmlrpcmsg("InstaDisc.askForDatabase", array( new xmlrpcval($cserver2, 'string'),
157 new xmlrpcval(md5($cserver2 . ':' . $getuk3['code'] . ':' . $verID), 'string'),
158 new xmlrpcval($verID, 'int'),
159 new xmlrpcval(instaDisc_getConfig('databaseVersion'), 'int')));
160 $client->send($msg);
161 } else if ($databaseVersion < instaDisc_getConfig('databaseVersion'))
162 {
163 instaDisc_sendDatabase($cserver);
164 }
165
166 $subscriptionURL = instaDisc_resolveSubscription($subscriptionSeriesURL, $subscriptionID);
167 if ($subscriptionURL != 'false')
168 {
169 $getsed = "SELECT * FROM subscriptions WHERE url = \"" . mysql_real_escape_string($subscriptionSeriesURL) . "\" AND identity = \"" . mysql_real_escape_string($subscriptionID) . "\"";
170 $getsed2 = mysql_query($getsed);
171 $i=0;
172 while ($getsed3[$i] = mysql_fetch_array($getsed2))
173 {
174 instaDisc_addItem($getsed3[$i]['username'], $subscriptionURL, $title, $author, $url, $semantics, $encryptionID);
175 $i++;
176 }
177
178 return new xmlrpcresp(new xmlrpcval(0, "int"));
179 }
180 }
181
182 return new xmlrpcresp(new xmlrpcval(1, "int"));
183}
184
185function sendUpdateNotice($cserver, $verification, $verificationID, $softwareVersion)
186{
187 if (instaDisc_checkVerification($cserver, $verification, $verificationID, 'centralServers', 'url', 'code'))
188 {
189 if ($softwareVersion > instaDisc_getConfig('softwareVersion'))
190 { 87 {
191 instaDisc_sendUpdateNotice($softwareVersion); 88 instaDisc_addItem($getsed3[$i]['username'], $subscriptionURL, $title, $author, $url, $semantics, $encryptionID);
192 89 $i++;
193 return new xmlrpcresp(new xmlrpcval(0, "int"));
194 } 90 }
195 }
196
197 return new xmlrpcresp(new xmlrpcval(1, "int"));
198}
199
200function askForDatabase($cserver, $verification, $verificationID, $databaseVersion)
201{
202 if (instaDisc_checkVerification($cserver, $verification, $verificationID, 'centralServers', 'url', 'code'))
203 {
204 if ($databaseVersion < instaDisc_getConfig('databaseVersion'))
205 {
206 instaDisc_sendDatabase($cserver);
207 91
208 return new xmlrpcresp(new xmlrpcval(0, "int")); 92 return new xmlrpcresp(new xmlrpcval(0, "int"));
209 }
210 } 93 }
211 94
212 return new xmlrpcresp(new xmlrpcval(1, "int")); 95 return new xmlrpcresp(new xmlrpcval(1, "int"));
@@ -250,78 +133,13 @@ function addSubscription($username, $verification, $verificationID, $subscriptio
250 return new xmlrpcresp(new xmlrpcval(1, "int")); 133 return new xmlrpcresp(new xmlrpcval(1, "int"));
251} 134}
252 135
253function sendDatabase($cserver, $verification, $verificationID, $db, $databaseVersion)
254{
255 if (preg_match('/^(.*\.)?fourisland\.com$/', @gethostbyaddr($_SERVER['REMOTE_ADDR'])))
256 {
257 $db = unserialize($db);
258 if (isset($db['central.fourisland.com']))
259 {
260 if (strpos($db['central.fourisland.com']['xmlrpc'], 'fourisland.com') !== FALSE)
261 {
262 $deldb = "DELETE FROM centralServers";
263 $deldb2 = mysql_query($deldb);
264
265 foreach($db as $name => $value)
266 {
267 $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']) . "\")";
268 $insdb2 = mysql_query($insdb);
269 }
270
271 $setconfig = "UPDATE config SET value = " . $databaseVersion . " WHERE name = \"databaseVersion\"";
272 $setconfig2 = mysql_query($setconfig);
273
274 return new xmlrpcresp(new xmlrpcval("0", 'int'));
275 }
276 }
277 } else if (instaDisc_checkVerification($cserver, $verification, $verificationID, 'centralServers', 'url', 'code'))
278 {
279 if (instaDisc_getConfig('databaseVersion') < $databaseVersion)
280 {
281 $db = unserialize($db);
282 if (isset($db['central.fourisland.com']))
283 {
284 $getfi = "SELECT * FROM centralServers WHERE url = \"central.fourisland.com\"";
285 $getfi2 = mysql_query($getfi);
286 $getfi3 = mysql_fetch_array($getfi2);
287
288 if (strpos($db['central.fourisland.com']['xmlrpc'], 'fourisland.com') !== FALSE)
289 {
290 if ($db['central.fourisland.com']['code'] == $getfi3['code'])
291 {
292 $deldb = "DELETE FROM centralServers";
293 $deldb2 = mysql_query($deldb);
294
295 foreach($db as $name => $value)
296 {
297 $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']) . "\")";
298 $insdb2 = mysql_query($insdb);
299 }
300
301 $setconfig = "UPDATE config SET value = " . $databaseVersion . " WHERE name = \"databaseVersion\"";
302 $setconfig2 = mysql_query($setconfig);
303
304 return new xmlrpcresp(new xmlrpcval("0", 'int'));
305 }
306 }
307 }
308 }
309 }
310
311 return new xmlrpcresp(new xmlrpcval(1, "int"));
312}
313
314$s = new xmlrpc_server( array( "InstaDisc.checkRegistration" => array("function" => "checkRegistration"), 136$s = new xmlrpc_server( array( "InstaDisc.checkRegistration" => array("function" => "checkRegistration"),
315 "InstaDisc.deleteItem" => array("function" => "deleteItem"), 137 "InstaDisc.deleteItem" => array("function" => "deleteItem"),
316 "InstaDisc.resendItem" => array("function" => "resendItem"), 138 "InstaDisc.resendItem" => array("function" => "resendItem"),
317 "InstaDisc.requestRetained" => array("function" => "requestRetained"), 139 "InstaDisc.requestRetained" => array("function" => "requestRetained"),
318 "InstaDisc.sendFromUpdate" => array("function" => "sendFromUpdate"), 140 "InstaDisc.sendFromUpdate" => array("function" => "sendFromUpdate"),
319 "InstaDisc.sendFromCentral" => array("function" => "sendFromCentral"),
320 "InstaDisc.sendUpdateNotice" => array("function" => "sendUpdateNotice"),
321 "InstaDisc.askForDatabase" => array("function" => "askForDatabase"),
322 "InstaDisc.deleteSubscription" => array("function" => "deleteSubscription"), 141 "InstaDisc.deleteSubscription" => array("function" => "deleteSubscription"),
323 "InstaDisc.addSubscription" => array("function" => "addSubscription"), 142 "InstaDisc.addSubscription" => array("function" => "addSubscription")
324 "InstaDisc.sendDatabase" => array("function" => "sendDatabase")
325 ),0); 143 ),0);
326$s->functions_parameters_type = 'phpvals'; 144$s->functions_parameters_type = 'phpvals';
327$s->service(); 145$s->service();