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.

include/module.v400.php (2 issues)

Labels
1
<?php declare(strict_types=1);
2
/**
3
 * NewBB 4.3x, the forum module for XOOPS project
4
 *
5
 * @copyright      XOOPS Project (https://xoops.org)
6
 * @license        GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html)
7
 * @author         Taiwen Jiang (phppp or D.J.) <[email protected]>
8
 * @since          4.00
9
 * @return bool
10
 */
11
12
use XoopsModules\Tag;
13
14
/**
15
 * @return true
16
 */
17
function xoops_module_update_newbb_v400(XoopsModule $module): bool
18
{
19
    $statsHandler = xoops_getModuleHandler('stats', 'newbb');
20
21
    $sql = 'SELECT `forum_id`, `forum_topics`, `forum_posts` FROM ' . $GLOBALS['xoopsDB']->prefix('bb_forums');
22
    $result = $GLOBALS['xoopsDB']->query($sql);
23
    if (!$GLOBALS['xoopsDB']->isResultSet($result)) {
24
        \trigger_error("Query Failed! SQL: $sql- Error: " . $GLOBALS['xoopsDB']->error(), E_USER_ERROR);
25
    }
26
    while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
27
        $statsHandler->update($row['forum_id'], 'topic', $row['forum_topics']);
0 ignored issues
show
The method update() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler. ( Ignorable by Annotation )

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

27
        $statsHandler->/** @scrutinizer ignore-call */ 
28
                       update($row['forum_id'], 'topic', $row['forum_topics']);
Loading history...
28
        $statsHandler->update($row['forum_id'], 'post', $row['forum_posts']);
29
    }
30
31
    $sql = 'SELECT `forum_id`, SUM(topic_views) AS views FROM ' . $GLOBALS['xoopsDB']->prefix('bb_topics') . ' GROUP BY `forum_id`';
32
    $result = $GLOBALS['xoopsDB']->query($sql);
33
    if (!$GLOBALS['xoopsDB']->isResultSet($result)) {
34
        \trigger_error("Query Failed! SQL: $sql- Error: " . $GLOBALS['xoopsDB']->error(), E_USER_ERROR);
35
    }
36
    while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
37
        $statsHandler->update($row['forum_id'], 'view', $row['views']);
38
    }
39
40
    $sql = 'SELECT `forum_id`, COUNT(*) AS digests FROM ' . $GLOBALS['xoopsDB']->prefix('bb_topics') . ' WHERE topic_digest = 1 GROUP BY `forum_id`';
41
    $result = $GLOBALS['xoopsDB']->query($sql);
42
    if (!$GLOBALS['xoopsDB']->isResultSet($result)) {
43
        \trigger_error("Query Failed! SQL: $sql- Error: " . $GLOBALS['xoopsDB']->error(), E_USER_ERROR);
44
    }
45
    while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
46
        $statsHandler->update($row['forum_id'], 'digest', $row['digests']);
47
    }
48
49
    $sql = 'SELECT SUM(forum_topics) AS topics, SUM(forum_posts) AS posts FROM ' . $GLOBALS['xoopsDB']->prefix('bb_forums');
50
    $result = $GLOBALS['xoopsDB']->query($sql);
51
    if (!$GLOBALS['xoopsDB']->isResultSet($result)) {
52
        \trigger_error("Query Failed! SQL: $sql- Error: " . $GLOBALS['xoopsDB']->error(), E_USER_ERROR);
53
    }
54
    while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) {
55
        $statsHandler->update(-1, 'topic', $row['topics']);
56
        $statsHandler->update(-1, 'post', $row['posts']);
57
    }
58
59
    /*
60
    $GLOBALS['xoopsDB']->queryF(
61
            "    INSERT INTO ".$GLOBALS['xoopsDB']->prefix("bb_stats").
62
            "        (`id`, `value`, `type`, `period`, `time_update`, `time_format`)".
63
            "    SELECT `forum_id`, `forum_topics`, '".NEWBB_STATS_TYPE_TOPIC."', '".NEWBB_STATS_PERIOD_TOTAL."', NOW() + 0, ''".
64
            "         FROM ".$GLOBALS['xoopsDB']->prefix("bb_forums")
65
            );
66
    $GLOBALS['xoopsDB']->queryF(
67
            "    INSERT INTO ".$GLOBALS['xoopsDB']->prefix("bb_stats").
68
            "        (`id`, `value`, `type`, `period`, `time_update`, `time_format`)".
69
            "    SELECT `forum_id`, `forum_posts`, '".NEWBB_STATS_TYPE_POST."', '".NEWBB_STATS_PERIOD_TOTAL."', NOW() + 0, ''".
70
            "         FROM ".$GLOBALS['xoopsDB']->prefix("bb_forums")
71
            );
72
    $GLOBALS['xoopsDB']->queryF(
73
            "    INSERT INTO ".$GLOBALS['xoopsDB']->prefix("bb_stats").
74
            "        (`id`, `value`, `type`, `period`, `time_update`, `time_format`)".
75
            "    SELECT `forum_id`, count(*), '".NEWBB_STATS_TYPE_DIGEST."', '".NEWBB_STATS_PERIOD_TOTAL."', NOW() + 0, ''".
76
            "         FROM ".$GLOBALS['xoopsDB']->prefix("bb_topics").
77
            "        WHERE topic_digest = 1".
78
            "        GROUP BY `forum_id`".
79
            );
80
    $GLOBALS['xoopsDB']->queryF(
81
            "    INSERT INTO ".$GLOBALS['xoopsDB']->prefix("bb_stats").
82
            "        (`id`, `value`, `type`, `period`, `time_update`, `time_format`)".
83
            "    SELECT `forum_id`, SUM(topic_views), '".NEWBB_STATS_TYPE_VIEW."', '".NEWBB_STATS_PERIOD_TOTAL."', NOW() + 0, ''".
84
            "         FROM ".$GLOBALS['xoopsDB']->prefix("bb_topics").
85
            "        WHERE topic_digest = 1".
86
            "        GROUP BY `forum_id`".
87
            );
88
    */
