Issues (733)

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 (15 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://xoops.org
13
 * @license         GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
14
 */
15
16
use Xmf\Request;
17
use XoopsModules\Extcal\{Form
18
};
19
20
require __DIR__ . '/admin_header.php';
21
22
$moduleDirName      = basename(dirname(__DIR__));
23
$moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName
24
25
$helper->loadLanguage('blocksadmin');
26
27
global $xoopsModule;
28
29
if (!is_object($GLOBALS['xoopsUser']) || !is_object($xoopsModule)
30
    || !$GLOBALS['xoopsUser']->isAdmin($xoopsModule->mid())) {
31
    exit(constant('CO_' . $moduleDirNameUpper . '_' . 'ERROR403'));
32
}
33
if ($GLOBALS['xoopsUser']->isAdmin($xoopsModule->mid())) {
34
    require_once XOOPS_ROOT_PATH . '/class/xoopsblock.php';
35
    $op = 'list';
36
    if (isset($_POST)) {
37
        foreach ($_POST as $k => $v) {
38
            ${$k} = $v;
39
        }
40
    }
41
    /*
42
        if (Request::hasVar('op')) {
43
            if ($_GET['op'] === "edit" || $_GET['op'] === "delete" || $_GET['op'] === "delete_ok" || $_GET['op'] === "clone"
44
                || $_GET['op'] === "edit"
45
            ) {
46
                $op  = $_GET['op'];
47
                $bid = Request::getInt('bid',0 ,'GET'); //isset($_GET['bid']) ? (int) $_GET['bid'] : 0;
48
            }
49
        }
50
    */
51
52
    $op = Request::getString('op', $op);
53
    if (in_array($op, ['edit', 'delete', 'delete_ok', 'clone'])) {
54
        $bid = Request::getInt('bid', 0, 'GET');
55
    }
56
57
    function listBlocks()
58
    {
59
        global $xoopsModule, $pathIcon16;
60
        require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
61
        $moduleDirName      = basename(dirname(__DIR__));
62
        $moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName
63
        $db                 = \XoopsDatabaseFactory::getDatabaseConnection();
64
        xoops_loadLanguage('admin', 'system');
65
        xoops_loadLanguage('admin/blocksadmin', 'system');
66
        xoops_loadLanguage('admin/groups', 'system');
67
68
        /** @var \XoopsModuleHandler $moduleHandler */
69
        $moduleHandler = xoops_getHandler('module');
70
        /** @var \XoopsMemberHandler $memberHandler */
71
        $memberHandler = xoops_getHandler('member');
72
        /** @var \XoopsGroupPermHandler $grouppermHandler */
73
        $grouppermHandler = xoops_getHandler('groupperm');
74
        $groups           = $memberHandler->getGroups();
75
        $criteria         = new \CriteriaCompo(new \Criteria('hasmain', 1));
76
        $criteria->add(new \Criteria('isactive', 1));
77
        $module_list     = $moduleHandler->getList($criteria);
78
        $module_list[-1] = _AM_SYSTEM_BLOCKS_TOPPAGE;
79
        $module_list[0]  = _AM_SYSTEM_BLOCKS_ALLPAGES;
80
        ksort($module_list);
81
        echo "
82
        <h4 style='text-align:left;'>" . constant('CO_' . $moduleDirNameUpper . '_' . 'BADMIN') . '</h4>';
83
        /** @var \XoopsModuleHandler $moduleHandler */
84
        $moduleHandler = xoops_getHandler('module');
0 ignored issues
show
The assignment to $moduleHandler is dead and can be removed.
Loading history...
85
        echo "<form action='" . $_SERVER['SCRIPT_NAME'] . "' name='blockadmin' method='post'>";
86
        echo $GLOBALS['xoopsSecurity']->getTokenHTML();
87
        echo "<table width='100%' class='outer' cellpadding='4' cellspacing='1'>
88
        <tr valign='middle'><th align='center'>"
89
             . constant('CO_' . $moduleDirNameUpper . '_' . 'TITLE')
90
             . "</th><th align='center' nowrap='nowrap'>"
91
             . constant('CO_' . $moduleDirNameUpper . '_' . 'SIDE')
92
             . '<br>'
93
             . _LEFT
94
             . '-'
95
             . _CENTER
96
             . '-'
97
             . _RIGHT
98
             . "</th><th align='center'>"
99
             . constant(
100
                 'CO_' . $moduleDirNameUpper . '_' . 'WEIGHT'
101
             )
102
             . "</th><th align='center'>"
103
             . constant('CO_' . $moduleDirNameUpper . '_' . 'VISIBLE')
104
             . "</th><th align='center'>"
105
             . _AM_SYSTEM_BLOCKS_VISIBLEIN
106
             . "</th><th align='center'>"
107
             . _AM_SYSTEM_ADGS
108
             . "</th><th align='center'>"
109
             . _AM_SYSTEM_BLOCKS_BCACHETIME
110
             . "</th><th align='center'>"
111
             . constant('CO_' . $moduleDirNameUpper . '_' . 'ACTION')
112
             . '</th></tr>
113
        ';
114
        $block_arr   = \XoopsBlock::getByModule($xoopsModule->mid());
0 ignored issues
show
The method getByModule() does not exist on XoopsBlock. ( Ignorable by Annotation )

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

114
        /** @scrutinizer ignore-call */ 
115
        $block_arr   = \XoopsBlock::getByModule($xoopsModule->mid());

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
115
        $block_count = count($block_arr);
0 ignored issues
show
The assignment to $block_count is dead and can be removed.
Loading history...
116
        $class       = 'even';
117
        $cachetimes  = [
118
            '0'       => _NOCACHE,
119
            '30'      => sprintf(_SECONDS, 30),
120
            '60'      => _MINUTE,
121
            '300'     => sprintf(_MINUTES, 5),
122
            '1800'    => sprintf(_MINUTES, 30),
123
            '3600'    => _HOUR,
124
            '18000'   => sprintf(_HOURS, 5),
125
            '86400'   => _DAY,
126
            '259200'  => sprintf(_DAYS, 3),
127
            '604800'  => _WEEK,
128
            '2592000' => _MONTH,
129
        ];
130
        foreach ($block_arr as $i) {
131
            $groups_perms = $grouppermHandler->getGroupIds('block_read', $i->getVar('bid'));
132
            $sql          = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . $i->getVar('bid');
133
            $result       = $db->query($sql);
134
            $modules      = [];
135
            while (false !== ($row = $db->fetchArray($result))) {
136
                $modules[] = (int)$row['module_id'];
137
            }
138
139
            $cachetime_options = '';
140
            foreach ($cachetimes as $cachetime => $cachetime_name) {
141
                if ($i->getVar('bcachetime') == $cachetime) {
142
                    $cachetime_options .= "<option value='$cachetime' selected='selected'>$cachetime_name</option>\n";
143
                } else {
144
                    $cachetime_options .= "<option value='$cachetime'>$cachetime_name</option>\n";
145
                }
146
            }
147
148
            $sel0 = $sel1 = $ssel0 = $ssel1 = $ssel2 = $ssel3 = $ssel4 = $ssel5 = $ssel6 = $ssel7 = '';
149
            if (1 === $i->getVar('visible')) {
150
                $sel1 = ' checked';
151
            } else {
152
                $sel0 = ' checked';
153
            }
154
            if (XOOPS_SIDEBLOCK_LEFT === $i->getVar('side')) {
155
                $ssel0 = ' checked';
156
            } elseif (XOOPS_SIDEBLOCK_RIGHT === $i->getVar('side')) {
157
                $ssel1 = ' checked';
158
            } elseif (XOOPS_CENTERBLOCK_LEFT === $i->getVar('side')) {
159
                $ssel2 = ' checked';
160
            } elseif (XOOPS_CENTERBLOCK_RIGHT === $i->getVar('side')) {
161
                $ssel4 = ' checked';
162
            } elseif (XOOPS_CENTERBLOCK_CENTER === $i->getVar('side')) {
163
                $ssel3 = ' checked';
164
            } elseif (XOOPS_CENTERBLOCK_BOTTOMLEFT === $i->getVar('side')) {
165
                $ssel5 = ' checked';
166
            } elseif (XOOPS_CENTERBLOCK_BOTTOMRIGHT === $i->getVar('side')) {
167
                $ssel6 = ' checked';
168
            } elseif (XOOPS_CENTERBLOCK_BOTTOM === $i->getVar('side')) {
169
                $ssel7 = ' checked';
170
            }
171
            if ('' === $i->getVar('title')) {
172
                $title = '&nbsp;';
173
            } else {
174
                $title = $i->getVar('title');
175
            }
176
            $name = $i->getVar('name');
0 ignored issues
show
The assignment to $name is dead and can be removed.
Loading history...
177
            echo "<tr valign='top'><td class='$class' align='center'><input type='text' name='title["
178
                 . $i->getVar('bid')
179
                 . "]' value='"
180
                 . $title
181
                 . "'></td><td class='$class' align='center' nowrap='nowrap'>
182
                    <div align='center' >
183
                    <input type='radio' name='side["
184
                 . $i->getVar('bid')
185
                 . "]' value='"
186
                 . XOOPS_CENTERBLOCK_LEFT
187
                 . "'$ssel2>
188
                        <input type='radio' name='side["
189
                 . $i->getVar('bid')
190
                 . "]' value='"
191
                 . XOOPS_CENTERBLOCK_CENTER
192
                 . "'$ssel3>
193
                    <input type='radio' name='side["
194
                 . $i->getVar('bid')
195
                 . "]' value='"
196
                 . XOOPS_CENTERBLOCK_RIGHT
197
                 . "'$ssel4>
198
                    </div>
199
                    <div>
200
                        <span style='float:right;'><input type='radio' name='side["
201
                 . $i->getVar('bid')
202
                 . "]' value='"
203
                 . XOOPS_SIDEBLOCK_RIGHT
204
                 . "'$ssel1></span>
205
                    <div align='left'><input type='radio' name='side["
206
                 . $i->getVar('bid')
207
                 . "]' value='"
208
                 . XOOPS_SIDEBLOCK_LEFT
209
                 . "'$ssel0></div>
210
                    </div>
211
                    <div align='center'>
212
                    <input type='radio' name='side["
213
                 . $i->getVar('bid')
214
                 . "]' value='"
215
                 . XOOPS_CENTERBLOCK_BOTTOMLEFT
216
                 . "'$ssel5>
217
                        <input type='radio' name='side["
218
                 . $i->getVar('bid')
219
                 . "]' value='"
220
                 . XOOPS_CENTERBLOCK_BOTTOM
221
                 . "'$ssel7>
222
                    <input type='radio' name='side["
223
                 . $i->getVar('bid')
224
                 . "]' value='"
225
                 . XOOPS_CENTERBLOCK_BOTTOMRIGHT
226
                 . "'$ssel6>
227
                    </div>
228
                </td><td class='$class' align='center'><input type='text' name='weight["
229
                 . $i->getVar('bid')
230
                 . "]' value='"
231
                 . $i->getVar('weight')
232
                 . "' size='5' maxlength='5'></td><td class='$class' align='center' nowrap><input type='radio' name='visible["
233
                 . $i->getVar('bid')
234
                 . "]' value='1'$sel1>"
235
                 . _YES
236
                 . "&nbsp;<input type='radio' name='visible["
237
                 . $i->getVar('bid')
238
                 . "]' value='0'$sel0>"
239
                 . _NO
240
                 . '</td>';
241
242
            echo "<td class='$class' align='center'><select size='5' name='bmodule[" . $i->getVar('bid') . "][]' id='bmodule[" . $i->getVar('bid') . "][]' multiple='multiple'>";
243
            foreach ($module_list as $k => $v) {
244
                echo "<option value='$k'" . (in_array($k, $modules) ? " selected='selected'" : '') . ">$v</option>";
245
            }
246
            echo '</select></td>';
247
248
            echo "<td class='$class' align='center'><select size='5' name='groups[" . $i->getVar('bid') . "][]' id='groups[" . $i->getVar('bid') . "][]' multiple='multiple'>";
249
            foreach ($groups as $grp) {
250
                echo "<option value='" . $grp->getVar('groupid') . "' " . (in_array($grp->getVar('groupid'), $groups_perms) ? " selected='selected'" : '') . '>' . $grp->getVar('name') . '</option>';
251
            }
252
            echo '</select></td>';
253
254
            // Cache lifetime
255
            echo '<td class="' . $class . '" align="center"> <select name="bcachetime[' . $i->getVar('bid') . ']" size="1">' . $cachetime_options . '</select>
256
                                    </td>';
257
258
            // Actions
259
260
            echo "<td class='$class' align='center'>
261
					<a href='blocksadmin.php?op=edit&amp;bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/edit.png' . " alt='" . _EDIT . "' title='" . _EDIT . "'></a>
262
					<a href='blocksadmin.php?op=clone&amp;bid=" . $i->getVar('bid') . "'><img src=" . $pathIcon16 . '/editcopy.png' . " alt='" . _CLONE . "' title='" . _CLONE . "'></a>";
263
            if ('S' !== $i->getVar('block_type') && 'M' !== $i->getVar('block_type')) {
264
                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 . "'></a>";
265
            }
266
            echo "
267
            <input type='hidden' name='oldtitle[" . $i->getVar('bid') . "]' value='" . $i->getVar('title') . "'>
268
            <input type='hidden' name='oldside[" . $i->getVar('bid') . "]' value='" . $i->getVar('side') . "'>
269
            <input type='hidden' name='oldweight[" . $i->getVar('bid') . "]' value='" . $i->getVar('weight') . "'>
270
            <input type='hidden' name='oldvisible[" . $i->getVar('bid') . "]' value='" . $i->getVar('visible') . "'>
271
            <input type='hidden' name='oldgroups[" . $i->getVar('groups') . "]' value='" . $i->getVar('groups') . "'>
272
            <input type='hidden' name='oldbcachetime[" . $i->getVar('bid') . "]' value='" . $i->getVar('bcachetime') . "'>
273
            <input type='hidden' name='bid[" . $i->getVar('bid') . "]' value='" . $i->getVar('bid') . "'>
274
            </td></tr>
275
            ";
276
            $class = ('even' === $class) ? 'odd' : 'even';
277
        }
278
        echo "<tr><td class='foot' align='center' colspan='8'>
279
        <input type='hidden' name='op' value='order'>
280
        " . $GLOBALS['xoopsSecurity']->getTokenHTML() . "
281
        <input type='submit' name='submit' value='" . _SUBMIT . "'>
282
        </td></tr></table>
283
        </form>
284
        <br><br>";
285
    }
286
287
    /**
288
     * @param int $bid
289
     */
290
    function cloneBlock($bid)
291
    {
292
        require_once __DIR__ . '/admin_header.php';
293
        //require_once __DIR__ . '/admin_header.php';
294
        xoops_cp_header();
295
296
        xoops_loadLanguage('admin', 'system');
297
        xoops_loadLanguage('admin/blocksadmin', 'system');
298
        xoops_loadLanguage('admin/groups', 'system');
299
300
        $moduleDirName      = basename(dirname(__DIR__));
301
        $moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName
302
303
        //        mpu_adm_menu();
304
        $myblock = new \XoopsBlock($bid);
305
        $db      = \XoopsDatabaseFactory::getDatabaseConnection();
306
        $sql     = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . (int)$bid;
307
        $result  = $db->query($sql);
308
        $modules = [];
309
        while (false !== ($row = $db->fetchArray($result))) {
310
            $modules[] = (int)$row['module_id'];
311
        }
312
        $is_custom = ('C' === $myblock->getVar('block_type') || 'E' === $myblock->getVar('block_type'));
313
        $block     = [
0 ignored issues
show
The assignment to $block is dead and can be removed.
Loading history...
314
            'title'      => $myblock->getVar('title') . ' Clone',
315
            'form_title' => constant('CO_' . $moduleDirNameUpper . '_' . 'BLOCKS_CLONEBLOCK'),
316
            'name'       => $myblock->getVar('name'),
317
            'side'       => $myblock->getVar('side'),
318
            'weight'     => $myblock->getVar('weight'),
319
            'visible'    => $myblock->getVar('visible'),
320
            'content'    => $myblock->getVar('content', 'N'),
321
            'modules'    => $modules,
322
            'is_custom'  => $is_custom,
323
            'ctype'      => $myblock->getVar('c_type'),
324
            'bcachetime' => $myblock->getVar('bcachetime'),
325
            'op'         => 'clone_ok',
326
            'bid'        => $myblock->getVar('bid'),
327
            'edit_form'  => $myblock->getOptions(),
328
            'template'   => $myblock->getVar('template'),
329
            'options'    => $myblock->getVar('options'),
330
        ];
331
        echo '<a href="blocksadmin.php">' . _AM_BADMIN . '</a>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;' . _AM_SYSTEM_BLOCKS_CLONEBLOCK . '<br><br>';
332
        require_once __DIR__ . '/blockform.php';
333
        /** @var ThemeForm $form */
334
        $form->display();
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $form seems to be never defined.
Loading history...
335
        //        xoops_cp_footer();
336
        require_once __DIR__ . '/admin_footer.php';
337
        exit();
0 ignored issues
show
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
338
    }
339
340
    /**
341
     * @param int $bid
342
     * @param     $bside
343
     * @param     $bweight
344
     * @param     $bvisible
345
     * @param     $bcachetime
346
     * @param     $bmodule
347
     * @param     $options
348
     */
349
    function isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options)
350
    {
351
        xoops_loadLanguage('admin', 'system');
352
        xoops_loadLanguage('admin/blocksadmin', 'system');
353
        xoops_loadLanguage('admin/groups', 'system');
354
355
        $block = new \XoopsBlock($bid);
356
        $clone = $block->xoopsClone();
357
        if (empty($bmodule)) {
358
            xoops_cp_header();
359
            xoops_error(sprintf(_AM_NOTSELNG, _AM_VISIBLEIN));
360
            xoops_cp_footer();
361
            exit();
0 ignored issues
show
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
362
        }
363
        $clone->setVar('side', $bside);
364
        $clone->setVar('weight', $bweight);
365
        $clone->setVar('visible', $bvisible);
366
        //$clone->setVar('content', $_POST['bcontent']);
367
        $clone->setVar('title', Request::getString('btitle', '', 'POST'));
368
        $clone->setVar('bcachetime', $bcachetime);
369
        if (isset($options) && (count($options) > 0)) {
370
            $options = implode('|', $options);
371
            $clone->setVar('options', $options);
372
        }
373
        $clone->setVar('bid', 0);
374
        if ('C' === $block->getVar('block_type') || 'E' === $block->getVar('block_type')) {
375
            $clone->setVar('block_type', 'E');
376
        } else {
377
            $clone->setVar('block_type', 'D');
378
        }
379
        $newid = $clone->store();
380
        if (!$newid) {
381
            xoops_cp_header();
382
            $clone->getHtmlErrors();
383
            xoops_cp_footer();
384
            exit();
0 ignored issues
show
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
385
        }
386
        if ('' !== $clone->getVar('template')) {
387
            /** @var \XoopsTplfileHandler $tplfileHandler */
388
            $tplfileHandler = xoops_getHandler('tplfile');
389
            $btemplate      = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $bid);
390
            if (count($btemplate) > 0) {
391
                $tplclone = $btemplate[0]->xoopsClone();
392
                $tplclone->setVar('tpl_id', 0);
393
                $tplclone->setVar('tpl_refid', $newid);
394
                $tplfileHandler->insert($tplclone);
395
            }
396
        }
397
        $db = \XoopsDatabaseFactory::getDatabaseConnection();
398
        foreach ($bmodule as $bmid) {
399
            $sql = 'INSERT INTO ' . $db->prefix('block_module_link') . ' (block_id, module_id) VALUES (' . $newid . ', ' . $bmid . ')';
400
            $db->query($sql);
401
        }
402
        $groups = &$GLOBALS['xoopsUser']->getGroups();
403
        $count  = count($groups);
404
        for ($i = 0; $i < $count; ++$i) {
405
            $sql = 'INSERT INTO ' . $db->prefix('group_permission') . ' (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (' . $groups[$i] . ', ' . $newid . ", 1, 'block_read')";
406
            $db->query($sql);
407
        }
408
        redirect_header('blocksadmin.php?op=listar', 1, _AM_DBUPDATED);
409
    }
