Issues (299)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  Header Injection
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

admin/myblocksadmin.php (20 issues)

1
<?php declare(strict_types=1);
2
3
/**
4
 * Module: SmartFAQ
5
 * Author: The SmartFactory <www.smartfactory.ca>
6
 * Licence: GNU
7
 */
8
9
// ------------------------------------------------------------------------- //
10
//                            myblocksadmin.php                              //
11
//                - XOOPS block admin for each module -                      //
12
//                          GIJOE <https://www.peak.ne.jp>                   //
13
// ------------------------------------------------------------------------- //
14
15
use Xmf\Request;
16
use XoopsModules\Smartfaq;
17
use XoopsModules\Smartfaq\Constants;
18
19
require __DIR__ . '/admin_header.php';
20
xoops_cp_header();
21
22
$moduleDirName      = \basename(\dirname(__DIR__));
23
$moduleDirNameUpper = \mb_strtoupper($moduleDirName);
24
25
$helper->loadLanguage('admin');
26
27
//require_once __DIR__ . '/mygrouppermform.php';
28
require_once XOOPS_ROOT_PATH . '/class/xoopsblock.php';
29
//require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->dirname() . '/include/functions.php';
30
31
$xoops_system_path = XOOPS_ROOT_PATH . '/modules/system';
32
33
// language files
34
$language = $xoopsConfig['language'];
35
if (!file_exists("$xoops_system_path/language/$language/admin/blocksadmin.php")) {
36
    $language = 'english';
37
}
38
39
// to prevent from notice that constants already defined
40
$error_reporting_level = error_reporting(0);
41
require_once \dirname(__DIR__, 2) . '/system/constants.php';
42
require_once __DIR__ . "/../../language/$language/admin.php";
43
require_once __DIR__ . "/../../language/$language/admin/blocksadmin.php";
44
//require_once  \dirname(__DIR__) . '/include/functions.php';
45
error_reporting($error_reporting_level);
46
47
$group_defs = file("$xoops_system_path/language/$language/admin/groups.php");
48
foreach ($group_defs as $def) {
49
    if (false !== mb_strpos($def, '_AM_ACCESSRIGHTS') || false !== mb_strpos($def, '_AM_ACTIVERIGHTS')) {
50
        eval($def);
0 ignored issues
show
The use of eval() is discouraged.
Loading history...
51
    }
52
}
53
54
// check $xoopsModule
55
if (!is_object($xoopsModule)) {
56
    redirect_header(XOOPS_URL . '/user.php', 1, _NOPERM);
57
}
58
59
// set target_module if specified by $_GET['dirname']
60
/** @var \XoopsModuleHandler $moduleHandler */
61
$moduleHandler = xoops_getHandler('module');
62
if (!empty($_GET['dirname'])) {
63
    $target_module = $moduleHandler->getByDirname($_GET['dirname']);
64
}
65
66
if (!empty($target_module) && is_object($target_module)) {
67
    // specified by dirname
68
    $target_mid     = $target_module->getVar('mid');
69
    $target_mname   = $target_module->getVar('name') . '&nbsp;' . sprintf('(%2.2f)', $target_module->getVar('version') / 100.0);
70
    $query4redirect = '?dirname=' . urlencode(strip_tags($_GET['dirname']));
71
} elseif (Request::hasVar('mid', 'GET') && 0 == $_GET['mid'] || 'blocksadmin' === $xoopsModule->getVar('dirname')) {
0 ignored issues
show
Consider adding parentheses for clarity. Current Interpretation: (Xmf\Request::hasVar('mi...dule->getVar('dirname'), Probably Intended Meaning: Xmf\Request::hasVar('mid...ule->getVar('dirname'))
Loading history...
72
    $target_mid     = 0;
73
    $target_mname   = '';
74
    $query4redirect = '?mid=0';
75
} else {
76
    $target_mid     = $xoopsModule->getVar('mid');
77
    $target_mname   = $xoopsModule->getVar('name');
78
    $query4redirect = '';
79
}
80
81
// check access right (needs system_admin of BLOCK)
82
/** @var \XoopsGroupPermHandler $grouppermHandler */
83
$grouppermHandler = xoops_getHandler('groupperm');
84
if (!$grouppermHandler->checkRight('system_admin', XOOPS_SYSTEM_BLOCK, $xoopsUser->getGroups())) {
85
    redirect_header(XOOPS_URL . '/user.php', 1, _NOPERM);
86
}
87
88
// get blocks owned by the module (Imported from xoopsblock.php then modified)
89
$db        = \XoopsDatabaseFactory::getDatabaseConnection();
90
$sql       = 'SELECT * FROM ' . $db->prefix('newblocks') . " WHERE mid='$target_mid' ORDER BY visible DESC,side,weight";
91
$result    = $db->query($sql);
92
$block_arr = [];
93
while (false !== ($myrow = $db->fetchArray($result))) {
94
    $block_arr[] = new \XoopsBlock($myrow);
95
}
96
97
function list_blocks(): void
98
{
99
    global $query4redirect, $block_arr;
100
101
    // cachetime options
102
    $cachetimes = [
103
        0       => _NOCACHE,
104
        30      => sprintf(_SECONDS, 30),
105
        60      => _MINUTE,
106
        300     => sprintf(_MINUTES, 5),
107
        1800    => sprintf(_MINUTES, 30),
108
        3600    => _HOUR,
109
        18000   => sprintf(_HOURS, 5),
110
        86400   => _DAY,
111
        259200  => sprintf(_DAYS, 3),
112
        604800  => _WEEK,
113
        2592000 => _MONTH,
114
    ];
115
116
    // displaying TH
117
    Smartfaq\Utility::collapsableBar('toptable', 'toptableicon');
118
    echo "<img id='toptableicon' src=" . XOOPS_URL . '/modules/' . $xoopsModule->dirname() . "/assets/images/icon/close12.gif alt=''></a>&nbsp;" . _AM_SF_BLOCKS . '</h3>';
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $xoopsModule seems to be never defined.
Loading history...
119
    echo "<div id='toptable'>";
120
    echo '<span style="color: #567; margin: 3px 0 12px 0; font-size: small; display: block; ">' . _AM_SF_BLOCKSTXT . '</span>';
121
122
    echo "
123
    <form action='admin.php' name='blockadmin' method='post'>
124
        <table width='100%' class='outer' cellpadding='4' cellspacing='1'>
125
        <tr valign='middle'>
126
            <th>" . _AM_SYSTEM_BLOCKS_TITLE . "</th>
127
            <th align='center' nowrap='nowrap'>" . _AM_SF_POSITION . "</th>
128
            <th align='center'>" . constant('CO_' . $moduleDirNameUpper . '_' . 'WEIGHT') . "</th>
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $moduleDirNameUpper seems to be never defined.
Loading history...
129
            <th align='center'>" . _AM_SYSTEM_BLOCKS_VISIBLEIN . "</th>
130
            <th align='center'>" . _AM_SYSTEM_BLOCKS_BCACHETIME . "</th>
131
            <th align='center'>" . constant('CO_' . $moduleDirNameUpper . '_' . 'ACTION') . "</th>
132
        </tr>\n";
133
134
    // blocks displaying loop
135
    $class         = 'even';
136
    $block_configs = get_block_configs();
137
    foreach (array_keys($block_arr) as $i) {
138
        $sseln = $ssel0 = $ssel1 = $ssel2 = $ssel3 = $ssel4 = $ssel5 = $ssel6 = $ssel7 = '';
0 ignored issues
show
The assignment to $ssel5 is dead and can be removed.
Loading history...
The assignment to $ssel7 is dead and can be removed.
Loading history...
The assignment to $ssel6 is dead and can be removed.
Loading history...
139
        $scoln = $scol0 = $scol1 = $scol2 = $scol3 = $scol4 = $ssel5 = $ssel6 = $ssel7 = '';
0 ignored issues
show
The assignment to $scol1 is dead and can be removed.
Loading history...
The assignment to $scol4 is dead and can be removed.
Loading history...
The assignment to $scol3 is dead and can be removed.
Loading history...
The assignment to $scol0 is dead and can be removed.
Loading history...
The assignment to $scol2 is dead and can be removed.
Loading history...
140
141
        $weight     = $block_arr[$i]->getVar('weight');
142
        $title      = $block_arr[$i]->getVar('title');
143
        $name       = $block_arr[$i]->getVar('name');
144
        $bcachetime = $block_arr[$i]->getVar('bcachetime');
145
        $bid        = $block_arr[$i]->getVar('bid');
146
147
        // visible and side
148
        if (1 != $block_arr[$i]->getVar('visible')) {
149
            $sseln = ' checked';
150
            $scoln = '#FF9966';
151
        } else {
152
            switch ($block_arr[$i]->getVar('side')) {
153
                default:
154
                case XOOPS_SIDEBLOCK_LEFT:
155
                    $ssel0 = ' checked';
156
                    $scol0 = '#00FF00';
157
                    break;
158
                case XOOPS_SIDEBLOCK_RIGHT:
159
                    $ssel1 = ' checked';
160
                    $scol1 = '#00FF00';
161
                    break;
162
                case XOOPS_CENTERBLOCK_LEFT:
163
                    $ssel2 = ' checked';
164
                    $scol2 = '#00FF00';
165
                    break;
166
                case XOOPS_CENTERBLOCK_RIGHT:
167
                    $ssel4 = ' checked';
168
                    $scol4 = '#00FF00';
169
                    break;
170
                case XOOPS_CENTERBLOCK_CENTER:
171
                    $ssel3 = ' checked';
172
                    $scol3 = '#00FF00';
173
                    break;
174
                case XOOPS_CENTERBLOCK_BOTTOMLEFT:
175
                    $ssel5 = ' checked';
176
                    $scol5 = '#00FF00';
0 ignored issues
show
The assignment to $scol5 is dead and can be removed.
Loading history...
177
                    break;
178
                case XOOPS_CENTERBLOCK_BOTTOMRIGHT:
179
                    $ssel6 = ' checked';
180
                    $scol6 = '#00FF00';
0 ignored issues
show
The assignment to $scol6 is dead and can be removed.
Loading history...
181
                    break;
182
                case XOOPS_CENTERBLOCK_BOTTOM:
183
                    $ssel7 = ' checked';
184
                    $scol7 = '#00FF00';
0 ignored issues
show
The assignment to $scol7 is dead and can be removed.
Loading history...
185
                    break;
186
            }
187
        }
188
189
        // bcachetime
190
        $cachetime_options = '';
191
        foreach ($cachetimes as $cachetime => $cachetime_name) {
192
            if ($bcachetime == $cachetime) {
193
                $cachetime_options .= "<option value='$cachetime' selected>$cachetime_name</option>\n";
194
            } else {
195
                $cachetime_options .= "<option value='$cachetime'>$cachetime_name</option>\n";
196
            }
197
        }
198
199
        // target modules
200
        $db            = \XoopsDatabaseFactory::getDatabaseConnection();
201
        $result        = $db->query('SELECT module_id FROM ' . $db->prefix('block_module_link') . " WHERE block_id='$bid'");
202
        $selected_mids = [];
203
        while ([$selected_mid] = $db->fetchRow($result)) {
204
            $selected_mids[] = (int)$selected_mid;
205
        }
206
        /** @var \XoopsModuleHandler $moduleHandler */
207
        $moduleHandler = xoops_getHandler('module');
208
        $criteria      = new \CriteriaCompo(new \Criteria('hasmain', 1));
209
        $criteria->add(new \Criteria('isactive', 1));
210
        $module_list    = $moduleHandler->getList($criteria);
211
        $moduleList[-1] = _AM_SYSTEM_BLOCKS_TOPPAGE;
212
        $moduleList[0]  = _AM_SYSTEM_BLOCKS_ALLPAGES;
213
        ksort($module_list);
214
        $module_options = '';
215
        foreach ($module_list as $mid => $mname) {
216
            if (in_array($mid, $selected_mids, true)) {
217
                $module_options .= "<option value='$mid' selected>$mname</option>\n";
218
            } else {
219
                $module_options .= "<option value='$mid'>$mname</option>\n";
220
            }
221
        }
222
223
        // delete link if it is cloned block
224
        if ('D' === $block_arr[$i]->getVar('block_type') || 'C' === $block_arr[$i]->getVar('block_type')) {
225
            $delete_link = "<br><a href='admin.php?fct=blocksadmin&amp;op=delete&amp;bid=$bid'>" . _DELETE . '</a>';
226
        } else {
227
            $delete_link = '';
228
        }
229
230
        // clone link if it is marked as cloneable block
231
        // $modversion['blocks'][n]['can_clone']
232
        if ('D' === $block_arr[$i]->getVar('block_type') || 'C' === $block_arr[$i]->getVar('block_type')) {
233
            $can_clone = true;
234
        } else {
235
            $can_clone = false;
236
            foreach ($block_configs as $bconf) {
237
                if ($block_arr[$i]->getVar('show_func') == $bconf['show_func']
238
                    && $block_arr[$i]->getVar('func_file') == $bconf['file']
239
                    && (empty($bconf['template'])
240
                        || $block_arr[$i]->getVar('template') == $bconf['template'])) {
241
                    if (!empty($bconf['can_clone'])) {
242
                        $can_clone = true;
243
                    }
244
                }
245
            }
246
        }
247
        if ($can_clone) {
248
            $clone_link = "<br><a href='admin.php?fct=blocksadmin&amp;op=clone&amp;bid=$bid'>" . _CLONE . '</a>';
249
        } else {
250
            $clone_link = '';
251
        }
252
253
        // displaying part
254
        echo "
255
        <tr valign='middle'>
256
            <td class='$class'>
257
                $name
258
                <br>
259
                <input type='text' name='title[$bid]' value='$title' size='20'>
260
            </td>
261
            <td class='$class' align='center' nowrap='nowrap' width='125px'>
262
      <div align='center' >
263
          <input type='radio' name='side[$bid]' value='" . XOOPS_CENTERBLOCK_LEFT . "'$ssel2 >
264
          <input type='radio' name='side[$bid]' value='" . XOOPS_CENTERBLOCK_CENTER . "'$ssel3 >
265
          <input type='radio' name='side[$bid]' value='" . XOOPS_CENTERBLOCK_RIGHT . "'$ssel4 >
266
      </div>
267
      <div>
268
          <span style='float:right;'><input type='radio' name='side[$bid]' value='" . XOOPS_SIDEBLOCK_RIGHT . "'$ssel1 ></span>
269
          <div align='left'><input type='radio' name='side[$bid]' value='" . XOOPS_SIDEBLOCK_LEFT . "'$ssel0 ></div>
270
      </div>
271
      <div align='center'>
272
          <input type='radio' name='side[$bid]' value='" . XOOPS_CENTERBLOCK_BOTTOMLEFT . "'$ssel5 >
273
          <input type='radio' name='side[$bid]' value='" . XOOPS_CENTERBLOCK_BOTTOM . "'$ssel7 >
274
          <input type='radio' name='side[$bid]' value='" . XOOPS_CENTERBLOCK_BOTTOMRIGHT . "'$ssel6 >
275
      </div>
276
                <br>
277
        <div style='float:left;width:30%;'>&nbsp;</div>
278
                <div style='float:left;background-color:$scoln;'>
279
                <input type='radio' name='side[$bid]' value='-1'$sseln>
280
                </div>
281
                <div style='float:left;'>" . _NONE . "</div>
282
            </td>
283
            <td class='$class' align='center'>
284
                <input type='text' name=weight[$bid] value='$weight' size='3' maxlength='5' style='text-align:right;' >
285
            </td>
286
            <td class='$class' align='center'>
287
                <select name='bmodule[$bid][]' size='5' multiple='multiple'>
288
                    $module_options
289
                </select>
290
            </td>
291
            <td class='$class' align='center'>
292
                <select name='bcachetime[$bid]' size='1'>
293
                    $cachetime_options
294
                </select>
295
            </td>
296
            <td class='$class' align='right'>
297
                <a href='admin.php?fct=blocksadmin&amp;op=edit&amp;bid=$bid'>" . _EDIT . "</a>{$delete_link}{$clone_link}
298
                <input type='hidden' name='bid[$bid]' value='$bid'>
299
            </td>
300
        </tr>\n";
301
302
        $class = ('even' === $class) ? 'odd' : 'even';
303
    }
304
305
    echo "<tr>
306
            <td class='foot' align='center' colspan='6'>
307
                <input type='hidden' name='query4redirect' value='$query4redirect' >
308
                <input type='hidden' name='fct' value='blocksadmin'>
309
                <input type='hidden' name='op' value='order'>
310
                " . $GLOBALS['xoopsSecurity']->getTokenHTML('myblocksadmin') . "
311
                <input type='submit' name='submit' value='" . _SUBMIT . "'>
312
            </td>
313
        </tr>
314
        </table>
315
    </form>\n";
316
    echo '</div>';
317
}
318
319
/**
320
 * @return array
321
 */
322
function get_block_configs()
323
{
324
    $error_reporting_level = error_reporting(0);
325
    if (preg_match('/^[.0-9a-zA-Z_-]+$/', @$_GET['dirname'])) {
326
        require_once \dirname(__DIR__, 2) . '/' . $_GET['dirname'] . '/xoops_version.php';
327
    } else {
328
        require_once \dirname(__DIR__) . '/xoops_version.php';
329
    }
330
    error_reporting($error_reporting_level);
331
    if (empty($modversion['blocks'])) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $modversion seems to never exist and therefore empty should always be true.
Loading history...
332
        return [];
333
    }
334
335
    return $modversion['blocks'];
336
}
337
338
function list_groups(): void
339
{
340
    global $target_mid, $target_mname, $block_arr;
341
    lx_collapsableBar('groups', 'groupIcon');
0 ignored issues
show
The function lx_collapsableBar was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

341
    /** @scrutinizer ignore-call */ 
342
    lx_collapsableBar('groups', 'groupIcon');
Loading history...
342
    echo "<img  onclick=\"toggle('groups'); toggleIcon('groupsIcon');\" id='groupsIcon' src='" . XOOPS_URL . "/modules/smartfaq/assets/images/close12.gif' alt='' ></a>&nbsp; " . _MD_AM_ADGS . ' <br>';
0 ignored issues
show
The constant _MD_AM_ADGS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
343
    echo "<div id='groups' style='float:left; width:100%;'>";
344
    $item_list = [];
345
    foreach (array_keys($block_arr) as $i) {
346
        $item_list[$block_arr[$i]->getVar('bid')] = $block_arr[$i]->getVar('title');
347
    }
348
349
    $form = new Smartfaq\GroupPermForm(_MD_AM_ADGS, 1, 'block_read', '');
350
    if ($target_mid > 1) {
351
        $form->addAppendix('module_admin', $target_mid, $target_mname . ' ' . constant('CO_' . $moduleDirNameUpper . '_' . 'ACTIVERIGHTS'));
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $moduleDirNameUpper seems to be never defined.
Loading history...
352
        $form->addAppendix('module_read', $target_mid, $target_mname . ' ' . constant('CO_' . $moduleDirNameUpper . '_' . 'ACCESSRIGHTS'));
353
    }
354
    foreach ($item_list as $item_id => $item_name) {
355
        $form->addItem($item_id, $item_name);
356
    }
357
    echo $form->render();
358
    echo '</div>';
359
}
360
361
if (!empty($_POST['submit'])) {
362
    if (!$GLOBALS['xoopsSecurity']->check(true, $_REQUEST['myblocksadmin'])) {
363
        redirect_header(XOOPS_URL . '/', 3, $GLOBALS['xoopsSecurity']->getErrors());
364
    }
365
366
    require_once __DIR__ . '/mygroupperm.php';
367
    redirect_header(XOOPS_URL . '/modules/' . $xoopsModule->dirname() . "/admin/myblocksadmin.php$query4redirect", 1, _MD_AM_DBUPDATED);
0 ignored issues
show
The constant _MD_AM_DBUPDATED was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
368
}
369
370
xoops_cp_header();
371
require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->dirname() . '/admin/functions.php';
372
373
if (!empty($block_arr)) {
374
    echo "<h4 style='text-align:left;'>$target_mname : " . constant('CO_' . $moduleDirNameUpper . '_' . 'BADMIN') . "</h4>\n";
375
    list_blocks();
376
}
377
378
list_groups();
379
xoops_cp_footer();
380