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/includes | |
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/includes')
-rw-r--r-- | central/trunk/includes/instadisc.php | 80 |
1 files changed, 49 insertions, 31 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 | ?> |