Issues (278)

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.

admin/blocksadmin.php (7 issues)

1
<?php
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
 * PHP version 5
8
 *
9
 * @category        Module
10
 * @author          XOOPS Development Team
11
 * @copyright       XOOPS Project
12
 * @link            https://www.xoops.org
13
 * @license         GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
14
 */
15
16
use Xmf\Request;
17
18
require __DIR__ . '/admin_header.php';
19
20
$moduleDirName      = basename(dirname(__DIR__));
21
$moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName
22
23
if (!is_object($GLOBALS['xoopsUser']) || !is_object($xoopsModule)
24
    || !$GLOBALS['xoopsUser']->isAdmin($xoopsModule->mid())) {
25
    exit(constant('CO_' . $moduleDirNameUpper . '_' . 'ERROR403'));
26
}
27
if ($GLOBALS['xoopsUser']->isAdmin($xoopsModule->mid())) {
28
    require_once XOOPS_ROOT_PATH . '/class/xoopsblock.php';
29
    $op = 'list';
30
    if (isset($_POST)) {
31
        foreach ($_POST as $k => $v) {
32
            ${$k} = $v;
33
        }
34
    }
35
    /*
36
        if (Request::hasVar('op')) {
37
            if ($_GET['op'] === "edit" || $_GET['op'] === "delete" || $_GET['op'] === "delete_ok" || $_GET['op'] === "clone"
38
                || $_GET['op'] === "edit"
39
            ) {
40
                $op  = $_GET['op'];
41
                $bid = Request::getInt('bid',0 ,'GET'); //isset($_GET['bid']) ? (int) $_GET['bid'] : 0;
42
            }
43
        }
44
    */
45
46
    $op = Request::getString('op', $op);
47
    if (in_array($op, ['edit', 'delete', 'delete_ok', 'clone'], true)) {
48
        $bid = Request::getInt('bid', 0, 'GET');
49
    }
50
51
    function listBlocks()
52
    {
53
        global $xoopsModule, $pathIcon16;
54
        require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
55
        $moduleDirName      = basename(dirname(__DIR__));
56
        $moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName
57
        $db                 = \XoopsDatabaseFactory::getDatabaseConnection();
58
        xoops_loadLanguage('admin', 'system');
59
        xoops_loadLanguage('admin/blocksadmin', 'system');
60
        xoops_loadLanguage('admin/groups', 'system');
61
62
        /** @var XoopsModuleHandler $moduleHandler */
63
        $moduleHandler = xoops_getHandler('module');
64
        /** @var \XoopsMemberHandler $memberHandler */
65
        $memberHandler = xoops_getHandler('member');
66
        /** @var \XoopsGroupPermHandler $grouppermHandler */
67
        $grouppermHandler = xoops_getHandler('groupperm');
68
        $groups           = $memberHandler->getGroups();
69
        $criteria         = new \CriteriaCompo(new \Criteria('hasmain', 1));
70
        $criteria->add(new \Criteria('isactive', 1));
71
        $module_list     = $moduleHandler->getList($criteria);
72
        $module_list[-1] = _AM_SYSTEM_BLOCKS_TOPPAGE;
73
        $module_list[0]  = _AM_SYSTEM_BLOCKS_ALLPAGES;
74
        ksort($module_list);
75
        echo "
76
        <h4 style='text-align:left;'>" . constant('CO_' . $moduleDirNameUpper . '_' . 'BADMIN') . '</h4>';
77
        $moduleHandler = xoops_getHandler('module');
0 ignored issues
show
The assignment to $moduleHandler is dead and can be removed.
Loading history...
78
        echo "<form action='" . $_SERVER['PHP_SELF'] . "' name='blockadmin' method='post'>";
79
        echo $GLOBALS['xoopsSecurity']->getTokenHTML();
80
        echo "<table width='100%' class='outer' cellpadding='4' cellspacing='1'>
81
        <tr valign='middle'><th align='center'>"
82
             . constant('CO_' . $moduleDirNameUpper . '_' . 'TITLE')
83
             . "</th><th align='center' nowrap='nowrap'>"
84
             . constant('CO_' . $moduleDirNameUpper . '_' . 'SIDE')
85
             . '<br>'
86
             . _LEFT
87
             . '-'
88
             . _CENTER
89
             . '-'
90
             . _RIGHT
91
             . "</th><th align='center'>"
92
             . constant('CO_'
93
                        . $moduleDirNameUpper
94
                        . '_'
95
                        . 'WEIGHT')
96
             . "</th><th align='center'>"
97
             . constant('CO_' . $moduleDirNameUpper . '_' . 'VISIBLE')
98
             . "</th><th align='center'>"
99
             . _AM_SYSTEM_BLOCKS_VISIBLEIN
100
             . "</th><th align='center'>"
101
             . _AM_SYSTEM_ADGS
102
             . "</th><th align='center'>"
103
             . _AM_SYSTEM_BLOCKS_BCACHETIME
104
             . "</th><th align='center'>"
105
             . constant('CO_' . $moduleDirNameUpper . '_' . 'ACTION')
106
             . '</th></tr>
107
        ';
108
        $block_arr   = \XoopsBlock::getByModule($xoopsModule->mid());
109
        $block_count = count($block_arr);
0 ignored issues
show
The assignment to $block_count is dead and can be removed.
Loading history...
110
        $class       = 'even';
111
        $cachetimes  = [
112
            '0'       => _NOCACHE,
113
            '30'      => sprintf(_SECONDS, 30),
114
            '60'      => _MINUTE,
115
            '300'     => sprintf(_MINUTES, 5),
116
            '1800'    => sprintf(_MINUTES, 30),
117
            '3600'    => _HOUR,
118
            '18000'   => sprintf(_HOURS, 5),
119
            '86400'   => _DAY,
120
            '259200'  => sprintf(_DAYS, 3),
121
            '604800'  => _WEEK,
122
            '2592000' => _MONTH,
123
        ];
124
        foreach ($block_arr as $i) {
125
            $groups_perms = $grouppermHandler->getGroupIds('block_read', $i->getVar('bid'));
126
            $sql          = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . $i->getVar('bid');
127
            $result       = $db->query($sql);
128
            $modules      = [];
129
            while (false !== ($row = $db->fetchArray($result))) {
130
                $modules[] = (int)$row['module_id'];
131
            }
132
133
            $cachetime_options = '';
134
            foreach ($cachetimes as $cachetime => $cachetime_name) {
135
                if ($i->getVar('bcachetime') == $cachetime) {
136
                    $cachetime_options .= "<option value='$cachetime' selected='selected'>$cachetime_name</option>\n";
137
                } else {
138
                    $cachetime_options .= "<option value='$cachetime'>$cachetime_name</option>\n";
139
                }
140
            }
141
142
            $sel0 = $sel1 = $ssel0 = $ssel1 = $ssel2 = $ssel3 = $ssel4 = $ssel5 = $ssel6 = $ssel7 = '';
143
            if (1 === $i->getVar('visible')) {
144
                $sel1 = ' checked';
145
            } else {
146
                $sel0 = ' checked';
147
            }
148
            if (XOOPS_SIDEBLOCK_LEFT === $i->getVar('side')) {
149
                $ssel0 = ' checked';
150
            } elseif (XOOPS_SIDEBLOCK_RIGHT === $i->getVar('side')) {
151
                $ssel1 = ' checked';
152
            } elseif (XOOPS_CENTERBLOCK_LEFT === $i->getVar('side')) {
153
                $ssel2 = ' checked';
154
            } elseif (XOOPS_CENTERBLOCK_RIGHT === $i->getVar('side')) {
155
                $ssel4 = ' checked';
156
            } elseif (XOOPS_CENTERBLOCK_CENTER === $i->getVar('side')) {
157
                $ssel3 = ' checked';
158
            } elseif (XOOPS_CENTERBLOCK_BOTTOMLEFT === $i->getVar('side')) {
159
                $ssel5 = ' checked';
160
            } elseif (XOOPS_CENTERBLOCK_BOTTOMRIGHT === $i->getVar('side')) {
161
                $ssel6 = ' checked';
162
            } elseif (XOOPS_CENTERBLOCK_BOTTOM === $i->getVar('side')) {
163
                $ssel7 = ' checked';
164
            }
165
            if ('' === $i->getVar('title')) {
166
                $title = '&nbsp;';
167
            } else {
168
                $title = $i->getVar('title');
169
            }
170
            $name = $i->getVar('name');
0 ignored issues
show
The assignment to $name is dead and can be removed.
Loading history...
171
            echo "<tr valign='top'><td class='$class' align='center'><input type='text' name='title["
172
                 . $i->getVar('bid')
173
                 . "]' value='"
174
                 . $title
175
                 . "'></td><td class='$class' align='center' nowrap='nowrap'>
176
                    <div align='center' >
177
                    <input type='radio' name='side["
178
                 . $i->getVar('bid')
179
                 . "]' value='"
180
                 . XOOPS_CENTERBLOCK_LEFT
181
                 . "'$ssel2>
182
                        <input type='radio' name='side["
183
                 . $i->getVar('bid')
184
                 . "]' value='"
185
                 . XOOPS_CENTERBLOCK_CENTER
186
                 . "'$ssel3>
187
                    <input type='radio' name='side["
188
                 . $i->getVar('bid')
189
                 . "]' value='"
190
                 . XOOPS_CENTERBLOCK_RIGHT
191
                 . "'$ssel4>
192
                    </div>
193
                    <div>
194
                        <span style='float:right;'><input type='radio' name='side["
195
                 . $i->getVar('bid')
196
                 . "]' value='"
197
                 . XOOPS_SIDEBLOCK_RIGHT
198
                 . "'$ssel1></span>
199
                    <div align='left'><input type='radio' name='side["
200
                 . $i->getVar('bid')
201
                 . "]' value='"
202
                 . XOOPS_SIDEBLOCK_LEFT
203
                 . "'$ssel0></div>
204
                    </div>
205
                    <div align='center'>
206
                    <input type='radio' name='side["
207
                 . $i->getVar('bid')
208
                 . "]' value='"
209
                 . XOOPS_CENTERBLOCK_BOTTOMLEFT
210
                 . "'$ssel5>
211
                        <input type='radio' name='side["
212
                 . $i->getVar('bid')
213
                 . "]' value='"
214
                 . XOOPS_CENTERBLOCK_BOTTOM
215
                 . "'$ssel7>
216
                    <input type='radio' name='side["
217
                 . $i->getVar('bid')
218
                 . "]' value='"
219
                 . XOOPS_CENTERBLOCK_BOTTOMRIGHT
220
                 . "'$ssel6>
221
                    </div>
222
                </td><td class='$class' align='center'><input type='text' name='weight["
223
                 . $i->getVar('bid')
224
                 . "]' value='"
225
                 . $i->getVar('weight')
226
                 . "' size='5' maxlength='5'></td><td class='$class' align='center' nowrap><input type='radio' name='visible["
227
                 . $i->getVar('bid')
228
                 . "]' value='1'$sel1>"
229
                 . _YES
230
                 . "&nbsp;<input type='radio' name='visible["
231
                 . $i->getVar('bid')
232
                 . "]' value='0'$sel0>"
233
                 . _NO
234
                 . '</td>';
235
236
            echo "<td class='$class' align='center'><select size='5' name='bmodule[" . $i->getVar('bid') . "][]' id='bmodule[" . $i->getVar('bid') . "][]' multiple='multiple'>";
237
            foreach ($module_list as $k => $v) {
238
                echo "<option value='$k'" . (in_array($k, $modules, true) ? " selected='selected'" : '') . ">$v</option>";
239
            }
240
            echo '</select></td>';
241
242
            echo "<td class='$class' align='center'><select size='5' name='groups[" . $i->getVar('bid') . "][]' id='groups[" . $i->getVar('bid') . "][]' multiple='multiple'>";
243
            foreach ($groups as $grp) {
244
                echo "<option value='" . $grp->getVar('groupid') . "' " . (in_array($grp->getVar('groupid'), $groups_perms, true) ? " selected='selected'" : '') . '>' . $grp->getVar('name') . '</option>';
245
            }
246
            echo '</select></td>';
247
248
            // Cache lifetime
249
            echo '<td class="' . $class . '" align="center"> <select name="bcachetime[' . $i->getVar('bid') . ']" size="1">' . $cachetime_options . '</select>
250
                                    </td>';
251
252
            // Actions
253
254
            echo "<td class='$class' align='center'><a href='blocksadmin.php?op=edit&amp;bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/edit.png' . " alt='" . _EDIT . "' title='" . _EDIT . "'>
255
                 </a> <a href='blocksadmin.php?op=clone&amp;bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/editcopy.png' . " alt='" . _CLONE . "' title='" . _CLONE . "'>
256
                 </a>";
257
            if ('S' !== $i->getVar('block_type') && 'M' !== $i->getVar('block_type')) {
258
                echo "&nbsp;<a href='" . XOOPS_URL . '/modules/system/admin.php?fct=blocksadmin&amp;op=delete&amp;bid=' . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/delete.png' . " alt='" . _DELETE . "' title='" . _DELETE . "'>
259
                     </a>";
260
            }
261
            echo "
262
            <input type='hidden' name='oldtitle[" . $i->getVar('bid') . "]' value='" . $i->getVar('title') . "'>
263
            <input type='hidden' name='oldside[" . $i->getVar('bid') . "]' value='" . $i->getVar('side') . "'>
264
            <input type='hidden' name='oldweight[" . $i->getVar('bid') . "]' value='" . $i->getVar('weight') . "'>
265
            <input type='hidden' name='oldvisible[" . $i->getVar('bid') . "]' value='" . $i->getVar('visible') . "'>
266
            <input type='hidden' name='oldgroups[" . $i->getVar('groups') . "]' value='" . $i->getVar('groups') . "'>
267
            <input type='hidden' name='oldbcachetime[" . $i->getVar('bid') . "]' value='" . $i->getVar('bcachetime') . "'>
268
            <input type='hidden' name='bid[" . $i->getVar('bid') . "]' value='" . $i->getVar('bid') . "'>
269
            </td></tr>
270
            ";
271
            $class = ('even' === $class) ? 'odd' : 'even';
272
        }
273
        echo "<tr><td class='foot' align='center' colspan='7'>
274
        <input type='hidden' name='op' value='order'>
275
        " . $GLOBALS['xoopsSecurity']->getTokenHTML() . "
276
        <input type='submit' name='submit' value='" . _SUBMIT . "'>
277
        </td></tr></table>
278
        </form>
279
        <br><br>";
280
    }
281
282
    /**
283
     * @param $bid
284
     */
285
    function cloneBlock($bid)
286
    {
287
        require_once __DIR__ . '/admin_header.php';
288
        //require_once __DIR__ . '/admin_header.php';
289
        xoops_cp_header();
290
291
        xoops_loadLanguage('admin', 'system');
292
        xoops_loadLanguage('admin/blocksadmin', 'system');
293
        xoops_loadLanguage('admin/groups', 'system');
294
295
        //        mpu_adm_menu();
296
        $myblock = new \XoopsBlock($bid);
297
        $db      = \XoopsDatabaseFactory::getDatabaseConnection();
298
        $sql     = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . (int)$bid;
299
        $result  = $db->query($sql);
300
        $modules = [];
301
        while (false !== ($row = $db->fetchArray($result))) {
302
            $modules[] = (int)$row['module_id'];
303
        }
304
        $is_custom = ('C' === $myblock->getVar('block_type') || 'E' === $myblock->getVar('block_type'));
305
        $block     = [
0 ignored issues
show
The assignment to $block is dead and can be removed.
Loading history...
306
            'title'      => $myblock->getVar('title') . ' Clone',
307
            'form_title' => constant('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_CLONEBLOCK'),
308
            'name'       => $myblock->getVar('name'),
309
            'side'       => $myblock->getVar('side'),
310
            'weight'     => $myblock->getVar('weight'),
311
            'visible'    => $myblock->getVar('visible'),
312
            'content'    => $myblock->getVar('content', 'N'),
313
            'modules'    => $modules,
314
            'is_custom'  => $is_custom,
315
            'ctype'      => $myblock->getVar('c_type'),
316
            'bcachetime' => $myblock->getVar('bcachetime'),
317
            'op'         => 'clone_ok',
318
            'bid'        => $myblock->getVar('bid'),
319
            'edit_form'  => $myblock->getOptions(),
320
            'template'   => $myblock->getVar('template'),
321
            'options'    => $myblock->getVar('options'),
322
        ];
323
        echo '<a href="blocksadmin.php">' . _AM_BADMIN . '</a>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;' . _AM_SYSTEM_BLOCKS_CLONEBLOCK . '<br><br>';
324
        require_once __DIR__ . '/blockform.php';
325
        $form->display();
326
        //        xoops_cp_footer();
327
        require_once __DIR__ . '/admin_footer.php';
328
        exit();
329
    }
330
331
    /**
332
     * @param $bid
333
     * @param $bside
334
     * @param $bweight
335
     * @param $bvisible
336
     * @param $bcachetime
337
     * @param $bmodule
338
     * @param $options
339
     */
340
    function isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options)
