Issues (299)

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/GroupFormCheckBox.php (3 issues)

1
<?php declare(strict_types=1);
2
3
namespace XoopsModules\Smartfaq;
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
/**
16
 * @copyright    XOOPS Project (https://xoops.org)
17
 * @license      GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html)
18
 * @author       XOOPS Development Team, Kazumi Ono (AKA onokazu)
19
 */
20
21
/**
22
 * Module: SmartFAQ
23
 * Author: The SmartFactory <www.smartfactory.ca>
24
 */
25
26
use XoopsFormElement;
27
use XoopsModules\Smartfaq;
28
29
require_once XOOPS_ROOT_PATH . '/class/xoopsform/formelement.php';
30
require_once XOOPS_ROOT_PATH . '/class/xoopsform/formhidden.php';
31
require_once XOOPS_ROOT_PATH . '/class/xoopsform/formhiddentoken.php';
32
require_once XOOPS_ROOT_PATH . '/class/xoopsform/formbutton.php';
33
require_once XOOPS_ROOT_PATH . '/class/xoopsform/formelementtray.php';
34
require_once XOOPS_ROOT_PATH . '/class/xoopsform/form.php';
35
36
/**
37
 * Renders checkbox options for a group permission form
38
 *
39
 * @author      Kazumi Ono  <[email protected]>
40
 * @copyright   copyright (c) 2000-2003 XOOPS.org
41
 */
