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-28 21:40:47 +0000
committerKelly Rauchenberger <fefferburbia@gmail.com>2008-09-28 21:40:47 +0000
commitfb1b67b6922a20fdc3538dd6ae4659dfc1d8d7d2 (patch)
tree9ad7b7c72f451fd5bdcb2c33a6586c586309ab10 /central/trunk/xmlrpc.php
parent9d6ed35e4faa192ea734bfc353a6be65b977a6e6 (diff)
downloadinstadisc-fb1b67b6922a20fdc3538dd6ae4659dfc1d8d7d2.tar.gz
instadisc-fb1b67b6922a20fdc3538dd6ae4659dfc1d8d7d2.tar.bz2
instadisc-fb1b67b6922a20fdc3538dd6ae4659dfc1d8d7d2.zip
Central: Removed UI
Refs #63
Diffstat (limited to 'central/trunk/xmlrpc.php')
-rw-r--r--central/trunk/xmlrpc.php266
1 files changed, 0 insertions, 266 deletions
diff --git a/central/trunk/xmlrpc.php b/central/trunk/xmlrpc.php deleted file mode 100644 index ea77e3f..0000000 --- a/central/trunk/xmlrpc.php +++ /dev/null
@@ -1,266 +0,0 @@
1<?php
2
3/* InstaDisc Server - A Four Island Project */
4
5include('includes/xmlrpc/xmlrpc.inc');
6include('includes/xmlrpc/xmlrpcs.inc');
7include('includes/instadisc.php');
8
9function checkRegistration($username, $verification, $verificationID)
10{
11 if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password'))
12 {
13 return new xmlrpcresp(new xmlrpcval(0, "int"));
14 }
15
16 return new xmlrpcresp(new xmlrpcval(1, "int"));
17}
18
19function deleteItem($username, $verification, $verificationID, $id)
20{
21 if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password'))
22 {
23 $getitem = "SELECT * FROM inbox WHERE username = \"" . mysql_real_escape_string($username) . "\" AND itemID = " . $id;
24 $getitem2 = mysql_query($getitem);
25 $getitem3 = mysql_fetch_array($getitem2);
26 if ($getitem3['itemID'] == $id)
27 {
28 $delitem = "DELETE FROM inbox WHERE username = \"" . mysql_real_escape_string($username) . "\" AND itemID = " . $id;
29 $delitem2 = mysql_query($delitem);
30
31 return new xmlrpcresp(new xmlrpcval(0, "int"));
32 }
33 }
34
35 return new xmlrpcresp(new xmlrpcval(1, "int"));
36}
37
38function resendItem($username, $verification, $verificationID, $id)
39{
40 if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password'))
41 {
42 $getitem = "SELECT * FROM inbox WHERE username = \"" . mysql_real_escape_string($username) . "\" AND itemID = " . $id;
43 $getitem2 = mysql_query($getitem);
44 $getitem3 = mysql_fetch_array($getitem2);
45 if ($getitem3['itemID'] == $id)
46 {
47 $getuser = "SELECT * FROM users WHERE username = \"" . mysql_real_escape_string($username) . "\"";
48 $getuser2 = mysql_query($getuser);
49 $getuser3 = mysql_fetch_array($getuser2);
50 if ($getuser3['downloadItemMode'] == 'Push')
51 {
52 instaDisc_sendItem($username, $id);
53
54 return new xmlrpcresp(new xmlrpcval(0, "int"));
55 } else if ($getuser3['downloadItemMode'] == 'Pull')
56 {
57 return new xmlrpcresp(new xmlrpcval(instaDisc_formItem($username, $id), 'string'));
58 }
59 }
60 }
61
62 return new xmlrpcresp(new xmlrpcval(1, "int"));
63}
64
65function requestRetained($username, $verification, $verificationID)
66{
67 if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password'))
68 {
69 $getuser = "SELECT * FROM users WHERE username = \"" . mysql_real_escape_string($username) . "\"";
70 $getuser2 = mysql_query($getuser);
71 $getuser3 = mysql_fetch_array($getuser2);
72 if ($getuser3['downloadItemMode'] == 'Push')
73 {
74 $getitems = "SELECT * FROM inbox WHERE username = \"" . mysql_real_escape_string($username) . "\"";
75 $getitems2 = mysql_query($getitems);
76 $i=0;
77 while ($getitems3[$i] = mysql_fetch_array($getitems2))
78 {
79 if (!instaDisc_sendItem($username, $getitems3[$i]['itemID']))
80 {
81 return new xmlrpcresp(new xmlrpcval(1, "int"));
82 }
83 $i++;
84 }
85
86 return new xmlrpcresp(new xmlrpcval(0, "int"));
87 } else if ($getuser3['downloadItemMode'] == 'Pull')
88 {
89 $getitems = "SELECT * FROM inbox WHERE username = \"" . mysql_real_escape_string($username) . "\" LIMIT 0,2";
90 $getitems2 = mysql_query($getitems);
91 $getitems3 = mysql_fetch_array($getitems2);
92 $getitems4 = mysql_fetch_array($getitems2);
93 if ($getitems3['username'] == $username)
94 {
95 $item = instaDisc_formItem($username, $getitems3['id']);
96 if ($getitems4['username'] == $username)
97 {
98 $item .= 'More: ' . $getitems4['id'] . "\n";
99 }
100
101 return new xmlrpcresp(new xmlrpcval($item, 'string'));
102 }
103 }
104 }
105
106 return new xmlrpcresp(new xmlrpcval(1, "int"));
107}
108
109function sendItem($username, $verification, $verificationID, $id)
110{
111 if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password'))
112 {
113 $getuser = "SELECT * FROM users WHERE username = \"" . mysql_real_escape_string($username) . "\"";
114 $getuser2 = mysql_query($getuser);
115 $getuser3 = mysql_fetch_array($getuser2);
116 if ($getuser3['downloadItemMode'] == 'Pull')
117 {
118 $getitems = "SELECT * FROM inbox WHERE username = \"" . mysql_real_escape_string($username) . "\" AND itemID > " . ($id-1) . " LIMIT 0,2";
119 $getitems2 = mysql_query($getitems);
120 $getitems3 = mysql_fetch_array($getitems2);
121 $getitems4 = mysql_fetch_array($getitems2);
122 if ($getitems3['username'] == $username)
123 {
124 $item = instaDisc_formItem($username, $getitems3['id']);
125 if ($getitems4['username'] == $username)
126 {
127 $item .= 'More: ' . $getitems4['id'] . "\n";
128 }
129
130 return new xmlrpcresp(new xmlrpcval($item, 'string'));
131 }
132 }
133 }
134
135 return new xmlrpcresp(new xmlrpcval(1, "int"));
136}
137
138
139function sendFromUpdate($subscriptionURL, $title, $author, $url, $semantics, $encryptionID)
140{
141 $getsed = "SELECT * FROM subscriptions WHERE url = \"" . mysql_real_escape_string($subscriptionURL) . "\"";
142 $getsed2 = mysql_query($getsed);
143 $i=0;
144 while ($getsed3[$i] = mysql_fetch_array($getsed2))
145 {
146 instaDisc_addItem($getsed3[$i]['username'], $subscriptionURL, $title, $author, $url, $semantics, $encryptionID);
147 $i++;
148 }
149
150 return new xmlrpcresp(new xmlrpcval(0, "int"));
151}
152
153function deleteSubscription($username, $verification, $verificationID, $subscription)
154{
155 if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password'))
156 {
157 $getsub = "SELECT * FROM subscriptions WHERE url = \"" . mysql_real_escape_string($subscription) . "\" AND username = \"" . mysql_real_escape_string($username) . "\"";
158 $getsub2 = mysql_query($getsub);
159 $getsub3 = mysql_fetch_array($getsub2);
160 if ($getsub3['url'] == $subscription)
161 {
162 $delsub = "DELETE FROM subscriptions WHERE url = \"" . mysql_real_escape_string($subscription) . "\" AND username = \"" . mysql_real_escape_string($username) . "\"";
163 $delsub2 = mysql_query($delsub);
164
165 return new xmlrpcresp(new xmlrpcval(0, "int"));
166 }
167 }
168
169 return new xmlrpcresp(new xmlrpcval(1, "int"));
170}
171
172function addSubscription($username, $verification, $verificationID, $subscription, $category)
173{
174 if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password'))
175 {
176 $getsub = "SELECT * FROM subscriptions WHERE url = \"" . mysql_real_escape_string($subscription) . "\" AND username = \"" . mysql_real_escape_string($username) . "\"";
177 $getsub2 = mysql_query($getsub) or die($getsub);
178 $getsub3 = mysql_fetch_array($getsub2);
179 if ($getsub3['url'] != $subscription)
180 {
181 $inssub = "INSERT INTO subscriptions (url, username, category) VALUES (\"" . mysql_real_escape_string($subscription) . "\", \"" . mysql_real_escape_string($username) . "\", \"" . mysql_real_escape_string($category) . "\")";
182 $inssub2 = mysql_query($inssub);
183
184 return new xmlrpcresp(new xmlrpcval(0, "int"));
185 }
186 }
187
188 return new xmlrpcresp(new xmlrpcval(1, "int"));
189}
190
191function downloadItemModeTest()
192{
193 $fp = @fsockopen($_SERVER['REMOTE_ADDR'], 61200, $errno, $errstr);
194 if ($fp)
195 {
196 fwrite($fp, "InstaDisc Download Item Mode Test\r\n\r\n\r\n");
197 fclose($fp);
198 return new xmlrpcresp(new xmlrpcval('0', 'int'));
199 } else {
200 return new xmlrpcresp(new xmlrpcval('1', 'int'));
201 }
202}
203
204function setDownloadItemMode($username, $verification, $verificationID, $mode)
205{
206 if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password'))
207 {
208 $setuser = "UPDATE users SET downloadItemMode = \"" . mysql_real_escape_string($mode) . "\" WHERE username = \"" . mysql_real_escape_string($username) . "\"";
209 $setuser2 = mysql_query($setuser);
210
211 return new xmlrpcresp(new xmlrpcval('0', 'int'));
212 }
213
214 return new xmlrpcresp(new xmlrpcval('1', 'int'));
215}
216
217function initalizePort($username, $verification, $verificationID)
218{
219 if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password'))
220 {
221 return new xmlrpcresp(new xmlrpcval(instaDisc_initalizePort($username), 'int'));
222 }
223
224 return new xmlrpcresp(new xmlrpcval('0', 'int'));
225}
226
227function deinitalizePort($username, $verification, $verificationID)
228{
229 if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password'))
230 {
231 $setuser = "UPDATE users SET port = 0 WHERE username = \"" . mysql_real_escape_string($username) . "\"";
232 $setuser2 = mysql_query($setuser);
233
234 return new xmlrpcresp(new xmlrpcval('0', 'int'));
235 }
236
237 return new xmlrpcresp(new xmlrpcval('1', 'int'));
238}
239
240function countSubscribers($url)
241{
242 $cntsub = "SELECT * FROM subscriptions WHERE url = \"" . mysql_real_escape_string($url) . "\"";
243 $cntsub2 = mysql_query($cntsub);
244 $cntsub3 = mysql_fetch_array($cntsub2);
245
246 return new xmlrpcresp(new xmlrpcval($cntsub3[0], 'int'));
247}
248
249$s = new xmlrpc_server( array( "InstaDisc.checkRegistration" => array("function" => "checkRegistration"),
250 "InstaDisc.deleteItem" => array("function" => "deleteItem"),
251 "InstaDisc.resendItem" => array("function" => "resendItem"),
252 "InstaDisc.requestRetained" => array("function" => "requestRetained"),
253 "InstaDisc.sendItem" => array("function" => "sendItem"),
254 "InstaDisc.sendFromUpdate" => array("function" => "sendFromUpdate"),
255 "InstaDisc.deleteSubscription" => array("function" => "deleteSubscription"),
256 "InstaDisc.addSubscription" => array("function" => "addSubscription"),
257 "InstaDisc.downloadItemModeTest" => array("function" => "downloadItemModeTest"),
258 "InstaDisc.setDownloadItemMode" => array("function" => "setDownloadItemMode"),
259 "InstaDisc.initalizePort" => array("function" => "initalizePort"),
260 "InstaDisc.deinitalizePort" => array("function" => "deinitalizePort"),
261 "InstaDisc.countSubscribers" => array("function" => "countSubscribers")
262 ),0);
263$s->functions_parameters_type = 'phpvals';
264$s->service();
265
266?>