about summary refs log tree commit diff stats
path: root/central
diff options
context:
space:
mode:
Diffstat (limited to 'central')
-rw-r--r--central/trunk/instadisc.php106
1 files changed, 106 insertions, 0 deletions
diff --git a/central/trunk/instadisc.php b/central/trunk/instadisc.php index 98a9385..de0a90e 100644 --- a/central/trunk/instadisc.php +++ b/central/trunk/instadisc.php
@@ -239,4 +239,110 @@ function instaDisc_getConfig($key)
239 return $getconfig3['value']; 239 return $getconfig3['value'];
240} 240}
241 241
242function instaDisc_listSubscriptions($username)
243{
244 $getsubs = "SELECT * FROM subscriptions WHERE username = \"" . mysql_escape_string($username) . "\" AND owner = \"true\"";
245 $getsubs2 = mysql_query($getsubs);
246 $i=0;
247 while ($getsubs3[$i] = mysql_fetch_array($getsubs2))
248 {
249 $subs[$i] = $getsubs3[$i]['url'];
250
251 $i++;
252 }
253
254 $subs['size'] = $i;
255 return $subs;
256}
257
258function instaDisc_addSubscription($username, $url)
259{
260 $getcode = "SELECT * FROM pending2 WHERE username = \"" . mysql_escape_string($username) . "\" AND url = \"" . mysql_escape_string($url) . "\"";
261 $getcode2 = mysql_query($getcode);
262 $getcode3 = mysql_fetch_array($getcode2);
263 if ($getcode3['username'] == $username)
264 {
265 $delcode = "DELETE FROM pending2 WHERE username = \"" . mysql_escape_string($username) . "\" AND url = \"" . mysql_escape_string($url) . "\"";
266 $delcode2 = mysql_query($delcode);
267
268 $c = curl_init();
269 curl_setopt($c, CURLOPT_URL, $url);
270 curl_setopt($c, CURLOPT_HEADER, false);
271 curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
272 $page_data = curl_exec($c);
273 curl_close($c);
274
275 $headers = split("\n", $page_date);
276 foreach ($headers as $name => $value)
277 {
278 $header = split(": ", $value);
279 $headerMap[$header[0]] = $header[1];
280 }
281
282 if (isset($header['Subscription']))
283 {
284 if (isset($header['Title']))
285 {
286 if (isset($header['Category']))
287 {
288 if (isset($header['Key']))
289 {
290 if ($header['Key'] == $getcode3['code'])
291 {
292 $inssub = "INSERT INTO subscriptions (username,url,owner) VALUES (\"" . mysql_escape_string($username) . "\", \"" . mysql_escape_string($header['Subscription']) . "\", \"true\")";
293 $inssub2 = mysql_query($inssub);
294
295 return true;
296 }
297 }
298 }
299 }
300 }
301 }
302
303 return false;
304}
305
306function instaDisc_listPendingSubscriptions($username)
307{
308 $getsubs = "SELECT * FROM pending2 WHERE username = \"" . mysql_escape_string($username) . "\"";
309 $getsubs2 = mysql_query($getsubs);
310 $i=0;
311 while ($getsubs3[$i] = mysql_fetch_array($getsubs2))
312 {
313 $subs[$i] = array('url' => $getsubs3[$i]['url'], 'key' => $getsubs3[$i]['key']);
314
315 $i++;
316 }
317
318 $subs['size'] = $i;
319 return $subs;
320}
321
322function instaDisc_generateSubscriptionActivation($username, $url)
323{
324 $key = md5(rand(1,65536));
325
326 $inspending = "INSERT INTO pending2 (username, url, key) VALUES (\"" . mysql_escape_string($username) . "\", \"" . mysql_escape_string($url) . "\", \"" . mysql_escape_string($key) . "\")";
327 $inspending2 = mysql_query($inspending);
328
329 return $key;
330}
331
332function instaDisc_deleteSubscription($username, $url)
333{
334 $delsub = "DELETE FROM subscriptions WHERE username = \"" . mysql_escape_string($username) . "\" AND url = \"" . mysql_escape_string($url) . "\")";
335 $delsub2 = mysql_query($delsub);
336
337 return true;
338}
339
340function instaDisc_cancelSubscription($username, $url)
341{
342 $delsub = "DELETE FROM pending2 WHERE username = \"" . mysql_escape_string($username) . "\" AND url = \"" . mysql_escape_string($url) . "\")";
343 $delsub2 = mysql_query($delsub);
344
345 return true;
346}
347
242?> 348?>