modifyAd()   F
last analyzed

Complexity

Conditions 15
Paths 3458

Size

Total Lines 203
Code Lines 140

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 140
c 0
b 0
f 0
dl 0
loc 203
rs 1.3999
cc 15
nc 3458
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 declare(strict_types=1);
2
3
/*
4
 * You may not change or alter any portion of this comment or credits
5
 * of supporting developers from this source code or any supporting source code
6
 * which is considered copyrighted (c) material of the original comment or credit authors.
7
 *
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 */
12
13
/**
14
 * @copyright    XOOPS Project (https://xoops.org)
15
 * @license      GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html)
16
 * @author       XOOPS Development Team
17
 * @author       Pascal Le Boustouller: original author ([email protected])
18
 * @author       Luc Bizet (www.frxoops.org)
19
 * @author       jlm69 (www.jlmzone.com)
20
 * @author       mamba (www.xoops.org)
21
 */
22
23
use Xmf\Request;
24
use XoopsModules\Adslight\{
25
    Helper,
26
    Tree,
27
    Utility
28
};
29
/** @var Admin $adminObject */
30
/** @var Helper $helper */
31
require_once __DIR__ . '/admin_header.php';
32
$op = Request::getString('op', 'list');
33
/**
34
 * Main Ad Display
35
 */
36
function index(): void
37
{
38
    global $xoopsDB;
39
    $helper = Helper::getInstance();
40
41
    //    $mytree = new Tree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid');
42
43
    //    require_once __DIR__ . '/admin_header.php';
44
    xoops_cp_header();
45
    //    loadModuleAdminMenu(0, "");
46
47
    // photo dir setting checker
48
    $photo_dir         = $helper->getConfig('adslight_path_upload', '');
49
    $photo_thumb_dir   = $helper->getConfig('adslight_path_upload') . '/thumbs';
50
    $photo_resized_dir = $helper->getConfig('adslight_path_upload') . '/midsize';
51
    if (!is_dir($photo_dir) && (!mkdir($photo_dir) && !is_dir($photo_dir))) {
52
        throw new \RuntimeException(sprintf('Directory "%s" was not created', $photo_dir));
53
    }
54
    if (!is_dir($photo_thumb_dir) && (!mkdir($photo_thumb_dir) && !is_dir($photo_thumb_dir))) {
55
        throw new \RuntimeException(sprintf('Directory "%s" was not created', $photo_thumb_dir));
56
    }
57
    if (!is_dir($photo_resized_dir) && (!mkdir($photo_resized_dir) && !is_dir($photo_resized_dir))) {
58
        throw new \RuntimeException(sprintf('Directory "%s" was not created', $photo_resized_dir));
59
    }
60
    if (!is_writable($photo_dir) || !is_readable($photo_dir)) {
61
        echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_CHECKER . '</legend><br>';
62
        echo "<span style='color: #FF0000;'><b>" . _AM_ADSLIGHT_DIRPERMS . $photo_dir . "</b></span><br><br>\n";
63
        echo '</fieldset><br>';
64
    }
65
66
    if (!is_writable($photo_thumb_dir) || !is_readable($photo_thumb_dir)) {
67
        echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_CHECKER . '</legend><br>';
68
        echo "<span style='color: #FF0000;'><b>" . _AM_ADSLIGHT_DIRPERMS . $photo_thumb_dir . "</b></span><br><br>\n";
69
        echo '</fieldset><br>';
70
    }
71
72
    if (!is_writable($photo_resized_dir) || !is_readable($photo_resized_dir)) {
73
        echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_CHECKER . '</legend><br>';
74
        echo "<span style='color: #FF0000;'><b>" . _AM_ADSLIGHT_DIRPERMS . $photo_resized_dir . "</b></span><br><br>\n";
75
        echo '</fieldset><br>';
76
    }
77
78
    $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";
79
    $result  = $xoopsDB->query($sql);
80
    $numrows = $xoopsDB->getRowsNum($result);
81
    if ($numrows > 0) {
82
        ///////// Il y a [..] Annonces en attente d'être approuvées //////
83
        echo "<table class='outer bnone' cellspacing=5 cellpadding=0><tr><td width=40>";
84
        echo "<img src='../assets/images/admin/error_button.png' border=0 ></td><td>";
85
        echo "<span style='color:#00B4C4;'><b>" . _AM_ADSLIGHT_THEREIS . "</b></span> <b>{$numrows}</b> <span style='color:#00B4C4;'>" . _AM_ADSLIGHT_WAIT . '</b></span>';
86
        echo '</td></tr></table><br>';
87
    } else {
88
        echo "<table class='outer' width='50%' border='0'><tr><td width=40>";
89
        echo "<img src='../assets/images/admin/search_button_green_32.png' border=0 alt=\"._AM_ADSLIGHT_RELEASEOK.\" ></td><td>";
90
        echo "<span style='color: #00B4C4;'><b>" . _AM_ADSLIGHT_NOANNVAL . '</b></span>';
91
        echo '</td></tr></table><br>';
92
    }
93
94
    // Modify Annonces
95
    $sql = 'SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_listing');