341
    {
342
        xoops_loadLanguage('admin', 'system');
343
        xoops_loadLanguage('admin/blocksadmin', 'system');
344
        xoops_loadLanguage('admin/groups', 'system');
345
346
        /** @var \XoopsBlock $block */
347
        $block = new \XoopsBlock($bid);
348
        $clone = $block->xoopsClone();
349
        if (empty($bmodule)) {
350
            xoops_cp_header();
351
            xoops_error(sprintf(_AM_NOTSELNG, _AM_VISIBLEIN));
352
            xoops_cp_footer();
353
            exit();
354
        }
355
        $clone->setVar('side', $bside);
356
        $clone->setVar('weight', $bweight);
357
        $clone->setVar('visible', $bvisible);
358
        //$clone->setVar('content', $_POST['bcontent']);
359
        $clone->setVar('title', Request::getString('btitle', '', 'POST'));
360
        $clone->setVar('bcachetime', $bcachetime);
361
        if (isset($options) && (count($options) > 0)) {
362
            $options = implode('|', $options);
363
            $clone->setVar('options', $options);
364
        }
365
        $clone->setVar('bid', 0);
366
        if ('C' === $block->getVar('block_type') || 'E' === $block->getVar('block_type')) {
367
            $clone->setVar('block_type', 'E');
368
        } else {
369
            $clone->setVar('block_type', 'D');
370
        }
371
        $newid = $clone->store();
372
        if (!$newid) {
373
            xoops_cp_header();
374
            $clone->getHtmlErrors();
375
            xoops_cp_footer();
376
            exit();
377
        }
378
        if ('' !== $clone->getVar('template')) {
379
            /** @var \XoopsTplfileHandler $tplfileHandler */
380
            $tplfileHandler = xoops_getHandler('tplfile');
381
            $btemplate      = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $bid);
382
            if (count($btemplate) > 0) {
383
                $tplclone = $btemplate[0]->xoopsClone();
384
                $tplclone->setVar('tpl_id', 0);
385
                $tplclone->setVar('tpl_refid', $newid);
386
                $tplfileHandler->insert($tplclone);
387
            }
388
        }
