Passed
Push — master ( 926303...2aaf26 )
by Michael
05:21
created

modifyAd()   C

Complexity

Conditions 11
Paths 217

Size

Total Lines 191
Code Lines 132

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 132
c 0
b 0
f 0
dl 0
loc 191
rs 5.0166
cc 11
nc 217
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
2
3
declare(strict_types=1);
4
5
/*
6
 * You may not change or alter any portion of this comment or credits
7
 * of supporting developers from this source code or any supporting source code
8
 * which is considered copyrighted (c) material of the original comment or credit authors.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
 */
14
15
/**
16
 * @copyright    XOOPS Project (https://xoops.org)
17
 * @license      GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
18
 * @author       XOOPS Development Team
19
 * @author       Pascal Le Boustouller: original author ([email protected])
20
 * @author       Luc Bizet (www.frxoops.org)
21
 * @author       jlm69 (www.jlmzone.com)
22
 * @author       mamba (www.xoops.org)
23
 */
24
25
use Xmf\Request;
26
use XoopsModules\Adslight\{
27
    Helper,
28
    Tree,
29
    Utility
30
};
31
/** @var Admin $adminObject */
32
/** @var Helper $helper */
33
34
require_once __DIR__ . '/admin_header.php';
35
$op = Request::getString('op', 'list');
36
/**
37
 * Main Ad Display
38
 */
