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

index()   D

Complexity

Conditions 17
Paths 128

Size

Total Lines 151
Code Lines 112

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 151
rs 4.5364
cc 17
eloc 112
nc 128
nop 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 32 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::getInt('op', 'liste');
29
30
#  function index
31
#####################################################
32
function index()
33
{
34
    global $xoopsDB, $xoopsConfig, $xoopsModule, $myts, $desctext, $moduleDirName, $admin_lang;
35
36
    //    $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...
37
    $photo3 = '';
38
    require_once __DIR__ . '/admin_header.php';
39
    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

39
    /** @scrutinizer ignore-call */ 
40
    xoops_cp_header();
Loading history...
40
    //    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...
41
42
    // photo dir setting checker
43
    $photo_dir         = $GLOBALS['xoopsModuleConfig']['adslight_path_upload'];
44
    $photo_thumb_dir   = $GLOBALS['xoopsModuleConfig']['adslight_path_upload'] . '/thumbs';
45
    $photo_resized_dir = $GLOBALS['xoopsModuleConfig']['adslight_path_upload'] . '/midsize';
46
    if (!is_dir($photo_dir)) {
47
        mkdir($photo_dir);
48
    }
49
    if (!is_dir($photo_thumb_dir)) {
50
        mkdir($photo_thumb_dir);
51
    }
52
    if (!is_dir($photo_resized_dir)) {
53
        mkdir($photo_resized_dir);
54
    }
55
    if (!is_writable($photo_dir) || !is_readable($photo_dir)) {
56
        echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_CHECKER . '</legend><br>';
57
        echo "<span style='color: #FF0000;'><b>" . _AM_ADSLIGHT_DIRPERMS . '' . $photo_dir . "</b></span><br><br>\n";
58
        echo '</fieldset><br>';
59
    }
60
61
    if (!is_writable($photo_thumb_dir) || !is_readable($photo_thumb_dir)) {
62
        echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_CHECKER . '</legend><br>';
63
        echo "<span style='color: #FF0000;'><b>" . _AM_ADSLIGHT_DIRPERMS . '' . $photo_thumb_dir . "</b></span><br><br>\n";
64
        echo '</fieldset><br>';
65
    }
66
67
    if (!is_writable($photo_resized_dir) || !is_readable($photo_resized_dir)) {
68
        echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_CHECKER . '</legend><br>';
69
        echo "<span style='color: #FF0000;'><b>" . _AM_ADSLIGHT_DIRPERMS . '' . $photo_resized_dir . "</b></span><br><br>\n";
70
        echo '</fieldset><br>';
71
    }
72
73
    $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='Yes' ORDER BY lid");
74
    $numrows = $xoopsDB->getRowsNum($result);
75
    if ($numrows > 0) {
76
77
        // Il y a [..] Annonces en attente d'être approuvées //////
78
        echo "<table class='outer bnone' cellspacing=5 cellpadding=0><tr><td width=40>";
79
        echo "<img src='../assets/images/admin/error_button.png' border=0 ></td><td>";
80
        echo "<span style='color:#00B4C4;'><b>" . _AM_ADSLIGHT_THEREIS . "</b></span> <b>$numrows</b> <b><span style='color:#00B4C4;'>" . _AM_ADSLIGHT_ADSVALIDE . '</b></span>';
81
        echo '</td></tr></table><br>';
82
83
        // Liste des ID  ///// Soumis par /////  Titre   /////  Description  /////  Date d'ajout
84
        echo "<table class='outer width100 bnone'>";
85
        $rank = 1;
86
87
        while (list($lid, $cid, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $typeusure, $date, $email, $submitter, $town, $country, $contactby, $premium, $photo, $usid) = $xoopsDB->fetchRow($result)) {
88
            $title    = $myts->htmlSpecialChars($title);
89
            $desctext = $myts->displayTarea($desctext, 1, 0, 1, 1, 1);
90
91
            if (strlen($desctext) >= 200) {
92
                $desctext = substr($desctext, 0, 199) . '...';
93
            } else {
94
                $desctext = $myts->displayTarea($desctext, 1, 1, 1);
95
            }
96
            $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

96
            $date2  = /** @scrutinizer ignore-call */ formatTimestamp($date, 's');
Loading history...
97
            $color  = is_int($rank / 2) ? '#ffffff' : 'head';
0 ignored issues
show
Unused Code introduced by
The assignment to $color is dead and can be removed.
Loading history...
98
            $status = $myts->htmlSpecialChars($status);
99
            $expire = $myts->htmlSpecialChars($expire);
100
            $type   = $myts->htmlSpecialChars($type);
101
            $tel    = $myts->htmlSpecialChars($tel);
102
            //            $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...
103
            $typeprice = $myts->htmlSpecialChars($typeprice);
104
            $typeusure = $myts->htmlSpecialChars($typeusure);
105
            $submitter = $myts->htmlSpecialChars($submitter);
106
            $town      = $myts->htmlSpecialChars($town);
107
            $country   = $myts->htmlSpecialChars($country);
108
            $contactby = $myts->htmlSpecialChars($contactby);
109
            $premium   = $myts->htmlSpecialChars($premium);
110
111
            $updir   = $GLOBALS['xoopsModuleConfig']['adslight_link_upload'];
112
            $sql     = 'SELECT cod_img, lid, uid_owner, url FROM ' . $xoopsDB->prefix('adslight_pictures') . " WHERE  uid_owner={$usid} AND lid={$lid} ORDER BY date_added ASC LIMIT 1";
113
            $resultp = $xoopsDB->query($sql);
114
            while (list($cod_img, $pic_lid, $uid_owner, $url) = $xoopsDB->fetchRow($resultp)) {
115
                if ($photo) {
116
                    $photo3 = "<a href='" . XOOPS_URL . "/modules/adslight/viewads.php?lid={$lid}'><img class=\"thumb\" src=\"{$updir}/thumbs/thumb_{$url}\" align=\"left\" width=\"100px\" alt=\"{$title}\"></a>";
0 ignored issues
show
Bug introduced by
The constant XOOPS_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
117
                }
118
            }
119
            if ($photo <= 0) {
120
                $photo3 = "<a href=\"index.php?op=IndexView&lid=$lid\"><img class=\"thumb\" src=\"" . XOOPS_URL . "/modules/adslight/assets/images/nophoto.jpg\" align=\"left\" width=\"100px\" alt=\"$title\"></a>";
121
            } else {
122
                $photo4 = "$photo";
123
            }
124
125
            $result7 = $xoopsDB->query('SELECT nom_type FROM ' . $xoopsDB->prefix('adslight_type') . ' WHERE id_type=' . (int)$type);
126
            list($nom_type) = $xoopsDB->fetchRow($result7);
127
128
            $result8 = $xoopsDB->query('SELECT nom_price FROM ' . $xoopsDB->prefix('adslight_price') . ' WHERE id_price=' . (int)$typeprice);
129
            list($nom_price) = $xoopsDB->fetchRow($result8);
130
131
            echo '<form action="view_ads.php" method="post">';
132
            echo $GLOBALS['xoopsSecurity']->getTokenHTML();
133
            echo "<tr><th class='left'>" . _AM_ADSLIGHT_LID . ": {$lid}</th><th class='left'>{$photo4} " . _AM_ADSLIGHT_NBR_PHOTO . "</th><th class='left'>" . _AM_ADSLIGHT_TITLE . ":</th><th class='left'>" . _AM_ADSLIGHT_DESC . "</th><th class='left'><!--" . _AM_ADSLIGHT_ACTIONS . '--></th></tr>';
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $photo4 does not seem to be defined for all execution paths leading up to this point.
Loading history...
134
135
            echo "<tr><td class='even width3'></td>";
136
            echo "<td class='odd width10' >{$photo3}</td>";
137
            echo "<td class='even width20'><b>{$title}</b><br><br>{$nom_type}<br>{$price} " . $GLOBALS['xoopsModuleConfig']['adslight_currency_symbol'] . " $nom_price<br>";
138
            echo "$town - $country<br>";
139
            echo '<b>' . _AM_ADSLIGHT_SUBMITTER . ":</b> {$submitter}<br>";
140
            echo '<b>' . _AM_ADSLIGHT_DATE . ":</b> {$date2}</td>";
141
            echo "<td class='even width='35%'>{$desctext}</td><td class='even right width2'></td>";
142
            echo "</tr><tr><td width='5%'></td><td>";
143
144
            echo '<select name="op">
145
        <option value="ModifyAds"> ' . _AM_ADSLIGHT_MODIF . '
146
        <option value="ListingDel"> ' . _AM_ADSLIGHT_DEL . '
147
               </select><input type="submit" value="' . _AM_ADSLIGHT_GO . '">';
148
149
            echo '<input type="hidden" name="valid" value="Yes">';
150
            echo "<input type=\"hidden\" name=\"lid\" value=\"{$lid}\">";
151
            echo "<input type=\"hidden\" name=\"cid\" value=\"{$cid}\">";
152
            echo "<input type=\"hidden\" name=\"title\" value=\"{$title}\">";
153
            echo "<input type=\"hidden\" name=\"status\" value=\"{$status}\">";
154
            echo "<input type=\"hidden\" name=\"expire\" value=\"{$expire}\">";
155
            echo "<input type=\"hidden\" name=\"type\" value=\"{$type}\">";
156
            echo "<input type=\"hidden\" name=\"desctext\" value=\"{$desctext}\">";
157
            echo "<input type=\"hidden\" name=\"tel\" value=\"{$tel}\">";
158
            echo "<input type=\"hidden\" name=\"price\" value=\"{$price}\">";
159
            echo "<input type=\"hidden\" name=\"typeprice\" value=\"{$typeprice}\">";
160
            echo "<input type=\"hidden\" name=\"typeusure\" value=\"{$typeusure}\">";
161
            echo "<input type=\"hidden\" name=\"date\" value=\"{$date}\">";
162
            echo "<input type=\"hidden\" name=\"email\" value=\"{$email}\">";
163
            echo "<input type=\"hidden\" name=\"submitter\" value=\"{$submitter}\">";
164
            echo "<input type=\"hidden\" name=\"town\" value=\"{$town}\">";
165
            echo "<input type=\"hidden\" name=\"country\" value=\"{$country}\">";
166
            echo "<input type=\"hidden\" name=\"contactby\" value=\"{$contactby}\">";
167
            echo "<input type=\"hidden\" name=\"premium\" value=\"{$premium}\">";
168
            echo "<input type=\"hidden\" name=\"photo\" value=\"{$photo}\">";
169
            echo '</form><br></td></tr>';
170
            ++$rank;
171
        }
172
173
        echo '</td></tr></table>
174
              <br><br>';
175
    } else {
176
        echo "<table class='outer width50 bnone'><tr><td class='width40'>";
177
        echo "<img src='../assets/images/admin/search_button_green_32.png' border=0 ></td><td>";
178
        echo "<span style='color: #00B4C4;'><b>" . _AM_ADSLIGHT_NOANNVALADS . '</b></span>';
179
        echo '</td></tr></table><br>';
180
    }
181
182
    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

182
    /** @scrutinizer ignore-call */ 
183
    xoops_cp_footer();
Loading history...
183
}
184
185
#  function IndexView
186
#####################################################
187
/**
188
 * @param null $lid
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $lid is correct as it would always require null to be passed?
Loading history...
189
 */
