Issues (314)

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/Tables.php (6 issues)

1
<?php
2
3
namespace XoopsModules\Modulebuilder;
4
5
use XoopsModules\Modulebuilder;
6
7
/*
8
 You may not change or alter any portion of this comment or credits
9
 of supporting developers from this source code or any supporting source code
10
 which is considered copyrighted (c) material of the original comment or credit authors.
11
12
 This program is distributed in the hope that it will be useful,
13
 but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
 */
16
17
/**
18
 * modulebuilder module.
19
 *
20
 * @copyright       XOOPS Project (https://xoops.org)
21
 * @license         GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
22
 *
23
 * @since           2.5.7
24
 *
25
 * @author          Txmod Xoops <[email protected]> - <https://xoops.org/>
26
 *
27
 */
28
29
/**
30
 * Class Tables.
31
 */
32
class Tables extends \XoopsObject
33
{
34
    /**
35
     * Options.
36
     */
37
    public $options = [
38
        'install',
39
        'index',
40
        'blocks',
41
        'admin',
42
        'user',
43
        'submenu',
44
        'submit',
45
        'tag',
46
        'broken',
47
        'search',
48
        'comments',
49
        'notifications',
50
        'permissions',
51
        'rate',
52
        'print',
53
        'pdf',
54
        'rss',
55
        'reads',
56
        //'single',
57
        //'visit',
58
    ];
59
60
    /**
61
     * @public function constructor class
62
     * @param null
63
     */
64
    public function __construct()
65
    {
66
        $this->initVar('table_id', XOBJ_DTYPE_INT);
67
        $this->initVar('table_mid', XOBJ_DTYPE_INT);
68
        $this->initVar('table_category', XOBJ_DTYPE_INT);
69
        $this->initVar('table_name', XOBJ_DTYPE_TXTBOX);
70
        $this->initVar('table_solename', XOBJ_DTYPE_TXTBOX);
71
        $this->initVar('table_fieldname', XOBJ_DTYPE_TXTBOX);
72
        $this->initVar('table_nbfields', XOBJ_DTYPE_INT);
73
        $this->initVar('table_order', XOBJ_DTYPE_INT);
74
        $this->initVar('table_image', XOBJ_DTYPE_TXTBOX);
75
        $this->initVar('table_autoincrement', XOBJ_DTYPE_INT);
76
        $this->initVar('table_install', XOBJ_DTYPE_INT);
77
        $this->initVar('table_index', XOBJ_DTYPE_INT);
78
        $this->initVar('table_blocks', XOBJ_DTYPE_INT);
79
        $this->initVar('table_admin', XOBJ_DTYPE_INT);
80
        $this->initVar('table_user', XOBJ_DTYPE_INT);
81
        $this->initVar('table_submenu', XOBJ_DTYPE_INT);
82
        $this->initVar('table_submit', XOBJ_DTYPE_INT);
83
        $this->initVar('table_tag', XOBJ_DTYPE_INT);
84
        $this->initVar('table_broken', XOBJ_DTYPE_INT);
85
        $this->initVar('table_search', XOBJ_DTYPE_INT);
86
        $this->initVar('table_comments', XOBJ_DTYPE_INT);
87
        $this->initVar('table_notifications', XOBJ_DTYPE_INT);
88
        $this->initVar('table_permissions', XOBJ_DTYPE_INT);
89
        $this->initVar('table_rate', XOBJ_DTYPE_INT);
90
        $this->initVar('table_print', XOBJ_DTYPE_INT);
91
        $this->initVar('table_pdf', XOBJ_DTYPE_INT);
92
        $this->initVar('table_rss', XOBJ_DTYPE_INT);
93
        $this->initVar('table_reads', XOBJ_DTYPE_INT);
94
        $this->initVar('table_single', XOBJ_DTYPE_INT);
95
        $this->initVar('table_visit', XOBJ_DTYPE_INT);
96
    }
97
98
    /**
99
     * @param string $method
100
     * @param array  $args
101
     *
102
     * @return mixed
103
     */
104
    public function __call($method, $args)
105
    {
106
        $arg = isset($args[0]) ? $args[0] : null;
107
108
        return $this->getVar($method, $arg);
109
    }
110
111
    /**
112
     * @static function getInstance
113
     * @param null
114
     * @return Tables
115
     */
116
    public static function getInstance()
117
    {
118
        static $instance = false;
119
        if (!$instance) {
120
            $instance = new self();
121
        }
122
123
        return $instance;
124
    }
125
126
    /**
127
     * @static function getFormTables
128
     * @param mixed $action
129
     *
130
     * @return \XoopsThemeForm
131
     */
132
    public function getFormTables($action = false)
133
    {
134
        if (false === $action) {
135
            $action = \Xmf\Request::getString('REQUEST_URI', '', 'SERVER');
136
        }
137
        $helper    = Modulebuilder\Helper::getInstance();
138
        $isNew     = $this->isNew();
139
        $tableName = $this->getVar('table_name');
140
        $tableMid  = $this->getVar('table_mid');
141
        $title     = $isNew ? \sprintf(\_AM_MODULEBUILDER_TABLES_NEW) : \sprintf(\_AM_MODULEBUILDER_TABLES_EDIT);
142
143
        \xoops_load('XoopsFormLoader');
144
        $form = new \XoopsThemeForm($title, 'tableform', $action, 'post', true);
145
        $form->setExtra('enctype="multipart/form-data"');
146
147
        $modules       = $helper->getHandler('Modules')->getObjects(null);
148
        $modulesSelect = new \XoopsFormSelect(\_AM_MODULEBUILDER_TABLE_MODULES, 'table_mid', $tableMid);
149
        $modulesSelect->addOption('', \_AM_MODULEBUILDER_TABLE_MODSELOPT);
150
        foreach ($modules as $mod) {
151
            $modulesSelect->addOption($mod->getVar('mod_id'), $mod->getVar('mod_name'));
152
        }
153
        $form->addElement($modulesSelect, true);
154
155
        $tableNameText = new \XoopsFormText(\_AM_MODULEBUILDER_TABLE_NAME, 'table_name', 40, 150, $tableName);
0 ignored issues
show
It seems like $tableName can also be of type array and array; however, parameter $value of XoopsFormText::__construct() does only seem to accept 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

155
        $tableNameText = new \XoopsFormText(\_AM_MODULEBUILDER_TABLE_NAME, 'table_name', 40, 150, /** @scrutinizer ignore-type */ $tableName);
Loading history...
156
        $tableNameText->setDescription(\_AM_MODULEBUILDER_TABLE_NAME_DESC);
157
        $form->addElement($tableNameText, true);
158
159
        $tableSoleNameText = new \XoopsFormText(\_AM_MODULEBUILDER_TABLE_SOLENAME, 'table_solename', 40, 150, $this->getVar('table_solename'));
160
        $tableSoleNameText->setDescription(\_AM_MODULEBUILDER_TABLE_SOLENAME_DESC);
161
        $form->addElement($tableSoleNameText, true);
162
163
        $radioCategory = $isNew ? 0 : $this->getVar('table_category');
164
        $category      = new \XoopsFormRadioYN(\_AM_MODULEBUILDER_TABLE_CATEGORY, 'table_category', $radioCategory);
0 ignored issues
show
It seems like $radioCategory can also be of type array and array; however, parameter $value of XoopsFormRadioYN::__construct() does only seem to accept 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

164
        $category      = new \XoopsFormRadioYN(\_AM_MODULEBUILDER_TABLE_CATEGORY, 'table_category', /** @scrutinizer ignore-type */ $radioCategory);
Loading history...
165
        $category->setDescription(\_AM_MODULEBUILDER_TABLE_CATEGORY_DESC);
166
        $form->addElement($category);
167
168
        $tableFieldname = new \XoopsFormText(\_AM_MODULEBUILDER_TABLE_FIELDNAME, 'table_fieldname', 30, 50, $this->getVar('table_fieldname'));
169
        $tableFieldname->setDescription(\_AM_MODULEBUILDER_TABLE_FIELDNAME_DESC);
170
        $form->addElement($tableFieldname);
171
172
        $tableNumbFileds = new \XoopsFormText(\_AM_MODULEBUILDER_TABLE_NBFIELDS, 'table_nbfields', 10, 25, $this->getVar('table_nbfields'));
173
        $tableNumbFileds->setDescription(\_AM_MODULEBUILDER_TABLE_NBFIELDS_DESC);
174
        $form->addElement($tableNumbFileds, true);
175
176
        if (!$isNew) {
177
            $tableOrder = new \XoopsFormText(\_AM_MODULEBUILDER_TABLE_ORDER, 'table_order', 5, 10, $this->getVar('table_order'));
178
            $tableOrder->setDescription(\_AM_MODULEBUILDER_TABLE_ORDER_DESC);
179
            $form->addElement($tableOrder, true);
180
        }
181
182
        $getTableImage    = $this->getVar('table_image');
183
        $tableImage       = $getTableImage ?: 'blank.gif';
184
        $icons32Directory = '/Frameworks/moduleclasses/icons/32';
185
        $uploadsDirectory = '/uploads/modulebuilder/images/tables';
186
        $iconsDirectory   = \is_dir(\XOOPS_ROOT_PATH . $icons32Directory) ? $icons32Directory : $uploadsDirectory;
187
188
        $imgtray1     = new \XoopsFormElementTray(\_AM_MODULEBUILDER_TABLE_IMAGE, '<br>');
189
        $imgpath1     = \sprintf(\_AM_MODULEBUILDER_FORMIMAGE_PATH, ".{$iconsDirectory}/");
190
        $imageSelect1 = new \XoopsFormSelect($imgpath1, 'table_image', $tableImage, 10);
191
        $imageArray1  = \XoopsLists::getImgListAsArray(\XOOPS_ROOT_PATH . $iconsDirectory);
192
        foreach ($imageArray1 as $image1) {
193
            $imageSelect1->addOption($image1, $image1);
194
        }
195
        $imageSelect1->setExtra("onchange='showImgSelected(\"image1\", \"table_image\", \"" . $iconsDirectory . '", "", "' . \XOOPS_URL . "\")'");
196
        $imgtray1->addElement($imageSelect1, false);
197
        $imgtray1->addElement(new \XoopsFormLabel('', "<br><img src='" . \XOOPS_URL . '/' . $iconsDirectory . '/' . $tableImage . "' id='image1' alt='' />"));
198
        $fileseltray1 = new \XoopsFormElementTray('', '<br>');
199
        $fileseltray1->addElement(new \XoopsFormFile(\_AM_MODULEBUILDER_FORMUPLOAD, 'attachedfile', $helper->getConfig('maxsize_image')));
200
        $fileseltray1->addElement(new \XoopsFormLabel(''));
201
        $imgtray1->addElement($fileseltray1);
202
        $imgtray1->setDescription(\_AM_MODULEBUILDER_TABLE_IMAGE_DESC);
203
        $form->addElement($imgtray1);
204
205
        $tableAutoincrement      = $this->isNew() ? 1 : $this->getVar('table_autoincrement');
206
        $checkTableAutoincrement = new \XoopsFormRadioYN(\_AM_MODULEBUILDER_TABLE_AUTO_INCREMENT, 'table_autoincrement', $tableAutoincrement);
207
        $checkTableAutoincrement->setDescription(\_AM_MODULEBUILDER_TABLE_AUTO_INCREMENT_DESC);
208
        $form->addElement($checkTableAutoincrement);
209
210
        $optionsTray = new \XoopsFormElementTray(_OPTIONS, '<br>');
211
212
        $tableCheckAll = new \XoopsFormCheckBox('', 'tablebox', 1);
213
        $tableCheckAll->addOption('allbox', \_AM_MODULEBUILDER_TABLE_ALL);
214
        $tableCheckAll->setExtra(' onclick="xoopsCheckAll(\'tableform\', \'tablebox\');" ');
215
        $tableCheckAll->setClass('xo-checkall');
216
        $optionsTray->addElement($tableCheckAll);
217
        // Options
218
        $checkbox = new \XoopsFormCheckbox(' ', 'table_option', $this->getOptionsTables(), '<br>');
219
        $checkbox->setDescription(\_AM_MODULEBUILDER_OPTIONS_DESC);
220
        foreach ($this->options as $option) {
221
            $checkbox->addOption($option, self::getDefinedLanguage('\_AM_MODULEBUILDER_TABLE_' . \mb_strtoupper($option)));
222
        }
223
        $optionsTray->addElement($checkbox);
224
225
        $optionsTray->setDescription(\_AM_MODULEBUILDER_TABLE_OPTIONS_CHECKS_DESC);
226
227
        $form->addElement($optionsTray);
228
229
        $buttonTray = new \XoopsFormElementTray(_REQUIRED . ' <sup class="red bold">*</sup>', '');
230
        $buttonTray->addElement(new \XoopsFormHidden('op', 'save'));
231
        $buttonTray->addElement(new \XoopsFormHidden('table_id', ($isNew ? 0 : $this->getVar('table_id'))));
0 ignored issues
show
It seems like $isNew ? 0 : $this->getVar('table_id') can also be of type array and array; however, parameter $value of XoopsFormHidden::__construct() does only seem to accept 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

231
        $buttonTray->addElement(new \XoopsFormHidden('table_id', /** @scrutinizer ignore-type */ ($isNew ? 0 : $this->getVar('table_id'))));
Loading history...
232
        $buttonTray->addElement(new \XoopsFormButton('', 'submit', \_SUBMIT, 'submit'));
233
        $form->addElement($buttonTray);
234
235
        return $form;
236
    }
237
238
    /**
239
     * Get Values.
240
     *
241
     * @param null $keys
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $keys is correct as it would always require null to be passed?
Loading history...
242
     * @param null $format
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $format is correct as it would always require null to be passed?
Loading history...
243
     * @param null $maxDepth
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $maxDepth is correct as it would always require null to be passed?
Loading history...
244
     *
245
     * @return array
246
     */
247
    public function getValuesTables($keys = null, $format = null, $maxDepth = null)
248
    {
249
        $helper = Modulebuilder\Helper::getInstance();
250
251
        $ret = $this->getValues($keys, $format, $maxDepth);
252
        // Values
253
        $ret['id']  = $this->getVar('table_id');
254
        $ret['mid'] = $this->getVar('table_mid');
255
        $modulesObj = $helper->getHandler('Modules')->get($ret['mid']);
256
        if (\is_object($modulesObj)) {
257
            $ret['module'] = $modulesObj->getVar('mod_name');
258
        }
259
        $ret['name']          = \ucfirst($this->getVar('table_name'));
260
        $ret['image']         = $this->getVar('table_image');
261
        $ret['nbfields']      = $this->getVar('table_nbfields');
262
        $ret['order']         = $this->getVar('table_order');
263
        $ret['blocks']        = $this->getVar('table_blocks');
264
        $ret['admin']         = $this->getVar('table_admin');
265
        $ret['user']          = $this->getVar('table_user');
266
        $ret['submenu']       = $this->getVar('table_submenu');
267
        $ret['search']        = $this->getVar('table_search');
268
        $ret['comments']      = $this->getVar('table_comments');
269
        $ret['notifications'] = $this->getVar('table_notifications');
270
        $ret['permissions']   = $this->getVar('table_permissions');
271
272
        return $ret;
273
    }
274
275
    /**
276
     * Get Options.
277
     *
278
     * @return array
279
     */
280
    public function getOptionsTables()
281
    {
282
        $retTable = [];
283
        foreach ($this->options as $option) {
284
            if (1 == $this->getVar('table_' . $option)) {
285
                $retTable[] = $option;
286
            }
287
        }
288
289
        return $retTable;
290
    }
291
292
    /**
293
     * Get Defined Language.
294
     *
295
     * @param $lang
296
     *
297
     * @return string
298
     */
299
    private static function getDefinedLanguage($lang)
300
    {
301
        if (\defined($lang)) {
302
            return \constant($lang);
303
        }
304
305
        return $lang;
306
    }
307
}
308