410
411
    /**
412
     * @param int    $bid
413
     * @param string $title
414
     * @param int    $weight
415
     * @param bool   $visible
416
     * @param string $side
417
     * @param int    $bcachetime
418
     */
419
    function setOrder($bid, $title, $weight, $visible, $side, $bcachetime)
420
    {
421
        $myblock = new \XoopsBlock($bid);
422
        $myblock->setVar('title', $title);
423
        $myblock->setVar('weight', $weight);
424
        $myblock->setVar('visible', $visible);
425
        $myblock->setVar('side', $side);
426
        $myblock->setVar('bcachetime', $bcachetime);
427
        $myblock->store();
0 ignored issues
show
The method store() does not exist on XoopsBlock. ( Ignorable by Annotation )

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

427
        $myblock->/** @scrutinizer ignore-call */ 
428
                  store();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
428
    }
429
430
    /**
431
     * @param int $bid
432
     */
433
    function editBlock($bid)
434
    {
435
        require_once __DIR__ . '/admin_header.php';
436
        //require_once __DIR__ . '/admin_header.php';
437
        xoops_cp_header();
438
439
        xoops_loadLanguage('admin', 'system');
440
        xoops_loadLanguage('admin/blocksadmin', 'system');
441
        xoops_loadLanguage('admin/groups', 'system');
442
        //        mpu_adm_menu();
443
        $myblock = new \XoopsBlock($bid);
444
        $db      = \XoopsDatabaseFactory::getDatabaseConnection();
445
        $sql     = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . (int)$bid;
446
        $result  = $db->query($sql);
447
        $modules = [];
448
        while (false !== ($row = $db->fetchArray($result))) {
449
            $modules[] = (int)$row['module_id'];
450
        }
451
        $is_custom = ('C' === $myblock->getVar('block_type') || 'E' === $myblock->getVar('block_type'));
452
        $block     = [
0 ignored issues
show
The assignment to $block is dead and can be removed.
Loading history...
453
            'title'      => $myblock->getVar('title'),
454
            'form_title' => _AM_SYSTEM_BLOCKS_EDITBLOCK,
455
            //        'name'       => $myblock->getVar('name'),
456
            'side'       => $myblock->getVar('side'),
457
            'weight'     => $myblock->getVar('weight'),
458
            'visible'    => $myblock->getVar('visible'),
459
            'content'    => $myblock->getVar('content', 'N'),
460
            'modules'    => $modules,
461
            'is_custom'  => $is_custom,
462
            'ctype'      => $myblock->getVar('c_type'),
463
            'bcachetime' => $myblock->getVar('bcachetime'),
464
            'op'         => 'edit_ok',
465
            'bid'        => $myblock->getVar('bid'),
466
            'edit_form'  => $myblock->getOptions(),
467
            'template'   => $myblock->getVar('template'),
468
            'options'    => $myblock->getVar('options'),
469
        ];
470
        echo '<a href="blocksadmin.php">' . _AM_BADMIN . '</a>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;' . _AM_SYSTEM_BLOCKS_EDITBLOCK . '<br><br>';
471
        require_once __DIR__ . '/blockform.php';
472
        /** @var ThemeForm $form */
473
        $form->display();
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $form seems to be never defined.
Loading history...
474
        //        xoops_cp_footer();
475
        require_once __DIR__ . '/admin_footer.php';
476
        exit();
0 ignored issues
show
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
477
    }