190
function indexView($lid = null)
191
{
192
    global $xoopsDB, $xoopsModule, $xoopsConfig, $xoopsModuleConfig, $myts, $desctext, $moduleDirName, $admin_lang;
193
194
    $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...
195
196
    require_once __DIR__ . '/admin_header.php';
197
    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

197
    /** @scrutinizer ignore-call */ 
198
    xoops_cp_header();
Loading history...
198
    //    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...
199
200
    $result  = $xoopsDB->query('SELECT lid, cid, title, status, expire, type, desctext, tel, price, typeprice, typeusure, date, email, submitter, town, country, contactby, premium, photo FROM ' . $xoopsDB->prefix('adslight_listing') . " WHERE valid='No' AND lid='{$lid}'");
201
    $numrows = $xoopsDB->getRowsNum($result);
202
    if ($numrows > 0) {
203
        echo "<table class='width100' cellspacing='1' cellpadding='8' style='border: 2px solid #DFE0E0;'><tr class='bg4'><td class='top'>";
204
        echo '<b>' . _AM_ADSLIGHT_WAIT . '</b><br><br>';
205
206
        list($lid, $cid, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $typeusure, $date, $email, $submitter, $town, $country, $contactby, $premium, $photo) = $xoopsDB->fetchRow($result);
207
208
        $lid      = (int)$lid;
209
        $cid      = (int)$cid;
210
        $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

210
        $date2    = /** @scrutinizer ignore-call */ formatTimestamp($date, 's');
Loading history...
211
        $title    = $myts->htmlSpecialChars($title);
212
        $status   = $myts->htmlSpecialChars($status);
213
        $expire   = $myts->htmlSpecialChars($expire);
214
        $type     = $myts->htmlSpecialChars($type);
215
        $desctext = $myts->displayTarea($desctext, 1, 1, 1);
216
        $tel      = $myts->htmlSpecialChars($tel);
217
        //        $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...
218
        $typeprice = $myts->htmlSpecialChars($typeprice);
219
        $typeusure = $myts->htmlSpecialChars($typeusure);
220
        $submitter = $myts->htmlSpecialChars($submitter);
221
        $town      = $myts->htmlSpecialChars($town);
222
        $country   = $myts->htmlSpecialChars($country);
223
        $contactby = $myts->htmlSpecialChars($contactby);
224
        $premium   = $myts->htmlSpecialChars($premium);
225
226
        echo '<form action="index.php" method="post">';
227
        echo $GLOBALS['xoopsSecurity']->getTokenHTML();
228
        echo "<table><tr class='head' border='1'>
229
            <td>" . _AM_ADSLIGHT_NUMANN . " </td><td>{$lid} &nbsp;&nbsp;&nbsp;&nbsp;   " . _AM_ADSLIGHT_ADDED_ON . " &nbsp;&nbsp;&nbsp;&nbsp; {$date2}</td>
230
            </tr><tr class='head' border='1'>
231
        <td>" . _AM_ADSLIGHT_SENDBY . " </td><td>{$submitter}</td>
232
            </tr><tr class='head' border='1'>
233
        <td>" . _AM_ADSLIGHT_EMAIL . " </td><td><input type=\"text\" name=\"email\" size=\"40\" value=\"{$email}\"></td>
234
            </tr><tr class='head' border='1'>
235
        <td>" . _AM_ADSLIGHT_TEL . " </td><td><input type=\"text\" name=\"tel\" size=\"50\" value=\"{$tel}\"></td>
236
            </tr><tr class='head' border='1'>
237
        <td>" . _AM_ADSLIGHT_TOWN . " </td><td><input type=\"text\" name=\"town\" size=\"40\" value=\"{$town}\"></td>
238
            </tr><tr class='head' border='1'>
239
        <td>" . _AM_ADSLIGHT_COUNTRY . " </td><td><input type=\"text\" name=\"country\" size=\"40\" value=\"{$country}\"></td>
240
            </tr><tr class='head' border='1'>
241
        <td>" . _AM_ADSLIGHT_CONTACTBY . " </td><td><input type=\"text\" name=\"contactby\" size=\"40\" value=\"{$contactby}\"></td>
242
            </tr>";
243
244
        echo "<tr>
245
            <td class='head'>" . _AM_ADSLIGHT_STATUS . "</td><td class='head'><input type=\"radio\" name=\"status\" value=\"0\"";
246
        if ('0' == $status) {
247
            echo 'checked';
248
        }
249
        echo '>' . _AM_ADSLIGHT_ACTIVE . '&nbsp;&nbsp; <input type="radio" name="status" value="1"';
250
        if ('1' == $status) {
251
            echo 'checked';
252
        }
253
        echo '>' . _AM_ADSLIGHT_INACTIVE . '&nbsp;&nbsp; <input type="radio" name="status" value="2"';
254
        if ('2' == $status) {
255
            echo 'checked';
256
        }
257
        echo '>' . _AM_ADSLIGHT_SOLD . '</td></tr>';
258
259
        echo "<tr class='head' border='1'>
260
           <td>" . _AM_ADSLIGHT_TITLE2 . " </td><td><input type=\"text\" name=\"title\" size=\"40\" value=\"{$title}\"></td>
261
            </tr><tr class='head' border='1'>
262
           <td>" . _AM_ADSLIGHT_PREMIUM . " </td><td><input type=\"text\" name=\"premium\" size=\"3\" value=\"{$premium}\"></td>
263
            </tr><tr class='head' border='1'>
264
           <td>" . _AM_ADSLIGHT_EXPIRE . " </td><td><input type=\"text\" name=\"expire\" size=\"40\" value=\"{$expire}\"></td>
265
            </tr><tr class='head' border='1'>
266
            <td>" . _AM_ADSLIGHT_TYPE . ' </td><td><select name="type">';
267
268
        $result5 = $xoopsDB->query('SELECT nom_type FROM ' . $xoopsDB->prefix('adslight_type') . ' ORDER BY nom_type');
269
        while (list($nom_type) = $xoopsDB->fetchRow($result5)) {
270
            $sel = '';
271
            if ($nom_type == $type) {
272
                $sel = 'selected';
273
            }
274
            echo "<option value=\"{$nom_type}\"{$sel}>{$nom_type}</option>";
275
        }
276
277
        echo '</select></td></tr>';
278
279
        ////// Etat d'usure
280
        echo "<tr class='head' border='1'>
281
            <td>" . _AM_ADSLIGHT_TYPE_USURE . ' </td><td><select name="typeusure">';
282
283
        $result6 = $xoopsDB->query('SELECT nom_usure FROM ' . $xoopsDB->prefix('adslight_usure') . ' ORDER BY nom_usure');
284
        while (list($nom_usure) = $xoopsDB->fetchRow($result6)) {
285
            $sel = '';
286
            if ($nom_usure == $typeusure) {
287
                $sel = 'selected';
288
            }
289
            echo "<option value=\"{$nom_usure}\"{$sel}>{$nom_usure}</option>";
290
        }
291
        echo '</select></td></tr>';
292
293
        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'] . '';
294
        $result3 = $xoopsDB->query('SELECT nom_price FROM ' . $xoopsDB->prefix('adslight_price') . ' ORDER BY id_price');
295
        echo " <select name=\"typeprice\"><option value=\"{$typeprice}\">{$typeprice}</option>";
296
        while (list($nom_price) = $xoopsDB->fetchRow($result3)) {
297
            echo "<option value=\"${nom_price}\">${nom_price}</option>";
298
        }
299
        echo '</select></td></tr>';
300
301
        echo "<tr class='head' border='1'>
302
           <td>" . _AM_ADSLIGHT_PHOTO1 . " </td><td><input type=\"text\" name=\"photo\" size=\"40\" value=\"{$photo}\"></td>
303
            </tr>";
304
        echo "<tr class='head' border='1'><td>" . _AM_ADSLIGHT_DESC . '</td><td>';
305
        $wysiwyg_text_area = Adslight\Utility::getEditor(_AM_ADSLIGHT_DESC, 'desctext', $desctext, '100%', '200px', 'small');
306
        echo $wysiwyg_text_area->render();
307
        echo '</td></tr>';
308
        echo "<tr class='head' border='1'><td>" . _AM_ADSLIGHT_CAT . ' </td><td>';
309
        $mytree->makeMySelBox('title', 'title', $cid);
310
        echo "</td>
311
        </tr><tr class='head' border='1'>
312
        <td>&nbsp;</td><td><select name=\"op\">
313
        <option value=\"ListingValid\"> " . _AM_ADSLIGHT_OK . '
314
        <option value="ListingDel"> ' . _AM_ADSLIGHT_DEL . '
315
        </select><input type="submit" value="' . _AM_ADSLIGHT_GO . '"></td>
316
        </tr></table>';
317
        echo '<input type="hidden" name="valid" value="Yes">';
318
        echo "<input type=\"hidden\" name=\"lid\" value=\"{$lid}\">";
319
        echo "<input type=\"hidden\" name=\"date\" value=\"{$date}\">";
320
        echo "<input type=\"hidden\" name=\"submitter\" value=\"{$submitter}\">
321
            </form>";
322
323
        echo '</td></tr></table>';
324
        echo '<br>';
325
    }
326
327
    require_once __DIR__ . '/admin_footer.php';
328
}
329
330
#  function modifyAds
331
#####################################################
332
/**
333
 * @param $lid
334
 */