96
    $result = $xoopsDB->query($sql);
97
    if (!$xoopsDB->isResultSet($result)) {
98
        \trigger_error("Query Failed! SQL: $sql- Error: " . $xoopsDB->error(), E_USER_ERROR);
99
    }
100
    [$numrows] = $xoopsDB->fetchRow($result);
101
    if ($numrows > 0) {
102
        echo "<table width='100%' border='0' class='outer'><tr class='bg4'><td valign='top'>";
103
        echo '<form method="post" action="modify_ads.php">'
104
             . '<b>'
105
             . _AM_ADSLIGHT_MODANN
106
             . '</b><br><br>'
107
             . _AM_ADSLIGHT_NUMANN
108
             . ' <input type="text" name="lid" size="12" maxlength="11">&nbsp;&nbsp;'
109
             . '<input type="hidden" name="op" value="modifyAd">'
110
             . '<input type="submit" value="'
111
             . _AM_ADSLIGHT_MODIF
112
             . '">'
113
             . '</form><br>';
114
        echo '</td></tr></table><br>';
115
    }
116
117
    echo "<table width='100%' border='0' cellspacing='1' cellpadding='8' style='border: 2px solid #DFE0E0;'><tr class='bg4'><td valign='top'>";
118
    echo '<a href="map.php">' . _AM_ADSLIGHT_GESTCAT . '</a> | <a href="../index.php">' . _AM_ADSLIGHT_ACCESMYANN . '</a>';
119
    echo '</td></tr></table><br>';
120
121
    xoops_cp_footer();
122
}
123
124
#  function modifyAd
125
#####################################################
126
/**
127
 * @param $lid
128
 */
129
function modifyAd($lid): void
130
{
131
    global $xoopsDB, $xoopsModule, $xoopsConfig, $myts, $desctext;
132
133
    $helper        = Helper::getInstance();
0 ignored issues
show
Unused Code introduced by
The assignment to $helper is dead and can be removed.
Loading history...
134
    $mytree        = new Tree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid');
135
    $helper        = Helper::getInstance();
136
    $contactselect = '';
0 ignored issues
show
Unused Code introduced by
The assignment to $contactselect is dead and can be removed.
Loading history...
137
    //    require_once __DIR__ . '/admin_header.php';
138
    xoops_cp_header();
139
    //    loadModuleAdminMenu(0, "");
140
    $id_price  = '';
141
    $nom_price = '';
142
    $lid       = (int)$lid;
143
144
    echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_MODANN . '</legend>';
145
146
    $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}";
147
    $result = $xoopsDB->query($sql);
148
    if (!$xoopsDB->isResultSet($result)) {
149
        \trigger_error("Query Failed! SQL: $sql- Error: " . $xoopsDB->error(), E_USER_ERROR);
150
    }
