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

modify_ads.php ➔ modifyAds()   D

Complexity

Conditions 11
Paths 217

Size

Total Lines 181
Code Lines 117

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 11
eloc 117
nc 217
nop 1
dl 0
loc 181
rs 4.5254
c 0
b 0
f 0

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 35 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
28
$op = Request::getString('op', 'liste');
29
30
/**
31
 * Main Ad Display
32
 *
33
 * @return void
34
 */
35
function index()
36
{
37
    global $xoopsDB, $xoopsModuleConfig;
38
39
    //    $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...
40
41
    //    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...
42
    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

42
    /** @scrutinizer ignore-call */ 
43
    xoops_cp_header();
Loading history...
43
    //    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...
44
45
    // photo dir setting checker
46
    $photo_dir         = $GLOBALS['xoopsModuleConfig']['adslight_path_upload'];
47
    $photo_thumb_dir   = $GLOBALS['xoopsModuleConfig']['adslight_path_upload'] . '/thumbs';
48
    $photo_resized_dir = $GLOBALS['xoopsModuleConfig']['adslight_path_upload'] . '/midsize';
49
    if (!is_dir($photo_dir)) {
50
        mkdir($photo_dir);
51
    }
52
    if (!is_dir($photo_thumb_dir)) {
53
        mkdir($photo_thumb_dir);
54
    }
55
    if (!is_dir($photo_resized_dir)) {
56
        mkdir($photo_resized_dir);
57
    }
58
    if (!is_writable($photo_dir) || !is_readable($photo_dir)) {
59
        echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_CHECKER . '</legend><br>';
60
        echo "<span style='color: #FF0000;'><b>" . _AM_ADSLIGHT_DIRPERMS . '' . $photo_dir . "</b></span><br><br>\n";
61
        echo '</fieldset><br>';
62
    }
63
64
    if (!is_writable($photo_thumb_dir) || !is_readable($photo_thumb_dir)) {
65
        echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_CHECKER . '</legend><br>';
66
        echo "<span style='color: #FF0000;'><b>" . _AM_ADSLIGHT_DIRPERMS . '' . $photo_thumb_dir . "</b></span><br><br>\n";
67
        echo '</fieldset><br>';
68
    }
69
70
    if (!is_writable($photo_resized_dir) || !is_readable($photo_resized_dir)) {
71
        echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_CHECKER . '</legend><br>';
72
        echo "<span style='color: #FF0000;'><b>" . _AM_ADSLIGHT_DIRPERMS . '' . $photo_resized_dir . "</b></span><br><br>\n";
73
        echo '</fieldset><br>';
74
    }
75
76
    $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 ' . $xoopsDB->prefix('adslight_listing') . " WHERE valid='no' ORDER BY lid");
77
    $numrows = $xoopsDB->getRowsNum($result);
78
    if ($numrows > 0) {
79
80
        ///////// Il y a [..] Annonces en attente d'être approuvées //////
81
        echo "<table class='outer bnone' cellspacing=5 cellpadding=0><tr><td width=40>";
82
        echo "<img src='../assets/images/admin/error_button.png' border=0 ></td><td>";
83
        echo "<span style='color:#00B4C4;'><b>" . _AM_ADSLIGHT_THEREIS . "</b></span> <b>$numrows</b> <span style='color:#00B4C4;'>" . _AM_ADSLIGHT_WAIT . '</b></span>';
84
        echo '</td></tr></table><br>';
85
    } else {
86
        echo "<table class='outer' width='50%' border='0'><tr><td width=40>";
87
        echo "<img src='../assets/images/admin/search_button_green_32.png' border=0 alt=\"._AM_ADSLIGHT_RELEASEOK.\" ></td><td>";
88
        echo "<span style='color: #00B4C4;'><b>" . _AM_ADSLIGHT_NOANNVAL . '</b></span>';
89
        echo '</td></tr></table><br>';
90
    }
91
92
    // Modify Annonces
93
    list($numrows) = $xoopsDB->fetchRow($xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_listing')));
94
    if ($numrows > 0) {
95
        echo "<table width='100%' border='0' class='outer'><tr class='bg4'><td valign='top'>";
96
        echo '<form method="post" action="modify_ads.php">'
97
             . '<b>'
98
             . _AM_ADSLIGHT_MODANN
99
             . '</b><br><br>'
100
             . _AM_ADSLIGHT_NUMANN
101
             . ' <input type="text" name="lid" size="12" maxlength="11">&nbsp;&nbsp;'
102
             . '<input type="hidden" name="op" value="ModifyAds">'
103
             . '<input type="submit" value="'
104
             . _AM_ADSLIGHT_MODIF
105
             . '">'
106
             . '</form><br>';
107
        echo '</td></tr></table><br>';
108
    }
109
110
    echo "<table width='100%' border='0' cellspacing='1' cellpadding='8' style='border: 2px solid #DFE0E0;'><tr class='bg4'><td valign='top'>";
111
    echo '<a href="map.php">' . _AM_ADSLIGHT_GESTCAT . '</a> | <a href="../index.php">' . _AM_ADSLIGHT_ACCESMYANN . '</a>';
112
    echo '</td></tr></table><br>';
113
114
    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

114
    /** @scrutinizer ignore-call */ 
115
    xoops_cp_footer();
Loading history...
115
}
116
117
#  function modifyAds
118
#####################################################
119
/**
120
 * @param $lid
121
 */
122
function modifyAds($lid)
123
{
124
    global $xoopsDB, $xoopsModule, $xoopsConfig, $myts, $desctext, $moduleDirName, $admin_lang;
125
126
    $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...
127
    $contactselect = '';
0 ignored issues
show
Unused Code introduced by
The assignment to $contactselect is dead and can be removed.
Loading history...
128
    //    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...
129
    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

129
    /** @scrutinizer ignore-call */ 
130
    xoops_cp_header();
Loading history...
130
    //    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...
131
    $id_price  = '';
132
    $nom_price = '';
133
    $lid       = (int)$lid;
134
135
    echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_MODANN . '</legend>';
136
137
    $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 ' . $xoopsDB->prefix('adslight_listing') . " WHERE lid={$lid}");
138
139
    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)) {
140
        $title    = $myts->htmlSpecialChars($title);
141
        $status   = $myts->htmlSpecialChars($status);
142
        $expire   = $myts->htmlSpecialChars($expire);
143
        $type     = $myts->htmlSpecialChars($type);
144
        $desctext = $myts->displayTarea($desctext, 1, 1, 1);
145
        $tel      = $myts->htmlSpecialChars($tel);
146
        //        $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...
147
148
        xoops_load('XoopsLocal');
0 ignored issues
show
Bug introduced by
The function xoops_load 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

148
        /** @scrutinizer ignore-call */ 
149
        xoops_load('XoopsLocal');
Loading history...
149
        $tempXoopsLocal = new \XoopsLocal;
0 ignored issues
show
Bug introduced by
The type XoopsLocal 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...
150
        //  For US currency with 2 numbers after the decimal comment out if you dont want 2 numbers after decimal
151
        $price = $tempXoopsLocal->number_format($price, 2, ',', ' ');
152
        //  For other countries uncomment the below line and comment out the above line
153
        //      $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...
154
155
        $typeprice = $myts->htmlSpecialChars($typeprice);
156
        $typeusure = $myts->htmlSpecialChars($typeusure);
157
        $submitter = $myts->htmlSpecialChars($submitter);
158
        $town      = $myts->htmlSpecialChars($town);
159
        $country   = $myts->htmlSpecialChars($country);
160
        $contactby = $myts->htmlSpecialChars($contactby);
161
        $premium   = $myts->htmlSpecialChars($premium);
162
163
        $date2 = formatTimestamp($date, 's');
0 ignored issues
show
Bug introduced by
The function formatTimestamp 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

163
        $date2 = /** @scrutinizer ignore-call */ formatTimestamp($date, 's');
Loading history...
164
165
        echo '<form action="modify_ads.php" method=post>';
166
        echo $GLOBALS['xoopsSecurity']->getTokenHTML();
167
        echo "<table class='bnone'><tr class='head' border='1'>
168
            <td>" . _AM_ADSLIGHT_NUMANN . " </td><td>{$lid} &nbsp;" . _AM_ADSLIGHT_ADDED_ON . "&nbsp; {$date2}</td>
169
            </tr><tr class='head' border='1'>
170
            <td>" . _AM_ADSLIGHT_SENDBY . " </td><td>{$submitter}</td>
171
            </tr><tr class='head' border='1'>
172
            <td>" . _AM_ADSLIGHT_EMAIL . " </td><td><input type=\"text\" name=\"email\" size=\"40\" value=\"{$email}\"></td>
173
            </tr><tr class='head' border='1'>
174
            <td>" . _AM_ADSLIGHT_TEL . " </td><td><input type=\"text\" name=\"tel\" size=\"50\" value=\"{$tel}\"></td>
175
            </tr><tr class='head' border='1'>
176
            <td>" . _AM_ADSLIGHT_TOWN . " </td><td><input type=\"text\" name=\"town\" size=\"40\" value=\"{$town}\"></td>
177
            </tr><tr class='head' border='1'>
178
            <td>" . _AM_ADSLIGHT_COUNTRY . " </td><td><input type=\"text\" name=\"country\" size=\"40\" value=\"{$country}\"></td>
179
            </tr></tr><tr class='head' border='1'>";
180
181
        $contactSel1 = $contactSel2 = $contactSel3 = $contactSel4 = '';
182
        $selected    = 'contactSel' . (int)$contactby;
183
        $$selected   = ' selected';
184
185
        echo " <td class='head'>"
186
             . _AM_ADSLIGHT_CONTACTBY
187
             . " </td><td class='head'><select name=\"contactby\">\n"
188
             //           . "  <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...
189
             . "  <option value=\"1\"{$contactSel1}>"
190
             . _AM_ADSLIGHT_CONTACT_BY_EMAIL
191
             . "</option>\n"
192
             . "  <option value=\"2\"{$contactSel2}>"
193
             . _AM_ADSLIGHT_CONTACT_BY_PM
194
             . "</option>\n"
195
             . "  <option value=\"3\"{$contactSel3}>"
196
             . _AM_ADSLIGHT_CONTACT_BY_BOTH
197
             . "</option>\n"
198
             . "  <option value=\"4\"{$contactSel4}>"
199
             . _AM_ADSLIGHT_CONTACT_BY_PHONE
200
             . "</option></select>\n"
201
             . " </td>\n"
202
             . '</tr>';
203
204
        echo "<tr><td class='head'>" . _AM_ADSLIGHT_STATUS . "</td><td class='head'><input type=\"radio\" name=\"status\" value=\"0\"";
205
        if ('0' == $status) {
206
            echo 'checked';
207
        }
208
        echo '>' . _AM_ADSLIGHT_ACTIVE . '&nbsp;&nbsp; <input type="radio" name="status" value="1"';
209
        if ('1' == $status) {
210
            echo 'checked';
211
        }
212
        echo '>' . _AM_ADSLIGHT_INACTIVE . '&nbsp;&nbsp; <input type="radio" name="status" value="2"';
213
        if ('2' == $status) {
214
            echo 'checked';
215
        }
216
        echo '>' . _AM_ADSLIGHT_SOLD . '</td></tr>';
217
218
        echo "<tr class='head' border='1'>
219
        <td>" . _AM_ADSLIGHT_TITLE2 . " </td><td><input type=\"text\" name=\"title\" size=\"40\" value=\"{$title}\"></td>
220
            </tr><tr class='head' border='1'>
221
        <td>" . _AM_ADSLIGHT_PREMIUM . " </td><td><input type=\"text\" name=\"premium\" size=\"3\" value=\"{$premium}\"></td>
222
            </tr><tr class='head' border='1'>
223
        <td>" . _AM_ADSLIGHT_EXPIRE . " </td><td><input type=\"text\" name=\"expire\" size=\"40\" value=\"{$expire}\"></td>
224
            </tr>";
225
        ////// Type d'annonce
226
        echo "<tr class='head' border='1'>
227
            <td>" . _AM_ADSLIGHT_TYPE . ' </td><td><select name="type">';
228
229
        $result5 = $xoopsDB->query('SELECT nom_type, id_type FROM ' . $xoopsDB->prefix('adslight_type') . ' ORDER BY nom_type');
230
        while (list($nom_type, $id_type) = $xoopsDB->fetchRow($result5)) {
231
            $sel = '';
232
            if ($id_type == $type) {
233
                $sel = 'selected';
234
            }
235
            echo "<option value=\"{$id_type}\"{$sel}>{$nom_type}</option>";
236
        }
237
        echo '</select></td></tr>';
238
239
        ////// Etat d'usure
240
        echo "<tr class='head' border='1'>
241
            <td>" . _AM_ADSLIGHT_TYPE_USURE . ' </td><td><select name="typeusure">';
242
243
        $result6 = $xoopsDB->query('SELECT nom_usure, id_usure FROM ' . $xoopsDB->prefix('adslight_usure') . ' ORDER BY nom_usure');
244
        while (list($nom_usure, $id_usure) = $xoopsDB->fetchRow($result6)) {
245
            $sel = '';
246
            if ($id_usure == $typeusure) {
247
                $sel = 'selected';
248
            }
249
            echo "<option value=\"{$id_usure}\"{$sel}>{$nom_usure}</option>";
250
        }
251
        echo '</select></td></tr>';
252
253
        /////// Price
254
        echo "<tr class='head' border='1'><td>" . _AM_ADSLIGHT_PRICE2 . " </td><td><input type=\"text\" name=\"price\" size=\"20\" value=\"$price\"> " . $GLOBALS['xoopsModuleConfig']['adslight_currency_symbol'] . '';
255
256
        //////// Price type
257
258
        $resultx = $xoopsDB->query('SELECT nom_price, id_price FROM ' . $xoopsDB->prefix('adslight_price') . ' ORDER BY nom_price');
259
260
        echo " <select name=\"typeprice\"><option value=\"{$id_price}\">{$nom_price}</option>";
261
        while (list($nom_price, $id_price) = $xoopsDB->fetchRow($resultx)) {
262
            $sel = '';
263
            if ($id_price == $typeprice) {
264
                $sel = 'selected';
265
            }
266
            echo "<option value=\"{$id_price}\"{$sel}>{$nom_price}</option>";
267
        }
268
        echo '</select></td>';
269
270
        /////// Category
271
272
        echo "<tr class='head' border='1'>
273
            <td>" . _AM_ADSLIGHT_CAT2 . ' </td><td>';
274
        $mytree->makeMySelBox('title', 'title', $cid);
275
        echo "</td>
276
            </tr><tr class='head' border='1'>
277
            <td>" . _AM_ADSLIGHT_DESC . ' </td><td>';
278
279
        $wysiwyg_text_area = Adslight\Utility::getEditor('', 'desctext', $desctext, '100%', '200px', 'small');
280
        echo $wysiwyg_text_area->render();
281
282
        echo '</td></tr>';
283
284
        echo "<tr class='head' border='1'>
285
            <td>" . _AM_ADSLIGHT_PHOTO1 . " </td><td><input type=\"text\" name=\"photo\" size=\"50\" value=\"{$photo}\"></td>
286
            </tr><tr>";
287
        $time = time();
288
        echo "</tr><tr class='head' border='1'>
289
            <td>&nbsp;</td><td><select name=\"op\">
290
            <option value=\"ModifyAdsS\"> " . _AM_ADSLIGHT_MODIF . '
291
            <option value="ListingDel"> ' . _AM_ADSLIGHT_DEL . '
292
            </select><input type="submit" value="' . _AM_ADSLIGHT_GO . '"></td>
293
            </tr></table>';
294
        echo '<input type="hidden" name="valid" value="Yes">';
295
        echo "<input type=\"hidden\" name=\"lid\" value=\"{$lid}\">";
296
        echo "<input type=\"hidden\" name=\"date\" value=\"{$time}\">";
297
        echo "<input type=\"hidden\" name=\"submitter\" value=\"{$submitter}\">
298
        </form><br>";
299
        echo '</fieldset><br>';
300
        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

300
        /** @scrutinizer ignore-call */ 
301
        xoops_cp_footer();
Loading history...
301
    }
