diff options
-rw-r--r-- | central/trunk/includes/instadisc.php | 40 | ||||
-rw-r--r-- | central/trunk/instadisc.sql | 17 | ||||
-rw-r--r-- | central/trunk/theme/index.tpl | 3 | ||||
-rw-r--r-- | central/trunk/xmlrpc.php | 202 |
4 files changed, 12 insertions, 250 deletions
diff --git a/central/trunk/includes/instadisc.php b/central/trunk/includes/instadisc.php index f35d021..438fcfb 100644 --- a/central/trunk/includes/instadisc.php +++ b/central/trunk/includes/instadisc.php | |||
@@ -97,46 +97,6 @@ function instaDisc_sendItem($username, $id) | |||
97 | } | 97 | } |
98 | } | 98 | } |
99 | 99 | ||
100 | function instaDisc_sendUpdateNotice($softwareVersion) | ||
101 | { | ||
102 | $username = instaDisc_getConfig('owner'); | ||
103 | $subscription = 'http://fourisland.com/' . $_SERVER['SERVER_NAME'] . '/'; | ||
104 | $title = 'Update your software to ' . $software; | ||
105 | $author = 'Hatkirby'; | ||
106 | $url = 'http://fourisland.com/projects/instadisc/wiki/CentralSoftwareUpdate'; | ||
107 | $semantics = array(); | ||
108 | |||
109 | instaDisc_addItem($username, $subscription, $title, $author, $url, $semantics); | ||
110 | } | ||
111 | |||
112 | function instaDisc_sendDatabase($cserver) | ||
113 | { | ||
114 | $getdb = "SELECT * FROM centralServers"; | ||
115 | $getdb2 = mysql_query($getdb); | ||
116 | $i=0; | ||
117 | while ($getdb3[$i] = mysql_fetch_array($getdb2)) | ||
118 | { | ||
119 | $db[$getdb3[$i]['url']]['code'] = $getdb3[$i]['code']; | ||
120 | $db[$getdb3[$i]['url']]['xmlrpc'] = $getdb3[$i]['xmlrpc']; | ||
121 | $i++; | ||
122 | } | ||
123 | |||
124 | $cserver2 = $_SERVER['SERVER_NAME']; | ||
125 | $getuk = "SELECT * FROM centralServers WHERE url = \"" . mysql_real_escape_string($cserver2) . "\""; | ||
126 | $getuk2 = mysql_query($getuk); | ||
127 | $getuk3 = mysql_fetch_array($getuk2); | ||
128 | |||
129 | $verID = rand(1,2147483647); | ||
130 | |||
131 | $client = new xmlrpc_client($cserver); | ||
132 | $msg = new xmlrpcmsg("InstaDisc.sendDatabase", array( new xmlrpcval($cserver2, 'string'), | ||
133 | new xmlrpcval(md5($cserver2 . ":" . $getuk3['code'] . ":" . $verID), 'string'), | ||
134 | new xmlrpcval($verID, 'int'), | ||
135 | new xmlrpcval(serialize($db), 'string'), | ||
136 | new xmlrpcval(instaDisc_getConfig('databaseVersion'), 'string'))); | ||
137 | $client->send($msg); | ||
138 | } | ||
139 | |||
140 | function instaDisc_addItem($username, $subscription, $title, $author, $url, $semantics, $encryptionID = 0) | 100 | function instaDisc_addItem($username, $subscription, $title, $author, $url, $semantics, $encryptionID = 0) |
141 | { | 101 | { |
142 | $getuser = "SELECT * FROM users WHERE username = \"" . mysql_real_escape_string($username) . "\""; | 102 | $getuser = "SELECT * FROM users WHERE username = \"" . mysql_real_escape_string($username) . "\""; |
diff --git a/central/trunk/instadisc.sql b/central/trunk/instadisc.sql index 70e3c3b..3f39a2a 100644 --- a/central/trunk/instadisc.sql +++ b/central/trunk/instadisc.sql | |||
@@ -3,7 +3,7 @@ | |||
3 | -- http://www.phpmyadmin.net | 3 | -- http://www.phpmyadmin.net |
4 | -- | 4 | -- |
5 | -- Host: localhost | 5 | -- Host: localhost |
6 | -- Generation Time: Sep 06, 2008 at 05:37 PM | 6 | -- Generation Time: Sep 06, 2008 at 06:34 PM |
7 | -- Server version: 5.0.51 | 7 | -- Server version: 5.0.51 |
8 | -- PHP Version: 5.2.4-2ubuntu5.3 | 8 | -- PHP Version: 5.2.4-2ubuntu5.3 |
9 | -- | 9 | -- |
@@ -13,21 +13,6 @@ | |||
13 | -- -------------------------------------------------------- | 13 | -- -------------------------------------------------------- |
14 | 14 | ||
15 | -- | 15 | -- |
16 | -- Table structure for table `centralServers` | ||
17 | -- | ||
18 | |||
19 | DROP TABLE IF EXISTS `centralServers`; | ||
20 | CREATE TABLE `centralServers` ( | ||
21 | `id` int(11) NOT NULL auto_increment, | ||
22 | `url` varchar(255) NOT NULL, | ||
23 | `code` varchar(255) NOT NULL, | ||
24 | `xmlrpc` varchar(255) NOT NULL, | ||
25 | PRIMARY KEY (`id`) | ||
26 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1; | ||
27 | |||
28 | -- -------------------------------------------------------- | ||
29 | |||
30 | -- | ||
31 | -- Table structure for table `config` | 16 | -- Table structure for table `config` |
32 | -- | 17 | -- |
33 | 18 | ||
diff --git a/central/trunk/theme/index.tpl b/central/trunk/theme/index.tpl index 54c58c7..06be1c9 100644 --- a/central/trunk/theme/index.tpl +++ b/central/trunk/theme/index.tpl | |||
@@ -10,8 +10,7 @@ | |||
10 | <P>Welcome to <!--SITENAME-->'s InstaDisc Central Server! | 10 | <P>Welcome to <!--SITENAME-->'s InstaDisc Central Server! |
11 | <P>InstaDisc is a wonderful productivity-increasing notification program. For more information about the project itself, see | 11 | <P>InstaDisc is a wonderful productivity-increasing notification program. For more information about the project itself, see |
12 | <A HREF="http://fourisland.com/projects/instadisc/">its project site</A>.<P>An InstaDisc "Central Server" is where you can | 12 | <A HREF="http://fourisland.com/projects/instadisc/">its project site</A>.<P>An InstaDisc "Central Server" is where you can |
13 | register for the InstaDisc service. There are many Central Servers around the world, you generally pick the one that is | 13 | register for the InstaDisc service. |
14 | closest to you. If you would like to choose <!--SITENAME-->'s, why not register now? | ||
15 | <P><A HREF="register.php">Register</A> | 14 | <P><A HREF="register.php">Register</A> |
16 | <BR><A HREF="login.php">Login</A> | 15 | <BR><A HREF="login.php">Login</A> |
17 | <BR><A HREF="activate.php">Activation page</A> | 16 | <BR><A HREF="activate.php">Activation page</A> |
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 | ||
78 | function sendFromUpdate($username, $verification, $verificationID, $subscriptionSeriesURL, $subscriptionID, $title, $author, $url, $semantics, $encryptionID) | 78 | function 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 | |||
122 | function 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 | |||
185 | function 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 | |||
200 | function 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 | ||
253 | function 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(); |