335
function modifyAds($lid)
336
{
337
    global $xoopsDB, $xoopsModule, $xoopsConfig, $xoopsModuleConfig, $myts, $desctext, $moduleDirName, $admin_lang;
338
339
    $mytree = new ClassifiedsTree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid');
340
341
    require_once __DIR__ . '/admin_header.php';
342
    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

342
    /** @scrutinizer ignore-call */ 
343
    xoops_cp_header();
Loading history...
343
    //    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...
344
345
    $lid           = (int)$lid;
346
    $id_price      = '';
347
    $nom_price     = '';
348
    $contactselect = '';
0 ignored issues
show
Unused Code introduced by
The assignment to $contactselect is dead and can be removed.
Loading history...
349
350
    echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_MODANN . '</legend>';
351
352
    $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}");
353
354
    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)) {
355
        $title = $myts->htmlSpecialChars($title);
356
        //        $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...
357
        $status   = (int)$status;
358
        $expire   = $myts->htmlSpecialChars($expire);
359
        $type     = $myts->htmlSpecialChars($type);
360
        $desctext = $myts->displayTarea($desctext, 1, 1, 1);
361
        $tel      = $myts->htmlSpecialChars($tel);
362
        //        $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...
363
        $typeprice = $myts->htmlSpecialChars($typeprice);
364
        $typeusure = $myts->htmlSpecialChars($typeusure);
365
        $submitter = $myts->htmlSpecialChars($submitter);
366
        $town      = $myts->htmlSpecialChars($town);
367
        $country   = $myts->htmlSpecialChars($country);
368
        $contactby = $myts->htmlSpecialChars($contactby);
369
        $premium   = $myts->htmlSpecialChars($premium);
370
371
        $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

371
        $date2 = /** @scrutinizer ignore-call */ formatTimestamp($date, 's');
Loading history...
372
373
        echo '<form action="view_ads.php" method="post">';
374
        echo $GLOBALS['xoopsSecurity']->getTokenHTML();
375
        echo "<table border=0><tr class='head' border='1'>
376
           <td>" . _AM_ADSLIGHT_NUMANN . " </td><td>{$lid} &nbsp;" . _AM_ADSLIGHT_ADDED_ON . "&nbsp; {$date2}</td>
377
            </tr><tr class='head' border='1'>
378
           <td>" . _AM_ADSLIGHT_SENDBY . " </td><td>{$submitter}</td>
379
            </tr><tr class='head' border='1'>
380
           <td>" . _AM_ADSLIGHT_EMAIL . " </td><td><input type=\"text\" name=\"email\" size=\"40\" value=\"{$email}\"></td>
381
            </tr><tr class='head' border='1'>
382
           <td>" . _AM_ADSLIGHT_TEL . " </td><td><input type=\"text\" name=\"tel\" size=\"50\" value=\"{$tel}\"></td>
383
            </tr><tr class='head' border='1'>
384
           <td>" . _AM_ADSLIGHT_TOWN . " </td><td><input type=\"text\" name=\"town\" size=\"40\" value=\"{$town}\"></td>
385
            </tr><tr class='head' border='1'>
386
           <td>" . _AM_ADSLIGHT_COUNTRY . " </td><td><input type=\"text\" name=\"country\" size=\"40\" value=\"{$country}\"></td>
387
            </tr>
388
            <tr class='head' border='1'>";
389
390
        $contactSel1 = $contactSel2 = $contactSel3 = $contactSel4 = '';
391
        $selected    = 'contactSel' . (int)$contactby;
392
        $$selected   = ' selected';
393
394
        echo " <td class='head'>"
395
             . _AM_ADSLIGHT_CONTACTBY
396
             . " </td><td class='head'><select name=\"contactby\">\n"
397
             //           . "  <option value=\"{$contactby}\">{$contactselect}</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...
398
             . "  <option value=\"1\"{$contactSel1}>"
399
             . _AM_ADSLIGHT_CONTACT_BY_EMAIL
400
             . "</option>\n"
401
             . "  <option value=\"2\"{$contactSel2}>"
402
             . _AM_ADSLIGHT_CONTACT_BY_PM
403
             . "</option>\n"
404
             . "  <option value=\"3\"{$contactSel3}>"
405
             . _AM_ADSLIGHT_CONTACT_BY_BOTH
406
             . "</option>\n"
407
             . "  <option value=\"4\"{$contactSel4}>"
408
             . _AM_ADSLIGHT_CONTACT_BY_PHONE
409
             . "</option></select>\n"
410
             . " </td>\n"
411
             . '</tr>';
412
413
        echo "<tr><td class='head'>" . _AM_ADSLIGHT_STATUS . "</td><td class='head'><input type=\"radio\" name=\"status\" value=\"0\"";
414
        if ('0' == $status) {
415
            echo 'checked';
416
        }
417
        echo '>' . _AM_ADSLIGHT_ACTIVE . '&nbsp;&nbsp; <input type="radio" name="status" value="1"';
418
        if ('1' == $status) {
419
            echo 'checked';
420
        }
421
        echo '>' . _AM_ADSLIGHT_INACTIVE . '&nbsp;&nbsp; <input type="radio" name="status" value="2"';
422
        if ('2' == $status) {
423
            echo 'checked';
424
        }
425
        echo '>' . _AM_ADSLIGHT_SOLD . '</td></tr>';
426
427
        echo "<tr class='head' border='1'>
428
           <td>" . _AM_ADSLIGHT_TITLE2 . " </td><td><input type=\"text\" name=\"title\" size=\"40\" value=\"{$title}\"></td>
429
            </tr><tr class='head' border='1'>
430
           <td>" . _AM_ADSLIGHT_PREMIUM . " </td><td><input type=\"text\" name=\"premium\" size=\"3\" value=\"{$premium}\"></td>
431
            </tr><tr class='head' border='1'>
432
           <td>" . _AM_ADSLIGHT_EXPIRE . " </td><td><input type=\"text\" name=\"expire\" size=\"40\" value=\"{$expire}\"></td>
433
            </tr>";
434
        // Type d'annonce
435
        echo "<tr class='head' border='1'>
436
            <td>" . _AM_ADSLIGHT_TYPE . ' </td><td><select name="type">';
437
438
        $result5 = $xoopsDB->query('SELECT nom_type, id_type FROM ' . $xoopsDB->prefix('adslight_type') . ' ORDER BY nom_type');
439
        while (list($nom_type, $id_type) = $xoopsDB->fetchRow($result5)) {
440
            $sel = '';
441
            if ($id_type == $type) {
442
                $sel = 'selected';
443
            }
444
            echo "<option value=\"{$id_type}\"{$sel}>{$nom_type}</option>";
445
        }
446
        echo '</select></td></tr>';
447
448
        // Etat d'usure
449
        echo "<tr class='head' border='1'>
450
            <td>" . _AM_ADSLIGHT_TYPE_USURE . ' </td><td><select name="typeusure">';
451
452
        $result6 = $xoopsDB->query('SELECT nom_usure, id_usure FROM ' . $xoopsDB->prefix('adslight_usure') . ' ORDER BY nom_usure');
453
        while (list($nom_usure, $id_usure) = $xoopsDB->fetchRow($result6)) {
454
            $sel = '';
455
            if ($id_usure == $typeusure) {
456
                $sel = 'selected';
457
            }
458
            echo "<option value=\"{$id_usure}\"{$sel}>{$nom_usure}</option>";
459
        }
460
        echo '</select></td></tr>';
461
462
        /////// Price
463
        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']}";
464
465
        // Price type
466
        $resultx = $xoopsDB->query('SELECT nom_price, id_price FROM ' . $xoopsDB->prefix('adslight_price') . ' ORDER BY nom_price');
467
468
        echo " <select name=\"typeprice\"><option value=\"{$id_price}\">{$nom_price}</option>";
469
        while (list($nom_price, $id_price) = $xoopsDB->fetchRow($resultx)) {
470
            $sel = '';
471
            if ($id_price == $typeprice) {
472
                $sel = 'selected';
473
            }
474
475
            echo "<option value=\"{$id_price}\"{$sel}>{$nom_price}</option>";
476
        }
477
        echo '</select></td>';
478
479
        // Category
480
        echo "<tr class='head' border='1'>
481
            <td>" . _AM_ADSLIGHT_CAT2 . ' </td><td>';
482
        $mytree->makeMySelBox('title', 'title', $cid);
483
        echo "</td>
484
            </tr><tr class='head' border='1'>
485
            <td>" . _AM_ADSLIGHT_DESC . ' </td><td>';
486
487
        $wysiwyg_text_area = Adslight\Utility::getEditor('', 'desctext', $desctext, '100%', '200px', 'small');
488
        echo $wysiwyg_text_area->render();
489
490
        echo '</td></tr>';
491
492
        echo "<tr class='head' border='1'>
493
            <td>" . _AM_ADSLIGHT_PHOTO1 . " </td><td><input type=\"text\" name=\"photo\" size=\"50\" value=\"{$photo}\"></td>
494
            </tr><tr>";
495
        $time = time();
496
        echo "</tr><tr class='head' border='1'>
497
            <td>&nbsp;</td><td><select name=\"op\">
498
            <option value=\"ModifyAdsS\"> " . _AM_ADSLIGHT_MODIF . '
499
            <option value="ListingDel"> ' . _AM_ADSLIGHT_DEL . '
500
            </select><input type="submit" value="' . _AM_ADSLIGHT_GO . '"></td>
501
            </tr></table>';
502
        echo '<input type="hidden" name="valid" value="Yes">';
503
        echo "<input type=\"hidden\" name=\"lid\" value=\"{$lid}\">";
504
        echo "<input type=\"hidden\" name=\"date\" value=\"{$time}\">";
505
        echo "<input type=\"hidden\" name=\"submitter\" value=\"{$submitter}\">
506
              </form><br>";
507
        echo '</fieldset><br>';
508
        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

508
        /** @scrutinizer ignore-call */ 
509
        xoops_cp_footer();
Loading history...
509
    }