89
90
    $sql = '    UPDATE '
91
           . $GLOBALS['xoopsDB']->prefix('bb_posts_text')
92
           . ' AS t, '
93
           . $GLOBALS['xoopsDB']->prefix('bb_posts')
94
           . ' AS p'
95
           . '    SET t.dohtml = p.dohtml, '
96
           . '        t.dosmiley = p.dosmiley, '
97
           . '        t.doxcode = p.doxcode, '
98
           . '        t.doimage = p.doimage, '
99
           . '        t.dobr = p.dobr'
100
           . '    WHERE p.post_id =t.post_id ';
101
    if ($GLOBALS['xoopsDB']->queryF($sql)) {
102
        $sql = '    ALTER TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_posts') . '        DROP `dohtml`,' . '        DROP `dosmiley`,' . '        DROP `doxcode`,' . '        DROP `doimage`,' . '        DROP `dobr`';
103
        $GLOBALS['xoopsDB']->queryF($sql);
104
    } else {
105
        xoops_error($GLOBALS['xoopsDB']->error() . '<br>' . $sql);
106
    }
107
108
    if (\class_exists(\XoopsModules\Tag\TagHandler::class) && xoops_isActiveModule('tag')) {
109
        $tagHandler  = \XoopsModules\Tag\Helper::getInstance()
110
                                               ->getHandler('Tag');
111
        $table_topic = $GLOBALS['xoopsDB']->prefix('bb_topics');
112
        $sql    = '    SELECT topic_id, topic_tags' . "    FROM {$table_topic}";
113
        $result = $GLOBALS['xoopsDB']->query($sql);
114
        if ($GLOBALS['xoopsDB']->isResultSet($result)) {
115
            while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result))) {
116
                if (empty($myrow['topic_tags'])) {
117
                    continue;
118
                }
119
                $tagHandler->updateByItem($myrow['topic_tags'], $myrow['topic_id'], $module->getVar('mid'));
0 ignored issues
show
It seems like $module->getVar('mid') can also be of type array and array; however, parameter $modid of XoopsModules\Tag\TagHandler::updateByItem() does only seem to accept integer|string, 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

119
                $tagHandler->updateByItem($myrow['topic_tags'], $myrow['topic_id'], /** @scrutinizer ignore-type */ $module->getVar('mid'));
Loading history...
120
            }
121
        } else {
122
            xoops_error($GLOBALS['xoopsDB']->error());
123
            //            \trigger_error("Query Failed! SQL: $sql- Error: " . $xoopsDB->error(), E_USER_ERROR);
124
125
        }
126
    }
127
128
    $sql = ' SELECT COUNT(*)
129
            FROM ' . $GLOBALS['xoopsDB']->prefix('bb_type_tmp') . ' AS a, ' . $GLOBALS['xoopsDB']->prefix('bb_type_forum_tmp') . ' AS b
130
            WHERE a.type_id = b.type_id AND a.type_id >0;';
131
    $result = $GLOBALS['xoopsDB']->query($sql);
132
    if (!$result) {
133
        //xoops_error($GLOBALS['xoopsDB']->error());
134
        $GLOBALS['xoopsDB']->queryF('DROP TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_type_tmp'));
135
        $GLOBALS['xoopsDB']->queryF('DROP TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_type_forum_tmp'));
136
137
        return true;
138
    }
139
140
    $sql = ' INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('bb_type') . '        (`type_id`, `type_name`, `type_color`)' . '    SELECT `type_id`, `type_name`, `type_color`' . '         FROM ' . $GLOBALS['xoopsDB']->prefix('bb_type_tmp');
141
    $result = $GLOBALS['xoopsDB']->queryF($sql);
142
    if (!$result){
143
    xoops_error($GLOBALS['xoopsDB']->error());
144
    }
145
146
    $sql = '    INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('bb_type_forum') . '        (`type_id`, `forum_id`, `type_order`)' . '    SELECT `type_id`, `forum_id`, `type_order`' . '         FROM ' . $GLOBALS['xoopsDB']->prefix('bb_type_forum_tmp');
147
    $result = $GLOBALS['xoopsDB']->queryF($sql);
148
    if (!$result){
149
        xoops_error($GLOBALS['xoopsDB']->error());
150
    }
151
152
    $GLOBALS['xoopsDB']->queryF('DROP TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_type_tmp'));
153
    $GLOBALS['xoopsDB']->queryF('DROP TABLE ' . $GLOBALS['xoopsDB']->prefix('bb_type_forum_tmp'));
154
155
    return true;
156
}
157