Issues (432)

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/oninstall.php (2 issues)

1
<?php declare(strict_types=1);
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
12
/**
13
 * @category        Module
14
 * @copyright       {@link https://xoops.org/ XOOPS Project}
15
 * @license         GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html)
16
 * @author          Jan Pedersen
17
 * @author          Taiwen Jiang <[email protected]>
18
 */
19
20
use XoopsModules\Suico\{
21
    Common\Configurator,
22
    Helper,
23
    Utility
24
};
25
/** @var Helper $helper */
26
/** @var Utility $utility */
27
/** @var Configurator $configurator */
28
include \dirname(
29
            __DIR__
30
        ) . '/preloads/autoloader.php';
31
/**
32
 * Prepares system prior to attempting to install module
33
 * @param \XoopsModule $module {@link XoopsModule}
34
 *
35
 * @return bool true if ready to install, false if not
36
 */
37
function xoops_module_pre_install_suico(
38
    XoopsModule $module
39
) {
40
    require __DIR__ . '/common.php';
41
    $utility = new Utility();
42
    //check for minimum XOOPS version
43
    $xoopsSuccess = $utility::checkVerXoops($module);
44
    // check for minimum PHP version
45
    $phpSuccess = $utility::checkVerPhp($module);
46
    if ($xoopsSuccess && $phpSuccess) {
47
        $moduleTables = &$module->getInfo('tables');
48
        foreach ($moduleTables as $table) {
49
            $GLOBALS['xoopsDB']->queryF('DROP TABLE IF EXISTS ' . $GLOBALS['xoopsDB']->prefix($table) . ';');
50
        }
51
    }
52
53
    return $xoopsSuccess && $phpSuccess;
54
}
55
56
/**
57
 * Performs tasks required during installation of the module
58
 * @param \XoopsModule $module {@link XoopsModule}
59
 *
60
 * @return bool true if installation successful, false if not
61
 */