510
}
511
512
#  function modifyAdsS
513
#####################################################
514
515
/**
516
 * @param $lid
517
 * @param $cat
518
 * @param $title
519
 * @param $status
520
 * @param $expire
521
 * @param $type
522
 * @param $desctext
523
 * @param $tel
524
 * @param $price
525
 * @param $typeprice
526
 * @param $typeusure
527
 * @param $date
528
 * @param $email
529
 * @param $submitter
530
 * @param $town
531
 * @param $country
532
 * @param $contactby
533
 * @param $premium
534
 * @param $valid
535
 * @param $photo
536
 */
537
function modifyAdsS($lid, $cat, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $typeusure, $date, $email, $submitter, $town, $country, $contactby, $premium, $valid, $photo)
538
{
539
    global $xoopsDB, $xoopsConfig, $myts, $moduleDirName, $admin_lang;
540
541
    $lid   = (int)$lid;
542
    $cat   = (int)$cat;
543
    $title = $myts->htmlSpecialChars($title);
544
    //    $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...
545
    $status    = (int)$status;
546
    $expire    = $myts->htmlSpecialChars($expire);
547
    $type      = $myts->htmlSpecialChars($type);
548
    $desctext  = $myts->displayTarea($desctext, 1, 1, 1);
549
    $tel       = $myts->htmlSpecialChars($tel);
550
    $price     = str_replace([' '], '', $price);
551
    $typeprice = $myts->htmlSpecialChars($typeprice);
552
    $typeusure = $myts->htmlSpecialChars($typeusure);
553
    $submitter = $myts->htmlSpecialChars($submitter);
554
    $town      = $myts->htmlSpecialChars($town);
555
    $country   = $myts->htmlSpecialChars($country);
556
    $contactby = $myts->htmlSpecialChars($contactby);
557
    $premium   = $myts->htmlSpecialChars($premium);
558
559
    $xoopsDB->query('UPDATE '
560
                    . $xoopsDB->prefix('adslight_listing')
561
                    . " 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}");
562
563
    redirect_header('view_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

563
    /** @scrutinizer ignore-call */ 
564
    redirect_header('view_ads.php', 1, _AM_ADSLIGHT_ANNMOD);
Loading history...
564
}
565
566
#  function listingDel
567
#####################################################
568
/**
569
 * @param $lid
570
 * @param $photo
571
 */
572
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

572
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...
573
{
574
    global $xoopsDB, $moduleDirName, $admin_lang;
575
576
    $lid     = (int)$lid;
577
    $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}");
578
579
    while (list($purl) = $xoopsDB->fetchRow($result2)) {
580
        if ($purl) {
581
            $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...
582
            if (file_exists("$destination/$purl")) {
583
                unlink("$destination/$purl");
584
            }
585
            $destination2 = XOOPS_ROOT_PATH . '/uploads/AdsLight/thumbs';
586
            if (file_exists("$destination2/thumb_$purl")) {
587
                unlink("$destination2/thumb_$purl");
588
            }
589
            $destination3 = XOOPS_ROOT_PATH . '/uploads/AdsLight/midsize';
590
            if (file_exists("$destination3/resized_$purl")) {
591
                unlink("$destination3/resized_$purl");
592
            }
593
            $xoopsDB->query('DELETE FROM ' . $xoopsDB->prefix('adslight_pictures') . " WHERE lid={$lid}");
594
        }
595
    }
596
597
    $xoopsDB->query('DELETE FROM ' . $xoopsDB->prefix('adslight_listing') . " WHERE lid={$lid}");
598
    redirect_header('view_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

598
    /** @scrutinizer ignore-call */ 
599
    redirect_header('view_ads.php', 1, _AM_ADSLIGHT_ANNDEL);
Loading history...
599
}
600
601
#  function listingValid
602
#####################################################
603
/**
604
 * @param $lid
605
 * @param $cat
606
 * @param $title
607
 * @param $status
608
 * @param $expire
609
 * @param $type
610
 * @param $desctext
611
 * @param $tel
612
 * @param $price
613
 * @param $typeprice
614
 * @param $typeusure
615
 * @param $date
616
 * @param $email
617
 * @param $submitter
618
 * @param $town
619
 * @param $country
620
 * @param $contactby
621
 * @param $premium
622
 * @param $valid
623
 * @param $photo
624
 */
625
function listingValid($lid, $cat, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $typeusure, $date, $email, $submitter, $town, $country, $contactby, $premium, $valid, $photo)
0 ignored issues
show
Unused Code introduced by
The parameter $date 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

625
function listingValid($lid, $cat, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $typeusure, /** @scrutinizer ignore-unused */ $date, $email, $submitter, $town, $country, $contactby, $premium, $valid, $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...
626
{
627
    global $xoopsDB, $xoopsConfig, $xoopsModule, $myts, $meta, $moduleDirName, $admin_lang;
628
629
    $lid       = (int)$lid;
630
    $cid       = (int)$cid;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $cid seems to be never defined.
Loading history...
Unused Code introduced by
The assignment to $cid is dead and can be removed.
Loading history...
631
    $title     = $myts->htmlSpecialChars($title);
632
    $status    = (int)$status;
633
    $expire    = $myts->htmlSpecialChars($expire);
634
    $type      = $myts->htmlSpecialChars($type);
635
    $desctext  = $myts->displayTarea($desctext, 1, 1, 1);
636
    $tel       = $myts->htmlSpecialChars($tel);
637
    $price     = str_replace([' '], '', $price);
638
    $typeprice = $myts->htmlSpecialChars($typeprice);
639
    $typeusure = $myts->htmlSpecialChars($typeusure);
640
    $submitter = $myts->htmlSpecialChars($submitter);
641
    $town      = $myts->htmlSpecialChars($town);
642
    $country   = $myts->htmlSpecialChars($country);
643
    $contactby = $myts->htmlSpecialChars($contactby);
644
    $premium   = $myts->htmlSpecialChars($premium);
645
    $valid     = $myts->htmlSpecialChars($valid);
646
    $photo     = $myts->htmlSpecialChars($photo);
647
    $now       = time();
648
    $xoopsDB->query('UPDATE '
649
                    . $xoopsDB->prefix('adslight_listing')
650
                    . " SET cid='{$cat}', title='{$title}', status='{$status}', expire='{$expire}', type='{$type}', desctext='{$desctext}', tel='{$tel}', price='{$price}', typeprice='{$typeprice}', typeusure='{$typeusure}', date='{$now}', email='{$email}', submitter='{$submitter}', town='{$town}', country='{$country}', contactby='{$contactby}', premium='{$premium}', valid='{$valid}', photo='{$photo}' WHERE lid={$lid}");
651
652
    if ('' != $email) {
653
        $tags               = [];
654
        $tags['TITLE']      = $title;
655
        $tags['TYPE']       = Adslight\Utility::getNameType($type);
656
        $tags['SUBMITTER']  = $submitter;
657
        $tags['DESCTEXT']   = stripslashes($desctext);
658
        $tags['EMAIL']      = _AM_ADSLIGHT_EMAIL;
659
        $tags['TEL']        = _AM_ADSLIGHT_TEL;
660
        $tags['HELLO']      = _AM_ADSLIGHT_HELLO;
661
        $tags['VEDIT_AD']   = _AM_ADSLIGHT_VEDIT_AD;
662
        $tags['ANNACCEPT']  = _AM_ADSLIGHT_ANNACCEPT;
663
        $tags['CONSULTTO']  = _AM_ADSLIGHT_CONSULTTO;
664
        $tags['THANKS']     = _ADSLIGHT_THANKS;
665
        $tags['TEAMOF']     = _AM_ADSLIGHT_TEAMOF;
666
        $tags['META_TITLE'] = $meta['title'];
667
        $tags['LINK_URL']   = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/viewads.php?lid={$lid}";
0 ignored issues
show
Bug introduced by
The constant XOOPS_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
668
        $tags['YOUR_AD']    = _AM_ADSLIGHT_YOUR_AD;
669
        $tags['WEBMASTER']  = _AM_ADSLIGHT_WEBMASTER;
670
        $tags['YOUR_AD_ON'] = _AM_ADSLIGHT_YOUR_AD_ON;
671
        $tags['APPROVED']   = _AM_ADSLIGHT_APPROVED;
672
673
        $subject = _AM_ADSLIGHT_ANNACCEPT;
674
        $mail    =& getMailer();
0 ignored issues
show
Bug introduced by
The function getMailer 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

674
        $mail    =& /** @scrutinizer ignore-call */ getMailer();
Loading history...
675
        $mail->setTemplateDir(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . "/language/{$xoopsConfig['language']}/mail_template/");
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...
676
        $mail->setTemplate('listing_approve.tpl');
677
        $mail->useMail();
678
        $mail->multimailer->isHTML(true);
679
        $mail->setFromName($meta['title']);
680
        $mail->setFromEmail($xoopsConfig['adminmail']);
681
        $mail->setToEmails($email);
682
        $mail->setSubject($subject);
683
        $mail->assign($tags);
684
        $mail->send();
685
        echo $mail->getErrors();
686
    }
687
688
    $tags                    = [];
689
    $tags['TITLE']           = $title;
690
    $tags['ADDED_TO_CAT']    = _AM_ADSLIGHT_ADDED_TO_CAT;
691
    $tags['RECIEVING_NOTIF'] = _AM_ADSLIGHT_RECIEVING_NOTIF;
692
    $tags['ERROR_NOTIF']     = _AM_ADSLIGHT_ERROR_NOTIF;
693
    $tags['WEBMASTER']       = _AM_ADSLIGHT_WEBMASTER;
694
    $tags['HELLO']           = _AM_ADSLIGHT_HELLO;
695
    $tags['FOLLOW_LINK']     = _AM_ADSLIGHT_FOLLOW_LINK;
696
    $tags['TYPE']            = Adslight\Utility::getNameType($type);
697
    $tags['LINK_URL']        = XOOPS_URL . "/modules/adslight/viewads.php?&lid={$lid}";
698
699
    $sql                    = 'SELECT title FROM ' . $xoopsDB->prefix('adslight_categories') . " WHERE cid={$cat}";
700
    $result                 = $xoopsDB->query($sql);
701
    $row                    = $xoopsDB->fetchArray($result);
702
    $tags['CATEGORY_TITLE'] = $row['title'];
703
    $tags['CATEGORY_URL']   = XOOPS_URL . "/modules/adslight/viewcats.php?cid={$cat}";
704
    /** @var XoopsNotificationHandler $notificationHandler */
705
    $notificationHandler = xoops_getHandler('notification');
0 ignored issues
show
Bug introduced by
The function xoops_getHandler 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

705
    $notificationHandler = /** @scrutinizer ignore-call */ xoops_getHandler('notification');
Loading history...
706
    $notificationHandler->triggerEvent('global', 0, 'new_listing', $tags);
707
    $notificationHandler->triggerEvent('category', $cat, 'new_listing', $tags);
708
    $notificationHandler->triggerEvent('listing', $lid, 'new_listing', $tags);
709
710
    redirect_header('view_ads.php', 3, _AM_ADSLIGHT_ANNVALID);
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

710
    /** @scrutinizer ignore-call */ 
711
    redirect_header('view_ads.php', 3, _AM_ADSLIGHT_ANNVALID);
Loading history...
711
}
712
713
#####################################################
714
#####################################################
715
716
foreach ($_POST as $k => $v) {
717
    ${$k} = $v;
718
}
719
720
//$pa  = Request::getString('pa', '', 'GET');
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...
721
//$lid = Request::getInt('lid', 0);
722
//$op  = Request::getCmd('op', '');
723
724
$pa  = Request::getInt('pa', '', 'GET');
725
$lid = 0;
726
if (!Request::hasVar('lid', 'POST') && Request::hasVar('lid', 'GET')) {
727
    $lid = Request::getInt('lid', 0, 'GET');
728
}
729
730
if (!Request::hasVar('op', 'POST') && Request::hasVar('op', 'GET')) {
731
    $op = Request::getString('op', '', 'GET');
732
}
733
734
if (!isset($op)) {
735
    $op = '';
736
}
737
738
switch ($op) {
739
740
    case 'IndexView':
741
        indexView($lid);
742
        break;
743
744
    case 'ListingDel':
745
        listingDel($lid, $photo);
746
        break;
747
748
    case 'ListingValid':
749
        listingValid($lid, $cid, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $typeusure, $date, $email, $submitter, $town, $country, $contactby, $premium, $valid, $photo);
750
        break;
751
752
    case 'ModifyAds':
753
        modifyAds($lid);
754
        break;
755
756
    case 'ModifyAdsS':
757
        modifyAdsS($lid, $cid, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $typeusure, $date, $email, $submitter, $town, $country, $contactby, $premium, $valid, $photo);
758
        break;
759
760
    default:
761
        index();
762
        break;
763
764
}
765