389
        $db = \XoopsDatabaseFactory::getDatabaseConnection();
390
        foreach ($bmodule as $bmid) {
391
            $sql = 'INSERT INTO ' . $db->prefix('block_module_link') . ' (block_id, module_id) VALUES (' . $newid . ', ' . $bmid . ')';
392
            $db->query($sql);
393
        }
394
        $groups = &$GLOBALS['xoopsUser']->getGroups();
395
        $count  = count($groups);
396
        for ($i = 0; $i < $count; ++$i) {
397
            $sql = 'INSERT INTO ' . $db->prefix('group_permission') . ' (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (' . $groups[$i] . ', ' . $newid . ", 1, 'block_read')";
398
            $db->query($sql);
399
        }
400
        redirect_header('blocksadmin.php?op=listar', 1, _AM_DBUPDATED);
401
    }
402
403
    /**
404
     * @param $bid
405
     * @param $title
406
     * @param $weight
407
     * @param $visible
408
     * @param $side
409
     * @param $bcachetime
410
     */
411
    function setOrder($bid, $title, $weight, $visible, $side, $bcachetime)
412
    {
413
        $myblock = new \XoopsBlock($bid);
414
        $myblock->setVar('title', $title);
415
        $myblock->setVar('weight', $weight);
416
        $myblock->setVar('visible', $visible);
417
        $myblock->setVar('side', $side);
418
        $myblock->setVar('bcachetime', $bcachetime);
419
        $myblock->store();
420
    }