39
function index(): void
40
{
41
    global $xoopsDB, $xoopsModuleConfig;
42
    $helper = Helper::getInstance();
43
44
    //    $mytree = new Tree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid');
45
46
    //    require_once __DIR__ . '/admin_header.php';
47
    xoops_cp_header();
48
    //    loadModuleAdminMenu(0, "");
49
50
    // photo dir setting checker
51
    $photo_dir         = $helper->getConfig('adslight_path_upload');
52
    $photo_thumb_dir   = $helper->getConfig('adslight_path_upload') . '/thumbs';
53
    $photo_resized_dir = $helper->getConfig('adslight_path_upload') . '/midsize';
54
    if (!is_dir($photo_dir) && (!mkdir($photo_dir) && !is_dir($photo_dir))) {
0 ignored issues
show
Bug introduced by
It seems like $photo_dir can also be of type null; however, parameter $directory of mkdir() does only seem to accept string, 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

54
    if (!is_dir($photo_dir) && (!mkdir(/** @scrutinizer ignore-type */ $photo_dir) && !is_dir($photo_dir))) {
Loading history...
Bug introduced by
It seems like $photo_dir can also be of type null; however, parameter $filename of is_dir() does only seem to accept string, 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

54
    if (!is_dir(/** @scrutinizer ignore-type */ $photo_dir) && (!mkdir($photo_dir) && !is_dir($photo_dir))) {
Loading history...
55
        throw new \RuntimeException(sprintf('Directory "%s" was not created', $photo_dir));
56
    }
57
    if (!is_dir($photo_thumb_dir) && (!mkdir($photo_thumb_dir) && !is_dir($photo_thumb_dir))) {
58
        throw new \RuntimeException(sprintf('Directory "%s" was not created', $photo_thumb_dir));
59
    }
60
    if (!is_dir($photo_resized_dir) && (!mkdir($photo_resized_dir) && !is_dir($photo_resized_dir))) {
61
        throw new \RuntimeException(sprintf('Directory "%s" was not created', $photo_resized_dir));
62
    }
63
    if (!is_writable($photo_dir) || !is_readable($photo_dir)) {
64
        echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_CHECKER . '</legend><br>';
65
        echo "<span style='color: #FF0000;'><b>" . _AM_ADSLIGHT_DIRPERMS . '' . $photo_dir . "</b></span><br><br>\n";
66
        echo '</fieldset><br>';
67
    }
68
69
    if (!is_writable($photo_thumb_dir) || !is_readable($photo_thumb_dir)) {
70
        echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_CHECKER . '</legend><br>';
71
        echo "<span style='color: #FF0000;'><b>" . _AM_ADSLIGHT_DIRPERMS . '' . $photo_thumb_dir . "</b></span><br><br>\n";
72
        echo '</fieldset><br>';
73
    }
74
75
    if (!is_writable($photo_resized_dir) || !is_readable($photo_resized_dir)) {
76
        echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_CHECKER . '</legend><br>';
77
        echo "<span style='color: #FF0000;'><b>" . _AM_ADSLIGHT_DIRPERMS . '' . $photo_resized_dir . "</b></span><br><br>\n";
78
        echo '</fieldset><br>';
79
    }
80
81
    $sql     = 'SELECT lid, cid, title, status, expire, type, desctext, tel, price, typeprice, typecondition, date_created, email, submitter, town, country, contactby, premium, photo, usid FROM ' . $xoopsDB->prefix('adslight_listing') . " WHERE valid='no' ORDER BY lid";
82
    $result  = $xoopsDB->query($sql);
83
    $numrows = $xoopsDB->getRowsNum($result);
84
    if ($numrows > 0) {
85
        ///////// Il y a [..] Annonces en attente d'être approuvées //////
86
        echo "<table class='outer bnone' cellspacing=5 cellpadding=0><tr><td width=40>";
87
        echo "<img src='../assets/images/admin/error_button.png' border=0 ></td><td>";
88
        echo "<span style='color:#00B4C4;'><b>" . _AM_ADSLIGHT_THEREIS . "</b></span> <b>${numrows}</b> <span style='color:#00B4C4;'>" . _AM_ADSLIGHT_WAIT . '</b></span>';
89
        echo '</td></tr></table><br>';
90
    } else {
91
        echo "<table class='outer' width='50%' border='0'><tr><td width=40>";
92
        echo "<img src='../assets/images/admin/search_button_green_32.png' border=0 alt=\"._AM_ADSLIGHT_RELEASEOK.\" ></td><td>";
93
        echo "<span style='color: #00B4C4;'><b>" . _AM_ADSLIGHT_NOANNVAL . '</b></span>';
94
        echo '</td></tr></table><br>';
95
    }
96
97
    // Modify Annonces
98
    $sql = 'SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_listing');
99
    [$numrows] = $xoopsDB->fetchRow($xoopsDB->query($sql));
100
    if ($numrows > 0) {
101
        echo "<table width='100%' border='0' class='outer'><tr class='bg4'><td valign='top'>";
102
        echo '<form method="post" action="modify_ads.php">'
103
             . '<b>'
104
             . _AM_ADSLIGHT_MODANN
105
             . '</b><br><br>'
106
             . _AM_ADSLIGHT_NUMANN
107
             . ' <input type="text" name="lid" size="12" maxlength="11">&nbsp;&nbsp;'
108
             . '<input type="hidden" name="op" value="modifyAd">'
109
             . '<input type="submit" value="'
110
             . _AM_ADSLIGHT_MODIF
111
             . '">'
112
             . '</form><br>';
113
        echo '</td></tr></table><br>';
114
    }
115
116
    echo "<table width='100%' border='0' cellspacing='1' cellpadding='8' style='border: 2px solid #DFE0E0;'><tr class='bg4'><td valign='top'>";
117
    echo '<a href="map.php">' . _AM_ADSLIGHT_GESTCAT . '</a> | <a href="../index.php">' . _AM_ADSLIGHT_ACCESMYANN . '</a>';
118
    echo '</td></tr></table><br>';
119
120
    xoops_cp_footer();
121
}
122
123
#  function modifyAd
124
#####################################################
125
/**
126
 * @param $lid
127
 */
128
function modifyAd($lid): void
129
{
130
    global $xoopsDB, $xoopsModule, $xoopsConfig, $myts, $desctext;
131
132
    $helper        = Helper::getInstance();
0 ignored issues
show
Unused Code introduced by
The assignment to $helper is dead and can be removed.
Loading history...
133
    $mytree        = new Tree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid');
134
    $helper        = Helper::getInstance();
135
    $contactselect = '';
0 ignored issues
show
Unused Code introduced by
The assignment to $contactselect is dead and can be removed.
Loading history...
136
    //    require_once __DIR__ . '/admin_header.php';
137
    xoops_cp_header();
138
    //    loadModuleAdminMenu(0, "");
139
    $id_price  = '';
140
    $nom_price = '';
141
    $lid       = (int)$lid;
142
143
    echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_MODANN . '</legend>';
144
145
    $sql    = 'SELECT lid, cid, title, status, expire, type, desctext, tel, price, typeprice, typecondition, date_created, email, submitter, town, country, contactby, premium, valid, photo FROM ' . $xoopsDB->prefix('adslight_listing') . " WHERE lid={$lid}";
146
    $result = $xoopsDB->query($sql);
147
    while ([$lid, $cid, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $typecondition, $date_created, $email, $submitter, $town, $country, $contactby, $premium, $valid, $photo] = $xoopsDB->fetchRow(
148
        $result
149
    )) {
150
        $title    = \htmlspecialchars($title, ENT_QUOTES | ENT_HTML5);
151
        $status   = \htmlspecialchars($status, ENT_QUOTES | ENT_HTML5);
152
        $expire   = \htmlspecialchars($expire, ENT_QUOTES | ENT_HTML5);
153
        $type     = \htmlspecialchars($type, ENT_QUOTES | ENT_HTML5);
154
        $desctext = $myts->displayTarea($desctext, 1, 1, 1);
155
        $tel      = \htmlspecialchars($tel, ENT_QUOTES | ENT_HTML5);
156
        //        $price     = number_format($price, 2, ',', ' ');
157
158
        xoops_load('XoopsLocal');
159
        $tempXoopsLocal = new \XoopsLocal();
160
        //  For US currency with 2 numbers after the decimal comment out if you don't want 2 numbers after decimal
161
        $priceFormatted = $tempXoopsLocal->number_format($price, 2, ',', ' ');
0 ignored issues
show
Unused Code introduced by
The call to XoopsLocal::number_format() has too many arguments starting with 2. ( Ignorable by Annotation )

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

161
        /** @scrutinizer ignore-call */ 
162
        $priceFormatted = $tempXoopsLocal->number_format($price, 2, ',', ' ');

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...
Unused Code introduced by
The assignment to $priceFormatted is dead and can be removed.
Loading history...
162
        //  For other countries uncomment the below line and comment out the above line
163
        //      $priceFormatted = $tempXoopsLocal->number_format($price);
164
165
        $typeprice     = \htmlspecialchars($typeprice, ENT_QUOTES | ENT_HTML5);
166
        $typecondition = \htmlspecialchars($typecondition, ENT_QUOTES | ENT_HTML5);
167
        $submitter     = \htmlspecialchars($submitter, ENT_QUOTES | ENT_HTML5);
168
        $town          = \htmlspecialchars($town, ENT_QUOTES | ENT_HTML5);
169
        $country       = \htmlspecialchars($country, ENT_QUOTES | ENT_HTML5);
170
        $contactby     = \htmlspecialchars($contactby, ENT_QUOTES | ENT_HTML5);
171
        $premium       = \htmlspecialchars($premium, ENT_QUOTES | ENT_HTML5);
172
173
        $date2 = formatTimestamp($date_created, 's');
174
175
        echo '<form action="modify_ads.php" method=post>';
176
        echo $GLOBALS['xoopsSecurity']->getTokenHTML();
177
        echo "<table class='bnone'><tr class='head' border='1'>
178
            <td>" . _AM_ADSLIGHT_NUMANN . " </td><td>{$lid} &nbsp;" . _AM_ADSLIGHT_ADDED_ON . "&nbsp; {$date2}</td>
179
            </tr><tr class='head' border='1'>
180
            <td>" . _AM_ADSLIGHT_SENDBY . " </td><td>{$submitter}</td>
181
            </tr><tr class='head' border='1'>
182
            <td>" . _AM_ADSLIGHT_EMAIL . " </td><td><input type=\"text\" name=\"email\" size=\"40\" value=\"{$email}\"></td>
183
            </tr><tr class='head' border='1'>
184
            <td>" . _AM_ADSLIGHT_TEL . " </td><td><input type=\"text\" name=\"tel\" size=\"50\" value=\"{$tel}\"></td>
185
            </tr><tr class='head' border='1'>
186
            <td>" . _AM_ADSLIGHT_TOWN . " </td><td><input type=\"text\" name=\"town\" size=\"40\" value=\"{$town}\"></td>
187
            </tr><tr class='head' border='1'>
188
            <td>" . _AM_ADSLIGHT_COUNTRY . " </td><td><input type=\"text\" name=\"country\" size=\"40\" value=\"{$country}\"></td>
189
            </tr></tr><tr class='head' border='1'>";
190
191
        $contactSel1 = $contactSel2 = $contactSel3 = $contactSel4 = '';
192
        $selected    = 'contactSel' . (int)$contactby;
193
        ${$selected} = ' selected';
194
195
        echo " <td class='head'>"
196
             . _AM_ADSLIGHT_CONTACTBY
197
             . " </td><td class='head'><select name=\"contactby\">\n"
198
             //           . "  <option value=\"{$contactby}\">{$contactselect[$contactby]}</option>\n"
199
             . "  <option value=\"1\"{$contactSel1}>"
200
             . _AM_ADSLIGHT_CONTACT_BY_EMAIL
201
             . "</option>\n"
202
             . "  <option value=\"2\"{$contactSel2}>"
203
             . _AM_ADSLIGHT_CONTACT_BY_PM
204
             . "</option>\n"
205
             . "  <option value=\"3\"{$contactSel3}>"
206
             . _AM_ADSLIGHT_CONTACT_BY_BOTH
207
             . "</option>\n"
208
             . "  <option value=\"4\"{$contactSel4}>"
209
             . _AM_ADSLIGHT_CONTACT_BY_PHONE
210
             . "</option></select>\n"
211
             . " </td>\n"
212
             . '</tr>';
213
214
        echo "<tr><td class='head'>" . _AM_ADSLIGHT_STATUS . "</td><td class='head'><input type=\"radio\" name=\"status\" value=\"0\"";
215
        if (0 === (int)$status) {
216
            echo 'checked';
217
        }
218
        echo '>' . _AM_ADSLIGHT_ACTIVE . '&nbsp;&nbsp; <input type="radio" name="status" value="1"';
219
        if (1 === (int)$status) {
220
            echo 'checked';
221
        }
222
        echo '>' . _AM_ADSLIGHT_INACTIVE . '&nbsp;&nbsp; <input type="radio" name="status" value="2"';
223
        if (2 === (int)$status) {
224
            echo 'checked';
225
        }
226
        echo '>' . _AM_ADSLIGHT_SOLD . '</td></tr>';
227
228
        echo "<tr class='head' border='1'>
229
        <td>" . _AM_ADSLIGHT_TITLE2 . " </td><td><input type=\"text\" name=\"title\" size=\"40\" value=\"{$title}\"></td>
230
            </tr><tr class='head' border='1'>
231
        <td>" . _AM_ADSLIGHT_PREMIUM . " </td><td><input type=\"text\" name=\"premium\" size=\"3\" value=\"{$premium}\"></td>
232
            </tr><tr class='head' border='1'>
233
        <td>" . _AM_ADSLIGHT_EXPIRE . " </td><td><input type=\"text\" name=\"expire\" size=\"40\" value=\"{$expire}\"></td>
234
            </tr>";
235
        ////// Type d'annonce
236
        echo "<tr class='head' border='1'>
237
            <td>" . _AM_ADSLIGHT_TYPE . ' </td><td><select name="type">';
238
        $sql     = 'SELECT nom_type, id_type FROM ' . $xoopsDB->prefix('adslight_type') . ' ORDER BY nom_type';
239
        $result5 = $xoopsDB->query($sql);
240
        while ([$nom_type, $id_type] = $xoopsDB->fetchRow($result5)) {
241
            $sel = '';
242
            if ($id_type === $type) {
243
                $sel = 'selected';
244
            }
245
            echo "<option value=\"{$id_type}\"{$sel}>{$nom_type}</option>";
246
        }
247
        echo '</select></td></tr>';
248
249
        ////// Condition
250
        echo "<tr class='head' border='1'>
251
            <td>" . _AM_ADSLIGHT_TYPE_CONDITION . ' </td><td><select name="typecondition">';
252
        $sql     = 'SELECT nom_condition, id_condition FROM ' . $xoopsDB->prefix('adslight_condition') . ' ORDER BY nom_condition';
253
        $result6 = $xoopsDB->query($sql);
254
        while ([$nom_condition, $id_condition] = $xoopsDB->fetchRow($result6)) {
255
            $sel = '';
256
            if ($id_condition === $typecondition) {
257
                $sel = 'selected';
258
            }
259
            echo "<option value=\"{$id_condition}\"{$sel}>{$nom_condition}</option>";
260
        }
261
        echo '</select></td></tr>';
262
263
        /////// Price
264
        echo "<tr class='head' border='1'><td>" . _AM_ADSLIGHT_PRICE2 . " </td><td><input type=\"text\" name=\"price\" size=\"20\" value=\"${price}\"> " . $helper->getConfig('adslight_currency_symbol') . '';
265
266
        //////// Price type
267
        $sql     = 'SELECT nom_price, id_price FROM ' . $xoopsDB->prefix('adslight_price') . ' ORDER BY nom_price';
268
        $resultx = $xoopsDB->query($sql);
269
270
        echo " <select name=\"typeprice\"><option value=\"{$id_price}\">{$nom_price}</option>";
271
        while ([$nom_price, $id_price] = $xoopsDB->fetchRow($resultx)) {
272
            $sel = '';
273
            if ($id_price === $typeprice) {
274
                $sel = 'selected';
275
            }
276
            echo "<option value=\"{$id_price}\"{$sel}>{$nom_price}</option>";
277
        }
278
        echo '</select></td>';
279
280
        /////// Category
281
282
        echo "<tr class='head' border='1'>
283
            <td>" . _AM_ADSLIGHT_CAT2 . ' </td><td>';
284
        $mytree->makeMySelBox('title', 'title', $cid);
285
        echo "</td>
286
            </tr><tr class='head' border='1'>
287
            <td>" . _AM_ADSLIGHT_DESC . ' </td><td>';
288
        //        $options = ['desctext', $desctext, '100%', '200px', 'small'];
289
        $options           = [];
290
        $options['name']   = 'desctext';
291
        $options['value']  = $desctext;
292
        $options['cols']   = '100%';
293
        $options['width']  = '100%';
294
        $options['height'] = '400px';
295
        $options['rows']   = 10;
296
297
        $wysiwyg_text_area = Utility::getEditor($helper, $options);
298
        echo $wysiwyg_text_area->render();
299
300
        echo '</td></tr>';
301
302
        echo "<tr class='head' border='1'>
303
            <td>" . _AM_ADSLIGHT_PHOTO1 . " </td><td><input type=\"text\" name=\"photo\" size=\"50\" value=\"{$photo}\"></td>
304
            </tr><tr>";
305
        $time = time();
306
        echo "</tr><tr class='head' border='1'>
307
            <td>&nbsp;</td><td><select name=\"op\">
308
            <option value=\"modifyAds\"> " . _AM_ADSLIGHT_MODIF . '
309
            <option value="ListingDel"> ' . _AM_ADSLIGHT_DEL . '
310
            </select><input type="submit" value="' . _AM_ADSLIGHT_GO . '"></td>
311
            </tr></table>';
312
        echo '<input type="hidden" name="valid" value="Yes">';
313
        echo "<input type=\"hidden\" name=\"lid\" value=\"{$lid}\">";
314
        echo "<input type=\"hidden\" name=\"date_created\" value=\"{$time}\">";
315
        echo "<input type=\"hidden\" name=\"submitter\" value=\"{$submitter}\">
316
        </form><br>";
317
        echo '</fieldset><br>';
318
        xoops_cp_footer();
319
    }
320
}
321
322
#  function modifyAds
323
#####################################################
324
/**
325
 * @param $lid
326
 * @param $cat
327
 * @param $title
328
 * @param $status
329
 * @param $expire
330
 * @param $type
331
 * @param $desctext
332
 * @param $tel
333
 * @param $price
334
 * @param $typeprice
335
 * @param $typecondition
336
 * @param $date_created
337
 * @param $email
338
 * @param $submitter
339
 * @param $town
340
 * @param $country
341
 * @param $contactby
342
 * @param $premium
343
 * @param $valid
344
 * @param $photo
345
 */
346
function modifyAds(
347
    $lid,
348
    $cat,
349
    $title,
350
    $status,
351
    $expire,
352
    $type,
353
    $desctext,
354
    $tel,
355
    $price,
356
    $typeprice,
357
    $typecondition,
358
    $date_created,
359
    $email,
360
    $submitter,
361
    $town,
362
    $country,
363
    $contactby,
364
    $premium,
365
    $valid,
366
    $photo
367
): void {
368
    global $xoopsDB, $myts;
369
    $helper = Helper::getInstance();
370
371
    $sql = 'UPDATE '
372
           . $xoopsDB->prefix('adslight_listing')
373
           . " SET cid='{$cat}', title='{$title}', status='{$status}', expire='{$expire}', type='{$type}', desctext='{$desctext}', tel='{$tel}', price='{$price}', typeprice='{$typeprice}', typecondition='{$typecondition}', date_created='{$date_created}', email='{$email}', submitter='{$submitter}', town='{$town}', country='{$country}', contactby='{$contactby}', premium='{$premium}', valid='{$valid}', photo='{$photo}' WHERE lid={$lid}";
374
375
    $result = $xoopsDB->query($sql);
0 ignored issues
show
Unused Code introduced by
The assignment to $result is dead and can be removed.
Loading history...
376
377
    $helper->redirect('admin/modify_ads.php', 1, _AM_ADSLIGHT_ANNMOD);
378
}
379
380
/**
381
 * Delete Listing
382
 *
383
 * @param int    $lid
384
 * @param string $photo
385
 */
386
function listingDel($lid, $photo): void
0 ignored issues
show
Unused Code introduced by
The parameter $photo 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

386
function listingDel($lid, /** @scrutinizer ignore-unused */ $photo): void

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...
387
{
388
    global $xoopsDB;
389
    $helper  = Helper::getInstance();
390
    $lid     = (int)$lid;
391
    $sql     = 'SELECT p.url FROM ' . $xoopsDB->prefix('adslight_listing') . ' l LEFT JOIN ' . $xoopsDB->prefix('adslight_pictures') . " p  ON l.lid=p.lid WHERE l.lid={$lid}";
392
    $result2 = $xoopsDB->query($sql);
393
    while ([$purl] = $xoopsDB->fetchRow($result2)) {
394
        if ($purl) {
395
            $destination = XOOPS_ROOT_PATH . '/uploads/adslight';
396
            if (is_file("{$destination}/{$purl}")) {
397
                unlink("{$destination}/{$purl}");
398
            }
399
            $destination2 = XOOPS_ROOT_PATH . '/uploads/adslight/thumbs';
400
            if (is_file("{$destination2}/thumb_{$purl}")) {
401
                unlink("{$destination2}/thumb_{$purl}");
402
            }
403
            $destination3 = XOOPS_ROOT_PATH . '/uploads/adslight/midsize';
404
            if (is_file("{$destination3}/resized_{$purl}")) {
405
                unlink("{$destination3}/resized_{$purl}");
406
            }
407
            $sql = 'DELETE FROM ' . $xoopsDB->prefix('adslight_pictures') . " WHERE lid={$lid}";
408
            $xoopsDB->query($sql);
409
        }
410
    }
411
412
    $sql = 'DELETE FROM ' . $xoopsDB->prefix('adslight_listing') . " WHERE lid={$lid}";
413
    $xoopsDB->query($sql);
414
    $helper->redirect('admin/modify_ads.php', 1, _AM_ADSLIGHT_ANNDEL);
415
}
416
417
#####################################################
418
#####################################################
419
//@todo REMOVE THIS ASAP. This code is extremely unsafe
420
foreach ($_POST as $k => $v) {
421
    ${$k} = $v;
422
}
423
424
425
$cid           = Request::getInt('cid', 0, 'POST');
426
$contactby     = Request::getInt('contactby', 0, 'POST');
427
$country       = Request::getString('country', '', 'POST');
428
$date_created  = Request::getInt('date_created', time(), 'POST');
429
$desctext      = Request::getText('Description', '', 'POST');
430
$email         = Request::getString('email', '', 'POST');
431
$expire        = Request::getInt('expire', 14, 'POST');
432
$lid           = Request::getInt('lid', 0, 'POST');
433
$op            = Request::getCmd('op', '', 'POST');
434
$photo         = Request::getString('photo', '', 'POST');
435
$premium       = Request::getInt('premium', 0, 'POST');
436
$price         = Request::getFloat('price', 0.00, 'POST');
437
$status        = Request::getInt('status', 0, 'POST');
438
$submitter     = Request::getInt('submitter', 0, 'POST');
439
$tel           = Request::getString('tel', '', 'POST');
440
$title         = Request::getString('title', '', 'POST');
441
$town          = Request::getString('town', '', 'POST');
442
$type          = Request::getInt('type', 0, 'POST');
443
$typecondition = Request::getInt('typecondition', 0, 'POST');
444
$typeprice     = Request::getInt('typeprice', 0, 'POST');
445
$valid         = Request::getString('valid', '', 'POST');
446
447
448
$pa  = Request::getString('pa', '', 'GET');
449
$lid = Request::getInt('lid', 0);
450
$op  = Request::getString('op', '');
451
switch ($op) {
452
    case 'IndexView':
453
        indexView($lid);
454
        break;
455
    case 'ListingDel':
456
        listingDel($lid, $photo);
457
        break;
458
    case 'modifyAd':
459
       modifyAd($lid);
460
        break;
461
    case 'modifyAds':
462
        modifyAds(
463
            $lid,
464
            $cid,
465
            $title,
466
            $status,
467
            $expire,
468
            $type,
469
            $desctext,
470
            $tel,
471
            $price,
472
            $typeprice,
473
            $typecondition,
474
            $date_created,
475
            $email,
476
            $submitter,
477
            $town,
478
            $country,
479
            $contactby,
480
            $premium,
481
            $valid,
482
            $photo
0 ignored issues
show
Unused Code introduced by
The call to modifyAds() has too many arguments starting with $photo. ( Ignorable by Annotation )

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

482
        /** @scrutinizer ignore-call */ 
483
        modifyAds(

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...
483
        );
484
        break;
485
    default:
486
        index();
487
        break;
488
}
489