4 * This test class pretends to be an RSS aggregator. It logs notifications
11 * @author Zach Copley <zach@status.net>
12 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
13 * @link http://status.net/
15 * StatusNet - the distributed open-source microblogging tool
16 * Copyright (C) 2009, StatusNet, Inc.
18 * This program is free software: you can redistribute it and/or modify
19 * it under the terms of the GNU Affero General Public License as published by
20 * the Free Software Foundation, either version 3 of the License, or
21 * (at your option) any later version.
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU Affero General Public License for more details.
28 * You should have received a copy of the GNU Affero General Public License
29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
32 if (!defined('STATUSNET')) {
36 class LoggingAggregatorAction extends Action
39 var $challenge = null;
45 * @param array $args Web and URL arguments
47 * @return boolean false if user doesn't exist
49 function prepare($args)
51 parent::prepare($args);
53 $this->url = $this->arg('url');
54 $this->challenge = $this->arg('challenge');
56 common_debug("args = " . var_export($this->args, true));
57 common_debug('url = ' . $this->url . ' challenge = ' . $this->challenge);
62 function handle($args)
64 parent::handle($args);
66 if (empty($this->url)) {
67 $this->showError('Hey, you have to provide a url parameter.');
71 if (!empty($this->challenge)) {
75 if ($_SERVER['REQUEST_METHOD'] != 'GET') {
76 $this->showError('This resource requires an HTTP GET.');
80 header('Content-Type: text/xml');
81 echo "<notifyResult success='true' msg='Thanks for the update.' challenge='" .
82 $this->challenge . "' />\n";
88 if ($_SERVER['REQUEST_METHOD'] != 'POST') {
89 $this->showError('This resource requires an HTTP POST.');
93 header('Content-Type: text/xml');
94 echo '<notifyResult success=\'true\' msg=\'Thanks for the update.\' />' . "\n";
98 $this->ip = $_SERVER['REMOTE_ADDR'];
100 common_log(LOG_INFO, 'RSSCloud Logging Aggregator - ' . $this->ip . ' claims the feed at ' .
101 $this->url . ' has been updated.');
104 function showError($msg)
106 header('HTTP/1.1 400 Bad Request');
107 header('Content-Type: text/xml');
108 echo "<?xml version='1.0'?>\n";
109 echo "<notifyResult success='false' msg='$msg' />\n";