3 * This test class pretends to be an RSS aggregator. It logs notifications
10 * @author Zach Copley <zach@status.net>
11 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
12 * @link http://status.net/
14 * StatusNet - the distributed open-source microblogging tool
15 * Copyright (C) 2009, StatusNet, Inc.
17 * This program is free software: you can redistribute it and/or modify
18 * it under the terms of the GNU Affero General Public License as published by
19 * the Free Software Foundation, either version 3 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU Affero General Public License for more details.
27 * You should have received a copy of the GNU Affero General Public License
28 * along with this program. If not, see <http://www.gnu.org/licenses/>.
31 if (!defined('STATUSNET')) {
35 class LoggingAggregatorAction extends Action
38 var $challenge = null;
44 * @param array $args Web and URL arguments
46 * @return boolean false if user doesn't exist
48 function prepare($args)
50 parent::prepare($args);
52 $this->url = $this->arg('url');
53 $this->challenge = $this->arg('challenge');
55 common_debug("args = " . var_export($this->args, true));
56 common_debug('url = ' . $this->url . ' challenge = ' . $this->challenge);
61 function handle($args)
63 parent::handle($args);
65 if (empty($this->url)) {
66 $this->showError('Hey, you have to provide a url parameter.');
70 if (!empty($this->challenge)) {
74 if ($_SERVER['REQUEST_METHOD'] != 'GET') {
75 $this->showError('This resource requires an HTTP GET.');
79 header('Content-Type: text/xml');
80 echo $this->challenge;
86 if ($_SERVER['REQUEST_METHOD'] != 'POST') {
87 $this->showError('This resource requires an HTTP POST.');
91 header('Content-Type: text/xml');
92 echo '<notifyResult success=\'true\' msg=\'Thanks for the update.\' />' . "\n";
95 $this->ip = $_SERVER['REMOTE_ADDR'];
97 common_log(LOG_INFO, 'RSSCloud Logging Aggregator - ' . $this->ip . ' claims the feed at ' .
98 $this->url . ' has been updated.');
101 function showError($msg)
103 header('HTTP/1.1 400 Bad Request');
104 header('Content-Type: text/xml');
105 echo "<?xml version='1.0'?>\n";
106 echo "<notifyResult success='false' msg='$msg' />\n";