]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/RSSCloud/RSSCloudRequestNotify.php
1d4087334f206945012334a7a6aa77b2797b4284
[quix0rs-gnu-social.git] / plugins / RSSCloud / RSSCloudRequestNotify.php
1 <?php
2
3 /**
4  * Notifier
5  *
6  * PHP version 5
7  *
8  * @category Plugin
9  * @package  StatusNet
10  * @author   Zach Copley <zach@status.net>
11  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
12  * @link     http://status.net/
13  *
14  * StatusNet - the distributed open-source microblogging tool
15  * Copyright (C) 2009, StatusNet, Inc.
16  *
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.
21  *
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.
26  *
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/>.
29  */
30
31 if (!defined('STATUSNET')) {
32     exit(1);
33 }
34
35 class RSSCloudRequestNotifyAction extends Action 
36 {
37
38     /**
39      * Initialization.
40      *
41      * @param array $args Web and URL arguments
42      *
43      * @return boolean false if user doesn't exist
44      */
45     function prepare($args)
46     {
47         parent::prepare($args);
48         return true;
49     }
50
51     function handle($args)
52     {
53         parent::handle($args);
54         
55         if ($_SERVER['REQUEST_METHOD'] != 'POST') {
56             showResult(false, 'Request must be POST.');
57         }
58         
59         $ip      = $_SERVER['REMOTE_ADDR'];
60         $missing = array();
61         $port    = $this->arg('port');
62         
63         if (empty($this->port)) {
64             $missing[] = 'port';
65         }
66         
67         $path = $this->arg('path');
68
69         if (empty($this->path)) {
70             $missing[] = 'path';
71         }
72         
73         $protocol = $this->arg('protocol');
74
75         if (empty($this->protocol)) {
76             $missing[] = 'protocol';
77         }
78         
79         if (empty($this->notifyProcedure)) {
80             $missing[] = 'notifyProcedure';
81         }
82         
83         if (!empty($missing)) {
84             $msg = 'The following parameters were missing from the request body: ' .
85               implode(',', $missing) . '.';
86             $this->showResult(false, $msg);
87         }
88         
89         $feeds = $this->getFeeds();
90         
91         if (empty($feeds)) {
92             $this->showResult(false, 
93                               'You must provide at least one feed url (url1, url2, url3 ... urlN).');
94         }
95         
96         $endpoint = $ip . ':' . $port . $path;
97         
98         foreach ($feeds as $feed) {
99             
100         }
101         
102         
103     }
104     
105     
106     function getFeeds()
107     {
108         $feeds = array();
109         
110         foreach ($this->args as $key => $feed ) {
111             if (preg_match('|url\d+|', $key)) {
112                 
113                 // XXX: validate feeds somehow and kick bad ones out
114                 
115                 $feeds[] = $feed;
116             }
117         }
118         
119         return $feeds;
120     }
121     
122     
123     function checkNotifyHandler() 
124     {
125         
126     }
127     
128     function validateFeed() 
129     {
130     }
131     
132     function showResult($success, $msg) 
133     {
134         $this->startXML();
135         $this->elementStart('notifyResult', array('success' => ($success) ? 'true' : 'false',
136                                                   'msg'     => $msg));
137         $this->endXML();
138         
139     }
140     
141     
142 }
143
144
145