421
422
    /**
423
     * @param $bid
424
     */
425
    function editBlock($bid)
426
    {
427
        require_once __DIR__ . '/admin_header.php';
428
        //require_once __DIR__ . '/admin_header.php';
429
        xoops_cp_header();
430
431
        xoops_loadLanguage('admin', 'system');
432
        xoops_loadLanguage('admin/blocksadmin', 'system');
433
        xoops_loadLanguage('admin/groups', 'system');
434
        //        mpu_adm_menu();
435
        $myblock = new \XoopsBlock($bid);
436
        $db      = \XoopsDatabaseFactory::getDatabaseConnection();
437
        $sql     = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . (int)$bid;
438
        $result  = $db->query($sql);
439
        $modules = [];
440
        while (false !== ($row = $db->fetchArray($result))) {
441
            $modules[] = (int)$row['module_id'];
442
        }
443
        $is_custom = ('C' === $myblock->getVar('block_type') || 'E' === $myblock->getVar('block_type'));
444
        $block     = [
0 ignored issues
show
The assignment to $block is dead and can be removed.
Loading history...
445
            'title'      => $myblock->getVar('title'),
446
            'form_title' => constant('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_EDITBLOCK'),
447
            //        'name'       => $myblock->getVar('name'),
448
            'side'       => $myblock->getVar('side'),
449
            'weight'     => $myblock->getVar('weight'),
450
            'visible'    => $myblock->getVar('visible'),
451
            'content'    => $myblock->getVar('content', 'N'),
452
            'modules'    => $modules,
453
            'is_custom'  => $is_custom,
454
            'ctype'      => $myblock->getVar('c_type'),
455
            'bcachetime' => $myblock->getVar('bcachetime'),
456
            'op'         => 'edit_ok',
457
            'bid'        => $myblock->getVar('bid'),
458
            'edit_form'  => $myblock->getOptions(),
459
            'template'   => $myblock->getVar('template'),
460
            'options'    => $myblock->getVar('options'),
461
        ];
462
        echo '<a href="blocksadmin.php">' . _AM_BADMIN . '</a>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;' . _AM_SYSTEM_BLOCKS_EDITBLOCK . '<br><br>';
463
        require_once __DIR__ . '/blockform.php';
464
        $form->display();
465
        //        xoops_cp_footer();
466
        require_once __DIR__ . '/admin_footer.php';
467
        exit();
468
    }
