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.

blocks/columns_spot.php (7 issues)

1
<?php
2
/**
3
 * Module: Soapbox
4
 * Author: hsalazar
5
 * Licence: GNU
6
 * @param $options
7
 * @return array
8
 */
9
10
use XoopsModules\Soapbox;
11
12
/* This function spotlights a column, with a spotlight article and links to others */
13
// defined('XOOPS_ROOT_PATH') || die('Restricted access');
14
15
/**
16
 * @param $options
17
 * @return array
18
 */
19
function b_columns_spot_show($options)
20
{
21
    $block_outdata = [];
22
    //-------------------------------------
23
    $myts          = \MyTextSanitizer:: getInstance();
24
    $helper        = \XoopsModules\Soapbox\Helper::getInstance();
0 ignored issues
show
The assignment to $helper is dead and can be removed.
Loading history...
25
    $module_name   = 'soapbox';
26
    $moduleHandler = xoops_getHandler('module');
27
    $soapModule    = $moduleHandler->getByDirname($module_name);
0 ignored issues
show
The method getByDirname() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsModuleHandler 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

27
    /** @scrutinizer ignore-call */ 
28
    $soapModule    = $moduleHandler->getByDirname($module_name);
Loading history...
28
    if (!is_object($soapModule)) {
29
        return null;
30
    }
31
32
    $hModConfig = xoops_getHandler('config');
33
    $module_id  = $soapModule->getVar('mid');
34
    $soapConfig = $hModConfig->getConfigsByCat(0, $module_id);
0 ignored issues
show
The method getConfigsByCat() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler. ( Ignorable by Annotation )

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

34
    /** @scrutinizer ignore-call */ 
35
    $soapConfig = $hModConfig->getConfigsByCat(0, $module_id);
Loading history...
35
    //-------------------------------------
36
    // To handle options in the template
37
    if (isset($options[0]) && 1 === $options[0]) {
38
        $block_outdata['showspotlight'] = 1;
39
    } else {
40
        $block_outdata['showspotlight'] = 0;
41
    }
42
    //-------------------------------------
43
    if (isset($options[1])) {
44
        $options[1] = (int)$options[1];
45
    } else {
46
        $options[1] = 0;
47
    }
48
    if (0 === $options[1]) {
49
        $block_outdata['showartcles'] = 0;
50
    } else {
51
        $block_outdata['showartcles'] = 1;
52
    }
53
    //-------------------------------------
54
    if (isset($options[2]) && 1 === $options[2]) {
55
        $block_outdata['showdateask'] = 1;
56
    } else {
57
        $block_outdata['showdateask'] = 0;
58
    }
59
    //-------------------------------------
60
    if (isset($options[3]) && 1 === $options[3]) {
61
        $block_outdata['showbylineask'] = 1;
62
    } else {
63
        $block_outdata['showbylineask'] = 0;
64
    }
65
    //-------------------------------------
66
    if (isset($options[4]) && 1 === $options[4]) {
67
        $block_outdata['showstatsask'] = 1;
68
    } else {
69
        $block_outdata['showstatsask'] = 0;
70
    }
71
    //-------------------------------------
72
    if (isset($options[5]) && 'ver' === $options[5]) {
73
        $block_outdata['verticaltemplate'] = 1;
74
    } else {
75
        $block_outdata['verticaltemplate'] = 0;
76
    }
77
    //-------------------------------------
78
    if (isset($options[6]) && 1 === $options[6]) {
79
        $block_outdata['showpicask'] = 1;
80
    } else {
81
        $block_outdata['showpicask'] = 0;
82
    }
83
    //-------------------------------------
84
    $sortname = $options[7];
85
    if (!in_array($sortname, ['datesub', 'weight', 'counter', 'rating', 'headline'], true)) {
86
        $sortname = 'datesub';
87
    }
88
    $sortorder = 'DESC';
89
    if ('weight' === $sortname) {
90
        $sortorder = 'ASC';
91
    }
92
    //-------------------------------------
93
    if (isset($options[8]) && (int)$options[8] > 0) {
94
        $options[8] = (int)$options[8];
95
    } else {
96
        $options[8] = 65;
97
    }
98
    //-------------------------------------
99
    // Try to see what tabs are visibles (if we are in restricted view of course)
100
    $opt_columnIDs = [];
101
    if (!empty($options[9])) {
102
        $opt_columnIDs = array_slice($options, 9);
103
    }
104
    if (!empty($opt_columnIDs) && is_array($opt_columnIDs)) {
105
        foreach ($opt_columnIDs as $v) {
106
            $columnIDs[] = (int)$v;
107
        }
108
    } else {
109
        $columnIDs = null;
110
    }
111
    // Retrieve the column's name
112
    //    $resultB = $xoopsDB -> query( "SELECT name, colimage FROM ". $xoopsDB -> prefix( "sbcolumns" ) . " WHERE columnID = " . $options[0] . " " );
113
    //    list ( $name, $colimage ) = $xoopsDB -> fetchRow( $resultB );
114
    //-------------------------------------
115
    /** @var \XoopsModules\Soapbox\EntrygetHandler $entrydataHandler */
116
    $entrydataHandler = new \XoopsModules\Soapbox\EntrygetHandler();
117
    //-------------------------------------
118
    //get category object
119
    $categoryobArray = $entrydataHandler->getColumnsAllPermcheck(0, 0, true, 'weight', 'ASC', $columnIDs, null, true, false);
0 ignored issues
show
The call to XoopsModules\Soapbox\Ent...etColumnsAllPermcheck() has too many arguments starting with false. ( Ignorable by Annotation )

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

119
    /** @scrutinizer ignore-call */ 
120
    $categoryobArray = $entrydataHandler->getColumnsAllPermcheck(0, 0, true, 'weight', 'ASC', $columnIDs, null, true, false);

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...
Comprehensibility Best Practice introduced by
The variable $columnIDs does not seem to be defined for all execution paths leading up to this point.
Loading history...
120
    if (empty($categoryobArray) || 0 === count($categoryobArray)) {
121
        $block_outdata['display'] = 0;
122
123
        return $block_outdata;
124
    }
125
    $block_outdata['display'] = 1;
126
    //-------------------------------------
127
    $block_outdata['totalcols']   = $entrydataHandler->total_getColumnsAllPermcheck;
128
    $block_outdata['moduledir']   = $module_name;
129
    $block_outdata['modulename']  = $soapModule->getVar('name');
130
    $block_outdata['sbuploaddir'] = $myts->htmlSpecialChars($soapConfig['sbuploaddir']);
131
    //-------------------------------------
132
    $i_col = 1;
133
    xoops_load('XoopsUserUtility');
134
    foreach ($categoryobArray as $_categoryob) {
135
        //----------------------------
136
        $category                   = $_categoryob->toArray(); //all assign
137
        $_outdata_arr               = [];
0 ignored issues
show
The assignment to $_outdata_arr is dead and can be removed.
Loading history...
138
        $_outdata_arr               = $category;
139
        $_outdata_arr['authorname'] = \XoopsUserUtility::getUnameFromId((int)$category['author']);
140
        //-------------------------------------
141
        if (0 === $options[1]) {
142
            $_outdata_arr['artdatas'] = [];
143
        } else {
144
            //-------------------------------------
145
            // Retrieve the latest article in the selected column
146
            $entryobArray              = $entrydataHandler->getArticlesAllPermcheck($options[1], 0, true, true, 0, 0, 1, $sortname, $sortorder, $category['columnID'], null, false, false);
147
            $_outdata_arr['totalarts'] = $entrydataHandler->total_getArticlesAllPermcheck;
148
            //----------------------------
149
            //xoops_load('XoopsUserUtility');
150
            $i = 1;
151
            foreach ($entryobArray as $key => $_entryob) {
152
                // get vars initialize
153
                //-------------------------------------
154
                $articles   = $_entryob->toArray();
155
                $articles[] = $articles;
156
                //spot
157
                $articles['poster'] = \XoopsUserUtility::getUnameFromId($articles['uid']);
158
                $articles['date']   = $myts->htmlSpecialChars(formatTimestamp($articles['datesub'], $soapConfig['dateformat']));
159
                $articles['rating'] = number_format($articles['rating'], 2, '.', '');
160
                // -- Then the teaser text and as sorted data
161
                $articles['subhead']     = xoops_substr($articles['headline'], 0, $options[8]);
162
                $articles['sublead']     = xoops_substr($articles['lead'], 0, $options[8]);
163
                $articles['subteaser']   = xoops_substr($articles['teaser'], 0, $options[8]);
164
                $articles['subbodytext'] = xoops_substr($articles['bodytext'], 0, $options[8]);
165
                $articles['bodytext']    = '';
166
167
                if ('datesub' === $sortname) {
168
                    $articles['new'] = $myts->htmlSpecialChars(formatTimestamp($articles['datesub'], $soapConfig['dateformat']));
169
                } elseif ('counter' === $sortname) {
170
                    $articles['new'] = _MB_SOAPBOX_HITS . $articles['counter'];
171
                } elseif ('weight' === $sortname) {
172
                    $articles['new'] = _MB_SOAPBOX_WEIGHT . $articles['weight'];
173
                } elseif ('rating' === $sortname) {
174
                    $articles['new'] = _MB_SOAPBOX_RATING . number_format($articles['rating'], 2, '.', '') . _MB_SOAPBOX_VOTE . $articles['votes'];
175
                } else {
176
                    $articles['new'] = $myts->htmlSpecialChars(formatTimestamp($articles['datesub'], $soapConfig['dateformat']));
177
                }
178
                //--------------------
179
                $_outdata_arr['artdatas'][$i] = $articles;
180
                unset($articles);
181
                ++$i;
182
            }
183
        }
184
        //-------------------------------------
185
        $block_outdata['coldatas'][$i_col] = $_outdata_arr;
186
        unset($_outdata_arr);
187
        ++$i_col;
188
    }
189
190
    return $block_outdata;
191
}
192
193
/**
194
 * @param $options
195
 * @return string
196
 */