62
function xoops_module_install_suico(XoopsModule $module)
63
{
64
    global $module_id;
65
    $module_id = $module->getVar('mid');
66
    xoops_loadLanguage('user');
67
    require_once \dirname(__DIR__) . '/preloads/autoloader.php';
68
    $moduleDirName = \basename(\dirname(__DIR__));
69
    // Create registration steps
70
    suico_install_addStep(_MI_SUICO_STEP_BASIC, '', 1, 1);
71
    // Create categories
72
    suico_install_addCategory(_MI_SUICO_CATEGORY_PERSONAL, 1);
73
    suico_install_addCategory(_MI_SUICO_CATEGORY_MESSAGING, 2);
74
    suico_install_addCategory(_MI_SUICO_CATEGORY_SETTINGS, 3);
75
    suico_install_addCategory(_MI_SUICO_CATEGORY_COMMUNITY, 4);
76
    // Add user fields
77
    xoops_loadLanguage('notification');
78
    xoops_loadLanguage('main', $module->getVar('dirname', 'n'));
0 ignored issues
show
It seems like $module->getVar('dirname', 'n') can also be of type array and array; however, parameter $domain of xoops_loadLanguage() 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

78
    xoops_loadLanguage('main', /** @scrutinizer ignore-type */ $module->getVar('dirname', 'n'));
Loading history...
79
    require_once $GLOBALS['xoops']->path('include/notification_constants.php');
80
    $umode_options         = [
81
        'nest'   => _NESTED,
82
        'flat'   => _FLAT,
83
        'thread' => _THREADED,
84
    ];
85
    $uorder_options        = [
86
        0 => _OLDESTFIRST,
87
        1 => _NEWESTFIRST,
88
    ];
89
    $notify_mode_options   = [
90
        XOOPS_NOTIFICATION_MODE_SENDALWAYS         => _NOT_MODE_SENDALWAYS,
91
        XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE => _NOT_MODE_SENDONCE,
92
        XOOPS_NOTIFICATION_MODE_SENDONCETHENWAIT   => _NOT_MODE_SENDONCEPERLOGIN,
93
    ];
94
    $notify_method_options = [
95
        XOOPS_NOTIFICATION_METHOD_DISABLE => _NOT_METHOD_DISABLE,
96
        XOOPS_NOTIFICATION_METHOD_PM      => _NOT_METHOD_PM,
97
        XOOPS_NOTIFICATION_METHOD_EMAIL   => _NOT_METHOD_EMAIL,
98
    ];
99
    suico_install_addField('name', _US_REALNAME, '', 1, 'textbox', 1, 1, 1, [], 0, 255);
100
    suico_install_addField('user_from', _US_LOCATION, '', 1, 'textbox', 1, 2, 1, [], 0, 255);
101
    suico_install_addField('user_occ', _US_OCCUPATION, '', 1, 'textbox', 1, 3, 1, [], 0, 255);
102
    suico_install_addField('user_intrest', _US_INTEREST, '', 1, 'textbox', 1, 4, 1, [], 0, 255);
103
    suico_install_addField('bio', _US_EXTRAINFO, '', 1, 'textarea', 2, 5, 1, [], 0, 0);
104
    suico_install_addField('user_sig', _US_SIGNATURE, '', 1, 'dhtml', 1, 6, 1, [], 0, 0);
105
    suico_install_addField('url', _MI_SUICO_URL_TITLE, '', 1, 'textbox', 1, 7, 1, [], 0, 255, false);
106
    suico_install_addField('timezone_offset', _US_TIMEZONE, '', 3, 'timezone', 1, 0, 1, [], 0, 0, false);
107
    suico_install_addField('user_viewemail', _US_ALLOWVIEWEMAIL, '', 3, 'yesno', 3, 1, 1, [], 0, 1, false);
108
    suico_install_addField('attachsig', _US_SHOWSIG, '', 3, 'yesno', 3, 2, 1, [], 0, 1, false);
109
    suico_install_addField('user_mailok', _US_MAILOK, '', 3, 'yesno', 3, 3, 1, [], 0, 1, false);
110
    suico_install_addField('theme', _MD_SUICO_THEME, '', 3, 'theme', 1, 4, 1, [], 0, 0, false);
111
    suico_install_addField('umode', _US_CDISPLAYMODE, '', 3, 'select', 1, 5, 1, $umode_options, 0, 0, false);
112
    suico_install_addField('uorder', _US_CSORTORDER, '', 3, 'select', 3, 6, 1, $uorder_options, 0, 0, false);
113
    suico_install_addField('notify_mode', _NOT_NOTIFYMODE, '', 3, 'select', 3, 7, 1, $notify_mode_options, 0, 0, false);
114
    suico_install_addField('notify_method', _NOT_NOTIFYMETHOD, '', 3, 'select', 3, 8, 1, $notify_method_options, 0, 0, false);
115
    suico_install_addField('user_regdate', _US_MEMBERSINCE, '', 4, 'datetime', 3, 1, 0, [], 0, 10);
116
    suico_install_addField('posts', _US_POSTS, '', 4, 'textbox', 3, 2, 0, [], 0, 255);
117
    suico_install_addField('rank', _US_RANK, '', 4, 'rank', 3, 3, 2, [], 0, 0);
118
    suico_install_addField('last_login', _US_LASTLOGIN, '', 4, 'datetime', 3, 4, 0, [], 0, 10);
119
    suico_install_initializeProfiles();
120
    $helper       = Helper::getInstance();
121
    $utility      = new Utility();
122
    $configurator = new Configurator();
123
    // Load language files
124
    $helper->loadLanguage('admin');
125
    $helper->loadLanguage('modinfo');
126
    // default Permission Settings ----------------------
127
    $moduleId = $module->getVar('mid');
128
    //$moduleName = $module->getVar('name');
129
    $grouppermHandler = xoops_getHandler('groupperm');
130
    // access rights ------------------------------------------
131
    $grouppermHandler->addRight(
0 ignored issues
show
The method addRight() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsGroupPermHandler or XoopsPersistableObjectHandler. ( Ignorable by Annotation )

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

131
    $grouppermHandler->/** @scrutinizer ignore-call */ 
132
                       addRight(
Loading history...
132
        $moduleDirName . '_approve',
133
        1,
134
        XOOPS_GROUP_ADMIN,
135
        $moduleId
136
    );
137
    $grouppermHandler->addRight($moduleDirName . '_submit', 1, XOOPS_GROUP_ADMIN, $moduleId);
138
    $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ADMIN, $moduleId);
139
    $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_USERS, $moduleId);