469
470
    /**
471
     * @param $bid
472
     * @param $btitle
473
     * @param $bside
474
     * @param $bweight
475
     * @param $bvisible
476
     * @param $bcachetime
477
     * @param $bmodule
478
     * @param $options
479
     * @param $groups
480
     */
481
    function updateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options, $groups)
0 ignored issues
show
The parameter $options is not used and could be removed. ( Ignorable by Annotation )

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

481
    function updateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $bmodule, /** @scrutinizer ignore-unused */ $options, $groups)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
482
    {
483
        $myblock = new \XoopsBlock($bid);
484
        $myblock->setVar('title', $btitle);
485
        $myblock->setVar('weight', $bweight);
486
        $myblock->setVar('visible', $bvisible);
487
        $myblock->setVar('side', $bside);
488
        $myblock->setVar('bcachetime', $bcachetime);
489
        $myblock->store();
490
491
        if (!empty($bmodule) && count($bmodule) > 0) {
492
            $sql = sprintf('DELETE FROM `%s` WHERE block_id = %u', $GLOBALS['xoopsDB']->prefix('block_module_link'), $bid);
493
            $GLOBALS['xoopsDB']->query($sql);
494
            if (in_array(0, $bmodule, true)) {
495
                $sql = sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $GLOBALS['xoopsDB']->prefix('block_module_link'), $bid, 0);
496
                $GLOBALS['xoopsDB']->query($sql);
497
            } else {
498
                foreach ($bmodule as $bmid) {
499
                    $sql = sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $GLOBALS['xoopsDB']->prefix('block_module_link'), $bid, (int)$bmid);
500
                    $GLOBALS['xoopsDB']->query($sql);
501
                }
502
            }