151
    while ([$lid, $cid, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $typecondition, $date_created, $email, $submitter, $town, $country, $contactby, $premium, $valid, $photo] = $xoopsDB->fetchRow(
152
        $result
153
    )) {
154
        $title    = \htmlspecialchars($title, ENT_QUOTES | ENT_HTML5);
155
        $status   = \htmlspecialchars($status, ENT_QUOTES | ENT_HTML5);
156
        $expire   = \htmlspecialchars($expire, ENT_QUOTES | ENT_HTML5);
157
        $type     = \htmlspecialchars($type, ENT_QUOTES | ENT_HTML5);
158
        $desctext = $myts->displayTarea($desctext, 1, 1, 1);
159
        $tel      = \htmlspecialchars($tel, ENT_QUOTES | ENT_HTML5);
160
        //        $price     = number_format($price, 2, ',', ' ');
161
162
        xoops_load('XoopsLocal');
163
        $tempXoopsLocal = new \XoopsLocal();
164
        //  For US currency with 2 numbers after the decimal comment out if you don't want 2 numbers after decimal
165
        $priceFormatted = $tempXoopsLocal->number_format($price);
0 ignored issues
show
Unused Code introduced by
The assignment to $priceFormatted is dead and can be removed.
Loading history...
166
        //  For other countries uncomment the below line and comment out the above line
167
        //      $priceFormatted = $tempXoopsLocal->number_format($price);
168
169
        $typeprice     = \htmlspecialchars($typeprice, ENT_QUOTES | ENT_HTML5);
170
        $typecondition = \htmlspecialchars($typecondition, ENT_QUOTES | ENT_HTML5);
171
        $submitter     = \htmlspecialchars($submitter, ENT_QUOTES | ENT_HTML5);
172
        $town          = \htmlspecialchars($town, ENT_QUOTES | ENT_HTML5);
173
        $country       = \htmlspecialchars($country, ENT_QUOTES | ENT_HTML5);
174
        $contactby     = \htmlspecialchars($contactby, ENT_QUOTES | ENT_HTML5);
175
        $premium       = \htmlspecialchars($premium, ENT_QUOTES | ENT_HTML5);
176
177
        $date2 = formatTimestamp($date_created, 's');
178
179
        echo '<form action="modify_ads.php" method=post>';
180
        echo $GLOBALS['xoopsSecurity']->getTokenHTML();
181
        echo "<table class='bnone'><tr class='head' border='1'>
182
            <td>" . _AM_ADSLIGHT_NUMANN . " </td><td>{$lid} &nbsp;" . _AM_ADSLIGHT_ADDED_ON . "&nbsp; {$date2}</td>
183
            </tr><tr class='head' border='1'>
184
            <td>" . _AM_ADSLIGHT_SENDBY . " </td><td>{$submitter}</td>
185
            </tr><tr class='head' border='1'>
186
            <td>" . _AM_ADSLIGHT_EMAIL . " </td><td><input type=\"text\" name=\"email\" size=\"40\" value=\"{$email}\"></td>
187
            </tr><tr class='head' border='1'>
188
            <td>" . _AM_ADSLIGHT_TEL . " </td><td><input type=\"text\" name=\"tel\" size=\"50\" value=\"{$tel}\"></td>
189
            </tr><tr class='head' border='1'>
190
            <td>" . _AM_ADSLIGHT_TOWN . " </td><td><input type=\"text\" name=\"town\" size=\"40\" value=\"{$town}\"></td>
191
            </tr><tr class='head' border='1'>
192
            <td>" . _AM_ADSLIGHT_COUNTRY . " </td><td><input type=\"text\" name=\"country\" size=\"40\" value=\"{$country}\"></td>
193
            </tr></tr><tr class='head' border='1'>";
194
195
        $contactSel1 = $contactSel2 = $contactSel3 = $contactSel4 = '';
196
        $selected    = 'contactSel' . (int)$contactby;
197
        ${$selected} = ' selected';
198
199
        echo " <td class='head'>"
200
             . _AM_ADSLIGHT_CONTACTBY
201
             . " </td><td class='head'><select name=\"contactby\">\n"
202
             //           . "  <option value=\"{$contactby}\">{$contactselect[$contactby]}</option>\n"
203
             . "  <option value=\"1\"{$contactSel1}>"
204
             . _AM_ADSLIGHT_CONTACT_BY_EMAIL
205
             . "</option>\n"
206
             . "  <option value=\"2\"{$contactSel2}>"
207
             . _AM_ADSLIGHT_CONTACT_BY_PM
208
             . "</option>\n"
209
             . "  <option value=\"3\"{$contactSel3}>"
210
             . _AM_ADSLIGHT_CONTACT_BY_BOTH
211
             . "</option>\n"
212
             . "  <option value=\"4\"{$contactSel4}>"
213
             . _AM_ADSLIGHT_CONTACT_BY_PHONE
214
             . "</option></select>\n"
215
             . " </td>\n"
216
             . '</tr>';
217
218
        echo "<tr><td class='head'>" . _AM_ADSLIGHT_STATUS . "</td><td class='head'><input type=\"radio\" name=\"status\" value=\"0\"";
219
        if (0 === (int)$status) {
220
            echo 'checked';
221
        }
222
        echo '>' . _AM_ADSLIGHT_ACTIVE . '&nbsp;&nbsp; <input type="radio" name="status" value="1"';
223
        if (1 === (int)$status) {
224
            echo 'checked';
225
        }
226
        echo '>' . _AM_ADSLIGHT_INACTIVE . '&nbsp;&nbsp; <input type="radio" name="status" value="2"';
227
        if (2 === (int)$status) {
228
            echo 'checked';
229
        }
230
        echo '>' . _AM_ADSLIGHT_SOLD . '</td></tr>';
231
232
        echo "<tr class='head' border='1'>
233
        <td>" . _AM_ADSLIGHT_TITLE2 . " </td><td><input type=\"text\" name=\"title\" size=\"40\" value=\"{$title}\"></td>
234
            </tr><tr class='head' border='1'>
235
        <td>" . _AM_ADSLIGHT_PREMIUM . " </td><td><input type=\"text\" name=\"premium\" size=\"3\" value=\"{$premium}\"></td>
236
            </tr><tr class='head' border='1'>
237
        <td>" . _AM_ADSLIGHT_EXPIRE . " </td><td><input type=\"text\" name=\"expire\" size=\"40\" value=\"{$expire}\"></td>
238
            </tr>";
239
        ////// Type d'annonce
240
        echo "<tr class='head' border='1'>
241
            <td>" . _AM_ADSLIGHT_TYPE . ' </td><td><select name="type">';
242
        $sql     = 'SELECT nom_type, id_type FROM ' . $xoopsDB->prefix('adslight_type') . ' ORDER BY nom_type';
243
        $result5 = $xoopsDB->query($sql);
244
        if (!$xoopsDB->isResultSet($result5)) {
245
            \trigger_error("Query Failed! SQL: $sql- Error: " . $xoopsDB->error(), E_USER_ERROR);
246
        }
247
        while ([$nom_type, $id_type] = $xoopsDB->fetchRow($result5)) {
248
            $sel = '';
249
            if ($id_type === $type) {
250
                $sel = 'selected';
251
            }
252
            echo "<option value=\"{$id_type}\"{$sel}>{$nom_type}</option>";
253
        }
254
        echo '</select></td></tr>';
255
256
        ////// Condition
257
        echo "<tr class='head' border='1'>
258
            <td>" . _AM_ADSLIGHT_TYPE_CONDITION . ' </td><td><select name="typecondition">';
259
        $sql     = 'SELECT nom_condition, id_condition FROM ' . $xoopsDB->prefix('adslight_condition') . ' ORDER BY nom_condition';
260
        $result6 = $xoopsDB->query($sql);
261
        if (!$xoopsDB->isResultSet($result6)) {
262
            \trigger_error("Query Failed! SQL: $sql- Error: " . $xoopsDB->error(), E_USER_ERROR);
263
        }
264
        while ([$nom_condition, $id_condition] = $xoopsDB->fetchRow($result6)) {
265
            $sel = '';
266
            if ($id_condition === $typecondition) {
267
                $sel = 'selected';
268
            }
269
            echo "<option value=\"{$id_condition}\"{$sel}>{$nom_condition}</option>";
270
        }
271
        echo '</select></td></tr>';
272
273
        /////// Price
274
        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');
275
276
        //////// Price type
277
        $sql     = 'SELECT nom_price, id_price FROM ' . $xoopsDB->prefix('adslight_price') . ' ORDER BY nom_price';
278
        $resultx = $xoopsDB->query($sql);
279
        if (!$xoopsDB->isResultSet($resultx)) {
280
            \trigger_error("Query Failed! SQL: $sql- Error: " . $xoopsDB->error(), E_USER_ERROR);
281
        }
282
283
        echo " <select name=\"typeprice\"><option value=\"{$id_price}\">{$nom_price}</option>";
284
        while ([$nom_price, $id_price] = $xoopsDB->fetchRow($resultx)) {
285
            $sel = '';
286
            if ($id_price === $typeprice) {
287
                $sel = 'selected';
288
            }
289
            echo "<option value=\"{$id_price}\"{$sel}>{$nom_price}</option>";
290
        }
291
        echo '</select></td>';
292
293
        /////// Category
294
295
        echo "<tr class='head' border='1'>
296
            <td>" . _AM_ADSLIGHT_CAT2 . ' </td><td>';
297
        $mytree->makeMySelBox('title', 'title', $cid);
298
        echo "</td>
299
            </tr><tr class='head' border='1'>
300
            <td>" . _AM_ADSLIGHT_DESC . ' </td><td>';
301
        //        $options = ['desctext', $desctext, '100%', '200px', 'small'];
302
        $options           = [];
303
        $options['name']   = 'desctext';
304
        $options['value']  = $desctext;
305
        $options['cols']   = '100%';
306
        $options['width']  = '100%';
307
        $options['height'] = '400px';
308
        $options['rows']   = 10;
309
310
        $wysiwyg_text_area = Utility::getEditor($helper, $options);
311
        echo $wysiwyg_text_area->render();
312
313
        echo '</td></tr>';
314
315
        echo "<tr class='head' border='1'>
316
            <td>" . _AM_ADSLIGHT_PHOTO1 . " </td><td><input type=\"text\" name=\"photo\" size=\"50\" value=\"{$photo}\"></td>
317
            </tr><tr>";
318
        $time = time();
319
        echo "</tr><tr class='head' border='1'>
320
            <td>&nbsp;</td><td><select name=\"op\">
321
            <option value=\"modifyAds\"> " . _AM_ADSLIGHT_MODIF . '
322
            <option value="ListingDel"> ' . _AM_ADSLIGHT_DEL . '
323
            </select><input type="submit" value="' . _AM_ADSLIGHT_GO . '"></td>
324
            </tr></table>';
325
        echo '<input type="hidden" name="valid" value="Yes">';
326
        echo "<input type=\"hidden\" name=\"lid\" value=\"{$lid}\">";
327
        echo "<input type=\"hidden\" name=\"date_created\" value=\"{$time}\">";
328
        echo "<input type=\"hidden\" name=\"submitter\" value=\"{$submitter}\">
329
        </form><br>";
330
        echo '</fieldset><br>';
331
        xoops_cp_footer();
332
    }
