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.

class/ReadtopicHandler.php (2 issues)

Labels
Severity
1
<?php declare(strict_types=1);
2
3
namespace XoopsModules\Newbb;
4
5
/*
6
 * You may not change or alter any portion of this comment or credits
7
 * of supporting developers from this source code or any supporting source code
8
 * which is considered copyrighted (c) material of the original comment or credit authors.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
 */
14
//  ------------------------------------------------------------------------ //
15
//  Author: phppp (D.J., [email protected])                                  //
16
//  URL: https://xoops.org                                                    //
17
//  Project: Article Project                                                 //
18
//  ------------------------------------------------------------------------ //
19
20
use XoopsModules\Newbb;
21
22
require_once __DIR__ . '/Read.php';
23
24
/**
25
 * A handler for read/unread handling
26
 *
27
 *
28
 * @author        D.J. (phppp, https://xoopsforge.com)
29
 * @copyright     copyright (c) 2005 XOOPS.org
30
 */
31
32
/**
33
 * Class ReadtopicHandler
34
 */
35
class ReadtopicHandler extends Newbb\ReadHandler
36
{
37
    /**
38
     * maximum records per forum for one user.
39
     * assigned from $GLOBALS['xoopsModuleConfig']["read_items"]
40
     *
41
     * @var int
42
     * @readonly
43
     */
44
    private int $items_per_forum;
45
46
    /**
47
     * @param \XoopsDatabase|null $db
48
     */
49
    public function __construct(\XoopsDatabase $db = null)
50
    {
51
        parent::__construct($db, 'topic');
0 ignored issues
show
It seems like $db can also be of type null; however, parameter $db of XoopsModules\Newbb\ReadHandler::__construct() does only seem to accept XoopsMySQLDatabase, 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

51
        parent::__construct(/** @scrutinizer ignore-type */ $db, 'topic');
Loading history...
52
        $newbbConfig           = \newbbLoadConfig();
53
        $this->items_per_forum = isset($newbbConfig['read_items']) ? (int)$newbbConfig['read_items'] : 100;
54
    }
55
56
    /**
57
     * clean orphan items from database
58
     *
59
     * @param string $table_link
60
     * @param string $field_link
61
     * @param string $field_object
62
     * @return bool   true on success
63
     */
64
    public function cleanOrphan($table_link = '', $field_link = '', $field_object = ''): bool //cleanOrphan()
65
    {
66
        parent::cleanOrphan($this->db->prefix('newbb_posts'), 'post_id');
67
68
        return parent::cleanOrphan($this->db->prefix('newbb_topics'), 'topic_id', 'read_item');
69
    }
70
71
    /**
72
     * Clear garbage
73
     *
74
     * Delete all expired and duplicated records
75
     */
76
    public function clearGarbage(): bool
77
    {
78
        parent::clearGarbage();
79
80
        // TODO: clearItemsExceedMaximumItemsPerForum
81
        return true;
82
    }
83
84
    /**
85
     * @param int      $status
86
     * @param int      $forum_id
87
     * @param int|null $uid
88
     * @return bool
89
     */
90
    public function setReadItems(int $status = 0, int $forum_id = 0, int $uid = null): bool
91
    {
92
        if (empty($this->mode)) {
93
            return true;
94
        }
95
96
        if (1 == $this->mode) {
97
            return $this->setReadItemsCookie($status, $forum_id);
98
        }
99
100
        return $this->setReadItemsDb($status, $forum_id, $uid);
0 ignored issues
show
It seems like $uid can also be of type null; however, parameter $uid of XoopsModules\Newbb\Readt...ndler::setReadItemsDb() 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

100
        return $this->setReadItemsDb($status, $forum_id, /** @scrutinizer ignore-type */ $uid);
Loading history...
101
    }
102
103
    /**
104
     * @param int $status
105
     * @param int $forum_id
106
     * @return bool
107
     */
108
    public function setReadItemsCookie(int $status, int $forum_id): bool
109
    {
110
        $cookie_name = 'LT';
111
        $cookie_vars = \newbbGetCookie($cookie_name, true);
112
113
        /** @var TopicHandler $itemHandler */
114
        $itemHandler = Helper::getInstance()->getHandler('Topic');
115
        $criteria    = new \CriteriaCompo(new \Criteria('forum_id', $forum_id));
116
        $criteria->setSort('topic_last_post_id');
117
        $criteria->setOrder('DESC');
118
        $criteria->setLimit($this->items_per_forum);
119
        $items = $itemHandler->getIds($criteria);
120
121
        foreach ($items as $var) {
122
            if (empty($status)) {
123
                if (isset($cookie_vars[$var])) {
124
                    unset($cookie_vars[$var]);
125
                }
126
            } else {
127
                $cookie_vars[$var] = \time(); /*$items[$var]*/
128
            }
129
        }
130
        \newbbSetCookie($cookie_name, $cookie_vars);
131
132
        return true;
133
    }
134
135
    /**
136
     * @param int $status
137
     * @param int $forum_id
138
     * @param int $uid
139
     * @return bool
140
     */
141
    public function setReadItemsDb(int $status, int $forum_id, int $uid): bool
142
    {
143
        if (empty($uid)) {
144
            if (\is_object($GLOBALS['xoopsUser'])) {
145
                $uid = $GLOBALS['xoopsUser']->getVar('uid');
146
            } else {
147
                return false;
148
            }
149
        }
150
151
        /** @var TopicHandler $itemHandler */
152
        $itemHandler    = Helper::getInstance()->getHandler('Topic');
153
        $criteria_topic = new \CriteriaCompo(new \Criteria('forum_id', $forum_id));
154
        $criteria_topic->setSort('topic_last_post_id');
155
        $criteria_topic->setOrder('DESC');
156
        $criteria_topic->setLimit($this->items_per_forum);
157
        $criteria_sticky = new \CriteriaCompo(new \Criteria('forum_id', $forum_id));
158
        $criteria_sticky->add(new \Criteria('topic_sticky', '1'));
159
160
        if (empty($status)) {
161
            $items_id  = $itemHandler->getIds($criteria_topic);
162
            $sticky_id = $itemHandler->getIds($criteria_sticky);
163
            $items     = $items_id + $sticky_id;
164
            $criteria  = new \CriteriaCompo(new \Criteria('uid', $uid));
165
            $criteria->add(new \Criteria('read_item', '(' . \implode(', ', $items) . ')', 'IN'));
166
            $this->deleteAll($criteria, true);
167
168
            return true;
169
        }
170
171
        $itemsObject  = $itemHandler->getAll($criteria_topic, ['topic_last_post_id']);
172
        $stickyObject = $itemHandler->getAll($criteria_sticky, ['topic_last_post_id']);
173
        $itemsObject  += $stickyObject;
174
        $items        = [];
175
        foreach (\array_keys($itemsObject) as $key) {
176
            $items[$key] = $itemsObject[$key]->getVar('topic_last_post_id');
177
        }
178
        unset($itemsObject, $stickyObject);
179
180
        foreach (\array_keys($items) as $key) {
181
            $this->setReadDb($key, $items[$key], $uid);
182
        }
183
184
        return true;
185
    }
186
187
    /**
188
     * @return void
189
     */
190
    public function synchronization(): void
191
    {
192
        //        return;
193
    }
194
}
195