From bd90f0965333b247a5e50422d0a1d9292dd9fd5a Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 28 Sep 2008 16:26:50 +0000 Subject: Central: Completed steps 10 and 11 Refs #69 --- central/trunk/xmlrpc.php | 82 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 72 insertions(+), 10 deletions(-) (limited to 'central/trunk/xmlrpc.php') diff --git a/central/trunk/xmlrpc.php b/central/trunk/xmlrpc.php index 2e3aa62..0e66940 100644 --- a/central/trunk/xmlrpc.php +++ b/central/trunk/xmlrpc.php @@ -44,9 +44,18 @@ function resendItem($username, $verification, $verificationID, $id) $getitem3 = mysql_fetch_array($getitem2); if ($getitem3['itemID'] == $id) { - instaDisc_sendItem($username, $id); + $getuser = "SELECT * FROM users WHERE username = \"" . mysql_real_escape_string($username) . "\""; + $getuser2 = mysql_query($getuser); + $getuser3 = mysql_fetch_array($getuser2); + if ($getuser3['downloadItemMode'] == 'Push') + { + instaDisc_sendItem($username, $id); - return new xmlrpcresp(new xmlrpcval(0, "int")); + return new xmlrpcresp(new xmlrpcval(0, "int")); + } else if ($getuser3['downloadItemMode'] == 'Pull') + { + return new xmlrpcresp(new xmlrpcval(instaDisc_formItem($username, $id), 'string')); + } } } @@ -57,24 +66,76 @@ function requestRetained($username, $verification, $verificationID) { if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password')) { - $getitems = "SELECT * FROM inbox WHERE username = \"" . mysql_real_escape_string($username) . "\""; - $getitems2 = mysql_query($getitems); - $i=0; - while ($getitems3[$i] = mysql_fetch_array($getitems2)) + $getuser = "SELECT * FROM users WHERE username = \"" . mysql_real_escape_string($username) . "\""; + $getuser2 = mysql_query($getuser); + $getuser3 = mysql_fetch_array($getuser2); + if ($getuser3['downloadItemMode'] == 'Push') + { + $getitems = "SELECT * FROM inbox WHERE username = \"" . mysql_real_escape_string($username) . "\""; + $getitems2 = mysql_query($getitems); + $i=0; + while ($getitems3[$i] = mysql_fetch_array($getitems2)) + { + if (!instaDisc_sendItem($username, $getitems3[$i]['itemID'])) + { + return new xmlrpcresp(new xmlrpcval(1, "int")); + } + $i++; + } + + return new xmlrpcresp(new xmlrpcval(0, "int")); + } else if ($getuser3['downloadItemMode'] == 'Pull') { - if (!instaDisc_sendItem($username, $getitems3[$i]['itemID'])) + $getitems = "SELECT * FROM inbox WHERE username = \"" . mysql_real_escape_string($username) . "\" LIMIT 0,2"; + $getitems2 = mysql_query($getitems); + $getitems3 = mysql_fetch_array($getitems2); + $getitems4 = mysql_fetch_array($getitems2); + if ($getitems3['username'] == $username) { - return new xmlrpcresp(new xmlrpcval(1, "int")); + $item = instaDisc_formItem($username, $getitems3['id']); + if ($getitems4['username'] == $username) + { + $item .= 'More: ' . $getitems4['id'] . "\n"; + } + + return new xmlrpcresp(new xmlrpcval($item, 'string')); } - $i++; } + } - return new xmlrpcresp(new xmlrpcval(0, "int")); + return new xmlrpcresp(new xmlrpcval(1, "int")); +} + +function sendItem($username, $verification, $verificationID, $id) +{ + if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password')) + { + $getuser = "SELECT * FROM users WHERE username = \"" . mysql_real_escape_string($username) . "\""; + $getuser2 = mysql_query($getuser); + $getuser3 = mysql_fetch_array($getuser2); + if ($getuser3['downloadItemMode'] == 'Pull') + { + $getitems = "SELECT * FROM inbox WHERE username = \"" . mysql_real_escape_string($username) . "\" AND itemID > " . ($id-1) . " LIMIT 0,2"; + $getitems2 = mysql_query($getitems); + $getitems3 = mysql_fetch_array($getitems2); + $getitems4 = mysql_fetch_array($getitems2); + if ($getitems3['username'] == $username) + { + $item = instaDisc_formItem($username, $getitems3['id']); + if ($getitems4['username'] == $username) + { + $item .= 'More: ' . $getitems4['id'] . "\n"; + } + + return new xmlrpcresp(new xmlrpcval($item, 'string')); + } + } } return new xmlrpcresp(new xmlrpcval(1, "int")); } + function sendFromUpdate($subscriptionURL, $title, $author, $url, $semantics, $encryptionID) { $getsed = "SELECT * FROM subscriptions WHERE url = \"" . mysql_real_escape_string($subscriptionURL) . "\""; @@ -180,6 +241,7 @@ $s = new xmlrpc_server( array( "InstaDisc.checkRegistration" => array("function" "InstaDisc.deleteItem" => array("function" => "deleteItem"), "InstaDisc.resendItem" => array("function" => "resendItem"), "InstaDisc.requestRetained" => array("function" => "requestRetained"), + "InstaDisc.sendItem" => array("function" => "sendItem"), "InstaDisc.sendFromUpdate" => array("function" => "sendFromUpdate"), "InstaDisc.deleteSubscription" => array("function" => "deleteSubscription"), "InstaDisc.addSubscription" => array("function" => "addSubscription"), -- cgit 1.4.1