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