Passed
Push — master ( df5caf...cd5737 )
by Michael
02:02
created

adsModCat()   F

Complexity

Conditions 15
Paths 2560

Size

Total Lines 114
Code Lines 79

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 114
rs 2
cc 15
eloc 79
nc 2560
nop 1

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 36 and the first side effect is on line 26.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/*
3
-------------------------------------------------------------------------
4
                     ADSLIGHT 2 : Module for Xoops
5
6
        Redesigned and ameliorate By Luc Bizet user at www.frxoops.org
7
        Started with the Classifieds module and made MANY changes
8
        Website : http://www.luc-bizet.fr
9
        Contact : [email protected]
10
-------------------------------------------------------------------------
11
             Original credits below Version History
12
##########################################################################
13
#                    Classified Module for Xoops                         #
14
#  By John Mordo user jlm69 at www.xoops.org and www.jlmzone.com         #
15
#      Started with the MyAds module and made MANY changes               #
16
##########################################################################
17
 Original Author: Pascal Le Boustouller
18
 Author Website : [email protected]
19
 Licence Type   : GPL
20
-------------------------------------------------------------------------
21
*/
22
23
use Xmf\Request;
0 ignored issues
show
Bug introduced by
The type Xmf\Request was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
24
use XoopsModules\Adslight;
25
26
require_once __DIR__ . '/admin_header.php';
27
xoops_cp_header();
0 ignored issues
show
Bug introduced by
The function xoops_cp_header 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

27
/** @scrutinizer ignore-call */ 
28
xoops_cp_header();
Loading history...
28
29
$op = Request::getString('op', 'liste');
30
31
#  function adsNewCat
32
#####################################################
33
/**
34
 * @param $cat
35
 */
