From 087e616b4eed27573d5a00b725eca02c1584fa4f Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Thu, 31 Mar 2016 20:46:01 +0200 Subject: wip pubsubhubbub --- www/push-subscription.php | 104 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 www/push-subscription.php (limited to 'www/push-subscription.php') diff --git a/www/push-subscription.php b/www/push-subscription.php new file mode 100644 index 0000000..014f15d --- /dev/null +++ b/www/push-subscription.php @@ -0,0 +1,104 @@ +get($hubTopic); + if ($sub === false) { + //we do not know this subscription + header('HTTP/1.0 404 Not Found'); + echo "We are not subscribed to this hub.topic\n"; + exit(1); + } + $pos = array_search($hubTopic, $GLOBALS['phinde']['subscriptions']); + if ($pos !== false) { + //we do not want to unsubscribe + header('HTTP/1.0 404 Not Found'); + echo "We do not want to unsubscribe from this hub.topic\n"; + exit(1); + } + $sub->remove($hubTopic); + header('HTTP/1.0 200 OK'); + header('Content-type: text/plain'); + echo "Unsubscribed.\n"; + exit(0); +} else { + header('HTTP/1.0 400 Bad Request'); + echo "Invalid parameter value for hub.mode\n"; + exit(1); +} + + +function isValidUrl($url) +{ + if (filter_var($url, FILTER_VALIDATE_URL) === false) { + return false; + } + if (substr($url, 0, 7) == 'http://' + || substr($url, 0, 8) == 'https://' + ) { + return true; + } + return false; +} +?> \ No newline at end of file -- cgit v1.2.3