478
479
    /**
480
     * @param int               $bid
481
     * @param string            $btitle
482
     * @param string            $bside
483
     * @param int               $bweight
484
     * @param bool              $bvisible
485
     * @param int               $bcachetime
486
     * @param array             $bmodule
487
     * @param null|array|string $options
488
     * @param null|array        $groups
489
     */
490
    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

490
    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...
491
    {
492
        $moduleDirName      = basename(dirname(__DIR__));
493
        $moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName
494
495
        $myblock = new \XoopsBlock($bid);
496
        $myblock->setVar('title', $btitle);
497
        $myblock->setVar('weight', $bweight);
498
        $myblock->setVar('visible', $bvisible);
499
        $myblock->setVar('side', $bside);
500
        $myblock->setVar('bcachetime', $bcachetime);
501
        $myblock->store();
502
503
        if (!empty($bmodule) && count($bmodule) > 0) {
504
            $sql = sprintf('DELETE FROM `%s` WHERE block_id = %u', $GLOBALS['xoopsDB']->prefix('block_module_link'), $bid);
505
            $GLOBALS['xoopsDB']->query($sql);
506
            if (in_array(0, $bmodule)) {
507
                $sql = sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $GLOBALS['xoopsDB']->prefix('block_module_link'), $bid, 0);
508
                $GLOBALS['xoopsDB']->query($sql);
509
            } else {
510
                foreach ($bmodule as $bmid) {
511
                    $sql = sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $GLOBALS['xoopsDB']->prefix('block_module_link'), $bid, (int)$bmid);
512
                    $GLOBALS['xoopsDB']->query($sql);
513
                }
514
            }