503
        }
504
        $sql = sprintf('DELETE FROM `%s` WHERE gperm_itemid = %u', $GLOBALS['xoopsDB']->prefix('group_permission'), $bid);
505
        $GLOBALS['xoopsDB']->query($sql);
506
        if (!empty($groups)) {
507
            foreach ($groups as $grp) {
508
                $sql = sprintf("INSERT INTO `%s` (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (%u, %u, 1, 'block_read')", $GLOBALS['xoopsDB']->prefix('group_permission'), $grp, $bid);
509
                $GLOBALS['xoopsDB']->query($sql);
510
            }
511
        }
512
        redirect_header($_SERVER['PHP_SELF'], 1, constant('CO_' . $moduleDirNameUpper . '_' . 'UPDATE_SUCCESS'));
513
    }
514
515
    if ('list' === $op) {
516
        xoops_cp_header();
517
        //        mpu_adm_menu();
518
        listBlocks();
519
        require_once __DIR__ . '/admin_footer.php';
520
        exit();
521
    }
522
523
    if ('order' === $op) {
524
        if (!$GLOBALS['xoopsSecurity']->check()) {
525
            redirect_header($_SERVER['PHP_SELF'], 3, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()));
526
        }
527
        foreach (array_keys($bid) as $i) {
528
            if ($oldtitle[$i] !== $title[$i] || $oldweight[$i] !== $weight[$i] || $oldvisible[$i] !== $visible[$i]
529
                || $oldside[$i] !== $side[$i]
530
                || $oldbcachetime[$i] !== $bcachetime[$i]) {
531
                setOrder($bid[$i], $title[$i], $weight[$i], $visible[$i], $side[$i], $bcachetime[$i], $bmodule[$i]);
0 ignored issues
show
The call to setOrder() has too many arguments starting with $bmodule[$i]. ( Ignorable by Annotation )

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

531
                /** @scrutinizer ignore-call */ 
532
                setOrder($bid[$i], $title[$i], $weight[$i], $visible[$i], $side[$i], $bcachetime[$i], $bmodule[$i]);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
532
            }
533
            if (!empty($bmodule[$i]) && count($bmodule[$i]) > 0) {
534
                $sql = sprintf('DELETE FROM `%s` WHERE block_id = %u', $GLOBALS['xoopsDB']->prefix('block_module_link'), $bid[$i]);
535
                $GLOBALS['xoopsDB']->query($sql);
536
                if (in_array(0, $bmodule[$i], true)) {
537
                    $sql = sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $GLOBALS['xoopsDB']->prefix('block_module_link'), $bid[$i], 0);
538
                    $GLOBALS['xoopsDB']->query($sql);
539
                } else {
540
                    foreach ($bmodule[$i] as $bmid) {
541
                        $sql = sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $GLOBALS['xoopsDB']->prefix('block_module_link'), $bid[$i], (int)$bmid);
542
                        $GLOBALS['xoopsDB']->query($sql);
543
                    }
544
                }
