Issues (340)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  Header Injection
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.
Labels
Severity
1
<?php declare(strict_types=1);
2
3
/*
4
 * You may not change or alter any portion of this comment or credits
5
 * of supporting developers from this source code or any supporting source code
6
 * which is considered copyrighted (c) material of the original comment or credit authors.
7
 *
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 */
12
13
/**
14
 * @copyright    XOOPS Project (https://xoops.org)/
15
 * @license      GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html)
16
 * @author       phppp (D.J., [email protected])
17
 * @author       XOOPS Development Team
18
 */
19
20
use Xmf\Request;
21
use XoopsModules\Newbb\{
22
    TypeHandler,
23
    XmlrssHandler,
24
    ForumHandler,
25
    TopicHandler
26
};
27
/** @var TypeHandler $typeHandler */
28
/** @var XmlrssHandler $xmlrssHandler */
29
require_once __DIR__ . '/header.php';
30
require_once $GLOBALS['xoops']->path('class/template.php');
31
require_once $GLOBALS['xoops']->path('modules/newbb/include/functions.rpc.php');
32
33
if (!empty($GLOBALS['xoopsModuleConfig']['do_rewrite'])) {
34
    require_once __DIR__ . '/seo_url.php';
35
}
36
/* for seo */
37
38
error_reporting(E_ALL);
39
$xoopsLogger->activated = false;
40
41
$forums   = [];
42
$category = Request::getInt('c', 0, 'GET');
43
$forumSet = Request::getString('f', '', 'GET');
44
if ('' !== $forumSet) {
45
    $forums = array_map('\intval', array_map('\trim', explode('|', (string) $forumSet)));
46
}
47
48
///** @var ForumHandler $forumHandler */
49
//$forumHandler = Helper::getInstance()->getHandler('Forum');
50
//$topicHandler = Helper::getInstance()->getHandler('Topic');
51
$validForums = $forumHandler->getIdsByPermission(); // get all accessible forums
52
53
if ($forums && is_array($forums)) {
54
    $validForums = array_intersect($forums, $validForums);
55
} elseif ($category > 0) {
56
    $crit_top = new \CriteriaCompo(new \Criteria('cat_id', (string)$category));
57
    $crit_top->add(new \Criteria('forum_id', '(' . implode(', ', $validForums) . ')', 'IN'));
58
    $forums_top  = $forumHandler->getIds($crit_top);
59
    $validForums = array_intersect($forums_top, $validForums);
60
}
61
if (0 === (is_countable($validForums) ? count($validForums) : 0)) {
62
    newbbTrackbackResponse(1, _NOPERM);
63
}
64
65
asort($validForums);
66
$forumSet = implode(',', $validForums);
67
68
$charset = 'UTF-8';
69
header('Content-Type:text/xml; charset=' . $charset);
70
71
/** @var \XoopsTpl $tpl */
72
$tpl                 = new \XoopsTpl();
73
$tpl->caching        = 2;
74
$tpl->cache_lifetime = $GLOBALS['xoopsModuleConfig']['rss_cachetime'] * 60;
75
if (!empty($GLOBALS['xoopsConfig']['rewrite'])) {
76
    $tpl->load_filter('output', 'xoRewriteModule');
77
}
78
79
//mod_loadFunctions('cache');
80
$xoopsCachedTemplateId = "newbbb_rss_$forumSet";
81
$compile_id            = null;
82
$type_list = null;
83
$users = null;
84
if (!$tpl->is_cached('db:newbb_rss.tpl', $xoopsCachedTemplateId, $compile_id)) {
85
    require_once __DIR__ . '/include/functions.time.php';
86
87
    //    $xmlrssHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Xmlrss');
88
    $rss = $xmlrssHandler->create();
89
90
    $rss->setVarRss('channel_title', $GLOBALS['xoopsConfig']['sitename'] . ' :: ' . _MD_NEWBB_FORUM);
91
    $rss->channel_link = XOOPS_URL . '/';
92
    $rss->setVarRss('channel_desc', $GLOBALS['xoopsConfig']['slogan'] . ' :: ' . $xoopsModule->getInfo('description'));
93
    $rss->setVarRss('channel_lastbuild', formatTimestamp(time(), 'rss'));
94
    $rss->channel_webmaster = $GLOBALS['xoopsConfig']['adminmail'];
95
    $rss->channel_editor    = $GLOBALS['xoopsConfig']['adminmail'];
96
    $rss->setVarRss('channel_category', $xoopsModule->getVar('name'));
97
    $rss->channel_generator = 'NewBB ' . $xoopsModule->getInfo('version');
98
    $rss->channel_language  = _LANGCODE;
99
    $rss->xml_encoding      = $charset;
100
    $rss->image_url         = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/' . $xoopsModule->getInfo('image');
101
102
    $dimension = @getimagesize($GLOBALS['xoops']->path('modules/' . $xoopsModule->getVar('dirname') . '/' . $xoopsModule->getInfo('image')));
103
    if (empty($dimension[0])) {
104
        $width = 88;
105
    } else {
106
        $width = ($dimension[0] > 144) ? 144 : $dimension[0];
107
    }
108
    if (empty($dimension[1])) {
109
        $height = 31;
110
    } else {
111
        $height = ($dimension[1] > 400) ? 400 : $dimension[1];
112
    }
113
    $rss->image_width  = $width;
114
    $rss->image_height = $height;
115
116
    $rss->max_items            = $GLOBALS['xoopsModuleConfig']['rss_maxitems'];
117
    $rss->max_item_description = $GLOBALS['xoopsModuleConfig']['rss_maxdescription'];
118
119
    $forumCriteria = ' AND t.forum_id IN (' . implode(',', $validForums) . ')';
120
    unset($validForums);
121
    $approveCriteria = ' AND t.approved = 1 AND p.approved = 1';
122
123
    $sql = 'SELECT'
124
             . '    f.forum_id, f.forum_name,'
125
             . '    t.topic_id, t.topic_title, t.type_id,'
126
             . '    p.post_id, p.post_time, p.subject, p.uid, p.poster_name, p.post_karma, p.require_reply, '
127
             . '    pt.dohtml, pt.dosmiley, pt.doxcode, pt.dobr,'
128
             . '    pt.post_text'
129
             . '    FROM '
130
             . $GLOBALS['xoopsDB']->prefix('newbb_posts')
131
             . ' AS p'
132
             . '    LEFT JOIN '
133
             . $GLOBALS['xoopsDB']->prefix('newbb_topics')
134
             . ' AS t ON t.topic_last_post_id=p.post_id'
135
             . '    LEFT JOIN '
136
             . $GLOBALS['xoopsDB']->prefix('newbb_posts_text')
137
             . ' AS pt ON pt.post_id=p.post_id'
138
             . '    LEFT JOIN '
139
             . $GLOBALS['xoopsDB']->prefix('newbb_forums')
140
             . ' AS f ON f.forum_id=p.forum_id'
141
             . '    WHERE 1=1 '
142
             . $forumCriteria
143
             . $approveCriteria
144
             . ' ORDER BY p.post_id DESC';
145
    $limit = (int)($GLOBALS['xoopsModuleConfig']['rss_maxitems'] * 1.5);
146
    $result = $GLOBALS['xoopsDB']->query($sql, $limit);
147
    if (!$GLOBALS['xoopsDB']->isResultSet($result)) {
148
        //                \trigger_error("Query Failed! SQL: $sql- Error: " . $GLOBALS['xoopsDB']->error(), E_USER_ERROR);
149
        newbbTrackbackResponse(1, _MD_NEWBB_ERROR);
150
        //xoops_error($GLOBALS['xoopsDB']->error());
151
        //return $xmlrssHandler->get($rss);
152
    }
153
    $rows  = [];
154
    $types = [];
155
    while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
156
        $users[$row['uid']] = 1;
157
        if ($row['type_id'] > 0) {
158
            $types[$row['type_id']] = 1;
159
        }
160
        $rows[] = $row;
161
    }
