summaryrefslogtreecommitdiff
path: root/plugins/RSSCloud
diff options
context:
space:
mode:
authorZach Copley <zach@status.net>2009-12-05 07:17:51 +0000
committerZach Copley <zach@status.net>2010-01-05 23:17:35 -0800
commit6b28fbe7b600b56ab06b373173d9f04fae9333ce (patch)
tree693c0c0b74b6b4859c0068b14da6ec105118e996 /plugins/RSSCloud
parent7638e2713d91a829646358fbac5ab8d6ad08d6f6 (diff)
Make dummy aggregator handle RSSCloud challenge/response with domain parameter
Diffstat (limited to 'plugins/RSSCloud')
-rw-r--r--plugins/RSSCloud/LoggingAggregator.php53
1 files changed, 40 insertions, 13 deletions
diff --git a/plugins/RSSCloud/LoggingAggregator.php b/plugins/RSSCloud/LoggingAggregator.php
index 2573d9343..cbdefc36b 100644
--- a/plugins/RSSCloud/LoggingAggregator.php
+++ b/plugins/RSSCloud/LoggingAggregator.php
@@ -36,6 +36,9 @@ if (!defined('STATUSNET')) {
class LoggingAggregatorAction extends Action
{
+ var $challenge = null;
+ var $url = null;
+
/**
* Initialization.
*
@@ -46,6 +49,13 @@ class LoggingAggregatorAction extends Action
function prepare($args)
{
parent::prepare($args);
+
+ $this->url = $this->arg('url');
+ $this->challenge = $this->arg('challenge');
+
+ common_debug("args = " . var_export($this->args, true));
+ common_debug('url = ' . $this->url . ' challenge = ' . $this->challenge);
+
return true;
}
@@ -53,33 +63,50 @@ class LoggingAggregatorAction extends Action
{
parent::handle($args);
- if ($_SERVER['REQUEST_METHOD'] != 'POST') {
- $this->showError('This resource requires an HTTP POST.');
+ if (empty($this->url)) {
+ $this->showError('Hey, you have to provide a url parameter.');
+ return;
}
- $this->url = $this->arg('url');
+ if (!empty($this->challenge)) {
+
+ // must be a GET
+
+ if ($_SERVER['REQUEST_METHOD'] != 'GET') {
+ $this->showError('This resource requires an HTTP GET.');
+ return;
+ }
+
+ header('Content-Type: text/xml');
+ echo "<notifyResult success='true' msg='Thanks for the update.' challenge='" .
+ $this->challenge . "' />\n";
+
+ } else {
+
+ // must be a POST
+
+ if ($_SERVER['REQUEST_METHOD'] != 'POST') {
+ $this->showError('This resource requires an HTTP POST.');
+ return;
+ }
+
+ header('Content-Type: text/xml');
+ echo '<notifyResult success=\'true\' msg=\'Thanks for the update.\' />' . "\n";
- if (empty($this->url)) {
- $this->showError('Hey, you have to provide a url parameter.');
}
- $this->ip = $_SERVER['REMOTE_ADDR'];
+ $this->ip = $_SERVER['REMOTE_ADDR'];
common_log(LOG_INFO, 'RSSCloud Logging Aggregator - ' . $this->ip . ' claims the feed at ' .
$this->url . ' has been updated.');
-
- header('Content-Type: text/xml');
- echo '<notifyResult success=\'true\' msg=\'Thanks for the update.\' />' . "\n";
-
- }
+ }
function showError($msg)
{
- header('HTTP/1.1 403 Forbidden');
+ header('HTTP/1.1 400 Bad Request');
header('Content-Type: text/xml');
echo "<?xml version='1.0'?>\n";
echo "<notifyResult success='false' msg='$msg' />\n";
- exit();
}
} \ No newline at end of file