diff options
Diffstat (limited to 'central/trunk/xmlrpc.php')
-rw-r--r-- | central/trunk/xmlrpc.php | 148 |
1 files changed, 142 insertions, 6 deletions
diff --git a/central/trunk/xmlrpc.php b/central/trunk/xmlrpc.php index a057c12..ec64704 100644 --- a/central/trunk/xmlrpc.php +++ b/central/trunk/xmlrpc.php | |||
@@ -89,11 +89,147 @@ function resendItem($xmlrpcmsg) | |||
89 | return new xmlrpcresp(new xmlrpcval(1, "int")); | 89 | return new xmlrpcresp(new xmlrpcval(1, "int")); |
90 | } | 90 | } |
91 | 91 | ||
92 | $s = new xmlrpc_server(array( | 92 | function sendFromUpdate($xmlrpcmsg) |
93 | "InstaDisc.checkRegistration" => array("function" => "checkRegistration"), | 93 | { |
94 | "InstaDisc.deleteItem" => array("function" => "deleteItem"), | 94 | $username = $xmlrpcmsg->getParam(0)->scalarVal(); |
95 | "InstaDisc.resendItem" => array("function" => "resendItem"), | 95 | $verification = $xmlrpcmsg->getParam(1)->scalarVal(); |
96 | "InstaDisc.requestRetained" => array("function" => "requestRetained") | 96 | $verificationID = $xmlrpcmsg->getParam(2)->scalarVal(); |
97 | )); | 97 | $subscription = $xmlrpcmsg->getParam(3)->scalarVal(); |
98 | $title = $xmlrpcmsg->getParam(4)->scalarVal(); | ||
99 | $author = $xmlrpcmsg->getParam(5)->scalarVal(); | ||
100 | $url = $xmlrpcmsg->getParam(6)->scalarVal(); | ||
101 | $semantics = deserialize($xmlrpcmsg->getParam(7)->serialize()); | ||
102 | |||
103 | $getuser = "SELECT * FROM users WHERE username = \"" . $username . "\""; | ||
104 | $getuser2 = mysql_query($getuser); | ||
105 | $getuser3 = mysql_fetch_array($getuser2); | ||
106 | if ($getuser3['username'] == $username) | ||
107 | { | ||
108 | $test = $username . ':' . $getuser3['password'] . ':' . $verificationID; | ||
109 | if (md5($test) == $verification) | ||
110 | { | ||
111 | $getusubs = "SELECT * FROM subscriptions WHERE username = \"" . $username . "\" AND uri = \"" . $subscription . "\" AND owner = \"true\""; | ||
112 | $getusubs2 = mysql_query($getusubs); | ||
113 | $getusubs3 = mysql_fetch_array($getusubs2); | ||
114 | if ($getusubs['username'] == $username) | ||
115 | { | ||
116 | $cserver = $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; | ||
117 | $getuk = "SELECT * FROM centralServers WHERE url = \"" . $cserver . "\""; | ||
118 | $getuk2 = mysql_query($getuk); | ||
119 | $getuk3 = mysql_fetch_array($getuk2); | ||
120 | |||
121 | $getcs = "SELECT * FROM centralServers"; | ||
122 | $getcs2 = mysql_query($getcs); | ||
123 | $i=0; | ||
124 | while ($getcs3[$i] = mysql_fetch_array($getcs2)) | ||
125 | { | ||
126 | $verID = rand(1,65536); | ||
127 | |||
128 | $client = new xmlrpc_client($getcs3[$i]['url']); | ||
129 | $msg = new xmlrpcmsg("InstaDisc.sendFromCentral", array( new xmlrpcval($cserver, 'string'), | ||
130 | new xmlrpcval(md5($cserver + ":" + $getuk3['key'] + ":" + $verID), 'string'), | ||
131 | new xmlrpcval($verID, 'int'), | ||
132 | new xmlrpcval($subscription, 'string'), | ||
133 | new xmlrpcval($title, 'string'), | ||
134 | new xmlrpcval($author, 'string'), | ||
135 | new xmlrpcval($url, 'string'), | ||
136 | new xmlrpcval($semantics, 'array'), | ||
137 | new xmlrpcval(getConfig('softwareVersion'), 'int'), | ||
138 | new xmlrpcval(getConfig('databaseVersion'), 'int'))); | ||
139 | $client->send($msg); | ||
140 | $i++; | ||
141 | } | ||
142 | |||
143 | return new xmlrpcresp(new xmlrpcval(0, "int")); | ||
144 | } | ||
145 | } | ||
146 | } | ||
147 | |||
148 | return new xmlrpcresp(new xmlrpcval(1, "int")); | ||
149 | } | ||
150 | |||
151 | function sendFromCentral($xmlrpcmsg) | ||
152 | { | ||
153 | $cserver = $xmlrpcmsg->getParam(0)->scalarVal(); | ||
154 | $verification = $xmlrpcmsg->getParam(1)->scalarVal(); | ||
155 | $verificationID = $xmlrpcmsg->getParam(2)->scalarVal(); | ||
156 | $subscription = $xmlrpcmsg->getParam(3)->scalarVal(); | ||
157 | $title = $xmlrpcmsg->getParam(4)->scalarVal(); | ||
158 | $author = $xmlrpcmsg->getParam(5)->scalarVal(); | ||
159 | $url = $xmlrpcmsg->getParam(6)->scalarVal(); | ||
160 | $semantics = deserialize($xmlrpcmsg->getParam(7)->serialize()); | ||
161 | $softwareVersion = $xmlrpcmsg->getParam(8)->scalarVal(); | ||
162 | $databaseVersion = $xmlrpcmsg->getParam(9)->scalarVal(); | ||
163 | |||
164 | $getcs = "SELECT * FROM centralServers WHERE url = \"" . $cserver . "\""; | ||
165 | $getcs2 = mysql_query($getcs); | ||
166 | $getcs3 = mysql_fetch_array($getcs2); | ||
167 | if ($getcs3['url'] == $cserver) | ||
168 | { | ||
169 | $test = $cserver . ':' . $getcs3['key'] . ':' . $verificationID; | ||
170 | if (md5($test) == $verification) | ||
171 | { | ||
172 | if ($softwareVersion > getConfig('softwareVersion')) | ||
173 | { | ||
174 | instaDisc_sendUpdateNotice(); | ||
175 | } else if ($softwareVersion < getConfig('softwareVersion')) | ||
176 | { | ||
177 | $cserver2 = $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; | ||
178 | $getuk = "SELECT * FROM centralServers WHERE url = \"" . $cserver2 . "\""; | ||
179 | $getuk2 = mysql_query($getuk); | ||
180 | $getuk3 = mysql_fetch_array($getuk2); | ||
181 | |||
182 | $verID = rand(1,65536); | ||
183 | |||
184 | $client = new xmlrpc_client($cserver); | ||
185 | $msg = new xmlrpcmsg("InstaDisc.sendUpdateNotice", array( new xmlrpcval($cserver2, 'string'), | ||
186 | new xmlrpcval(md5($cserver2 . ':' . $getuk3['key'] . ':' . $verID), 'string'), | ||
187 | new xmlrpcval($verID, 'int'), | ||
188 | new xmlrpcval(getConfig('softwareVersion'), 'int'))); | ||
189 | $client->send($msg); | ||
190 | } | ||
191 | |||
192 | if ($databaseVersion > getConfig('databaseVersion')) | ||
193 | { | ||
194 | $cserver2 = $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; | ||
195 | $getuk = "SELECT * FROM centralServers WHERE url = \"" . $cserver2 . "\""; | ||
196 | $getuk2 = mysql_query($getuk); | ||
197 | $getuk3 = mysql_fetch_array($getuk2); | ||
198 | |||
199 | $verID = rand(1,65536); | ||
200 | |||
201 | $client = new xmlrpc_client($cserver); | ||
202 | $msg = new xmlrpcmsg("InstaDisc.askForDatabase", array( new xmlrpcval($cserver2, 'string'), | ||
203 | new xmlrpcval(md5($cserver2 . ':' . $getuk3['key'] . ':' . $verID), 'string'), | ||
204 | new xmlrpcval($verID, 'int'), | ||
205 | new xmlrpcval(getConfig('databaseVersion'), 'int'))); | ||
206 | $client->send($msg); | ||
207 | } else if ($databaseVersion < getConfig('databaseVersion')) | ||
208 | { | ||
209 | instaDisc_sendDatabase($cserver); | ||
210 | } | ||
211 | |||
212 | $getsed = "SELECT * FROM subscriptions WHERE uri = \"" . $subscription . "\""; | ||
213 | $getsed2 = mysql_query($getsed); | ||
214 | $i=0; | ||
215 | while ($getsed3[$i] = mysql_fetch_array($getsed2)) | ||
216 | { | ||
217 | instaDisc_addItem($getsed3['username'], $subscription, $title, $author, $url, $semantics); | ||
218 | $i++; | ||
219 | } | ||
220 | |||
221 | return new xmlrpcresp(new xmlrpcval(0, "int")); | ||
222 | } | ||
223 | } | ||
224 | |||
225 | return new xmlrpcresp(new xmlrpcval(1, "int")); | ||
226 | } | ||
227 | |||
228 | $s = new xmlrpc_server(array( "InstaDisc.checkRegistration" => array("function" => "checkRegistration"), | ||
229 | "InstaDisc.deleteItem" => array("function" => "deleteItem"), | ||
230 | "InstaDisc.resendItem" => array("function" => "resendItem"), | ||
231 | "InstaDisc.requestRetained" => array("function" => "requestRetained"), | ||
232 | "InstaDisc.sendFromUpdate" => array("function" => "sendFromUpdate"), | ||
233 | "InstaDisc.sendFromCentral" => array("function" => "sendFromCentral"))); | ||
98 | 234 | ||
99 | ?> | 235 | ?> |