diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2008-09-28 16:26:50 +0000 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2008-09-28 16:26:50 +0000 |
commit | bd90f0965333b247a5e50422d0a1d9292dd9fd5a (patch) | |
tree | b98a1dd2fe95b9d240fa42eb9ffcb734d790b0a7 /central/trunk | |
parent | eefbd2e03bed592549bc6a61b16e076ccccd819f (diff) | |
download | instadisc-bd90f0965333b247a5e50422d0a1d9292dd9fd5a.tar.gz instadisc-bd90f0965333b247a5e50422d0a1d9292dd9fd5a.tar.bz2 instadisc-bd90f0965333b247a5e50422d0a1d9292dd9fd5a.zip |
Central: Completed steps 10 and 11
Refs #69
Diffstat (limited to 'central/trunk')
-rw-r--r-- | central/trunk/includes/instadisc.php | 80 | ||||
-rw-r--r-- | central/trunk/xmlrpc.php | 82 |
2 files changed, 121 insertions, 41 deletions
diff --git a/central/trunk/includes/instadisc.php b/central/trunk/includes/instadisc.php index 1c4c968..1f40b7a 100644 --- a/central/trunk/includes/instadisc.php +++ b/central/trunk/includes/instadisc.php | |||
@@ -58,41 +58,22 @@ function instaDisc_sendItem($username, $id) | |||
58 | $getuser2 = mysql_query($getuser); | 58 | $getuser2 = mysql_query($getuser); |
59 | $getuser3 = mysql_fetch_array($getuser2); | 59 | $getuser3 = mysql_fetch_array($getuser2); |
60 | 60 | ||
61 | $fp = @fsockopen($getuser3['ip'], 1204, $errno, $errstr); | 61 | if (($getuser3['downloadItemMode'] == 'Push') && ($getuser3['port'] != 0)) |
62 | if ($fp) | ||
63 | { | 62 | { |
64 | $verID = rand(1,2147483647); | 63 | $fp = @fsockopen($getuser3['ip'], $getuser3['port'], $errno, $errstr); |
65 | 64 | if ($fp) | |
66 | $title = str_replace(': ', '__INSTADISC__', $getitem3['title']); | ||
67 | |||
68 | $out = 'ID: ' . $id . "\r\n"; | ||
69 | $out .= 'Verification: ' . md5($username . ':' . $getuser3['password'] . ':' . $verID) . "\r\n"; | ||
70 | $out .= 'Verification-ID: ' . $verID . "\r\n"; | ||
71 | $out .= 'Subscription: ' . $getitem3['subscription'] . "\r\n"; | ||
72 | $out .= 'Title: ' . $title . "\r\n"; | ||
73 | $out .= 'Author: ' . $getitem3['author'] . "\r\n"; | ||
74 | $out .= 'URL: ' . $getitem3['url'] . "\r\n"; | ||
75 | |||
76 | $semantics = unserialize($getitem3['semantics']); | ||
77 | foreach ($semantics as $name => $value) | ||
78 | { | ||
79 | $value = str_replace(': ', '__INSTADISC__', $value); | ||
80 | $out .= $name . ': ' . $value . "\r\n"; | ||
81 | } | ||
82 | |||
83 | if ($getitem3['encryptionID'] != 0) | ||
84 | { | 65 | { |
85 | $out .= 'Encryption-ID: ' . $getitem3['encryptionID'] . "\r\n"; | 66 | $title = str_replace(': ', '__INSTADISC__', $getitem3['title']); |
86 | } | ||
87 | 67 | ||
88 | $out .= "\r\n\r\n"; | 68 | $out = instaDisc_formItem($username, $id, "\r\n") . "\r\n\r\n"; |
89 | 69 | ||
90 | fwrite($fp, $out); | 70 | fwrite($fp, $out); |
91 | fclose($fp); | 71 | fclose($fp); |
92 | 72 | ||
93 | return true; | 73 | return true; |
94 | } else { | 74 | } else { |
95 | return false; | 75 | return false; |
76 | } | ||
96 | } | 77 | } |
97 | } | 78 | } |
98 | } | 79 | } |
@@ -111,7 +92,10 @@ function instaDisc_addItem($username, $subscription, $title, $author, $url, $sem | |||
111 | $insitem = "INSERT INTO inbox (username, itemID, subscription, title, author, url, semantics, encryptionID) VALUES (\"" . mysql_real_escape_string($username) . "\", " . $itemID . ", \"" . mysql_real_escape_string($subscription) . "\", \"" . mysql_real_escape_string($title) . "\", \"" . mysql_real_escape_string($author) . "\", \"" . mysql_real_escape_string($url) . "\", \"" . mysql_real_escape_string($semantics) . "\"," . $encryptionID . ")"; | 92 | $insitem = "INSERT INTO inbox (username, itemID, subscription, title, author, url, semantics, encryptionID) VALUES (\"" . mysql_real_escape_string($username) . "\", " . $itemID . ", \"" . mysql_real_escape_string($subscription) . "\", \"" . mysql_real_escape_string($title) . "\", \"" . mysql_real_escape_string($author) . "\", \"" . mysql_real_escape_string($url) . "\", \"" . mysql_real_escape_string($semantics) . "\"," . $encryptionID . ")"; |
112 | $insitem2 = mysql_query($insitem); | 93 | $insitem2 = mysql_query($insitem); |
113 | 94 | ||
114 | instaDisc_sendItem($username, $itemID); | 95 | if ($getuser3['downloadItemMode'] == 'Push') |
96 | { | ||
97 | instaDisc_sendItem($username, $itemID); | ||
98 | } | ||
115 | } | 99 | } |
116 | } | 100 | } |
117 | 101 | ||
@@ -263,4 +247,38 @@ function instaDisc_initalizePort($username) | |||
263 | return $port; | 247 | return $port; |
264 | } | 248 | } |
265 | 249 | ||
250 | function instaDisc_formItem($username, $id, $ln = "\n") | ||
251 | { | ||
252 | $getitem = "SELECT * FROM inbox WHERE username = \"" . mysql_real_escape_string($username) . "\" AND itemID = " . $id; | ||
253 | $getitem2 = mysql_query($getitem); | ||
254 | $getitem3 = mysql_fetch_array($getitem2); | ||
255 | if ($getitem3['username'] == $username) | ||
256 | { | ||
257 | $getuser = "SELECT * FROM users WHERE username = \"" . mysql_real_escape_string($username) . "\""; | ||
258 | $getuser2 = mysql_query($getuser); | ||
259 | $getuser3 = mysql_fetch_array($getuser2); | ||
260 | |||
261 | $verID = rand(1,2147483647); | ||
262 | |||
263 | $out = 'ID: ' . $id . $ln; | ||
264 | $out .= 'Verification: ' . md5($username . ':' . $getuser3['password'] . ':' . $verID) . $ln; | ||
265 | $out .= 'Verification-ID: ' . $verID . $ln; | ||
266 | $out .= 'Subscription: ' . $getitem3['subscription'] . $ln; | ||
267 | $out .= 'Title: ' . $title . $ln; | ||
268 | $out .= 'Author: ' . $getitem3['author'] . $ln; | ||
269 | $out .= 'URL: ' . $getitem3['url'] . $ln; | ||
270 | |||
271 | $semantics = unserialize($getitem3['semantics']); | ||
272 | foreach ($semantics as $name => $value) | ||
273 | { | ||
274 | $value = str_replace(': ', '__INSTADISC__', $value); | ||
275 | $out .= $name . ': ' . $value . $ln; | ||
276 | } | ||
277 | if ($getitem3['encryptionID'] != 0) | ||
278 | { | ||
279 | $out .= 'Encryption-ID: ' . $getitem3['encryptionID'] . $ln; | ||
280 | } | ||
281 | } | ||
282 | } | ||
283 | |||
266 | ?> | 284 | ?> |
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) | |||
44 | $getitem3 = mysql_fetch_array($getitem2); | 44 | $getitem3 = mysql_fetch_array($getitem2); |
45 | if ($getitem3['itemID'] == $id) | 45 | if ($getitem3['itemID'] == $id) |
46 | { | 46 | { |
47 | instaDisc_sendItem($username, $id); | 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); | ||
48 | 53 | ||
49 | return new xmlrpcresp(new xmlrpcval(0, "int")); | 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 | } | ||
50 | } | 59 | } |
51 | } | 60 | } |
52 | 61 | ||
@@ -57,24 +66,76 @@ function requestRetained($username, $verification, $verificationID) | |||
57 | { | 66 | { |
58 | if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password')) | 67 | if (instaDisc_checkVerification($username, $verification, $verificationID, 'users', 'username', 'password')) |
59 | { | 68 | { |
60 | $getitems = "SELECT * FROM inbox WHERE username = \"" . mysql_real_escape_string($username) . "\""; | 69 | $getuser = "SELECT * FROM users WHERE username = \"" . mysql_real_escape_string($username) . "\""; |
61 | $getitems2 = mysql_query($getitems); | 70 | $getuser2 = mysql_query($getuser); |
62 | $i=0; | 71 | $getuser3 = mysql_fetch_array($getuser2); |
63 | while ($getitems3[$i] = mysql_fetch_array($getitems2)) | 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') | ||
64 | { | 88 | { |
65 | if (!instaDisc_sendItem($username, $getitems3[$i]['itemID'])) | 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) | ||
66 | { | 94 | { |
67 | return new xmlrpcresp(new xmlrpcval(1, "int")); | 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')); | ||
68 | } | 102 | } |
69 | $i++; | ||
70 | } | 103 | } |
104 | } | ||
71 | 105 | ||
72 | return new xmlrpcresp(new xmlrpcval(0, "int")); | 106 | return new xmlrpcresp(new xmlrpcval(1, "int")); |
107 | } | ||
108 | |||
109 | function 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 | } | ||
73 | } | 133 | } |
74 | 134 | ||
75 | return new xmlrpcresp(new xmlrpcval(1, "int")); | 135 | return new xmlrpcresp(new xmlrpcval(1, "int")); |
76 | } | 136 | } |
77 | 137 | ||
138 | |||
78 | function sendFromUpdate($subscriptionURL, $title, $author, $url, $semantics, $encryptionID) | 139 | function sendFromUpdate($subscriptionURL, $title, $author, $url, $semantics, $encryptionID) |
79 | { | 140 | { |
80 | $getsed = "SELECT * FROM subscriptions WHERE url = \"" . mysql_real_escape_string($subscriptionURL) . "\""; | 141 | $getsed = "SELECT * FROM subscriptions WHERE url = \"" . mysql_real_escape_string($subscriptionURL) . "\""; |
@@ -180,6 +241,7 @@ $s = new xmlrpc_server( array( "InstaDisc.checkRegistration" => array("function" | |||
180 | "InstaDisc.deleteItem" => array("function" => "deleteItem"), | 241 | "InstaDisc.deleteItem" => array("function" => "deleteItem"), |
181 | "InstaDisc.resendItem" => array("function" => "resendItem"), | 242 | "InstaDisc.resendItem" => array("function" => "resendItem"), |
182 | "InstaDisc.requestRetained" => array("function" => "requestRetained"), | 243 | "InstaDisc.requestRetained" => array("function" => "requestRetained"), |
244 | "InstaDisc.sendItem" => array("function" => "sendItem"), | ||
183 | "InstaDisc.sendFromUpdate" => array("function" => "sendFromUpdate"), | 245 | "InstaDisc.sendFromUpdate" => array("function" => "sendFromUpdate"), |
184 | "InstaDisc.deleteSubscription" => array("function" => "deleteSubscription"), | 246 | "InstaDisc.deleteSubscription" => array("function" => "deleteSubscription"), |
185 | "InstaDisc.addSubscription" => array("function" => "addSubscription"), | 247 | "InstaDisc.addSubscription" => array("function" => "addSubscription"), |