Passed
Push — master ( b0fca4...7540c5 )
by Michael
06:08 queued 02:59
created
Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
/*
5
 * You may not change or alter any portion of this comment or credits
6
 * of supporting developers from this source code or any supporting source code
7
 * which is considered copyrighted (c) material of the original comment or credit authors.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
 */
13
14
/**
15
 * @copyright    XOOPS Project (https://xoops.org)
16
 * @license      GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
17
 * @package      RSSFit - Extendable XML news feed generator
18
 * @author       NS Tai (aka tuff) <http://www.brandycoke.com>
19
 * @author       XOOPS Development Team
20
 */
21
22
use XoopsModules\Rssfit\{
23
    FeedHandler,
24
    Helper
25
};
26
27
/** @var FeedHandler $feedHandler */
28
29
if (function_exists('mb_http_output')) {
30
    mb_http_output('pass');
31
}
32
require_once __DIR__ . '/header.php';
33
$helper = Helper::getInstance();
34
35
$charset  = $helper->getConfig('utf8') ? 'UTF-8' : _CHARSET;
36
$docache  = (bool)$helper->getConfig('cache');
37
$template = 'db:rssfit_rss.tpl';
38
if (3 == $helper->getConfig('mime')) {
39
    $xoopsLogger->enableRendering();
40
    $xoopsLogger->usePopup = (2 == $xoopsConfig['debug_mode']);
41
    $docache               = false;
42
} else {
43
    error_reporting(0);
44
    $xoopsLogger->activated = false;
45
}
46
47
require_once XOOPS_ROOT_PATH . '/class/template.php';
48
$xoopsTpl = new \XoopsTpl();
49
if ($docache) {
50
    $xoopsTpl->caching = 2;
51
    $xoopsTpl->xoops_setCacheTime($helper->getConfig('cache') * 60);
52
} else {
53
    $xoopsTpl->caching = 0;
54
}
55
56
$feed           = [];
57
$feed['plugin'] = isset($_GET['feed']) ? trim($_GET['feed']) : '';
58
59
$feedHandler->checkSubFeed($feed);
60
if (!$docache || !$xoopsTpl->is_cached($template, $feedHandler->cached)) {
61
    $xoopsTpl->assign('rss_encoding', $charset);
62
    $feedHandler->buildFeed($feed);
63
    $xoopsTpl->assign('feed', $feed);
64
}
65
66
switch ($helper->getConfig('mime')) {
67
    default:
68
        header('Content-Type:text/xml; charset=' . $charset);
69
        break;
70
    case 2:
71
    case 3:
72
        header('Content-Type:text/html; charset=' . $charset);
73
        break;
74
}
75
76
# if( $helper->getConfig('mime') == 3 ){
77
#   $src = $xoopsTpl->fetch($template, $feedHandler->cached, null);
78
#   unset($xoopsOption['template_main']);
79
#   require_once XOOPS_ROOT_PATH.'/header.php';
80
#   echo '<textarea cols="90" rows="20">'.$src.'</textarea><br>';
81
#   require_once XOOPS_ROOT_PATH.'/footer.php';
82
# }
83
84
$tempString = (string)$xoopsTpl->fetch($template, $feedHandler->cached, null);
85
if (null !== $tempString && $helper->getConfig('utf8') && function_exists('mb_convert_encoding')) {
86
    echo mb_convert_encoding($tempString, 'UTF-8', _CHARSET);
0 ignored issues
show
Are you sure mb_convert_encoding($tem...ing, 'UTF-8', _CHARSET) of type array|string can be used in echo? ( Ignorable by Annotation )

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

86
    echo /** @scrutinizer ignore-type */ mb_convert_encoding($tempString, 'UTF-8', _CHARSET);
Loading history...
87
} else {
88
    $xoopsTpl->display($template, $feedHandler->cached);
89
}
90