These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | // |
||
3 | // ------------------------------------------------------------------------ // |
||
4 | // XOOPS - PHP Content Management System // |
||
5 | // Copyright (c) 2000-2016 XOOPS.org // |
||
6 | // <http://xoops.org/> // |
||
7 | // ------------------------------------------------------------------------ // |
||
8 | // This program is free software; you can redistribute it and/or modify // |
||
9 | // it under the terms of the GNU General Public License as published by // |
||
10 | // the Free Software Foundation; either version 2 of the License, or // |
||
11 | // (at your option) any later version. // |
||
12 | // // |
||
13 | // You may not change or alter any portion of this comment or credits // |
||
14 | // of supporting developers from this source code or any supporting // |
||
15 | // source code which is considered copyrighted (c) material of the // |
||
16 | // original comment or credit authors. // |
||
17 | // // |
||
18 | // This program is distributed in the hope that it will be useful, // |
||
19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // |
||
20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
||
21 | // GNU General Public License for more details. // |
||
22 | // // |
||
23 | // You should have received a copy of the GNU General Public License // |
||
24 | // along with this program; if not, write to the Free Software // |
||
25 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
||
26 | // ------------------------------------------------------------------------ // |
||
27 | /** |
||
28 | * RSS per topics |
||
29 | * |
||
30 | * This script is used to generate RSS feeds for each topic. |
||
31 | * You can enable and disable this feature with the module's option named "Enable RSS feeds per topics?" |
||
32 | * The script uses the permissions to know what to display. |
||
33 | * |
||
34 | * @package News |
||
35 | * @author Xoops Modules Dev Team |
||
36 | * @copyright (c) XOOPS Project (http://xoops.org) |
||
37 | * |
||
38 | * @param type $nomvariable description |
||
39 | */ |
||
40 | include dirname(dirname(__DIR__)) . '/mainfile.php'; |
||
41 | include_once XOOPS_ROOT_PATH . '/class/template.php'; |
||
42 | include_once XOOPS_ROOT_PATH . '/modules/news/class/class.newsstory.php'; |
||
43 | include_once XOOPS_ROOT_PATH . '/modules/news/class/class.newstopic.php'; |
||
44 | include_once XOOPS_ROOT_PATH . '/modules/news/include/functions.php'; |
||
45 | |||
46 | error_reporting(0); |
||
47 | $GLOBALS['xoopsLogger']->activated = false; |
||
48 | |||
49 | if (!news_getmoduleoption('topicsrss')) { |
||
50 | exit(); |
||
51 | } |
||
52 | |||
53 | $topicid = isset($_GET['topicid']) ? (int)$_GET['topicid'] : 0; |
||
54 | if ($topicid == 0) { |
||
55 | exit(); |
||
56 | } |
||
57 | |||
58 | if (function_exists('mb_http_output')) { |
||
59 | mb_http_output('pass'); |
||
60 | } |
||
61 | |||
62 | $restricted = news_getmoduleoption('restrictindex'); |
||
63 | $newsnumber = news_getmoduleoption('storyhome'); |
||
64 | |||
65 | $charset = 'utf-8'; |
||
66 | |||
67 | header('Content-Type:text/xml; charset=' . $charset); |
||
68 | $story = new NewsStory(); |
||
69 | $tpl = new XoopsTpl(); |
||
70 | $tpl->caching = 2; |
||
71 | $tpl->xoops_setCacheTime(3600); // Change this to the value you want |
||
72 | if (!$tpl->is_cached('db:news_rss.tpl', $topicid)) { |
||
73 | $xt = new NewsTopic($topicid); |
||
74 | $sarray = NewsStory::getAllPublished($newsnumber, 0, $restricted, $topicid); |
||
75 | if (is_array($sarray) && count($sarray) > 0) { |
||
76 | $sitename = htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES); |
||
77 | $slogan = htmlspecialchars($xoopsConfig['slogan'], ENT_QUOTES); |
||
78 | $tpl->assign('channel_title', xoops_utf8_encode($sitename)); |
||
79 | $tpl->assign('channel_link', XOOPS_URL . '/'); |
||
80 | $tpl->assign('channel_desc', xoops_utf8_encode($slogan)); |
||
81 | $tpl->assign('channel_lastbuild', formatTimestamp(time(), 'rss')); |
||
82 | $tpl->assign('channel_webmaster', checkEmail($xoopsConfig['adminmail'], true)); // Fed up with spam |
||
83 | $tpl->assign('channel_editor', checkEmail($xoopsConfig['adminmail'], true)); // Fed up with spam |
||
84 | $tpl->assign('channel_category', $xt->topic_title()); |
||
85 | $tpl->assign('channel_generator', 'XOOPS'); |
||
86 | $tpl->assign('channel_language', _LANGCODE); |
||
87 | $tpl->assign('image_url', XOOPS_URL . '/images/logo.gif'); |
||
88 | $dimention = getimagesize(XOOPS_ROOT_PATH . '/images/logo.gif'); |
||
89 | View Code Duplication | if (empty($dimention[0])) { |
|
0 ignored issues
–
show
|
|||
90 | $width = 88; |
||
91 | } else { |
||
92 | $width = ($dimention[0] > 144) ? 144 : $dimention[0]; |
||
93 | } |
||
94 | View Code Duplication | if (empty($dimention[1])) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
95 | $height = 31; |
||
96 | } else { |
||
97 | $height = ($dimention[1] > 400) ? 400 : $dimention[1]; |
||
98 | } |
||
99 | $tpl->assign('image_width', $width); |
||
100 | $tpl->assign('image_height', $height); |
||
101 | $count = $sarray; |
||
102 | foreach ($sarray as $story) { |
||
103 | $storytitle = $story->title(); |
||
104 | //if we are allowing html, we need to use htmlspecialchars or any bug will break the output |
||
105 | $description = htmlspecialchars($story->hometext()); |
||
106 | $tpl->append('items', array( |
||
107 | 'title' => xoops_utf8_encode($storytitle), |
||
108 | 'link' => XOOPS_URL . '/modules/news/article.php?storyid=' . $story->storyid(), |
||
109 | 'guid' => XOOPS_URL . '/modules/news/article.php?storyid=' . $story->storyid(), |
||
110 | 'pubdate' => formatTimestamp($story->published(), 'rss'), |
||
111 | 'description' => xoops_utf8_encode($description))); |
||
112 | } |
||
113 | } |
||
114 | } |
||
115 | $tpl->display('db:news_rss.tpl', $topicid); |
||
116 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.