545
            }
546
            $sql = sprintf('DELETE FROM `%s` WHERE gperm_itemid = %u', $GLOBALS['xoopsDB']->prefix('group_permission'), $bid[$i]);
547
            $GLOBALS['xoopsDB']->query($sql);
548
            if (!empty($groups[$i])) {
549
                foreach ($groups[$i] as $grp) {
550
                    $sql = sprintf("INSERT INTO `%s` (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (%u, %u, 1, 'block_read')", $GLOBALS['xoopsDB']->prefix('group_permission'), $grp, $bid[$i]);
551
                    $GLOBALS['xoopsDB']->query($sql);
552
                }
553
            }
554
        }
555
        redirect_header($_SERVER['PHP_SELF'], 1, constant('CO_' . $moduleDirNameUpper . '_' . 'UPDATE_SUCCESS'));
556
    }
557
    if ('clone' === $op) {
558
        cloneBlock($bid);
559
    }
560
561
    if ('edit' === $op) {
562
        editBlock($bid);
563
    }
564
565
    if ('edit_ok' === $op) {
566
        updateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options, $groups);
567
    }
568
569
    if ('clone_ok' === $op) {
570
        isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options);
571
    }
572
} else {
573
    echo constant('CO_' . $moduleDirNameUpper . '_' . 'ERROR403');
574
}
575