197
function b_columns_spot_edit($options)
198
{
199
    $myts          = \MyTextSanitizer:: getInstance();
200
    $helper        = \XoopsModules\Soapbox\Helper::getInstance();
0 ignored issues
show
The assignment to $helper is dead and can be removed.
Loading history...
201
    $columnIDs     = [];
202
    $module_name   = 'soapbox';
203
    $moduleHandler = xoops_getHandler('module');
204
    $soapModule    = $moduleHandler->getByDirname($module_name);
205
    if (!is_object($soapModule)) {
206
        return null;
207
    }
208
    $form = '';
209
    //-----
210
    $chked = '';
211
    $form  .= _MB_SOAPBOX_SPOTLIGHT;
212
    if (1 === $options[0]) {
213
        $chked = ' checked';
214
    }
215
    $form  .= "<input type='radio' name='options[0]' value='1'" . $chked . '>&nbsp;' . _YES;
216
    $chked = '';
217
    if (0 === $options[0]) {
218
        $chked = ' checked';
219
    }
220
    $form .= "&nbsp;<input type='radio' name='options[0]' value='0'" . $chked . '>' . _NO . '<br>';
221
    //-----
222
    //-----
223
    $form .= _MB_SOAPBOX_ARTSTOSHOW . "<input type='text' name='options[1]' value='" . $myts->htmlSpecialChars($options[1]) . "'>&nbsp; " . _MB_SOAPBOX_ARTCLS . '.<br>';
224
    //-----
225
    $chked = '';
226
    $form  .= _MB_SOAPBOX_SHOWDATE;
227
    if (1 === $options[2]) {
228
        $chked = ' checked';
229
    }
230
    $form  .= "<input type='radio' name='options[2]' value='1'" . $chked . '>&nbsp;' . _YES;
231
    $chked = '';
232
    if (0 === $options[2]) {
233
        $chked = ' checked';
234
    }
235
    $form .= "&nbsp;<input type='radio' name='options[2]' value='0'" . $chked . '>' . _NO . '<br>';
236
    //-----
237
    $chked = '';
238
    $form  .= _MB_SOAPBOX_SHOWBYLINE;
239
    if (1 === $options[3]) {
240
        $chked = ' checked';
241
    }
242
    $form  .= "<input type='radio' name='options[3]' value='1'" . $chked . '>&nbsp;' . _YES;
243
    $chked = '';
244
    if (0 === $options[3]) {
245
        $chked = ' checked';
246
    }
247
    $form .= '&nbsp;<input type="radio" name="options[3]" value="0"' . $chked . '>' . _NO . '<br>';
248
    //-----
249
    $chked = '';
250
    $form  .= _MB_SOAPBOX_SHOWSTATS;
251
    if (1 === $options[4]) {
252
        $chked = ' checked';
253
    }
254
    $form  .= "<input type='radio' name='options[4]' value='1'" . $chked . '>&nbsp;' . _YES;
255
    $chked = '';
256
    if (0 === $options[4]) {
257
        $chked = ' checked';
258
    }
259
    $form .= "&nbsp;<input type='radio' name='options[4]' value='0' " . $chked . '>' . _NO . '<br>';
260
261
    $form .= _MB_SOAPBOX_TEMPLATE . "<select name='options[5]' >";
262
    $form .= "<option value='ver'";
263
    if ('ver' === $options[5]) {
264
        $form .= ' selected';
265
    }
266
    $form .= '>' . _MB_SOAPBOX_VERTICAL . "</option>\n";
267
    $form .= "<option value='hor'";
268
    if ('hor' === $options[5]) {
269
        $form .= ' selected';
270
    }
271
    $form .= '>' . _MB_SOAPBOX_HORIZONTAL . '</option>';
272
    $form .= '</select><br>';
273
274
    $chked = '';
275
    $form  .= _MB_SOAPBOX_SHOWPIC;
276
    if (1 === $options[6]) {
277
        $chked = ' checked';
278
    }
279
    $form .= "<input type='radio' name='options[6]' value='1' " . $chked . '>&nbsp;' . _YES;
280
281
    $chked = '';
282
    if (0 === $options[6]) {
283
        $chked = ' checked';
284
    }
285
    $form .= "&nbsp;<input type='radio' name='options[6]' value='0' " . $chked . '>' . _NO . '<br>';
286
    //---------- sortname ------
287
    $form .= '' . _MB_SOAPBOX_ORDER . "&nbsp;<select name='options[7]'>";
288
289
    $form .= "<option value='datesub'";
290
    if ('datesub' === $options[7]) {
291
        $form .= ' selected';
292
    }
293
    $form .= '>' . _MB_SOAPBOX_DATE . "</option>\n";
294
295
    $form .= "<option value='counter'";
296
    if ('counter' === $options[7]) {
297
        $form .= ' selected';
298
    }
299
    $form .= '>' . _MB_SOAPBOX_HITS . "</option>\n";
300
301
    $form .= "<option value='weight'";
302
    if ('weight' === $options[7]) {
303
        $form .= ' selected';
304
    }
305
    $form .= '>' . _MB_SOAPBOX_WEIGHT . "</option>\n";
306
307
    $form .= "<option value='rating'";
308
    if ('rating' === $options[7]) {
309
        $form .= ' selected';
310
    }
311
    $form .= '>' . _MB_SOAPBOX_RATING . "</option>\n";
312
313
    $form .= "</select>\n";
314
315
    $form .= '&nbsp;<br>' . _MB_SOAPBOX_CHARS . "&nbsp;<input type='text' name='options[8]' value='" . $myts->htmlSpecialChars($options[8]) . "'>&nbsp;" . _MB_SOAPBOX_LENGTH . '';
316
317
    //-------------------------------------
318
    // Try to see what tabs are visibles (if we are in restricted view of course)
319
    $opt_columnIDs = [];
320
    if (!empty($options[9])) {
321
        $opt_columnIDs = array_slice($options, 9);
322
    }
323
    if (!empty($opt_columnIDs) && is_array($opt_columnIDs)) {
324
        foreach ($opt_columnIDs as $v) {
325
            $columnIDs[] = (int)$v;
326
        }
327
    }
328
    /** @var \XoopsModules\Soapbox\EntrygetHandler $entrydataHandler */
329
    $entrydataHandler = new \XoopsModules\Soapbox\EntrygetHandler();
330
    $categoryobArray  = $entrydataHandler->getColumns();
331
    $form             .= '<br>' . _MB_SOAPBOX_SPOTLIGHT_TOPIC . "<br><select name='options[]' multiple='multiple'>";
332
    $form             .= "<option value='0'>(ALL)</option>";
333
    if (!empty($categoryobArray)) {
334
        foreach ($categoryobArray as $_categoryob) {
335
            $categoryID = $_categoryob->getVar('columnID');
336
            $name       = $_categoryob->getVar('name');
337
            $sel        = '';
338
            if (in_array($categoryID, $columnIDs, true)) {
339
                $sel = ' selected="selected"';
340
            }
341
            $form .= "<option value='" . $categoryID . "' " . $sel . '>' . $categoryID . ' : ' . $name . '</option>';
342
        }
343
    }
344
    $form .= "</select><br>\n";
345
346
    return $form;
347
}
348