Passed
Push — master ( 700d12...a1b81d )
by
unknown
03:06
created

backendt.php (1 issue)

Labels
Severity
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 https://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
 * @param type $nomvariable description
28
 * @author        Xoops Modules Dev Team
29
 * @copyright (c) XOOPS Project (https://xoops.org)
30
 *
31
 * @package       News
32
 */
33
34
use Xmf\Request;
35
use XoopsModules\News;
36
use XoopsModules\News\NewsStory;
37
use XoopsModules\News\NewsTopic;
38
39
require_once dirname(__DIR__, 2) . '/mainfile.php';
40
require_once XOOPS_ROOT_PATH . '/class/template.php';
41
//require_once XOOPS_ROOT_PATH . '/modules/news/class/class.newsstory.php';
42
//require_once XOOPS_ROOT_PATH . '/modules/news/class/class.newstopic.php';
43
44
error_reporting(0);
45
$GLOBALS['xoopsLogger']->activated = false;
46
47
if (!News\Utility::getModuleOption('topicsrss')) {
48
    exit();
49
}
50
51
$topicid = Request::getInt('topicid', 0, 'GET');
52
if (0 == $topicid) {
53
    exit();
54
}
55
56
if (function_exists('mb_http_output')) {
57
    mb_http_output('pass');
58
}
59
60
$restricted = News\Utility::getModuleOption('restrictindex');
61
$newsnumber = News\Utility::getModuleOption('storyhome');
62
63
$charset = 'utf-8';
64
65
header('Content-Type:text/xml; charset=' . $charset);
66
$story        = new NewsStory();
67
$tpl          = new \XoopsTpl();
68
$tpl->caching = 2;
69
$tpl->xoops_setCacheTime(3600); // Change this to the value you want
70
if (!$tpl->is_cached('db:news_rss.tpl', $topicid)) {
71
    $xt     = new  NewsTopic($topicid);
72
    $sarray = NewsStory::getAllPublished($newsnumber, 0, $restricted, $topicid);
0 ignored issues
show
It seems like $newsnumber can also be of type boolean; however, parameter $limit of XoopsModules\News\NewsStory::getAllPublished() does only seem to accept integer, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

72
    $sarray = NewsStory::getAllPublished(/** @scrutinizer ignore-type */ $newsnumber, 0, $restricted, $topicid);
Loading history...
73
    if ($sarray && is_array($sarray)) {
74
        $sitename = htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES);
75
        $slogan   = htmlspecialchars($xoopsConfig['slogan'], ENT_QUOTES);
76
        $tpl->assign('channel_title', xoops_utf8_encode($sitename));
77
        $tpl->assign('channel_link', XOOPS_URL . '/');
78
        $tpl->assign('channel_desc', xoops_utf8_encode($slogan));
79
        $tpl->assign('channel_lastbuild', formatTimestamp(time(), 'rss'));
80
        $tpl->assign('channel_webmaster', checkEmail($xoopsConfig['adminmail'], true)); // Fed up with spam
81
        $tpl->assign('channel_editor', checkEmail($xoopsConfig['adminmail'], true)); // Fed up with spam
82
        $tpl->assign('channel_category', $xt->topic_title());
83
        $tpl->assign('channel_generator', 'XOOPS');
84
        $tpl->assign('channel_language', _LANGCODE);
85
        $tpl->assign('image_url', XOOPS_URL . '/images/logo.gif');
86
        $dimention = getimagesize(XOOPS_ROOT_PATH . '/images/logo.gif');
87
        if (empty($dimention[0])) {
88
            $width = 88;
89
        } else {
90
            $width = ($dimention[0] > 144) ? 144 : $dimention[0];
91
        }
92
        if (empty($dimention[1])) {
93
            $height = 31;
94
        } else {
95
            $height = ($dimention[1] > 400) ? 400 : $dimention[1];
96
        }
97
        $tpl->assign('image_width', $width);
98
        $tpl->assign('image_height', $height);
99
        $count = $sarray;
100
        foreach ($sarray as $story) {
101
            $storytitle = $story->title();
102
            //if we are allowing html, we need to use htmlspecialchars or any bug will break the output
103
            $description = htmlspecialchars($story->hometext(), ENT_QUOTES | ENT_HTML5);
104
            $tpl->append(
105
                'items',
106
                [
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
    }
116
}
117
$tpl->display('db:news_rss.tpl', $topicid);
118