302
}
303
304
#  function modifyAdsS
305
#####################################################
306
307
/**
308
 * @param $lid
309
 * @param $cat
310
 * @param $title
311
 * @param $status
312
 * @param $expire
313
 * @param $type
314
 * @param $desctext
315
 * @param $tel
316
 * @param $price
317
 * @param $typeprice
318
 * @param $typeusure
319
 * @param $date
320
 * @param $email
321
 * @param $submitter
322
 * @param $town
323
 * @param $country
324
 * @param $contactby
325
 * @param $premium
326
 * @param $valid
327
 * @param $photo
328
 */
329
function modifyAdsS($lid, $cat, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $typeusure, $date, $email, $submitter, $town, $country, $contactby, $premium, $valid, $photo)
330
{
331
    global $xoopsDB, $myts;
332
333
    $lid   = (int)$lid;
334
    $cat   = (int)$cat;
335
    $title = $myts->htmlSpecialChars($title);
336
    //    $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...
337
    $status    = (int)$status;
338
    $expire    = $myts->htmlSpecialChars($expire);
339
    $type      = $myts->htmlSpecialChars($type);
340
    $desctext  = $myts->displayTarea($desctext, 1, 1, 1);
341
    $tel       = $myts->htmlSpecialChars($tel);
342
    $price     = str_replace([' '], '', $price);
343
    $typeprice = $myts->htmlSpecialChars($typeprice);
344
    $typeusure = $myts->htmlSpecialChars($typeusure);
345
    $date      = (int)$date;
346
    $email     = $myts->htmlSpecialChars($email);
347
    $submitter = $myts->htmlSpecialChars($submitter);
348
    $town      = $myts->htmlSpecialChars($town);
349
    $country   = $myts->htmlSpecialChars($country);
350
    $contactby = $myts->htmlSpecialChars($contactby);
351
    $premium   = $myts->htmlSpecialChars($premium);
352
    $valid     = $myts->htmlSpecialChars($valid);
353
    $photo     = $myts->htmlSpecialChars($photo);
354
355
    $xoopsDB->query('UPDATE '
356
                    . $xoopsDB->prefix('adslight_listing')
357
                    . " 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}");
358
359
    redirect_header('modify_ads.php', 1, _AM_ADSLIGHT_ANNMOD);
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

359
    /** @scrutinizer ignore-call */ 
360
    redirect_header('modify_ads.php', 1, _AM_ADSLIGHT_ANNMOD);
Loading history...
360
}
361
362
/**
363
 * Delete Listing
364
 *
365
 * @param  int    $lid
366
 * @param  string $photo
367
 * @return void
368
 */
