From 087e616b4eed27573d5a00b725eca02c1584fa4f Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Thu, 31 Mar 2016 20:46:01 +0200 Subject: [PATCH] wip pubsubhubbub --- data/config.php.dist | 10 +++- src/phinde/Subscriptions.php | 12 ++++ www/push-subscription.php | 104 +++++++++++++++++++++++++++++++++++ 3 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 src/phinde/Subscriptions.php create mode 100644 www/push-subscription.php diff --git a/data/config.php.dist b/data/config.php.dist index 4c6a14f..7eb8ccf 100644 --- a/data/config.php.dist +++ b/data/config.php.dist @@ -4,6 +4,14 @@ $GLOBALS['phinde'] = array( 'domains' => array( 'www.example.org', 'test.example.org' - ) + ), + //list of URL beginnings that should be ignored + 'blacklist' => array( + 'http://bad.example.org/' + ), + //list of URLs that should be subscribed to with PubSubHubbub + 'subscriptions' => array( + 'http://www.example.org/feed', + ), ); ?> \ No newline at end of file diff --git a/src/phinde/Subscriptions.php b/src/phinde/Subscriptions.php new file mode 100644 index 0000000..9db4b16 --- /dev/null +++ b/src/phinde/Subscriptions.php @@ -0,0 +1,12 @@ + 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 -- 2.30.2