140
    $grouppermHandler->addRight($moduleDirName . '_view', 1, XOOPS_GROUP_ANONYMOUS, $moduleId);
141
    //  ---  CREATE FOLDERS ---------------
142
    if (count($configurator->uploadFolders) > 0) {
143
        //    foreach (array_keys($GLOBALS['uploadFolders']) as $i) {
144
        foreach (
145
            array_keys(
146
                $configurator->uploadFolders
147
            ) as $i
148
        ) {
149
            $utility::createFolder($configurator->uploadFolders[$i]);
150
        }
151
    }
152
    //  ---  COPY blank.png FILES ---------------
153
    if (count($configurator->copyBlankFiles) > 0) {
154
        $file = \dirname(__DIR__) . '/assets/images/blank.png';
155
        foreach (array_keys($configurator->copyBlankFiles) as $i) {
156
            $dest = $configurator->copyBlankFiles[$i] . '/blank.png';
157
            $utility::copyFile($file, $dest);
158
        }
159
    }
160
    /*
161
        //  ---  COPY test folder files ---------------
162
    if (count($configurator->copyTestFolders) > 0) {
163
        //        $file =  \dirname(__DIR__) . '/testdata/images/';
164
        foreach (array_keys($configurator->copyTestFolders) as $i) {
165
            $src  = $configurator->copyTestFolders[$i][0];
166
            $dest = $configurator->copyTestFolders[$i][1];
167
            $utility::xcopy($src, $dest);
168
        }
169
    }
170
    */
171
    //delete .html entries from the tpl table
172
    $sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix(
173
            'tplfile'
174
        ) . " WHERE `tpl_module` = '" . $module->getVar(
175
            'dirname',
176
            'n'
177
        ) . "' AND `tpl_file` LIKE '%.html%'";
178
    $GLOBALS['xoopsDB']->queryF($sql);
179
180
    return true;
181
}
182
183
/**
184
 * @return void
185
 */