333
}
334
335
#  function modifyAds
336
#####################################################
337
/**
338
 * @param $lid
339
 * @param $cat
340
 * @param $title
341
 * @param $status
342
 * @param $expire
343
 * @param $type
344
 * @param $desctext
345
 * @param $tel
346
 * @param $price
347
 * @param $typeprice
348
 * @param $typecondition
349
 * @param $date_created
350
 * @param $email
351
 * @param $submitter
352
 * @param $town
353
 * @param $country
354
 * @param $contactby
355
 * @param $premium
356
 * @param $valid
357
 * @param $photo
358
 */
359
function modifyAds(
360
    $lid,
361
    $cat,
362
    $title,
363
    $status,
364
    $expire,
365
    $type,
366
    $desctext,
367
    $tel,
368
    $price,
369
    $typeprice,
370
    $typecondition,
371
    $date_created,
372
    $email,
373
    $submitter,
374
    $town,
375
    $country,
376
    $contactby,
377
    $premium,
378
    $valid,
379
    $photo
380
): void {
381
    global $xoopsDB, $myts;
382
    $helper = Helper::getInstance();
383
384
    $sql = 'UPDATE '
385
           . $xoopsDB->prefix('adslight_listing')
386
           . " 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}";
387
388
    $result = $xoopsDB->query($sql);
0 ignored issues
show
Unused Code introduced by
The assignment to $result is dead and can be removed.
Loading history...
389
390
    $helper->redirect('admin/modify_ads.php', 1, _AM_ADSLIGHT_ANNMOD);
391
}
392
393
/**
394
 * Delete Listing
395
 *
396
 * @param int    $lid
397
 * @param string $photo
398
 */
