Completed
Push — master ( 2a7c05...7c1d68 )
by Michael
02:50
created

modify_ads.php ➔ modifyAdsS()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 32
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 22
nc 1
nop 20
dl 0
loc 32
rs 8.8571
c 0
b 0
f 0

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

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 34 and the first side effect is on line 25.

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;
24
25
require_once __DIR__ . '/admin_header.php';
26
27
$op = Request::getString('op', 'liste');
28
29
/**
30
 * Main Ad Display
31
 *
32
 * @return void
33
 */
34
function index()
0 ignored issues
show
Best Practice introduced by
The function index() has been defined more than once; this definition is ignored, only the first definition in admin/main.php (L31-289) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
35
{
36
    global $xoopsDB, $xoopsModuleConfig;
37
38
    //    $mytree = new ClassifiedsTree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid');
0 ignored issues
show
Unused Code Comprehensibility introduced by
61% 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...
39
40
    //    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...
41
    xoops_cp_header();
42
    //    loadModuleAdminMenu(0, "");
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...
43
44
    // photo dir setting checker
45
    $photo_dir         = $GLOBALS['xoopsModuleConfig']['adslight_path_upload'];
46
    $photo_thumb_dir   = $GLOBALS['xoopsModuleConfig']['adslight_path_upload'] . '/thumbs';
47
    $photo_resized_dir = $GLOBALS['xoopsModuleConfig']['adslight_path_upload'] . '/midsize';
48
    if (!is_dir($photo_dir)) {
49
        mkdir($photo_dir);
50
    }
51
    if (!is_dir($photo_thumb_dir)) {
52
        mkdir($photo_thumb_dir);
53
    }
54
    if (!is_dir($photo_resized_dir)) {
55
        mkdir($photo_resized_dir);
56
    }
57 View Code Duplication
    if (!is_writable($photo_dir) || !is_readable($photo_dir)) {
58
        echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_CHECKER . '</legend><br>';
59
        echo "<span style='color: #FF0000;'><b>" . _AM_ADSLIGHT_DIRPERMS . '' . $photo_dir . "</b></span><br><br>\n";
60
        echo '</fieldset><br>';
61
    }
62
63 View Code Duplication
    if (!is_writable($photo_thumb_dir) || !is_readable($photo_thumb_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_thumb_dir . "</b></span><br><br>\n";
66
        echo '</fieldset><br>';
67
    }
68
69 View Code Duplication
    if (!is_writable($photo_resized_dir) || !is_readable($photo_resized_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_resized_dir . "</b></span><br><br>\n";
72
        echo '</fieldset><br>';
73
    }
74
75
    $result  = $xoopsDB->query('SELECT lid, cid, title, status, expire, type, desctext, tel, price, typeprice, typeusure, date, email, submitter, town, country, contactby, premium, photo, usid FROM '
76
                               . $xoopsDB->prefix('adslight_listing')
77
                               . " WHERE valid='no' ORDER BY lid");
78
    $numrows = $xoopsDB->getRowsNum($result);
79 View Code Duplication
    if ($numrows > 0) {
80
81
        ///////// Il y a [..] Annonces en attente d'être approuvées //////
82
        echo "<table class='outer bnone' cellspacing=5 cellpadding=0><tr><td width=40>";
83
        echo "<img src='../assets/images/admin/error_button.png' border=0 ></td><td>";
84
        echo "<span style='color:#00B4C4;'><b>" . _AM_ADSLIGHT_THEREIS . "</b></span> <b>$numrows</b> <span style='color:#00B4C4;'>" . _AM_ADSLIGHT_WAIT . '</b></span>';
85
        echo '</td></tr></table><br>';
86
    } else {
87
        echo "<table class='outer' width='50%' border='0'><tr><td width=40>";
88
        echo "<img src='../assets/images/admin/search_button_green_32.png' border=0 alt=\"._AM_ADSLIGHT_RELEASEOK.\" ></td><td>";
89
        echo "<span style='color: #00B4C4;'><b>" . _AM_ADSLIGHT_NOANNVAL . '</b></span>';
90
        echo '</td></tr></table><br>';
91
    }
92
93
    // Modify Annonces
94
    list($numrows) = $xoopsDB->fetchRow($xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_listing')));
95 View Code Duplication
    if ($numrows > 0) {
96
        echo "<table width='100%' border='0' class='outer'><tr class='bg4'><td valign='top'>";
97
        echo "<form method=\"post\" action=\"modify_ads.php\">"
98
             . '<b>'
99
             . _AM_ADSLIGHT_MODANN
100
             . '</b><br><br>'
101
             . _AM_ADSLIGHT_NUMANN
102
             . " <input type=\"text\" name=\"lid\" size=\"12\" maxlength=\"11\">&nbsp;&nbsp;"
103
             . "<input type=\"hidden\" name=\"op\" value=\"ModifyAds\">"
104
             . "<input type=\"submit\" value=\""
105
             . _AM_ADSLIGHT_MODIF
106
             . "\">"
107
             . '</form><br>';
108
        echo '</td></tr></table><br>';
109
    }
110
111
    echo "<table width='100%' border='0' cellspacing='1' cellpadding='8' style='border: 2px solid #DFE0E0;'><tr class='bg4'><td valign='top'>";
112
    echo "<a href=\"map.php\">" . _AM_ADSLIGHT_GESTCAT . "</a> | <a href=\"../index.php\">" . _AM_ADSLIGHT_ACCESMYANN . '</a>';
113
    echo '</td></tr></table><br>';
114
115
    xoops_cp_footer();
116
}
117
118
#  function modifyAds
119
#####################################################
120
/**
121
 * @param $lid
122
 */
123
function modifyAds($lid)
124
{
125
    global $xoopsDB, $xoopsModule, $xoopsConfig, $myts, $desctext, $moduleDirName, $admin_lang;
126
127
    $mytree        = new ClassifiedsTree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid');
128
    $contactselect = '';
0 ignored issues
show
Unused Code introduced by
$contactselect is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
129
    //    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...
130
    xoops_cp_header();
131
    //    loadModuleAdminMenu(0, "");
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...
132
    $id_price  = '';
133
    $nom_price = '';
134
    $lid       = (int)$lid;
135
136
    echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_MODANN . '</legend>';
137
138
    $result = $xoopsDB->query('SELECT lid, cid, title, status, expire, type, desctext, tel, price, typeprice, typeusure, date, email, submitter, town, country, contactby, premium, valid, photo FROM '
139
                              . $xoopsDB->prefix('adslight_listing')
140
                              . " WHERE lid={$lid}");
141
142
    while (list($lid, $cid, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $typeusure, $date, $email, $submitter, $town, $country, $contactby, $premium, $valid, $photo) = $xoopsDB->fetchRow($result)) {
0 ignored issues
show
Unused Code introduced by
The assignment to $valid is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
143
        $title    = $myts->htmlSpecialChars($title);
144
        $status   = $myts->htmlSpecialChars($status);
145
        $expire   = $myts->htmlSpecialChars($expire);
146
        $type     = $myts->htmlSpecialChars($type);
147
        $desctext = $myts->displayTarea($desctext, 1, 1, 1);
148
        $tel      = $myts->htmlSpecialChars($tel);
149
        //        $price     = number_format($price, 2, ',', ' ');
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% 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...
150
151
        xoops_load('XoopsLocal');
152
        $tempXoopsLocal = new XoopsLocal;
153
        //  For US currency with 2 numbers after the decimal comment out if you dont want 2 numbers after decimal
154
        $price = $tempXoopsLocal->number_format($price, 2, ',', ' ');
155
        //  For other countries uncomment the below line and comment out the above line
156
        //      $price = $tempXoopsLocal->number_format($price);
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% 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...
157
158
        $typeprice = $myts->htmlSpecialChars($typeprice);
159
        $typeusure = $myts->htmlSpecialChars($typeusure);
160
        $submitter = $myts->htmlSpecialChars($submitter);
161
        $town      = $myts->htmlSpecialChars($town);
162
        $country   = $myts->htmlSpecialChars($country);
163
        $contactby = $myts->htmlSpecialChars($contactby);
164
        $premium   = $myts->htmlSpecialChars($premium);
165
166
        $date2 = formatTimestamp($date, 's');
167
168
        echo "<form action=\"modify_ads.php\" method=post>";
169
        echo $GLOBALS['xoopsSecurity']->getTokenHTML();
170
        echo "<table class='bnone'><tr class='head' border='1'>
171
            <td>" . _AM_ADSLIGHT_NUMANN . " </td><td>{$lid} &nbsp;" . _AM_ADSLIGHT_ADDED_ON . "&nbsp; {$date2}</td>
172
            </tr><tr class='head' border='1'>
173
            <td>" . _AM_ADSLIGHT_SENDBY . " </td><td>{$submitter}</td>
174
            </tr><tr class='head' border='1'>
175
            <td>" . _AM_ADSLIGHT_EMAIL . " </td><td><input type=\"text\" name=\"email\" size=\"40\" value=\"{$email}\"></td>
176
            </tr><tr class='head' border='1'>
177
            <td>" . _AM_ADSLIGHT_TEL . " </td><td><input type=\"text\" name=\"tel\" size=\"50\" value=\"{$tel}\"></td>
178
            </tr><tr class='head' border='1'>
179
            <td>" . _AM_ADSLIGHT_TOWN . " </td><td><input type=\"text\" name=\"town\" size=\"40\" value=\"{$town}\"></td>
180
            </tr><tr class='head' border='1'>
181
            <td>" . _AM_ADSLIGHT_COUNTRY . " </td><td><input type=\"text\" name=\"country\" size=\"40\" value=\"{$country}\"></td>
182
            </tr></tr><tr class='head' border='1'>";
183
184
        $contactSel1 = $contactSel2 = $contactSel3 = $contactSel4 = '';
185
        $selected    = 'contactSel' . (int)$contactby;
186
        $$selected   = ' selected';
187
188
        echo " <td class='head'>"
189
             . _AM_ADSLIGHT_CONTACTBY
190
             . " </td><td class='head'><select name=\"contactby\">\n"
191
             //           . "  <option value=\"{$contactby}\">{$contactselect[$contactby]}</option>\n"
0 ignored issues
show
Unused Code Comprehensibility introduced by
56% 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...
192
             . "  <option value=\"1\"{$contactSel1}>"
193
             . _AM_ADSLIGHT_CONTACT_BY_EMAIL
194
             . "</option>\n"
195
             . "  <option value=\"2\"{$contactSel2}>"
196
             . _AM_ADSLIGHT_CONTACT_BY_PM
197
             . "</option>\n"
198
             . "  <option value=\"3\"{$contactSel3}>"
199
             . _AM_ADSLIGHT_CONTACT_BY_BOTH
200
             . "</option>\n"
201
             . "  <option value=\"4\"{$contactSel4}>"
202
             . _AM_ADSLIGHT_CONTACT_BY_PHONE
203
             . "</option></select>\n"
204
             . " </td>\n"
205
             . '</tr>';
206
207
        echo "<tr><td class='head'>" . _AM_ADSLIGHT_STATUS . "</td><td class='head'><input type=\"radio\" name=\"status\" value=\"0\"";
208
        if ('0' == $status) {
209
            echo 'checked';
210
        }
211
        echo '>' . _AM_ADSLIGHT_ACTIVE . "&nbsp;&nbsp; <input type=\"radio\" name=\"status\" value=\"1\"";
212
        if ('1' == $status) {
213
            echo 'checked';
214
        }
215
        echo '>' . _AM_ADSLIGHT_INACTIVE . "&nbsp;&nbsp; <input type=\"radio\" name=\"status\" value=\"2\"";
216
        if ('2' == $status) {
217
            echo 'checked';
218
        }
219
        echo '>' . _AM_ADSLIGHT_SOLD . '</td></tr>';
220
221
        echo "<tr class='head' border='1'>
222
        <td>" . _AM_ADSLIGHT_TITLE2 . " </td><td><input type=\"text\" name=\"title\" size=\"40\" value=\"{$title}\"></td>
223
            </tr><tr class='head' border='1'>
224
        <td>" . _AM_ADSLIGHT_PREMIUM . " </td><td><input type=\"text\" name=\"premium\" size=\"3\" value=\"{$premium}\"></td>
225
            </tr><tr class='head' border='1'>
226
        <td>" . _AM_ADSLIGHT_EXPIRE . " </td><td><input type=\"text\" name=\"expire\" size=\"40\" value=\"{$expire}\"></td>
227
            </tr>";
228
        ////// Type d'annonce
229
        echo "<tr class='head' border='1'>
230
            <td>" . _AM_ADSLIGHT_TYPE . " </td><td><select name=\"type\">";
231
232
        $result5 = $xoopsDB->query('SELECT nom_type, id_type FROM ' . $xoopsDB->prefix('adslight_type') . ' ORDER BY nom_type');
233
        while (list($nom_type, $id_type) = $xoopsDB->fetchRow($result5)) {
234
            $sel = '';
235
            if ($id_type == $type) {
236
                $sel = 'selected';
237
            }
238
            echo "<option value=\"{$id_type}\"{$sel}>{$nom_type}</option>";
239
        }
240
        echo '</select></td></tr>';
241
242
        ////// Etat d'usure
243
        echo "<tr class='head' border='1'>
244
            <td>" . _AM_ADSLIGHT_TYPE_USURE . " </td><td><select name=\"typeusure\">";
245
246
        $result6 = $xoopsDB->query('SELECT nom_usure, id_usure FROM ' . $xoopsDB->prefix('adslight_usure') . ' ORDER BY nom_usure');
247
        while (list($nom_usure, $id_usure) = $xoopsDB->fetchRow($result6)) {
248
            $sel = '';
249
            if ($id_usure == $typeusure) {
250
                $sel = 'selected';
251
            }
252
            echo "<option value=\"{$id_usure}\"{$sel}>{$nom_usure}</option>";
253
        }
254
        echo '</select></td></tr>';
255
256
        /////// Price
257
        echo "<tr class='head' border='1'><td>"
258
             . _AM_ADSLIGHT_PRICE2
259
             . " </td><td><input type=\"text\" name=\"price\" size=\"20\" value=\"$price\"> "
260
             . $GLOBALS['xoopsModuleConfig']['adslight_currency_symbol']
261
             . '';
262
263
        //////// Price type
264
265
        $resultx = $xoopsDB->query('SELECT nom_price, id_price FROM ' . $xoopsDB->prefix('adslight_price') . ' ORDER BY nom_price');
266
267
        echo " <select name=\"typeprice\"><option value=\"{$id_price}\">{$nom_price}</option>";
268
        while (list($nom_price, $id_price) = $xoopsDB->fetchRow($resultx)) {
269
            $sel = '';
270
            if ($id_price == $typeprice) {
271
                $sel = 'selected';
272
            }
273
            echo "<option value=\"{$id_price}\"{$sel}>{$nom_price}</option>";
274
        }
275
        echo '</select></td>';
276
277
        /////// Category
278
279
        echo "<tr class='head' border='1'>
280
            <td>" . _AM_ADSLIGHT_CAT2 . ' </td><td>';
281
        $mytree->makeMySelBox('title', 'title', $cid);
282
        echo "</td>
283
            </tr><tr class='head' border='1'>
284
            <td>" . _AM_ADSLIGHT_DESC . ' </td><td>';
285
286
        $wysiwyg_text_area = AdslightUtility::getEditor('', 'desctext', $desctext, '100%', '200px', 'small');
287
        echo $wysiwyg_text_area->render();
288
289
        echo '</td></tr>';
290
291
        echo "<tr class='head' border='1'>
292
            <td>" . _AM_ADSLIGHT_PHOTO1 . " </td><td><input type=\"text\" name=\"photo\" size=\"50\" value=\"{$photo}\"></td>
293
            </tr><tr>";
294
        $time = time();
295
        echo "</tr><tr class='head' border='1'>
296
            <td>&nbsp;</td><td><select name=\"op\">
297
            <option value=\"ModifyAdsS\"> " . _AM_ADSLIGHT_MODIF . "
298
            <option value=\"ListingDel\"> " . _AM_ADSLIGHT_DEL . "
299
            </select><input type=\"submit\" value=\"" . _AM_ADSLIGHT_GO . "\"></td>
300
            </tr></table>";
301
        echo "<input type=\"hidden\" name=\"valid\" value=\"Yes\">";
302
        echo "<input type=\"hidden\" name=\"lid\" value=\"{$lid}\">";
303
        echo "<input type=\"hidden\" name=\"date\" value=\"{$time}\">";
304
        echo "<input type=\"hidden\" name=\"submitter\" value=\"{$submitter}\">
305
        </form><br>";
306
        echo '</fieldset><br>';
307
        xoops_cp_footer();
308
    }
309
}
310
311
#  function modifyAdsS
312
#####################################################
313
314
/**
315
 * @param $lid
316
 * @param $cat
317
 * @param $title
318
 * @param $status
319
 * @param $expire
320
 * @param $type
321
 * @param $desctext
322
 * @param $tel
323
 * @param $price
324
 * @param $typeprice
325
 * @param $typeusure
326
 * @param $date
327
 * @param $email
328
 * @param $submitter
329
 * @param $town
330
 * @param $country
331
 * @param $contactby
332
 * @param $premium
333
 * @param $valid
334
 * @param $photo
335
 */
336
function modifyAdsS($lid, $cat, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $typeusure, $date, $email, $submitter, $town, $country, $contactby, $premium, $valid, $photo)
337
{
338
    global $xoopsDB, $myts;
339
340
    $lid   = (int)$lid;
341
    $cat   = (int)$cat;
342
    $title = $myts->htmlSpecialChars($title);
343
    //    $status    = $myts->htmlSpecialChars($status);
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% 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...
344
    $status    = (int)$status;
345
    $expire    = $myts->htmlSpecialChars($expire);
346
    $type      = $myts->htmlSpecialChars($type);
347
    $desctext  = $myts->displayTarea($desctext, 1, 1, 1);
348
    $tel       = $myts->htmlSpecialChars($tel);
349
    $price     = str_replace(array(' '), '', $price);
350
    $typeprice = $myts->htmlSpecialChars($typeprice);
351
    $typeusure = $myts->htmlSpecialChars($typeusure);
352
    $date      = (int)$date;
353
    $email     = $myts->htmlSpecialChars($email);
354
    $submitter = $myts->htmlSpecialChars($submitter);
355
    $town      = $myts->htmlSpecialChars($town);
356
    $country   = $myts->htmlSpecialChars($country);
357
    $contactby = $myts->htmlSpecialChars($contactby);
358
    $premium   = $myts->htmlSpecialChars($premium);
359
    $valid     = $myts->htmlSpecialChars($valid);
360
    $photo     = $myts->htmlSpecialChars($photo);
361
362
    $xoopsDB->query('UPDATE '
363
                    . $xoopsDB->prefix('adslight_listing')
364
                    . " SET cid='{$cat}', title='{$title}', status='{$status}', expire='{$expire}', type='{$type}', desctext='{$desctext}', tel='{$tel}', price='{$price}', typeprice='{$typeprice}', typeusure='{$typeusure}', date='{$date}', email='{$email}', submitter='{$submitter}', town='{$town}', country='{$country}', contactby='{$contactby}', premium='{$premium}', valid='{$valid}', photo='{$photo}' WHERE lid={$lid}");
365
366
    redirect_header('modify_ads.php', 1, _AM_ADSLIGHT_ANNMOD);
367
}
368
369
/**
370
 * Delete Listing
371
 *
372
 * @param  int    $lid
373
 * @param  string $photo
374
 * @return void
375
 */
376 View Code Duplication
function listingDel($lid, $photo)
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
377
{
378
    global $xoopsDB, $moduleDirName;
379
380
    $lid = (int)$lid;
381
382
    $result2 = $xoopsDB->query('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}");
383
384
    while (list($purl) = $xoopsDB->fetchRow($result2)) {
385
        if ($purl) {
386
            $destination = XOOPS_ROOT_PATH . '/uploads/AdsLight';
387
            if (file_exists("{$destination}/{$purl}")) {
388
                unlink("{$destination}/{$purl}");
389
            }
390
            $destination2 = XOOPS_ROOT_PATH . '/uploads/AdsLight/thumbs';
391
            if (file_exists("{$destination2}/thumb_{$purl}")) {
392
                unlink("{$destination2}/thumb_{$purl}");
393
            }
394
            $destination3 = XOOPS_ROOT_PATH . '/uploads/AdsLight/midsize';
395
            if (file_exists("{$destination3}/resized_{$purl}")) {
396
                unlink("{$destination3}/resized_{$purl}");
397
            }
398
            $xoopsDB->query('DELETE FROM ' . $xoopsDB->prefix('adslight_pictures') . " WHERE lid={$lid}");
399
        }
400
    }
401
402
    $xoopsDB->query('DELETE FROM ' . $xoopsDB->prefix('adslight_listing') . " WHERE lid={$lid}");
403
404
    redirect_header('modify_ads.php', 1, _AM_ADSLIGHT_ANNDEL);
405
}
406
407
#####################################################
408
#####################################################
409
//@todo REMOVE THIS ASAP. This code is extremely unsafe
410
foreach ($_POST as $k => $v) {
411
    ${$k} = $v;
412
}
413
$pa  = Request::getString('pa', '', 'GET');
414
$lid = Request::getInt('lid', 0);
415
$op  = Request::getString('op', '');
416
417
switch ($op) {
418
    case 'IndexView':
419
        indexView($lid);
420
        break;
421
422
    case 'ListingDel':
423
        listingDel($lid, $photo);
424
        break;
425
426
    case 'ModifyAds':
427
        modifyAds($lid);
428
        break;
429
430
    case 'ModifyAdsS':
431
        modifyAdsS($lid, $cid, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $typeusure, $date, $email, $submitter, $town, $country, $contactby, $premium, $valid, $photo);
432
        break;
433
434
    default:
435
        index();
436
        break;
437
}
438