186
function suico_install_initializeProfiles(): void
187
{
188
    global $module_id;
189
    $GLOBALS['xoopsDB']->queryF('   INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('suico_profile') . ' (profile_id) ' . '   SELECT uid ' . '   FROM ' . $GLOBALS['xoopsDB']->prefix('users'));
190
    $sql = 'INSERT INTO '
191
           . $GLOBALS['xoopsDB']->prefix('group_permission')
192
           . ' (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) '
193
           . ' VALUES '
194
           . ' ('
195
           . XOOPS_GROUP_ADMIN
196
           . ', '
197
           . XOOPS_GROUP_ADMIN
198
           . ", {$module_id}, 'profile_access'), "
199
           . ' ('
200
           . XOOPS_GROUP_ADMIN
201
           . ', '
202
           . XOOPS_GROUP_USERS
203
           . ", {$module_id}, 'profile_access'), "
204
           . ' ('
205
           . XOOPS_GROUP_USERS
206
           . ', '
207
           . XOOPS_GROUP_USERS
208
           . ", {$module_id}, 'profile_access'), "
209
           . ' ('
210
           . XOOPS_GROUP_ANONYMOUS
211
           . ', '
212
           . XOOPS_GROUP_USERS
213
           . ", {$module_id}, 'profile_access') "
214
           . ' ';
215
    $GLOBALS['xoopsDB']->queryF($sql);
216
}
217
218
// canedit: 0 - no; 1 - admin; 2 - admin & owner
219
/**
220
 * @param      $name
221
 * @param      $title
222
 * @param      $description
223
 * @param      $category
224
 * @param      $type
225
 * @param      $valuetype
226
 * @param      $weight
227
 * @param      $canedit
228
 * @param      $options
229
 * @param      $step_id
230
 * @param      $length
231
 * @param bool $visible
232
 *
233
 * @return bool
234
 */
235
function suico_install_addField($name, $title, $description, $category, $type, $valuetype, $weight, $canedit, $options, $step_id, $length, $visible = true)
236
{
237
    global $module_id;
238
    $fieldHandler = Helper::getInstance()->getHandler('Field');
239
    $obj          = $fieldHandler->create();
240
    $obj->setVar('field_name', $name, true);
241
    $obj->setVar('field_moduleid', $module_id, true);
242
    $obj->setVar('field_show', 1);
243
    $obj->setVar('field_edit', $canedit ? 1 : 0);
244
    $obj->setVar('field_config', 0);
245
    $obj->setVar('field_title', strip_tags($title), true);
246
    $obj->setVar('field_description', strip_tags($description), true);
247
    $obj->setVar('field_type', $type, true);
248
    $obj->setVar('field_valuetype', $valuetype, true);
249
    $obj->setVar('field_options', $options, true);
250
    if ($canedit) {
251
        $obj->setVar('field_maxlength', $length, true);
252
    }
253
    $obj->setVar('field_weight', $weight, true);
254
    $obj->setVar('cat_id', $category, true);
255
    $obj->setVar('step_id', $step_id, true);
256
    $fieldHandler->insert($obj);
257
    suico_install_setPermissions($obj->getVar('field_id'), $module_id, $canedit, $visible);
258
259
    return true;
260
    /*
261
    //$GLOBALS['xoopsDB']->query("INSERT INTO ".$GLOBALS['xoopsDB']->prefix("suico_field")." VALUES (0, {$category}, '{$type}', {$valuetype}, '{$name}', " . $GLOBALS['xoopsDB']->quote($title) . ", " . $GLOBALS['xoopsDB']->quote($description) . ", 0, {$length}, {$weight}, '', 1, {$canedit}, 1, 0, '" . serialize($options) . "', {$step_id})");
262
    $gperm_itemid = $obj->getVar('field_id');
263
    unset($obj);
264
    $gperm_modid = $module_id;
265
    $sql = "INSERT INTO " . $GLOBALS['xoopsDB']->prefix("group_permission") .
266
        " (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) " .
267
        " VALUES " .
268
        ($canedit ?
269
            " (" . XOOPS_GROUP_ADMIN . ", {$gperm_itemid}, {$gperm_modid}, 'suico_edit'), "
270
        : "" ) .
271
        ($canedit == 1 ?
272
            " (" . XOOPS_GROUP_USERS . ", {$gperm_itemid}, {$gperm_modid}, 'suico_edit'), "
273
        : "" ) .
274
        " (" . XOOPS_GROUP_ADMIN . ", {$gperm_itemid}, {$gperm_modid}, 'suico_search'), " .
275
        " (" . XOOPS_GROUP_USERS . ", {$gperm_itemid}, {$gperm_modid}, 'suico_search') " .
276
        " ";
277
    $GLOBALS['xoopsDB']->query($sql);
278
279
    if ($visible) {
280
        $sql = "INSERT INTO " . $GLOBALS['xoopsDB']->prefix("suico_profile_visibility") .
281
            " (field_id, user_group, suico_group) " .
282
            " VALUES " .
283
            " ({$gperm_itemid}, " . XOOPS_GROUP_ADMIN . ", " . XOOPS_GROUP_ADMIN . "), " .
284
            " ({$gperm_itemid}, " . XOOPS_GROUP_ADMIN . ", " . XOOPS_GROUP_USERS . "), " .
285
            " ({$gperm_itemid}, " . XOOPS_GROUP_USERS . ", " . XOOPS_GROUP_ADMIN . "), " .
286
            " ({$gperm_itemid}, " . XOOPS_GROUP_USERS . ", " . XOOPS_GROUP_USERS . "), " .
287
            " ({$gperm_itemid}, " . XOOPS_GROUP_ANONYMOUS . ", " . XOOPS_GROUP_ADMIN . "), " .
288
            " ({$gperm_itemid}, " . XOOPS_GROUP_ANONYMOUS . ", " . XOOPS_GROUP_USERS . ")" .
289
            " ";
290
        $GLOBALS['xoopsDB']->query($sql);
291
    }
292
    */
293
}
294
295
/**
296
 * @param $field_id
297
 * @param $module_id
298
 * @param $canedit
299
 * @param $visible
300
 */
301
function suico_install_setPermissions($field_id, $module_id, $canedit, $visible): void
302
{
303
    $gperm_itemid = $field_id;
304
    $gperm_modid  = $module_id;
305
    $sql          = 'INSERT INTO '
306
                    . $GLOBALS['xoopsDB']->prefix('group_permission')
307
                    . ' (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) '
308
                    . ' VALUES '
309
                    . ($canedit ? ' (' . XOOPS_GROUP_ADMIN . ", {$gperm_itemid}, {$gperm_modid}, 'profile_edit'), " : '')
310
                    . (1 == $canedit ? ' ('
311
                                       . XOOPS_GROUP_USERS
312
                                       . ", {$gperm_itemid}, {$gperm_modid}, 'profile_edit'), " : '')
313
                    . ' ('
314
                    . XOOPS_GROUP_ADMIN
315
                    . ", {$gperm_itemid}, {$gperm_modid}, 'profile_search'), "
316
                    . ' ('
317
                    . XOOPS_GROUP_USERS
318
                    . ", {$gperm_itemid}, {$gperm_modid}, 'profile_search') "
319
                    . ' ';
320
    $GLOBALS['xoopsDB']->queryF($sql);
321
    if ($visible) {
322
        $sql = 'INSERT INTO '
323
               . $GLOBALS['xoopsDB']->prefix('suico_profile_visibility')
324
               . ' (field_id, user_group, profile_group) '
325
               . ' VALUES '
326
               . " ({$gperm_itemid}, "
327
               . XOOPS_GROUP_ADMIN
328
               . ', '
329
               . XOOPS_GROUP_ADMIN
330
               . '), '
331
               . " ({$gperm_itemid}, "
332
               . XOOPS_GROUP_ADMIN
333
               . ', '
334
               . XOOPS_GROUP_USERS
335
               . '), '
336
               . " ({$gperm_itemid}, "
337
               . XOOPS_GROUP_USERS
338
               . ', '
339
               . XOOPS_GROUP_ADMIN
340
               . '), '
341
               . " ({$gperm_itemid}, "
342
               . XOOPS_GROUP_USERS
343
               . ', '
344
               . XOOPS_GROUP_USERS
345
               . '), '
346
               . " ({$gperm_itemid}, "
347
               . XOOPS_GROUP_ANONYMOUS
348
               . ', '
349
               . XOOPS_GROUP_ADMIN
350
               . '), '
351
               . " ({$gperm_itemid}, "
352
               . XOOPS_GROUP_ANONYMOUS
353
               . ', '
354
               . XOOPS_GROUP_USERS
355
               . ')'
356
               . ' ';
357
        $GLOBALS['xoopsDB']->queryF($sql);
358
    }
359
}
360
361
/**
362
 * @param $name
363
 * @param $weight
364
 */
365
function suico_install_addCategory($name, $weight): void
366
{
367
    $GLOBALS['xoopsDB']->query('INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('suico_profile_category') . ' VALUES (0, ' . $GLOBALS['xoopsDB']->quote($name) . ", '', {$weight})");
368
}
369
370
/**
371
 * @param $name
372
 * @param $desc
373
 * @param $order
374
 * @param $save
375
 */
376
function suico_install_addStep($name, $desc, $order, $save): void
377
{
378
    $GLOBALS['xoopsDB']->query('INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('suico_profile_regstep') . ' VALUES (0, ' . $GLOBALS['xoopsDB']->quote($name) . ', ' . $GLOBALS['xoopsDB']->quote($desc) . ", {$order}, {$save})");
379
}
380