369
function listingDel($lid, $photo)
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

369
function listingDel($lid, /** @scrutinizer ignore-unused */ $photo)

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...
370
{
371
    global $xoopsDB, $moduleDirName;
372
373
    $lid = (int)$lid;
374
375
    $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}");
376
377
    while (list($purl) = $xoopsDB->fetchRow($result2)) {
378
        if ($purl) {
379
            $destination = XOOPS_ROOT_PATH . '/uploads/AdsLight';
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...
380
            if (file_exists("{$destination}/{$purl}")) {
381
                unlink("{$destination}/{$purl}");
382
            }
383
            $destination2 = XOOPS_ROOT_PATH . '/uploads/AdsLight/thumbs';
384
            if (file_exists("{$destination2}/thumb_{$purl}")) {
385
                unlink("{$destination2}/thumb_{$purl}");
386
            }
387
            $destination3 = XOOPS_ROOT_PATH . '/uploads/AdsLight/midsize';
388
            if (file_exists("{$destination3}/resized_{$purl}")) {
389
                unlink("{$destination3}/resized_{$purl}");
390
            }
391
            $xoopsDB->query('DELETE FROM ' . $xoopsDB->prefix('adslight_pictures') . " WHERE lid={$lid}");
392
        }
393
    }
394
395
    $xoopsDB->query('DELETE FROM ' . $xoopsDB->prefix('adslight_listing') . " WHERE lid={$lid}");
396
397
    redirect_header('modify_ads.php', 1, _AM_ADSLIGHT_ANNDEL);
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

397
    /** @scrutinizer ignore-call */ 
398
    redirect_header('modify_ads.php', 1, _AM_ADSLIGHT_ANNDEL);
Loading history...
398
}
399
400
#####################################################
401
#####################################################
402
//@todo REMOVE THIS ASAP. This code is extremely unsafe
403
foreach ($_POST as $k => $v) {
404
    ${$k} = $v;
405
}
406
$pa  = Request::getString('pa', '', 'GET');
407
$lid = Request::getInt('lid', 0);
408
$op  = Request::getString('op', '');
409
410
switch ($op) {
411
    case 'IndexView':
412
        indexView($lid);
413
        break;
414
415
    case 'ListingDel':
416
        listingDel($lid, $photo);
417
        break;
418
419
    case 'ModifyAds':
420
        modifyAds($lid);
421
        break;
422
423
    case 'ModifyAdsS':
424
        modifyAdsS($lid, $cid, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $typeusure, $date, $email, $submitter, $town, $country, $contactby, $premium, $valid, $photo);
425
        break;
426
427
    default:
428
        index();
429
        break;
430
}
431