]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/userrss.php
XSS vulnerability when remote-subscribing
[quix0rs-gnu-social.git] / actions / userrss.php
1 <?php
2 /*
3  * StatusNet - the distributed open-source microblogging tool
4  * Copyright (C) 2008, 2009, StatusNet, Inc.
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Affero General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU Affero General Public License for more details.
15  *
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 if (!defined('GNUSOCIAL')) { exit(1); }
21
22 // Formatting of RSS handled by Rss10Action
23
24 class UserrssAction extends TargetedRss10Action
25 {
26     protected $tag = null;
27
28     protected function doStreamPreparation()
29     {
30         parent::doStreamPreparation();
31
32         $this->tag  = $this->trimmed('tag');
33     }
34
35     protected function getNotices()
36     {
37         if (!empty($this->tag)) {
38             $stream = $this->getTarget()->getTaggedNotices($this->tag, 0, $this->limit);
39             return $stream->fetchAll();
40         }
41         // otherwise we fetch a normal user stream
42
43         $stream = $this->getTarget()->getNotices(0, $this->limit);
44         return $stream->fetchAll();
45     }
46
47     function getChannel()
48     {
49         $c = array('url' => common_local_url('userrss',
50                                              array('nickname' =>
51                                                    $this->target->getNickname())),
52                    // TRANS: Message is used as link title. %s is a user nickname.
53                    'title' => sprintf(_('%s timeline'), $this->target->getNickname()),
54                    'link' => $this->target->getUrl(),
55                    // TRANS: Message is used as link description. %1$s is a username, %2$s is a site name.
56                    'description' => sprintf(_('Updates from %1$s on %2$s!'),
57                                             $this->target->getNickname(), common_config('site', 'name')));
58         return $c;
59     }
60
61     // override parent to add X-SUP-ID URL
62
63     function initRss()
64     {
65         $url = common_local_url('sup', null, null, $this->target->getID());
66         header('X-SUP-ID: '.$url);
67         parent::initRss();
68     }
69
70     function isReadOnly($args)
71     {
72         return true;
73     }
74 }