These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /* |
||
3 | * You may not change or alter any portion of this comment or credits |
||
4 | * of supporting developers from this source code or any supporting source code |
||
5 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||
6 | * |
||
7 | * This program is distributed in the hope that it will be useful, |
||
8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
10 | */ |
||
11 | |||
12 | /** |
||
13 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||
14 | * @license {@link http://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
||
15 | * @package |
||
16 | * @since |
||
17 | * @author XOOPS Development Team |
||
18 | */ |
||
19 | |||
20 | /** |
||
21 | * RSS per topics |
||
22 | * |
||
23 | * This script is used to generate RSS feeds for each topic. |
||
24 | * You can enable and disable this feature with the module's option named "Enable RSS feeds per topics?" |
||
25 | * The script uses the permissions to know what to display. |
||
26 | * |
||
27 | * @package News |
||
28 | * @author Xoops Modules Dev Team |
||
29 | * @copyright (c) XOOPS Project (https://xoops.org) |
||
30 | * |
||
31 | * @param type $nomvariable description |
||
32 | */ |
||
33 | include __DIR__ . '/../../mainfile.php'; |
||
34 | require_once XOOPS_ROOT_PATH . '/class/template.php'; |
||
35 | require_once XOOPS_ROOT_PATH . '/modules/news/class/class.newsstory.php'; |
||
36 | require_once XOOPS_ROOT_PATH . '/modules/news/class/class.newstopic.php'; |
||
37 | require_once XOOPS_ROOT_PATH . '/modules/news/class/utility.php'; |
||
38 | |||
39 | error_reporting(0); |
||
40 | $GLOBALS['xoopsLogger']->activated = false; |
||
41 | |||
42 | if (!NewsUtility::getModuleOption('topicsrss')) { |
||
43 | exit(); |
||
44 | } |
||
45 | |||
46 | $topicid = isset($_GET['topicid']) ? (int)$_GET['topicid'] : 0; |
||
47 | if (0 == $topicid) { |
||
48 | exit(); |
||
49 | } |
||
50 | |||
51 | if (function_exists('mb_http_output')) { |
||
52 | mb_http_output('pass'); |
||
53 | } |
||
54 | |||
55 | $restricted = NewsUtility::getModuleOption('restrictindex'); |
||
56 | $newsnumber = NewsUtility::getModuleOption('storyhome'); |
||
57 | |||
58 | $charset = 'utf-8'; |
||
59 | |||
60 | header('Content-Type:text/xml; charset=' . $charset); |
||
61 | $story = new NewsStory(); |
||
62 | $tpl = new XoopsTpl(); |
||
63 | $tpl->caching = 2; |
||
64 | $tpl->xoops_setCacheTime(3600); // Change this to the value you want |
||
65 | if (!$tpl->is_cached('db:news_rss.tpl', $topicid)) { |
||
66 | $xt = new NewsTopic($topicid); |
||
67 | $sarray = NewsStory::getAllPublished($newsnumber, 0, $restricted, $topicid); |
||
68 | if (is_array($sarray) && count($sarray) > 0) { |
||
69 | $sitename = htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES); |
||
70 | $slogan = htmlspecialchars($xoopsConfig['slogan'], ENT_QUOTES); |
||
71 | $tpl->assign('channel_title', xoops_utf8_encode($sitename)); |
||
72 | $tpl->assign('channel_link', XOOPS_URL . '/'); |
||
73 | $tpl->assign('channel_desc', xoops_utf8_encode($slogan)); |
||
74 | $tpl->assign('channel_lastbuild', formatTimestamp(time(), 'rss')); |
||
75 | $tpl->assign('channel_webmaster', checkEmail($xoopsConfig['adminmail'], true)); // Fed up with spam |
||
76 | $tpl->assign('channel_editor', checkEmail($xoopsConfig['adminmail'], true)); // Fed up with spam |
||
77 | $tpl->assign('channel_category', $xt->topic_title()); |
||
78 | $tpl->assign('channel_generator', 'XOOPS'); |
||
79 | $tpl->assign('channel_language', _LANGCODE); |
||
80 | $tpl->assign('image_url', XOOPS_URL . '/images/logo.gif'); |
||
81 | $dimention = getimagesize(XOOPS_ROOT_PATH . '/images/logo.gif'); |
||
82 | View Code Duplication | if (empty($dimention[0])) { |
|
0 ignored issues
–
show
|
|||
83 | $width = 88; |
||
84 | } else { |
||
85 | $width = ($dimention[0] > 144) ? 144 : $dimention[0]; |
||
86 | } |
||
87 | 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. ![]() |
|||
88 | $height = 31; |
||
89 | } else { |
||
90 | $height = ($dimention[1] > 400) ? 400 : $dimention[1]; |
||
91 | } |
||
92 | $tpl->assign('image_width', $width); |
||
93 | $tpl->assign('image_height', $height); |
||
94 | $count = $sarray; |
||
95 | foreach ($sarray as $story) { |
||
96 | $storytitle = $story->title(); |
||
97 | //if we are allowing html, we need to use htmlspecialchars or any bug will break the output |
||
98 | $description = htmlspecialchars($story->hometext()); |
||
99 | $tpl->append('items', [ |
||
100 | 'title' => xoops_utf8_encode($storytitle), |
||
101 | 'link' => XOOPS_URL . '/modules/news/article.php?storyid=' . $story->storyid(), |
||
102 | 'guid' => XOOPS_URL . '/modules/news/article.php?storyid=' . $story->storyid(), |
||
103 | 'pubdate' => formatTimestamp($story->published(), 'rss'), |
||
104 | 'description' => xoops_utf8_encode($description) |
||
105 | ]); |
||
106 | } |
||
107 | } |
||
108 | } |
||
109 | $tpl->display('db:news_rss.tpl', $topicid); |
||
110 |
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.