399
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

399
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...
400
{
401
    global $xoopsDB;
402
    $helper  = Helper::getInstance();
403
    $lid     = (int)$lid;
404
    $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}";
405
    $result2 = $xoopsDB->query($sql);
406
    if (!$xoopsDB->isResultSet($result2)) {
407
        \trigger_error("Query Failed! SQL: $sql- Error: " . $xoopsDB->error(), E_USER_ERROR);
408
    }
409
    while ([$purl] = $xoopsDB->fetchRow($result2)) {
410
        if ($purl) {
411
            $destination = XOOPS_ROOT_PATH . '/uploads/adslight';
412
            if (is_file("{$destination}/{$purl}")) {
413
                unlink("{$destination}/{$purl}");
414
            }
415
            $destination2 = XOOPS_ROOT_PATH . '/uploads/adslight/thumbs';
416
            if (is_file("{$destination2}/thumb_{$purl}")) {
417
                unlink("{$destination2}/thumb_{$purl}");
418
            }
419
            $destination3 = XOOPS_ROOT_PATH . '/uploads/adslight/midsize';
420
            if (is_file("{$destination3}/resized_{$purl}")) {
421
                unlink("{$destination3}/resized_{$purl}");
422
            }
423
            $sql = 'DELETE FROM ' . $xoopsDB->prefix('adslight_pictures') . " WHERE lid={$lid}";
424
            $xoopsDB->query($sql);
425
        }
426
    }