515
        }
516
        $sql = sprintf('DELETE FROM `%s` WHERE gperm_itemid = %u', $GLOBALS['xoopsDB']->prefix('group_permission'), $bid);
517
        $GLOBALS['xoopsDB']->query($sql);
518
        if (!empty($groups)) {
519
            foreach ($groups as $grp) {
520
                $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);
521
                $GLOBALS['xoopsDB']->query($sql);
522
            }
523
        }
524
        redirect_header($_SERVER['SCRIPT_NAME'], 1, constant('CO_' . $moduleDirNameUpper . '_' . 'UPDATE_SUCCESS'));
525
    }
526
527
    if ('list' === $op) {
528
        xoops_cp_header();
529
        //        mpu_adm_menu();
530
        listBlocks();
531
        require_once __DIR__ . '/admin_footer.php';
532
        exit();
533
    }
534
535
    if ('order' === $op) {
536
        if (!$GLOBALS['xoopsSecurity']->check()) {
537
            redirect_header($_SERVER['SCRIPT_NAME'], 3, implode('<br>', $GLOBALS['xoopsSecurity']->getErrors()));
538
        }
539
        foreach (array_keys($bid) as $i) {
540
            if ($oldtitle[$i] !== $title[$i] || $oldweight[$i] !== $weight[$i] || $oldvisible[$i] !== $visible[$i]
541
                || $oldside[$i] !== $side[$i]
542
                || $oldbcachetime[$i] !== $bcachetime[$i]) {
543
                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

543
                /** @scrutinizer ignore-call */ 
544
                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...
544
            }
545
            if (!empty($bmodule[$i]) && count($bmodule[$i]) > 0) {
546
                $sql = sprintf('DELETE FROM `%s` WHERE block_id = %u', $GLOBALS['xoopsDB']->prefix('block_module_link'), $bid[$i]);
547
                $GLOBALS['xoopsDB']->query($sql);
548
                if (in_array(0, $bmodule[$i])) {
549
                    $sql = sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $GLOBALS['xoopsDB']->prefix('block_module_link'), $bid[$i], 0);
550
                    $GLOBALS['xoopsDB']->query($sql);
551
                } else {
552
                    foreach ($bmodule[$i] as $bmid) {
553
                        $sql = sprintf('INSERT INTO `%s` (block_id, module_id) VALUES (%u, %d)', $GLOBALS['xoopsDB']->prefix('block_module_link'), $bid[$i], (int)$bmid);
554
                        $GLOBALS['xoopsDB']->query($sql);
555
                    }
556
                }
557
            }
558
            $sql = sprintf('DELETE FROM `%s` WHERE gperm_itemid = %u', $GLOBALS['xoopsDB']->prefix('group_permission'), $bid[$i]);
559
            $GLOBALS['xoopsDB']->query($sql);
560
            if (!empty($groups[$i])) {
561
                foreach ($groups[$i] as $grp) {
562
                    $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]);
563
                    $GLOBALS['xoopsDB']->query($sql);
564
                }
565
            }
566
        }
567
        redirect_header($_SERVER['SCRIPT_NAME'], 1, constant('CO_' . $moduleDirNameUpper . '_' . 'UPDATE_SUCCESS'));
568
    }
569
    if ('clone' === $op) {
570
        cloneBlock($bid);
571
    }
572
573
    if ('edit' === $op) {
574
        editBlock($bid);
575
    }
576
577
    if ('edit_ok' === $op) {
578
        updateBlock($bid, $btitle, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options, $groups);
579
    }
580
581
    if ('clone_ok' === $op) {
582
        isBlockCloned($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options);
583
    }
584
} else {
585
    echo constant('CO_' . $moduleDirNameUpper . '_' . 'ERROR403');
586
}
587