162
163
    if (count($rows) < 1) {
164
        newbbTrackbackResponse(1, _MD_NEWBB_NORSS_DATA);
165
        //return $xmlrssHandler->get($rss);
166
    }
167
    $users = newbbGetUnameFromIds(array_keys($users), $GLOBALS['xoopsModuleConfig']['show_realname']);
0 ignored issues
show
$users of type null is incompatible with the type array expected by parameter $array of array_keys(). ( Ignorable by Annotation )

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

167
    $users = newbbGetUnameFromIds(array_keys(/** @scrutinizer ignore-type */ $users), $GLOBALS['xoopsModuleConfig']['show_realname']);
Loading history...
168
    if (count($types) > 0) {
169
        //        $typeHandler = \XoopsModules\Newbb\Helper::getInstance()->getHandler('Type');
170
        $type_list = $typeHandler->getList(new \Criteria('type_id', '(' . implode(', ', array_keys($types)) . ')', 'IN'));
171
    }
172
173
    foreach ($rows as $topic) {
174
        if ($topic['post_karma'] > 0 && $GLOBALS['xoopsModuleConfig']['enable_karma']) {
175
            continue;
176
        }
177
        if ($topic['require_reply'] && $GLOBALS['xoopsModuleConfig']['allow_require_reply']) {
178
            continue;
179
        }
180
        if (!empty($users[$topic['uid']])) {
181
            $topic['uname'] = $users[$topic['uid']];
182
        } else {
183
            $topic['uname'] = $topic['poster_name'] ? htmlspecialchars((string)$topic['poster_name'], ENT_QUOTES | ENT_HTML5) : htmlspecialchars((string)$GLOBALS['xoopsConfig']['anonymous'], ENT_QUOTES | ENT_HTML5);
184
        }
185
        $description            = $topic['forum_name'] . '::';
186
        $topic['topic_subject'] = empty($type_list[$topic['type_id']]) ? '' : '[' . $type_list[$topic['type_id']] . '] ';
187
        $description            .= $topic['topic_subject'] . $topic['topic_title'] . "<br>\n";
188
        $description            .= $myts->displayTarea($topic['post_text'], $topic['dohtml'], $topic['dosmiley'], $topic['doxcode'], $topic['dobr']);
189
        $label                  = _MD_NEWBB_BY . ' ' . $topic['uname'];
190
        $time                   = formatTimestamp($topic['post_time'], 'rss');
191
        $link                   = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewtopic.php?post_id=' . $topic['post_id'] . '';
192
        if (!empty($GLOBALS['xoopsModuleConfig']['do_rewrite'])) {
193
            $link   = XOOPS_URL . '/' . REAL_MODULE_NAME . '/viewtopic.php?post_id=' . $topic['post_id'] . '';
194
            $oldurl = '<a href=\'' . $link . '\'>';
195
            $newurl = seo_urls($oldurl);
196
            $newurl = str_replace('<a href=\'', '', $newurl);
197
            $newurl = str_replace('\'>', '', $newurl);
198
            $link   = $newurl;
199
        }
200
        $title = $topic['subject'];
201
        if (false === $rss->addItem($title, $link, $description, $label, $time)) {
202
            break;
203
        }
204
    }
205
206
    $rss_feed = $xmlrssHandler->get($rss);
207
208
    $tpl->assign('rss', $rss_feed);
209
    unset($rss);
210
}
211
$tpl->display('db:newbb_rss.tpl', $xoopsCachedTemplateId, $compile_id);
212