36
function adsNewCat($cat)
37
{
38
    global $xoopsDB, $xoopsConfig, $xoopsModule, $myts, $moduleDirName;
39
40
    $mytree = new ClassifiedsTree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid');
0 ignored issues
show
Bug introduced by
The type ClassifiedsTree was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
41
42
    //    require_once __DIR__ . '/header.php';
0 ignored issues
show
Unused Code Comprehensibility introduced by
45% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
43
44
    //    loadModuleAdminMenu(1, "");
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
45
    echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_ADDSUBCAT . '</legend>';
46
    //    ShowImg();
47
    Adslight\Utility::showImage();
48
49
    echo '<form method="post" action="category.php" name="imcat"><input type="hidden" name="op" value="AdsAddCat"></font><br><br>
50
        <table class="outer" border=0>
51
    <tr>
52
      <td class="even">' . _AM_ADSLIGHT_CATNAME . ' </td><td class="odd" colspan=2><input type="text" name="title" size="50" maxlength="100">&nbsp; ' . _AM_ADSLIGHT_IN . ' &nbsp;';
53
54
    $cid = Request::getInt('cid', 0, 'GET');
0 ignored issues
show
Unused Code introduced by
The assignment to $cid is dead and can be removed.
Loading history...
55
56
    $result = $xoopsDB->query('SELECT cid, pid, title, cat_desc, cat_keywords, img, cat_order, affprice, cat_moderate, moderate_subcat FROM ' . $xoopsDB->prefix('adslight_categories') . " WHERE cid={$cat}");
57
    list($cat_id, $pid, $title, $cat_desc, $cat_keywords, $imgs, $cat_order, $affprice, $cat_moderate, $moderate_subcat) = $xoopsDB->fetchRow($result);
58
    $mytree->makeMySelBox('title', 'title', $cat, 1);
59
    echo "    </td>\n" . "  </tr>\n";
60
61
    $cat_desc     = '';
62
    $cat_keywords = '';
63
64
    if ('1' == $GLOBALS['xoopsModuleConfig']['adslight_cat_desc']) {
65
        echo '<tr><td class="even">'
66
             . _AM_ADSLIGHT_CAT_META_DESCRIPTION
67
             . " </td><td class=\"odd\" colspan=2>\n"
68
             . "    <input type=\"text\" name=\"cat_desc\" value=\"$cat_desc\" size=\"80\" maxlength=\"200\">\n"
69
             . "  </td></tr>\n"
70
             . '  <tr><td class="even">'
71
             . _AM_ADSLIGHT_CAT_META_KEYWORDS
72
             . " </td><td class=\"odd\" colspan=2>\n"
73
             . "    <input type=\"text\" name=\"cat_keywords\" value=\"$cat_keywords\" size=\"80\" maxlength=\"200\">\n"
74
             . "  </td></tr>\n";
75
    }
76
77
    echo "  <tr>\n" . '    <td class="even">' . _AM_ADSLIGHT_IMGCAT . '  </td><td class="odd" colspan=2><select name="img" onChange="showimage()">';
78
79
    $rep    = XOOPS_ROOT_PATH . '/modules/adslight/assets/images/img_cat';
0 ignored issues
show
Bug introduced by
The constant XOOPS_ROOT_PATH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
80
    $handle = opendir($rep);
81
    while ($file = readdir($handle)) {
0 ignored issues
show
Bug introduced by
It seems like $handle can also be of type false; however, parameter $dir_handle of readdir() does only seem to accept resource, maybe add an additional type check? ( Ignorable by Annotation )

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

81
    while ($file = readdir(/** @scrutinizer ignore-type */ $handle)) {
Loading history...
82
        $filelist[] = $file;
83
    }
84
    asort($filelist);
85
    //    while (list($key, $file) = each($filelist)) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
86
    foreach ($filelist as $key => $file) {
87
        if (!preg_match('`gif$|jpg$|png$`i', $file)) {
88
            if ('.' === $file || '..' === $file) {
89
                $a = 1;
0 ignored issues
show
Unused Code introduced by
The assignment to $a is dead and can be removed.
Loading history...
90
            }
91
        } else {
92
            if ('default.png' === $file) {
93
                echo "<option value=\"{$file}\" selected>{$file}</option>";
94
            } else {
95
                echo "<option value=\"{$file}\">{$file}</option>";
96
            }
97
        }
98
    }
99
    echo '</select>&nbsp;&nbsp;<img src="' . XOOPS_URL . '/modules/adslight/assets/images/img_cat/default.png" name="avatar" align="absmiddle"><br><b>' . _AM_ADSLIGHT_REPIMGCAT . '</b><br>../modules/adslight/assets/images/img_cat/..</td></tr>';
0 ignored issues
show
Bug introduced by
The constant XOOPS_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
100
101
    echo '<tr><td class="even">'
102
         . _AM_ADSLIGHT_DISPLPRICE2
103
         . ' </td><td class="odd" colspan=2><input type="radio" name="affprice" value="1" checked>'
104
         . _AM_ADSLIGHT_OUI
0 ignored issues
show
Bug introduced by
The constant _AM_ADSLIGHT_OUI was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
105
         . '&nbsp;&nbsp; <input type="radio" name="affprice" value="0">'
106
         . _AM_ADSLIGHT_NON
0 ignored issues
show
Bug introduced by
The constant _AM_ADSLIGHT_NON was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
107
         . ' ('
108
         . _AM_ADSLIGHT_INTHISCAT
109
         . ')</td></tr>';
110
111
    echo '<tr><td class="even">' . _AM_ADSLIGHT_MODERATE_CAT . ' </td><td class="odd" colspan=2><input type="radio" name="cat_moderate" value="1"checked>' . _AM_ADSLIGHT_OUI . '&nbsp;&nbsp; <input type="radio" name="cat_moderate" value="0">' . _AM_ADSLIGHT_NON . '</td></tr>';
112
113
    echo '<tr><td class="even">'
114
         . _AM_ADSLIGHT_MODERATE_SUBCATS
115
         . ' </td><td class="odd" colspan=2><input type="radio" name="moderate_subcat" value="1"checked>'
116
         . _AM_ADSLIGHT_OUI
117
         . '&nbsp;&nbsp; <input type="radio" name="moderate_subcat" value="0">'
118
         . _AM_ADSLIGHT_NON
119
         . '</td></tr>';
120
121
    if ('title' !== $GLOBALS['xoopsModuleConfig']['adslight_csortorder']) {
122
        echo '<tr><td>' . _AM_ADSLIGHT_ORDER . ' </td><td><input type="text" name="cat_order" size="4" value="0" ></td><td class="foot"><input type="submit" value="' . _AM_ADSLIGHT_ADD . '" ></td></tr>';
123
    } else {
124
        $cat_order = (int)$cat_order;
125
        echo "<input type=\"hidden\" name=\"cat_order\" value=\"$cat_order\">";
126
        echo '<tr><td class="foot" colspan=3><input type="submit" value="' . _AM_ADSLIGHT_ADD . '" ></td></tr>';
127
    }
128
129
    echo "</table>\n" . "</form>\n" . "<br>\n" . "</fieldset><br>\n";
130
    xoops_cp_footer();
0 ignored issues
show
Bug introduced by
The function xoops_cp_footer 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

130
    /** @scrutinizer ignore-call */ 
131
    xoops_cp_footer();
Loading history...
131
}
132
133
#  function adsModCat
134
#####################################################
135
/**
136
 * @param $cid
137
 */
138
function adsModCat($cid)
139
{
140
    global $xoopsDB, $xoopsConfig, $xoopsModule, $myts, $moduleDirName;
141
142
    $mytree = new ClassifiedsTree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid');
143
144
    //    require_once __DIR__ . '/admin_header.php';
0 ignored issues
show
Unused Code Comprehensibility introduced by
45% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
145
146
    //    loadModuleAdminMenu(1, '');
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
147
    echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_MODIFCAT . '</legend>';
148
    //    ShowImg();
149
    Adslight\Utility::showImage();
150
151
    $result = $xoopsDB->query('SELECT cid, pid, title, cat_desc, cat_keywords, img, cat_order, affprice, cat_moderate, moderate_subcat FROM ' . $xoopsDB->prefix('adslight_categories') . " WHERE cid=$cid");
152
    list($cat_id, $pid, $title, $cat_desc, $cat_keywords, $imgs, $order, $affprice, $cat_moderate, $moderate_subcat) = $xoopsDB->fetchRow($result);
153
154
    $title    = $myts->htmlSpecialChars($title);
155
    $cat_desc = $myts->addSlashes($cat_desc);
156
    echo '<form action="category.php" method="post" name="imcat">';
157
    echo $GLOBALS['xoopsSecurity']->getTokenHTML();
158
    echo '<table class="outer" border="0"><tr>
159
    <td class="even">' . _AM_ADSLIGHT_CATNAME . "   </td><td class=\"odd\"><input type=\"text\" name=\"title\" value=\"{$title}\" size=\"50\" maxlength=\"100\">&nbsp; " . _AM_ADSLIGHT_IN . ' &nbsp;';
160
    $mytree->makeMySelBox('title', 'title', $pid, 1);
161
    echo '</td></tr>';
162
163
    if ('1' == $GLOBALS['xoopsModuleConfig']['adslight_cat_desc']) {
164
        echo '<tr><td class="even">' . _AM_ADSLIGHT_CAT_META_DESCRIPTION . ' </td><td class="odd" colspan=2>';
165
        echo "<input type=\"text\" name=\"cat_desc\" value=\"{$cat_desc}\" size=\"80\" maxlength=\"200\">";
166
        echo '</td></tr>';
167
168
        echo '<tr><td class="even">' . _AM_ADSLIGHT_CAT_META_KEYWORDS . ' </td><td class="odd" colspan=2>';
169
        echo "<input type=\"text\" name=\"cat_keywords\" value=\"{$cat_keywords}\" size=\"80\" maxlength=\"200\">";
170
        echo '</td></tr>';
171
    }
172
173
    echo '<tr>
174
    <td class="even">' . _AM_ADSLIGHT_IMGCAT . '  </td><td class="odd"><select name="img" onChange="showimage()">';
175
176
    $rep    = XOOPS_ROOT_PATH . '/modules/adslight/assets/images/img_cat';
0 ignored issues
show
Bug introduced by
The constant XOOPS_ROOT_PATH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
177
    $handle = opendir($rep);
178
    while ($file = readdir($handle)) {
0 ignored issues
show
Bug introduced by
It seems like $handle can also be of type false; however, parameter $dir_handle of readdir() does only seem to accept resource, maybe add an additional type check? ( Ignorable by Annotation )

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

178
    while ($file = readdir(/** @scrutinizer ignore-type */ $handle)) {
Loading history...
179
        $filelist[] = $file;
180
    }
181
    asort($filelist);
182
    //    while (list($key, $file) = each($filelist)) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
183
    foreach ($filelist as $key => $file) {
184
        if (!preg_match('`gif$|jpg$|png$`i', $file)) {
185
            if ('.' === $file || '..' === $file) {
186
                $a = 1;
0 ignored issues
show
Unused Code introduced by
The assignment to $a is dead and can be removed.
Loading history...
187
            }
188
        } else {
189
            if ($file == $imgs) {
190
                echo "<option value=\"{$file}\" selected>{$file}</option>";
191
            } else {
192
                echo "<option value=\"{$file}\">{$file}</option>";
193
            }
194
        }
195
    }
196
    echo '</select>&nbsp;&nbsp;<img src="' . XOOPS_URL . "/modules/adslight/assets/images/img_cat/{$imgs}\" name=\"avatar\" align=\"absmiddle\"><br><b>" . _AM_ADSLIGHT_REPIMGCAT . '</b><br>../modules/adslight/assets/images/img_cat/..</td></tr>';
0 ignored issues
show
Bug introduced by
The constant XOOPS_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
197
198
    echo '<tr><td class="even">' . _AM_ADSLIGHT_DISPLPRICE2 . ' </td><td class="odd" colspan=2><input type="radio" name="affprice" value="1"';
199
    if ('1' == $affprice) {
200
        echo 'checked';
201
    }
202
    echo '>' . _YES . '&nbsp;&nbsp; <input type="radio" name="affprice" value="0"';
0 ignored issues
show
Bug introduced by
The constant _YES was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
203
    if ('0' == $affprice) {
204
        echo 'checked';
205
    }
206
    echo '>' . _NO . ' (' . _AM_ADSLIGHT_INTHISCAT . ')</td></tr>';
0 ignored issues
show
Bug introduced by
The constant _NO was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
207
208
    echo '<tr><td class="even">' . _AM_ADSLIGHT_MODERATE_CAT . ' </td><td class="odd" colspan=2><input type="radio" name="cat_moderate" value="1"';
209
    if ('1' == $cat_moderate) {
210
        echo 'checked';
211
    }
212
    echo '>' . _YES . '&nbsp;&nbsp; <input type="radio" name="cat_moderate" value="0"';
213
    if ('0' == $cat_moderate) {
214
        echo 'checked';
215
    }
216
    echo '>' . _NO . '</td></tr>';
217
218
    echo '<tr><td class="even">' . _AM_ADSLIGHT_MODERATE_SUBCATS . ' </td><td class="odd" colspan=2><input type="radio" name="moderate_subcat" value="1"';
219
    if ('1' == $moderate_subcat) {
220
        echo 'checked';
221
    }
222
    echo '>' . _YES . '&nbsp;&nbsp; <input type="radio" name="moderate_subcat" value="0"';
223
    if ('0' == $moderate_subcat) {
224
        echo 'checked';
225
    }
226
    echo '>' . _NO . '</td></tr>';
227
228
    if ('title' !== $GLOBALS['xoopsModuleConfig']['adslight_csortorder']) {
229
        echo '<tr><td class="even">' . _AM_ADSLIGHT_ORDER . " </td><td class=\"odd\"><input type=\"text\" name=\"cat_order\" size=\"4\" value=\"$cat_order\"></td></tr>";
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $cat_order seems to be never defined.
Loading history...
230
    } else {
231
        $cat_order = (int)$cat_order;
232
        echo "<input type=\"hidden\" name=\"cat_order\" value=\"{$cat_order}\">";
233
    }
234
235
    echo '</table>';
236
237
    echo "<input type=\"hidden\" name=\"cidd\" value=\"{$cid}\">"
238
         . '<input type="hidden" name="op" value="AdsModCatS">'
239
         . '<table class="foot" border="0"><tr><td width="20%"><br>'
240
241
         . '<input type="submit" value="'
242
         . _AM_ADSLIGHT_SAVMOD
243
         . '"></form></td><td><br>'
244
         . '<form action="category.php" method="post">'
245
         . "<input type=\"hidden\" name=\"cid\" value=\"{$cid}\">"
246
         . '<input type="hidden" name="op" value="AdsDelCat">'
247
         . '<input type="submit" value="'
248
         . _AM_ADSLIGHT_DEL
249
         . '"></form></td></tr></table>';
250
    echo '</fieldset><br>';
251
    xoops_cp_footer();
0 ignored issues
show
Bug introduced by
The function xoops_cp_footer 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

251
    /** @scrutinizer ignore-call */ 
252
    xoops_cp_footer();
Loading history...
252
}
253
254
#  function adsModCatS
255
#####################################################
256
/**
257
 * @param $cidd
258
 * @param $cid
259
 * @param $img
260
 * @param $title
261
 * @param $cat_desc
262
 * @param $cat_keywords
263
 * @param $cat_order
264
 * @param $affprice
265
 * @param $cat_moderate
266
 * @param $moderate_subcat
267
 */
268
function AdsModCatS($cidd, $cid, $img, $title, $cat_desc, $cat_keywords, $order, $affprice, $cat_moderate, $moderate_subcat)
0 ignored issues
show
Unused Code introduced by
The parameter $order 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

268
function AdsModCatS($cidd, $cid, $img, $title, $cat_desc, $cat_keywords, /** @scrutinizer ignore-unused */ $order, $affprice, $cat_moderate, $moderate_subcat)

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...
269
{
270
    global $xoopsDB, $xoopsConfig, $myts, $moduleDirName;
271
272
    $title = $myts->htmlSpecialChars($title);
273
    $cidd  = (int)$cidd;
274
275
    $xoopsDB->query('UPDATE '
276
                    . $xoopsDB->prefix('adslight_categories')
277
                    . " SET title='$title', cat_desc='$cat_desc', cat_keywords='$cat_keywords', pid='$cid', img='$img', cat_order='$cat_order', affprice='$affprice', cat_moderate='$cat_moderate', moderate_subcat='$moderate_subcat' WHERE cid={$cidd}");
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $cat_order seems to be never defined.
Loading history...
278
279
    if (1 != $moderate_subcat) {
280
        $xoopsDB->queryF('UPDATE ' . $xoopsDB->prefix('adslight_categories') . " SET cat_moderate=0, moderate_subcat=0 WHERE pid={$cidd}");
281
    } else {
282
        $xoopsDB->queryF('UPDATE ' . $xoopsDB->prefix('adslight_categories') . " SET cat_moderate=1, moderate_subcat=1 WHERE pid={$cidd}");
283
    }
284
285
    redirect_header('map.php', 10, _AM_ADSLIGHT_CATSMOD);
0 ignored issues
show
Bug introduced by
The function redirect_header 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

285
    /** @scrutinizer ignore-call */ 
286
    redirect_header('map.php', 10, _AM_ADSLIGHT_CATSMOD);
Loading history...
286
}
287
288
#  function adsAddCat
289
#####################################################
290
/**
291
 * @param $title
292
 * @param $cat_desc
293
 * @param $cat_keywords
294
 * @param $cid
295
 * @param $img
296
 * @param $order
297
 * @param $affprice
298
 * @param $cat_moderate
299
 * @param $moderate_subcat
300
 */
301
function adsAddCat($title, $cat_desc, $cat_keywords, $cid, $img, $order, $affprice, $cat_moderate, $moderate_subcat)
0 ignored issues
show
Unused Code introduced by
The parameter $order 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

301
function adsAddCat($title, $cat_desc, $cat_keywords, $cid, $img, /** @scrutinizer ignore-unused */ $order, $affprice, $cat_moderate, $moderate_subcat)

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...
302
{
303
    global $xoopsDB, $xoopsConfig, $myts, $moduleDirName;
304
305
    $moderate_subcat = (int)$moderate_subcat;
306
    $title           = $myts->htmlSpecialChars($title);
307
    if ('' == $title) {
308
        $title = '! ! ? ! !';
309
    }
310
311
    $xoopsDB->query('INSERT INTO ' . $xoopsDB->prefix('adslight_categories') . " VALUES (NULL, '$cid', '$title', '$cat_desc', '$cat_keywords', '$img', '$cat_order', '$affprice', '$cat_moderate', '$moderate_subcat')");
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $cat_order seems to be never defined.
Loading history...
312
313
    if (1 == $moderate_subcat) {
314
        $xoopsDB->queryF('UPDATE ' . $xoopsDB->prefix('adslight_categories') . ' SET cat_moderate=1 WHERE pid = ' . (int)$cid . '');
315
    } else {
316
        $xoopsDB->queryF('UPDATE ' . $xoopsDB->prefix('adslight_categories') . ' SET cat_moderate=0 WHERE pid = ' . (int)$cid . '');
317
    }
318
319
    redirect_header('map.php', 3, _AM_ADSLIGHT_CATADD);
0 ignored issues
show
Bug introduced by
The function redirect_header 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

319
    /** @scrutinizer ignore-call */ 
320
    redirect_header('map.php', 3, _AM_ADSLIGHT_CATADD);
Loading history...
320
}
321
322
#  function adsDelCat
323
#####################################################
324
/**
325
 * @param     $cid
326
 * @param int $ok
327
 */
328
function adsDelCat($cid, $ok = 0)
329
{
330
    global $xoopsDB, $xoopsConfig, $xoopsModule, $moduleDirName;
331
332
    $cid = (int)$cid;
333
    if (1 == (int)$ok) {
334
        $xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection();
0 ignored issues
show
Bug introduced by
The type XoopsDatabaseFactory was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
335
        $xoopsDB->queryF('DELETE FROM ' . $xoopsDB->prefix('adslight_categories') . " WHERE cid={$cid} OR pid={$cid}");
336
        $xoopsDB->queryf('DELETE FROM ' . $xoopsDB->prefix('adslight_listing') . " WHERE cid={$cid}");
337
338
        redirect_header('map.php', 3, _AM_ADSLIGHT_CATDEL);
0 ignored issues
show
Bug introduced by
The function redirect_header 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

338
        /** @scrutinizer ignore-call */ 
339
        redirect_header('map.php', 3, _AM_ADSLIGHT_CATDEL);
Loading history...
339
    } else {
340
        //        require_once __DIR__ . '/admin_header.php';
0 ignored issues
show
Unused Code Comprehensibility introduced by
45% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
341
        //        loadModuleAdminMenu(1, '');
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
342
343
        OpenTable();
0 ignored issues
show
Bug introduced by
The function OpenTable 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

343
        /** @scrutinizer ignore-call */ 
344
        OpenTable();
Loading history...
344
        echo '<br><center><b>' . _AM_ADSLIGHT_SURDELCAT . '</b><br><br>';
345
        echo "[ <a href=\"category.php?op=AdsDelCat&cid={$cid}&ok=1\">" . _YES . '</a> | <a href="map.php">' . _NO . '</a> ]<br><br>';
0 ignored issues
show
Bug introduced by
The constant _YES was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The constant _NO was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
346
        CloseTable();
0 ignored issues
show
Bug introduced by
The function CloseTable 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

346
        /** @scrutinizer ignore-call */ 
347
        CloseTable();
Loading history...
347
        xoops_cp_footer();
0 ignored issues
show
Bug introduced by
The function xoops_cp_footer 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

347
        /** @scrutinizer ignore-call */ 
348
        xoops_cp_footer();
Loading history...
348
    }
349
}
350
351
#####################################################
352
//@todo REMOVE THIS ASAP!  This code is extremely unsafe
353
foreach ($_POST as $k => $v) {
354
    ${$k} = $v;
355
}
356
357
$ok  = Request::getString('ok', '', 'GET');
358
$cid = Request::getInt('cid', 0);
359
$op  = Request::getString('op', '');
360
361
switch ($op) {
362
    case 'AdsNewCat':
363
        adsNewCat($cid);
364
        break;
365
366
    case 'AdsAddCat':
367
        adsAddCat($title, $cat_desc, $cat_keywords, $cid, $img, $cat_order, $affprice, $cat_moderate, $moderate_subcat);
368
        break;
369
370
    case 'AdsDelCat':
371
        adsDelCat($cid, $ok);
372
        break;
373
374
    case 'AdsModCat':
375
        adsModCat($cid);
376
        break;
377
378
    case 'AdsModCatS':
379
        AdsModCatS($cidd, $cid, $img, $title, $cat_desc, $cat_keywords, $cat_order, $affprice, $cat_moderate, $moderate_subcat);
380
        break;
381
382
    default:
383
        //        index();
384
        break;
385
386
}
387