427
428
    $sql = 'DELETE FROM ' . $xoopsDB->prefix('adslight_listing') . " WHERE lid={$lid}";
429
    $xoopsDB->query($sql);
430
    $helper->redirect('admin/modify_ads.php', 1, _AM_ADSLIGHT_ANNDEL);
431
}
432
433
#####################################################
434
#####################################################
435
//@todo REMOVE THIS ASAP. This code is extremely unsafe
436
foreach ($_POST as $k => $v) {
437
    ${$k} = $v;
438
}
439
440
$cid           = Request::getInt('cid', 0, 'POST');
441
$contactby     = Request::getInt('contactby', 0, 'POST');
442
$country       = Request::getString('country', '', 'POST');
443
$date_created  = Request::getInt('date_created', time(), 'POST');
444
$desctext      = Request::getText('Description', '', 'POST');
445
$email         = Request::getString('email', '', 'POST');
446
$expire        = Request::getInt('expire', 14, 'POST');
447
$lid           = Request::getInt('lid', 0, 'POST');
448
$op            = Request::getCmd('op', '', 'POST');
449
$photo         = Request::getString('photo', '', 'POST');
450
$premium       = Request::getInt('premium', 0, 'POST');
451
$price         = Request::getFloat('price', 0.00, 'POST');
452
$status        = Request::getInt('status', 0, 'POST');
453
$submitter     = Request::getInt('submitter', 0, 'POST');
454
$tel           = Request::getString('tel', '', 'POST');
455
$title         = Request::getString('title', '', 'POST');
456
$town          = Request::getString('town', '', 'POST');
457
$type          = Request::getInt('type', 0, 'POST');
458
$typecondition = Request::getInt('typecondition', 0, 'POST');
459
$typeprice     = Request::getInt('typeprice', 0, 'POST');
460
$valid         = Request::getString('valid', '', 'POST');
461
462
$pa  = Request::getString('pa', '', 'GET');
463
$lid = Request::getInt('lid', 0);
464
$op  = Request::getString('op', '');
465
switch ($op) {
466
    case 'IndexView':
467
        indexView($lid);
468
        break;
469
    case 'ListingDel':
470
        listingDel($lid, $photo);
471
        break;
472
    case 'modifyAd':
473
        modifyAd($lid);
474
        break;
475
    case 'modifyAds':
476
        modifyAds(
477
            $lid,
478
            $cid,
479
            $title,
480
            $status,
481
            $expire,
482
            $type,
483
            $desctext,
484
            $tel,
485
            $price,
486
            $typeprice,
487
            $typecondition,
488
            $date_created,
489
            $email,
490
            $submitter,
491
            $town,
492
            $country,
493
            $contactby,
494
            $premium,
495
            $valid,
496
            $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

496
        /** @scrutinizer ignore-call */ 
497
        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...
497
        );
498
        break;
499
    default:
500
        index();
501
        break;
502
}
503