42
class GroupFormCheckBox extends XoopsFormElement
43
{
44
    /**
45
     * Pre-selected value(s)
46
     * @var array;
47
     */
48
    public $_value;
49
    /**
50
     * Group ID
51
     * @var int
52
     */
53
    public $_groupId;
54
    /**
55
     * Option tree
56
     * @var array
57
     */
58
    public $_optionTree;
59
    /**
60
     * Appendix
61
     * @var array ('permname'=>,'itemid'=>,'itemname'=>,'selected'=>)
62
     */
63
    public $_appendix = [];
64
65
    /**
66
     * Constructor
67
     * @param      $caption
68
     * @param      $name
69
     * @param      $groupId
70
     * @param null $values
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $values is correct as it would always require null to be passed?
Loading history...
71
     */
72
    public function __construct($caption, $name, $groupId, $values = null)
73
    {
74
        $this->setCaption($caption);
75
        $this->setName($name);
76
        if (null !== $values) {
0 ignored issues
show
The condition null !== $values is always false.
Loading history...
77
            $this->setValue($values);
78
        }
79
        $this->_groupId = $groupId;
80
    }
81
82
    /**
83
     * Sets pre-selected values
84
     *
85
     * @param mixed $value A group ID or an array of group IDs
86
     */
87
    public function setValue($value): void
88
    {
89
        if (\is_array($value)) {
90
            foreach ($value as $v) {
91
                $this->setValue($v);
92
            }
93
        } else {
94
            $this->_value[] = $value;
95
        }
96
    }
97
98
    /**
99
     * Sets the tree structure of items
100
     *
101
     * @param array $optionTree
102
     */
103
    public function setOptionTree(&$optionTree): void
104
    {
105
        $this->_optionTree = &$optionTree;
106
    }
107
108
    /**
109
     * Sets appendix of checkboxes
110
     *
111
     * @param $appendix
112
     */
113
    public function setAppendix($appendix): void
114
    {
115
        $this->_appendix = $appendix;
116
    }
117
118
    /**
119
     * Renders checkbox options for this group
120
     *
121
     * @return string
122
     */
123
    public function render()
124
    {
125
        $ret = '';
126
127
        if (\count($this->_appendix) > 0) {
128
            $ret  .= '<table class="outer"><tr>';
129
            $cols = 1;
130
            foreach ($this->_appendix as $append) {
131
                if ($cols > 4) {
132
                    $ret  .= '</tr><tr>';
133
                    $cols = 1;
134
                }
135
                $checked = $append['selected'] ? 'checked' : '';
136
                $name    = 'perms[' . $append['permname'] . ']';
137
                $itemid  = $append['itemid'];
0 ignored issues
show
The assignment to $itemid is dead and can be removed.
Loading history...
138
                $itemid  = $append['itemid'];
139
                $ret     .= "<td class=\"odd\"><input type=\"checkbox\" name=\"{$name}[groups][$this->_groupId][$itemid]\" id=\"{$name}[groups][$this->_groupId][$itemid]\" value=\"1\" $checked>{$append['itemname']}<input type=\"hidden\" name=\"{$name}[parents][$itemid]\" value=\"\"><input type=\"hidden\" name=\"{$name}[itemname][$itemid]\" value=\"{$append['itemname']}\"><br></td>";
140
                ++$cols;
141
            }
142
            $ret .= '</tr></table>';
143
        }
144
145
        $ret  .= '<table class="outer"><tr>';
146
        $cols = 1;
147
        foreach ($this->_optionTree[0]['children'] as $topitem) {
148
            if ($cols > 4) {
149
                $ret  .= '</tr><tr>';
150
                $cols = 1;
151
            }
152
            $tree   = '<td class="odd">';
153
            $prefix = '';
154
            $this->renderOptionTree($tree, $this->_optionTree[$topitem], $prefix);
155
            $ret .= $tree . '</td>';
156
            ++$cols;
157
        }
158
        $ret .= '</tr></table>';
159
160
        return $ret;
161
    }
162
163
    /**
164
     * Renders checkbox options for an item tree
165
     *
166
     * @param string $tree
167
     * @param array  $option
168
     * @param string $prefix
169
     * @param array  $parentIds
170
     */
171
    private function renderOptionTree(&$tree, $option, $prefix, $parentIds = []): void
172
    {
173
        $tree .= $prefix . '<input type="checkbox" name="' . $this->getName() . '[groups][' . $this->_groupId . '][' . $option['id'] . ']" id="' . $this->getName() . '[groups][' . $this->_groupId . '][' . $option['id'] . ']" onclick="';
174
        // If there are parent elements, add javascript that will
175
        // make them selecteded when this element is checked to make
176
        // sure permissions to parent items are added as well.
177
        foreach ($parentIds as $pid) {
178
            $parent_ele = $this->getName() . '[groups][' . $this->_groupId . '][' . $pid . ']';
179
            $tree       .= "var ele = xoopsGetElementById('" . $parent_ele . "'); if (ele.checked !== true) {ele.checked = this.checked;}";
180
        }
181
        // If there are child elements, add javascript that will
182
        // make them unchecked when this element is unchecked to make
183
        // sure permissions to child items are not added when there
184
        // is no permission to this item.
185
        foreach ($option['allchild'] as $cid) {
186
            $child_ele = $this->getName() . '[groups][' . $this->_groupId . '][' . $cid . ']';
187
            $tree      .= "var ele = xoopsGetElementById('" . $child_ele . "'); if (this.checked !== true) {ele.checked = false;}";
188
        }
189
        $tree .= '" value="1"';
190
        if (null !== $this->_value && \in_array($option['id'], $this->_value, true)) {
191
            $tree .= ' checked';
192
        }
193
        $tree .= '>' . $option['name'] . '<input type="hidden" name="' . $this->getName() . '[parents][' . $option['id'] . ']" value="' . \implode(':', $parentIds) . '"><input type="hidden" name="' . $this->getName() . '[itemname][' . $option['id'] . ']" value="' . \htmlspecialchars(
194
                $option['name'],
195
                \ENT_QUOTES
196
            ) . "\"><br>\n";
197
        if (isset($option['children'])) {
198
            foreach ($option['children'] as $child) {
199
                $parentIds[] = $option['id'];
200
                $this->renderOptionTree($tree, $this->_optionTree[$child], $prefix . '&nbsp;-', $parentIds);
201
            }
202
        }
203
    }
204
}
205