Passed
Push — master ( 34ef5d...2f53de )
by Michael
04:04 queued 19s
created

listingDel()   B

Complexity

Conditions 6
Paths 10

Size

Total Lines 31
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 21
c 0
b 0
f 0
dl 0
loc 31
rs 8.9617
cc 6
nc 10
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * You may not change or alter any portion of this comment or credits
7
 * of supporting developers from this source code or any supporting source code
8
 * which is considered copyrighted (c) material of the original comment or credit authors.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
 */
14
15
/**
16
 * @copyright    XOOPS Project (https://xoops.org)
17
 * @license      GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
18
 * @author       XOOPS Development Team
19
 * @author       Pascal Le Boustouller: original author ([email protected])
20
 * @author       Luc Bizet (www.frxoops.org)
21
 * @author       jlm69 (www.jlmzone.com)
22
 * @author       mamba (www.xoops.org)
23
 */
24
25
use Xmf\Request;
26
use XoopsModules\Adslight\{
27
    Helper,
28
    Tree,
29
    Utility
30
};
31
/** @var Admin $adminObject */
32
/** @var Helper $helper */
33
34
require_once __DIR__ . '/admin_header.php';
35
36
$op = Request::getString('op', 'list');
37
38
#  function index
39
#####################################################
40
function index(): void
41
{
42
    global $xoopsDB, $myts, $desctext, $admin_lang;
43
44
    //    $mytree = new Tree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid');
45
    $photo3 = $photo4 = '';
46
    xoops_cp_header();
47
    //    loadModuleAdminMenu(0, '');
48
49
    // photo dir setting checker
50
    $photo_dir         = $GLOBALS['xoopsModuleConfig']['adslight_path_upload'];
51
    $photo_thumb_dir   = $GLOBALS['xoopsModuleConfig']['adslight_path_upload'] . '/thumbs';
52
    $photo_resized_dir = $GLOBALS['xoopsModuleConfig']['adslight_path_upload'] . '/midsize';
53
    if (!is_dir($photo_dir) && (!mkdir($photo_dir) && !is_dir($photo_dir))) {
54
        throw new \RuntimeException(sprintf('Directory "%s" was not created', $photo_dir));
55
    }
56
    if (!is_dir($photo_thumb_dir) && (!mkdir($photo_thumb_dir) && !is_dir($photo_thumb_dir))) {
57
        throw new \RuntimeException(sprintf('Directory "%s" was not created', $photo_thumb_dir));
58
    }
59
    if (!is_dir($photo_resized_dir) && (!mkdir($photo_resized_dir) && !is_dir($photo_resized_dir))) {
60
        throw new \RuntimeException(sprintf('Directory "%s" was not created', $photo_resized_dir));
61
    }
62
    if (!is_writable($photo_dir) || !is_readable($photo_dir)) {
63
        echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_CHECKER . '</legend><br>';
64
        echo "<span style='color: #FF0000;'><b>" . _AM_ADSLIGHT_DIRPERMS . '' . $photo_dir . "</b></span><br><br>\n";
65
        echo '</fieldset><br>';
66
    }
67
68
    if (!is_writable($photo_thumb_dir) || !is_readable($photo_thumb_dir)) {
69
        echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_CHECKER . '</legend><br>';
70
        echo "<span style='color: #FF0000;'><b>" . _AM_ADSLIGHT_DIRPERMS . '' . $photo_thumb_dir . "</b></span><br><br>\n";
71
        echo '</fieldset><br>';
72
    }
73
74
    if (!is_writable($photo_resized_dir) || !is_readable($photo_resized_dir)) {
75
        echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_CHECKER . '</legend><br>';
76
        echo "<span style='color: #FF0000;'><b>" . _AM_ADSLIGHT_DIRPERMS . '' . $photo_resized_dir . "</b></span><br><br>\n";
77
        echo '</fieldset><br>';
78
    }
79
80
    $sql     = 'SELECT lid, cid, title, status, expire, type, desctext, tel, price, typeprice, typecondition, date_created, email, submitter, town, country, contactby, premium, photo, usid FROM ' . $xoopsDB->prefix('adslight_listing') . " WHERE valid='Yes' ORDER BY lid";
81
    $result  = $xoopsDB->query($sql);
82
    $numrows = $xoopsDB->getRowsNum($result);
83
    if ($numrows > 0) {
84
        // Il y a [..] Annonces en attente d'être approuvées //////
85
        echo "<table class='outer bnone' cellspacing=5 cellpadding=0><tr><td width=40>";
86
        echo "<img src='../assets/images/admin/error_button.png' border=0 ></td><td>";
87
        echo "<span style='color:#00B4C4;'><b>" . _AM_ADSLIGHT_THEREIS . "</b></span> <b>${numrows}</b> <b><span style='color:#00B4C4;'>" . _AM_ADSLIGHT_ADSVALIDE . '</b></span>';
88
        echo '</td></tr></table><br>';
89
90
        // Liste des ID  ///// Soumis par /////  Titre   /////  Description  /////  Date d'ajout
91
        echo "<table class='outer width100 bnone'>";
92
        $rank = 1;
93
94
        while (false !== [$lid, $cid, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $typecondition, $date_created, $email, $submitter, $town, $country, $contactby, $premium, $photo, $usid] = $xoopsDB->fetchRow($result)) {
95
            $title    = \htmlspecialchars($title, ENT_QUOTES | ENT_HTML5);
96
            $desctext = $myts->displayTarea($desctext, 1, 0, 1, 1, 1);
97
98
            if (mb_strlen($desctext) >= 200) {
99
                $desctext = mb_substr($desctext, 0, 199) . '...';
100
            } else {
101
                $desctext = $myts->displayTarea($desctext, 1, 1, 1);
102
            }
103
            $date2  = formatTimestamp($date_created, 's');
104
            $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...
105
            $status = \htmlspecialchars($status, ENT_QUOTES | ENT_HTML5);
106
            $expire = \htmlspecialchars($expire, ENT_QUOTES | ENT_HTML5);
107
            $type   = \htmlspecialchars($type, ENT_QUOTES | ENT_HTML5);
108
            $tel    = \htmlspecialchars($tel, ENT_QUOTES | ENT_HTML5);
109
            //            $price = number_format($price, 2, ',', ' ');
110
            $typeprice     = \htmlspecialchars($typeprice, ENT_QUOTES | ENT_HTML5);
111
            $typecondition = \htmlspecialchars($typecondition, ENT_QUOTES | ENT_HTML5);
112
            $submitter     = \htmlspecialchars($submitter, ENT_QUOTES | ENT_HTML5);
113
            $town          = \htmlspecialchars($town, ENT_QUOTES | ENT_HTML5);
114
            $country       = \htmlspecialchars($country, ENT_QUOTES | ENT_HTML5);
115
            $contactby     = \htmlspecialchars($contactby, ENT_QUOTES | ENT_HTML5);
116
            $premium       = \htmlspecialchars($premium, ENT_QUOTES | ENT_HTML5);
117
118
            $updir   = $GLOBALS['xoopsModuleConfig']['adslight_link_upload'];
119
            $sql     = 'SELECT cod_img, lid, uid_owner, url FROM ' . $xoopsDB->prefix('adslight_pictures') . " WHERE  uid_owner={$usid} AND lid={$lid} ORDER BY date_created ASC LIMIT 1";
120
            $resultp = $xoopsDB->query($sql);
121
            while ([$cod_img, $pic_lid, $uid_owner, $url] = $xoopsDB->fetchRow($resultp)) {
122
                if ($photo) {
123
                    $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>";
124
                }
125
            }
126
            if ($photo <= 0) {
127
                $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>";
128
            } else {
129
                $photo4 = (string)$photo;
130
            }
131
132
            $sql     = 'SELECT nom_type FROM ' . $xoopsDB->prefix('adslight_type') . ' WHERE id_type=' . (int)$type;
133
            $result7 = $xoopsDB->query($sql);
134
            [$nom_type] = $xoopsDB->fetchRow($result7);
135
136
            $sql     = 'SELECT nom_price FROM ' . $xoopsDB->prefix('adslight_price') . ' WHERE id_price=' . (int)$typeprice;
137
            $result8 = $xoopsDB->query($sql);
138
            [$nom_price] = $xoopsDB->fetchRow($result8);
139
140
            echo '<form action="view_ads.php" method="post">';
141
            echo $GLOBALS['xoopsSecurity']->getTokenHTML();
142
            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>';
143
144
            echo "<tr><td class='even width3'></td>";
145
            echo "<td class='odd width10' >{$photo3}</td>";
146
            echo "<td class='even width20'><b>{$title}</b><br><br>{$nom_type}<br>{$price} " . $GLOBALS['xoopsModuleConfig']['adslight_currency_symbol'] . " ${nom_price}<br>";
147
            echo "${town} - ${country}<br>";
148
            echo '<b>' . _AM_ADSLIGHT_SUBMITTER . ":</b> {$submitter}<br>";
149
            echo '<b>' . _AM_ADSLIGHT_DATE . ":</b> {$date2}</td>";
150
            echo "<td class='even width='35%'>{$desctext}</td><td class='even right width2'></td>";
151
            echo "</tr><tr><td width='5%'></td><td>";
152
153
            echo '<select name="op">
154
        <option value="modifyAds"> ' . _AM_ADSLIGHT_MODIF . '
155
        <option value="listingDel"> ' . _AM_ADSLIGHT_DEL . '
156
               </select><input type="submit" value="' . _AM_ADSLIGHT_GO . '">';
157
158
            echo '<input type="hidden" name="valid" value="Yes">';
159
            echo "<input type=\"hidden\" name=\"lid\" value=\"{$lid}\">";
160
            echo "<input type=\"hidden\" name=\"cid\" value=\"{$cid}\">";
161
            echo "<input type=\"hidden\" name=\"title\" value=\"{$title}\">";
162
            echo "<input type=\"hidden\" name=\"status\" value=\"{$status}\">";
163
            echo "<input type=\"hidden\" name=\"expire\" value=\"{$expire}\">";
164
            echo "<input type=\"hidden\" name=\"type\" value=\"{$type}\">";
165
            echo "<input type=\"hidden\" name=\"desctext\" value=\"{$desctext}\">";
166
            echo "<input type=\"hidden\" name=\"tel\" value=\"{$tel}\">";
167
            echo "<input type=\"hidden\" name=\"price\" value=\"{$price}\">";
168
            echo "<input type=\"hidden\" name=\"typeprice\" value=\"{$typeprice}\">";
169
            echo "<input type=\"hidden\" name=\"typecondition\" value=\"{$typecondition}\">";
170
            echo "<input type=\"hidden\" name=\"date_created\" value=\"{$date_created}\">";
171
            echo "<input type=\"hidden\" name=\"email\" value=\"{$email}\">";
172
            echo "<input type=\"hidden\" name=\"submitter\" value=\"{$submitter}\">";
173
            echo "<input type=\"hidden\" name=\"town\" value=\"{$town}\">";
174
            echo "<input type=\"hidden\" name=\"country\" value=\"{$country}\">";
175
            echo "<input type=\"hidden\" name=\"contactby\" value=\"{$contactby}\">";
176
            echo "<input type=\"hidden\" name=\"premium\" value=\"{$premium}\">";
177
            echo "<input type=\"hidden\" name=\"photo\" value=\"{$photo}\">";
178
            echo '</form><br></td></tr>';
179
            ++$rank;
180
        }
181
182
        echo '</td></tr></table>
183
              <br><br>';
184
    } else {
185
        echo "<table class='outer width50 bnone'><tr><td class='width40'>";
186
        echo "<img src='../assets/images/admin/search_button_green_32.png' border=0 ></td><td>";
187
        echo "<span style='color: #00B4C4;'><b>" . _AM_ADSLIGHT_NOANNVALADS . '</b></span>';
188
        echo '</td></tr></table><br>';
189
    }
190
191
    xoops_cp_footer();
192
}
193
194
#  function indexView
195
#####################################################
196
/**
197
 * @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...
198
 */
199
function indexView($lid = null): void
200
{
201
    global $xoopsDB, $myts, $desctext, $admin_lang;
202
203
    $mytree = new Tree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid');
204
205
    require_once __DIR__ . '/admin_header.php';
206
    xoops_cp_header();
207
    //    loadModuleAdminMenu(0, '');
208
209
    $sql     = 'SELECT lid, cid, title, status, expire, type, desctext, tel, price, typeprice, typecondition, date_created, email, submitter, town, country, contactby, premium, photo FROM ' . $xoopsDB->prefix('adslight_listing') . " WHERE valid='No' AND lid='{$lid}'";
210
    $result  = $xoopsDB->query($sql);
211
    $numrows = $xoopsDB->getRowsNum($result);
212
    if ($numrows > 0) {
213
        echo "<table class='width100' cellspacing='1' cellpadding='8' style='border: 2px solid #DFE0E0;'><tr class='bg4'><td class='top'>";
214
        echo '<b>' . _AM_ADSLIGHT_WAIT . '</b><br><br>';
215
216
        [$lid, $cid, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $typecondition, $date_created, $email, $submitter, $town, $country, $contactby, $premium, $photo] = $xoopsDB->fetchRow($result);
217
218
        $lid      = (int)$lid;
219
        $cid      = (int)$cid;
220
        $date2    = formatTimestamp($date_created, 's');
221
        $title    = \htmlspecialchars($title, ENT_QUOTES | ENT_HTML5);
222
        $status   = \htmlspecialchars($status, ENT_QUOTES | ENT_HTML5);
223
        $expire   = \htmlspecialchars($expire, ENT_QUOTES | ENT_HTML5);
224
        $type     = \htmlspecialchars($type, ENT_QUOTES | ENT_HTML5);
225
        $desctext = $myts->displayTarea($desctext, 1, 1, 1);
226
        $tel      = \htmlspecialchars($tel, ENT_QUOTES | ENT_HTML5);
227
        //        $price = number_format($price, 2, ',', ' ');
228
        $typeprice     = \htmlspecialchars($typeprice, ENT_QUOTES | ENT_HTML5);
229
        $typecondition = \htmlspecialchars($typecondition, ENT_QUOTES | ENT_HTML5);
230
        $submitter     = \htmlspecialchars($submitter, ENT_QUOTES | ENT_HTML5);
231
        $town          = \htmlspecialchars($town, ENT_QUOTES | ENT_HTML5);
232
        $country       = \htmlspecialchars($country, ENT_QUOTES | ENT_HTML5);
233
        $contactby     = \htmlspecialchars($contactby, ENT_QUOTES | ENT_HTML5);
234
        $premium       = \htmlspecialchars($premium, ENT_QUOTES | ENT_HTML5);
235
236
        echo '<form action="index.php" method="post">';
237
        echo $GLOBALS['xoopsSecurity']->getTokenHTML();
238
        echo "<table><tr class='head' border='1'>
239
            <td>" . _AM_ADSLIGHT_NUMANN . " </td><td>{$lid} &nbsp;&nbsp;&nbsp;&nbsp;   " . _AM_ADSLIGHT_ADDED_ON . " &nbsp;&nbsp;&nbsp;&nbsp; {$date2}</td>
240
            </tr><tr class='head' border='1'>
241
        <td>" . _AM_ADSLIGHT_SENDBY . " </td><td>{$submitter}</td>
242
            </tr><tr class='head' border='1'>
243
        <td>" . _AM_ADSLIGHT_EMAIL . " </td><td><input type=\"text\" name=\"email\" size=\"40\" value=\"{$email}\"></td>
244
            </tr><tr class='head' border='1'>
245
        <td>" . _AM_ADSLIGHT_TEL . " </td><td><input type=\"text\" name=\"tel\" size=\"50\" value=\"{$tel}\"></td>
246
            </tr><tr class='head' border='1'>
247
        <td>" . _AM_ADSLIGHT_TOWN . " </td><td><input type=\"text\" name=\"town\" size=\"40\" value=\"{$town}\"></td>
248
            </tr><tr class='head' border='1'>
249
        <td>" . _AM_ADSLIGHT_COUNTRY . " </td><td><input type=\"text\" name=\"country\" size=\"40\" value=\"{$country}\"></td>
250
            </tr><tr class='head' border='1'>
251
        <td>" . _AM_ADSLIGHT_CONTACTBY . " </td><td><input type=\"text\" name=\"contactby\" size=\"40\" value=\"{$contactby}\"></td>
252
            </tr>";
253
254
        echo "<tr>
255
            <td class='head'>" . _AM_ADSLIGHT_STATUS . "</td><td class='head'><input type=\"radio\" name=\"status\" value=\"0\"";
256
        if (0 === (int)$status) {
257
            echo 'checked';
258
        }
259
        echo '>' . _AM_ADSLIGHT_ACTIVE . '&nbsp;&nbsp; <input type="radio" name="status" value="1"';
260
        if (1 === (int)$status) {
261
            echo 'checked';
262
        }
263
        echo '>' . _AM_ADSLIGHT_INACTIVE . '&nbsp;&nbsp; <input type="radio" name="status" value="2"';
264
        if (2 === (int)$status) {
265
            echo 'checked';
266
        }
267
        echo '>' . _AM_ADSLIGHT_SOLD . '</td></tr>';
268
269
        echo "<tr class='head' border='1'>
270
           <td>" . _AM_ADSLIGHT_TITLE2 . " </td><td><input type=\"text\" name=\"title\" size=\"40\" value=\"{$title}\"></td>
271
            </tr><tr class='head' border='1'>
272
           <td>" . _AM_ADSLIGHT_PREMIUM . " </td><td><input type=\"text\" name=\"premium\" size=\"3\" value=\"{$premium}\"></td>
273
            </tr><tr class='head' border='1'>
274
           <td>" . _AM_ADSLIGHT_EXPIRE . " </td><td><input type=\"text\" name=\"expire\" size=\"40\" value=\"{$expire}\"></td>
275
            </tr><tr class='head' border='1'>
276
            <td>" . _AM_ADSLIGHT_TYPE . ' </td><td><select name="type">';
277
278
        $sql     = 'SELECT nom_type FROM ' . $xoopsDB->prefix('adslight_type') . ' ORDER BY nom_type';
279
        $result5 = $xoopsDB->query($sql);
280
        while ([$nom_type] = $xoopsDB->fetchRow($result5)) {
281
            $sel = '';
282
            if ($nom_type === $type) {
283
                $sel = 'selected';
284
            }
285
            echo "<option value=\"{$nom_type}\"{$sel}>{$nom_type}</option>";
286
        }
287
288
        echo '</select></td></tr>';
289
290
        ////// Condition
291
        echo "<tr class='head' border='1'>
292
            <td>" . _AM_ADSLIGHT_TYPE_CONDITION . ' </td><td><select name="typecondition">';
293
294
        $sql     = 'SELECT nom_condition FROM ' . $xoopsDB->prefix('adslight_condition') . ' ORDER BY nom_condition';
295
        $result6 = $xoopsDB->query($sql);
296
        while ([$nom_condition] = $xoopsDB->fetchRow($result6)) {
297
            $sel = '';
298
            if ($nom_condition === $typecondition) {
299
                $sel = 'selected';
300
            }
301
            echo "<option value=\"{$nom_condition}\"{$sel}>{$nom_condition}</option>";
302
        }
303
        echo '</select></td></tr>';
304
305
        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'] . '';
306
        $sql     = 'SELECT nom_price FROM ' . $xoopsDB->prefix('adslight_price') . ' ORDER BY id_price';
307
        $result3 = $xoopsDB->query($sql);
308
        echo " <select name=\"typeprice\"><option value=\"{$typeprice}\">{$typeprice}</option>";
309
        while ([$nom_price] = $xoopsDB->fetchRow($result3)) {
310
            echo "<option value=\"${nom_price}\">${nom_price}</option>";
311
        }
312
        echo '</select></td></tr>';
313
314
        echo "<tr class='head' border='1'>
315
           <td>" . _AM_ADSLIGHT_PHOTO1 . " </td><td><input type=\"text\" name=\"photo\" size=\"40\" value=\"{$photo}\"></td>
316
            </tr>";
317
        echo "<tr class='head' border='1'><td>" . _AM_ADSLIGHT_DESC . '</td><td>';
318
        $wysiwyg_text_area = Utility::getEditor(_AM_ADSLIGHT_DESC, 'desctext', $desctext, '100%', '200px', 'small');
0 ignored issues
show
Bug introduced by
'desctext' of type string is incompatible with the type array|null expected by parameter $options of XoopsModules\Adslight\Co...SysUtility::getEditor(). ( Ignorable by Annotation )

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

318
        $wysiwyg_text_area = Utility::getEditor(_AM_ADSLIGHT_DESC, /** @scrutinizer ignore-type */ 'desctext', $desctext, '100%', '200px', 'small');
Loading history...
Bug introduced by
_AM_ADSLIGHT_DESC of type string is incompatible with the type Xmf\Module\Helper|null expected by parameter $helper of XoopsModules\Adslight\Co...SysUtility::getEditor(). ( Ignorable by Annotation )

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

318
        $wysiwyg_text_area = Utility::getEditor(/** @scrutinizer ignore-type */ _AM_ADSLIGHT_DESC, 'desctext', $desctext, '100%', '200px', 'small');
Loading history...
Unused Code introduced by
The call to XoopsModules\Adslight\Co...SysUtility::getEditor() has too many arguments starting with $desctext. ( Ignorable by Annotation )

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

318
        /** @scrutinizer ignore-call */ 
319
        $wysiwyg_text_area = Utility::getEditor(_AM_ADSLIGHT_DESC, 'desctext', $desctext, '100%', '200px', 'small');

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
319
        echo $wysiwyg_text_area->render();
320
        echo '</td></tr>';
321
        echo "<tr class='head' border='1'><td>" . _AM_ADSLIGHT_CAT . ' </td><td>';
322
        $mytree->makeMySelBox('title', 'title', $cid);
323
        echo "</td>
324
        </tr><tr class='head' border='1'>
325
        <td>&nbsp;</td><td><select name=\"op\">
326
        <option value=\"listingValid\"> " . _AM_ADSLIGHT_OK . '
327
        <option value="listingDel"> ' . _AM_ADSLIGHT_DEL . '
328
        </select><input type="submit" value="' . _AM_ADSLIGHT_GO . '"></td>
329
        </tr></table>';
330
        echo '<input type="hidden" name="valid" value="Yes">';
331
        echo "<input type=\"hidden\" name=\"lid\" value=\"{$lid}\">";
332
        echo "<input type=\"hidden\" name=\"date_created\" value=\"{$date_created}\">";
333
        echo "<input type=\"hidden\" name=\"submitter\" value=\"{$submitter}\">
334
            </form>";
335
336
        echo '</td></tr></table>';
337
        echo '<br>';
338
    }
339
340
    require_once __DIR__ . '/admin_footer.php';
341
}
342
343
#  function modifyAds
344
#####################################################
345
/**
346
 * @param $lid
347
 */
348
function modifyAds($lid): void
349
{
350
    global $xoopsDB, $myts, $desctext, $admin_lang;
351
352
    $mytree = new Tree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid');
353
354
    //    require_once __DIR__ . '/admin_header.php';
355
    xoops_cp_header();
356
    //    loadModuleAdminMenu(0, '');
357
358
    $lid           = (int)$lid;
359
    $id_price      = '';
360
    $nom_price     = '';
361
    $contactselect = '';
0 ignored issues
show
Unused Code introduced by
The assignment to $contactselect is dead and can be removed.
Loading history...
362
363
    echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_MODANN . '</legend>';
364
365
    $sql    = 'SELECT lid, cid, title, status, expire, type, desctext, tel, price, typeprice, typecondition, date_created, email, submitter, town, country, contactby, premium, valid, photo FROM ' . $xoopsDB->prefix('adslight_listing') . " WHERE lid={$lid}";
366
    $result = $xoopsDB->query($sql);
367
    while ([$lid, $cid, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $typecondition, $date_created, $email, $submitter, $town, $country, $contactby, $premium, $valid, $photo] = $xoopsDB->fetchRow(
368
        $result
369
    )) {
370
        $title = \htmlspecialchars($title, ENT_QUOTES | ENT_HTML5);
371
        //        $status    = \htmlspecialchars($status);
372
        $status   = (int)$status;
373
        $expire   = \htmlspecialchars($expire, ENT_QUOTES | ENT_HTML5);
374
        $type     = \htmlspecialchars($type, ENT_QUOTES | ENT_HTML5);
375
        $desctext = $myts->displayTarea($desctext, 1, 1, 1);
376
        $tel      = \htmlspecialchars($tel, ENT_QUOTES | ENT_HTML5);
377
        //        $price     = number_format($price, 2, ',', ' ');
378
        $typeprice     = \htmlspecialchars($typeprice, ENT_QUOTES | ENT_HTML5);
379
        $typecondition = \htmlspecialchars($typecondition, ENT_QUOTES | ENT_HTML5);
380
        $submitter     = \htmlspecialchars($submitter, ENT_QUOTES | ENT_HTML5);
381
        $town          = \htmlspecialchars($town, ENT_QUOTES | ENT_HTML5);
382
        $country       = \htmlspecialchars($country, ENT_QUOTES | ENT_HTML5);
383
        $contactby     = \htmlspecialchars($contactby, ENT_QUOTES | ENT_HTML5);
384
        $premium       = \htmlspecialchars($premium, ENT_QUOTES | ENT_HTML5);
385
386
        $date2 = formatTimestamp($date_created, 's');
387
388
        echo '<form action="view_ads.php" method="post">';
389
        echo $GLOBALS['xoopsSecurity']->getTokenHTML();
390
        echo "<table border=0><tr class='head' border='1'>
391
           <td>" . _AM_ADSLIGHT_NUMANN . " </td><td>{$lid} &nbsp;" . _AM_ADSLIGHT_ADDED_ON . "&nbsp; {$date2}</td>
392
            </tr><tr class='head' border='1'>
393
           <td>" . _AM_ADSLIGHT_SENDBY . " </td><td>{$submitter}</td>
394
            </tr><tr class='head' border='1'>
395
           <td>" . _AM_ADSLIGHT_EMAIL . " </td><td><input type=\"text\" name=\"email\" size=\"40\" value=\"{$email}\"></td>
396
            </tr><tr class='head' border='1'>
397
           <td>" . _AM_ADSLIGHT_TEL . " </td><td><input type=\"text\" name=\"tel\" size=\"50\" value=\"{$tel}\"></td>
398
            </tr><tr class='head' border='1'>
399
           <td>" . _AM_ADSLIGHT_TOWN . " </td><td><input type=\"text\" name=\"town\" size=\"40\" value=\"{$town}\"></td>
400
            </tr><tr class='head' border='1'>
401
           <td>" . _AM_ADSLIGHT_COUNTRY . " </td><td><input type=\"text\" name=\"country\" size=\"40\" value=\"{$country}\"></td>
402
            </tr>
403
            <tr class='head' border='1'>";
404
405
        $contactSel1 = $contactSel2 = $contactSel3 = $contactSel4 = '';
406
        $selected    = 'contactSel' . (int)$contactby;
407
        ${$selected} = ' selected';
408
409
        echo " <td class='head'>"
410
             . _AM_ADSLIGHT_CONTACTBY
411
             . " </td><td class='head'><select name=\"contactby\">\n"
412
             //           . "  <option value=\"{$contactby}\">{$contactselect}</option>\n"
413
             . "  <option value=\"1\"{$contactSel1}>"
414
             . _AM_ADSLIGHT_CONTACT_BY_EMAIL
415
             . "</option>\n"
416
             . "  <option value=\"2\"{$contactSel2}>"
417
             . _AM_ADSLIGHT_CONTACT_BY_PM
418
             . "</option>\n"
419
             . "  <option value=\"3\"{$contactSel3}>"
420
             . _AM_ADSLIGHT_CONTACT_BY_BOTH
421
             . "</option>\n"
422
             . "  <option value=\"4\"{$contactSel4}>"
423
             . _AM_ADSLIGHT_CONTACT_BY_PHONE
424
             . "</option></select>\n"
425
             . " </td>\n"
426
             . '</tr>';
427
428
        echo "<tr><td class='head'>" . _AM_ADSLIGHT_STATUS . "</td><td class='head'><input type=\"radio\" name=\"status\" value=\"0\"";
429
        if (0 === (int)$status) {
430
            echo 'checked';
431
        }
432
        echo '>' . _AM_ADSLIGHT_ACTIVE . '&nbsp;&nbsp; <input type="radio" name="status" value="1"';
433
        if (1 === (int)$status) {
434
            echo 'checked';
435
        }
436
        echo '>' . _AM_ADSLIGHT_INACTIVE . '&nbsp;&nbsp; <input type="radio" name="status" value="2"';
437
        if (2 === (int)$status) {
438
            echo 'checked';
439
        }
440
        echo '>' . _AM_ADSLIGHT_SOLD . '</td></tr>';
441
442
        echo "<tr class='head' border='1'>
443
           <td>" . _AM_ADSLIGHT_TITLE2 . " </td><td><input type=\"text\" name=\"title\" size=\"40\" value=\"{$title}\"></td>
444
            </tr><tr class='head' border='1'>
445
           <td>" . _AM_ADSLIGHT_PREMIUM . " </td><td><input type=\"text\" name=\"premium\" size=\"3\" value=\"{$premium}\"></td>
446
            </tr><tr class='head' border='1'>
447
           <td>" . _AM_ADSLIGHT_EXPIRE . " </td><td><input type=\"text\" name=\"expire\" size=\"40\" value=\"{$expire}\"></td>
448
            </tr>";
449
        // Type d'annonce
450
        echo "<tr class='head' border='1'>
451
            <td>" . _AM_ADSLIGHT_TYPE . ' </td><td><select name="type">';
452
453
        $sql     = 'SELECT nom_type, id_type FROM ' . $xoopsDB->prefix('adslight_type') . ' ORDER BY nom_type';
454
        $result5 = $xoopsDB->query($sql);
455
        while ([$nom_type, $id_type] = $xoopsDB->fetchRow($result5)) {
456
            $sel = '';
457
            if ($id_type === $type) {
458
                $sel = 'selected';
459
            }
460
            echo "<option value=\"{$id_type}\"{$sel}>{$nom_type}</option>";
461
        }
462
        echo '</select></td></tr>';
463
464
        // Condition
465
        echo "<tr class='head' border='1'>
466
            <td>" . _AM_ADSLIGHT_TYPE_CONDITION . ' </td><td><select name="typecondition">';
467
468
        $sql     = 'SELECT nom_condition, id_condition FROM ' . $xoopsDB->prefix('adslight_condition') . ' ORDER BY nom_condition';
469
        $result6 = $xoopsDB->query($sql);
470
        while ([$nom_condition, $id_condition] = $xoopsDB->fetchRow($result6)) {
471
            $sel = '';
472
            if ($id_condition === $typecondition) {
473
                $sel = 'selected';
474
            }
475
            echo "<option value=\"{$id_condition}\"{$sel}>{$nom_condition}</option>";
476
        }
477
        echo '</select></td></tr>';
478
479
        /////// Price
480
        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']}";
481
482
        // Price type
483
        $sql     = 'SELECT nom_price, id_price FROM ' . $xoopsDB->prefix('adslight_price') . ' ORDER BY nom_price';
484
        $resultx = $xoopsDB->query($sql);
485
486
        echo " <select name=\"typeprice\"><option value=\"{$id_price}\">{$nom_price}</option>";
487
        while ([$nom_price, $id_price] = $xoopsDB->fetchRow($resultx)) {
488
            $sel = '';
489
            if ($id_price === $typeprice) {
490
                $sel = 'selected';
491
            }
492
493
            echo "<option value=\"{$id_price}\"{$sel}>{$nom_price}</option>";
494
        }
495
        echo '</select></td>';
496
497
        // Category
498
        echo "<tr class='head' border='1'>
499
            <td>" . _AM_ADSLIGHT_CAT2 . ' </td><td>';
500
        $mytree->makeMySelBox('title', 'title', $cid);
501
        echo "</td>
502
            </tr><tr class='head' border='1'>
503
            <td>" . _AM_ADSLIGHT_DESC . ' </td><td>';
504
505
        $wysiwyg_text_area = Utility::getEditor('', 'desctext', $desctext, '100%', '200px', 'small');
0 ignored issues
show
Unused Code introduced by
The call to XoopsModules\Adslight\Co...SysUtility::getEditor() has too many arguments starting with $desctext. ( Ignorable by Annotation )

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

505
        /** @scrutinizer ignore-call */ 
506
        $wysiwyg_text_area = Utility::getEditor('', 'desctext', $desctext, '100%', '200px', 'small');

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
Bug introduced by
'' of type string is incompatible with the type Xmf\Module\Helper|null expected by parameter $helper of XoopsModules\Adslight\Co...SysUtility::getEditor(). ( Ignorable by Annotation )

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

505
        $wysiwyg_text_area = Utility::getEditor(/** @scrutinizer ignore-type */ '', 'desctext', $desctext, '100%', '200px', 'small');
Loading history...
Bug introduced by
'desctext' of type string is incompatible with the type array|null expected by parameter $options of XoopsModules\Adslight\Co...SysUtility::getEditor(). ( Ignorable by Annotation )

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

505
        $wysiwyg_text_area = Utility::getEditor('', /** @scrutinizer ignore-type */ 'desctext', $desctext, '100%', '200px', 'small');
Loading history...
506
        echo $wysiwyg_text_area->render();
507
508
        echo '</td></tr>';
509
510
        echo "<tr class='head' border='1'>
511
            <td>" . _AM_ADSLIGHT_PHOTO1 . " </td><td><input type=\"text\" name=\"photo\" size=\"50\" value=\"{$photo}\"></td>
512
            </tr><tr>";
513
        $time = time();
514
        echo "</tr><tr class='head' border='1'>
515
            <td>&nbsp;</td><td><select name=\"op\">
516
            <option value=\"modifyAdsS\"> " . _AM_ADSLIGHT_MODIF . '
517
            <option value="listingDel"> ' . _AM_ADSLIGHT_DEL . '
518
            </select><input type="submit" value="' . _AM_ADSLIGHT_GO . '"></td>
519
            </tr></table>';
520
        echo '<input type="hidden" name="valid" value="Yes">';
521
        echo "<input type=\"hidden\" name=\"lid\" value=\"{$lid}\">";
522
        echo "<input type=\"hidden\" name=\"date_created\" value=\"{$time}\">";
523
        echo "<input type=\"hidden\" name=\"submitter\" value=\"{$submitter}\">
524
              </form><br>";
525
        echo '</fieldset><br>';
526
        xoops_cp_footer();
527
    }
528
}
529
530
#  function modifyAdsS
531
#####################################################
532
533
/**
534
 * @param $lid
535
 * @param $cat
536
 * @param $title
537
 * @param $status
538
 * @param $expire
539
 * @param $type
540
 * @param $desctext
541
 * @param $tel
542
 * @param $price
543
 * @param $typeprice
544
 * @param $typecondition
545
 * @param $date_created
546
 * @param $email
547
 * @param $submitter
548
 * @param $town
549
 * @param $country
550
 * @param $contactby
551
 * @param $premium
552
 * @param $valid
553
 * @param $photo
554
 */
555
function modifyAdsS(
556
    $lid,
557
    $cat,
558
    $title,
559
    $status,
560
    $expire,
561
    $type,
562
    $desctext,
563
    $tel,
564
    $price,
565
    $typeprice,
566
    $typecondition,
567
    $date_created,
568
    $email,
569
    $submitter,
570
    $town,
571
    $country,
572
    $contactby,
573
    $premium,
574
    $valid,
575
    $photo
576
): void {
577
    global $xoopsDB, $myts, $admin_lang;
578
579
    $helper = Helper::getInstance();
580
    $lid    = (int)$lid;
581
    $cat    = (int)$cat;
582
    $title  = \htmlspecialchars($title, ENT_QUOTES | ENT_HTML5);
583
    //    $status    = \htmlspecialchars($status);
584
    $status        = (int)$status;
585
    $expire        = \htmlspecialchars($expire, ENT_QUOTES | ENT_HTML5);
586
    $type          = \htmlspecialchars($type, ENT_QUOTES | ENT_HTML5);
587
    $desctext      = $myts->displayTarea($desctext, 1, 1, 1);
588
    $tel           = \htmlspecialchars($tel, ENT_QUOTES | ENT_HTML5);
589
    $price         = str_replace([' '], '', $price);
590
    $typeprice     = \htmlspecialchars($typeprice, ENT_QUOTES | ENT_HTML5);
591
    $typecondition = \htmlspecialchars($typecondition, ENT_QUOTES | ENT_HTML5);
592
    $submitter     = \htmlspecialchars($submitter, ENT_QUOTES | ENT_HTML5);
593
    $town          = \htmlspecialchars($town, ENT_QUOTES | ENT_HTML5);
594
    $country       = \htmlspecialchars($country, ENT_QUOTES | ENT_HTML5);
595
    $contactby     = \htmlspecialchars($contactby, ENT_QUOTES | ENT_HTML5);
596
    $premium       = \htmlspecialchars($premium, ENT_QUOTES | ENT_HTML5);
597
598
    $xoopsDB->query(
599
        'UPDATE '
600
        . $xoopsDB->prefix('adslight_listing')
601
        . " SET cid='{$cat}', title='{$title}', status='{$status}', expire='{$expire}', type='{$type}', desctext='{$desctext}', tel='{$tel}', price='{$price}', typeprice='{$typeprice}', typecondition='{$typecondition}', date_created='{$date_created}', email='{$email}', submitter='{$submitter}', town='{$town}', country='{$country}', contactby='{$contactby}', premium='{$premium}', valid='{$valid}', photo='{$photo}' WHERE lid={$lid}"
602
    );
603
604
    $helper->redirect('admin/view_ads.php', 1, _AM_ADSLIGHT_ANNMOD);
605
}
606
607
#  function listingDel
608
#####################################################
609
/**
610
 * @param $lid
611
 * @param $photo
612
 */
613
function listingDel($lid, $photo): void
0 ignored issues
show
Unused Code introduced by
The parameter $photo is not used and could be removed. ( Ignorable by Annotation )

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

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

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
614
{
615
    global $xoopsDB, $admin_lang;
616
    $helper = Helper::getInstance();
617
618
    $lid     = (int)$lid;
619
    $sql     = 'SELECT p.url FROM ' . $xoopsDB->prefix('adslight_listing') . ' l LEFT JOIN ' . $xoopsDB->prefix('adslight_pictures') . " p  ON l.lid=p.lid WHERE l.lid={$lid}";
620
    $result2 = $xoopsDB->query($sql);
621
622
    while ([$purl] = $xoopsDB->fetchRow($result2)) {
623
        if ($purl) {
624
            $destination = XOOPS_ROOT_PATH . '/uploads/adslight';
625
            if (is_file("${destination}/${purl}")) {
626
                unlink("${destination}/${purl}");
627
            }
628
            $destination2 = XOOPS_ROOT_PATH . '/uploads/adslight/thumbs';
629
            if (is_file("${destination2}/thumb_${purl}")) {
630
                unlink("${destination2}/thumb_${purl}");
631
            }
632
            $destination3 = XOOPS_ROOT_PATH . '/uploads/adslight/midsize';
633
            if (is_file("${destination3}/resized_${purl}")) {
634
                unlink("${destination3}/resized_${purl}");
635
            }
636
            $sql = 'DELETE FROM ' . $xoopsDB->prefix('adslight_pictures') . " WHERE lid={$lid}";
637
            $xoopsDB->query($sql);
638
        }
639
    }
640
641
    $sql = 'DELETE FROM ' . $xoopsDB->prefix('adslight_listing') . " WHERE lid={$lid}";
642
    $xoopsDB->query($sql);
643
    $helper->redirect('admin/view_ads.php', 1, _AM_ADSLIGHT_ANNDEL);
644
}
645
646
#  function listingValid
647
#####################################################
648
/**
649
 * @param $lid
650
 * @param $cat
651
 * @param $title
652
 * @param $status
653
 * @param $expire
654
 * @param $type
655
 * @param $desctext
656
 * @param $tel
657
 * @param $price
658
 * @param $typeprice
659
 * @param $typecondition
660
 * @param $date_created
661
 * @param $email
662
 * @param $submitter
663
 * @param $town
664
 * @param $country
665
 * @param $contactby
666
 * @param $premium
667
 * @param $valid
668
 * @param $photo
669
 */
670
function listingValid(
671
    $lid,
672
    $cat,
673
    $title,
674
    $status,
675
    $expire,
676
    $type,
677
    $desctext,
678
    $tel,
679
    $price,
680
    $typeprice,
681
    $typecondition,
682
    $date_created,
0 ignored issues
show
Unused Code introduced by
The parameter $date_created 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

682
    /** @scrutinizer ignore-unused */ $date_created,

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...
683
    $email,
684
    $submitter,
685
    $town,
686
    $country,
687
    $contactby,
688
    $premium,
689
    $valid,
690
    $photo
691
): void {
692
    global $xoopsDB, $xoopsConfig, $xoopsModule, $myts, $meta, $admin_lang;
693
    $helper        = Helper::getInstance();
694
    $lid           = (int)$lid;
695
    $cid           = (int)$cid;
0 ignored issues
show
Unused Code introduced by
The assignment to $cid is dead and can be removed.
Loading history...
Comprehensibility Best Practice introduced by
The variable $cid seems to be never defined.
Loading history...
696
    $title         = \htmlspecialchars($title, ENT_QUOTES | ENT_HTML5);
697
    $status        = (int)$status;
698
    $expire        = \htmlspecialchars($expire, ENT_QUOTES | ENT_HTML5);
699
    $type          = \htmlspecialchars($type, ENT_QUOTES | ENT_HTML5);
700
    $desctext      = $myts->displayTarea($desctext, 1, 1, 1);
701
    $tel           = \htmlspecialchars($tel, ENT_QUOTES | ENT_HTML5);
702
    $price         = str_replace([' '], '', $price);
703
    $typeprice     = \htmlspecialchars($typeprice, ENT_QUOTES | ENT_HTML5);
704
    $typecondition = \htmlspecialchars($typecondition, ENT_QUOTES | ENT_HTML5);
705
    $submitter     = \htmlspecialchars($submitter, ENT_QUOTES | ENT_HTML5);
706
    $town          = \htmlspecialchars($town, ENT_QUOTES | ENT_HTML5);
707
    $country       = \htmlspecialchars($country, ENT_QUOTES | ENT_HTML5);
708
    $contactby     = \htmlspecialchars($contactby, ENT_QUOTES | ENT_HTML5);
709
    $premium       = \htmlspecialchars($premium, ENT_QUOTES | ENT_HTML5);
710
    $valid         = \htmlspecialchars($valid, ENT_QUOTES | ENT_HTML5);
711
    $photo         = \htmlspecialchars($photo, ENT_QUOTES | ENT_HTML5);
712
    $now           = time();
713
    $xoopsDB->query(
714
        'UPDATE '
715
        . $xoopsDB->prefix('adslight_listing')
716
        . " SET cid='{$cat}', title='{$title}', status='{$status}', expire='{$expire}', type='{$type}', desctext='{$desctext}', tel='{$tel}', price='{$price}', typeprice='{$typeprice}', typecondition='{$typecondition}', date_created='{$now}', email='{$email}', submitter='{$submitter}', town='{$town}', country='{$country}', contactby='{$contactby}', premium='{$premium}', valid='{$valid}', photo='{$photo}' WHERE lid={$lid}"
717
    );
718
719
    if ('' !== $email) {
720
        $tags               = [];
721
        $tags['TITLE']      = $title;
722
        $tags['TYPE']       = Utility::getNameType($type);
723
        $tags['SUBMITTER']  = $submitter;
724
        $tags['DESCTEXT']   = stripslashes($desctext);
725
        $tags['EMAIL']      = _AM_ADSLIGHT_EMAIL;
726
        $tags['TEL']        = _AM_ADSLIGHT_TEL;
727
        $tags['HELLO']      = _AM_ADSLIGHT_HELLO;
728
        $tags['VEDIT_AD']   = _AM_ADSLIGHT_VEDIT_AD;
729
        $tags['ANNACCEPT']  = _AM_ADSLIGHT_ANNACCEPT;
730
        $tags['CONSULTTO']  = _AM_ADSLIGHT_CONSULTTO;
731
        $tags['THANKS']     = _ADSLIGHT_THANKS;
732
        $tags['TEAMOF']     = _AM_ADSLIGHT_TEAMOF;
733
        $tags['META_TITLE'] = $meta['title'];
734
        $tags['LINK_URL']   = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/viewads.php?lid={$lid}";
735
        $tags['YOUR_AD']    = _AM_ADSLIGHT_YOUR_AD;
736
        $tags['WEBMASTER']  = _AM_ADSLIGHT_WEBMASTER;
737
        $tags['YOUR_AD_ON'] = _AM_ADSLIGHT_YOUR_AD_ON;
738
        $tags['APPROVED']   = _AM_ADSLIGHT_APPROVED;
739
740
        $subject = _AM_ADSLIGHT_ANNACCEPT;
741
        $mail    = getMailer();
742
        $mail->setTemplateDir(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . "/language/{$xoopsConfig['language']}/mail_template/");
743
        $mail->setTemplate('listing_approve.tpl');
744
        $mail->useMail();
745
        $mail->multimailer->isHTML(true);
746
        $mail->setFromName($meta['title']);
747
        $mail->setFromEmail($xoopsConfig['adminmail']);
748
        $mail->setToEmails($email);
749
        $mail->setSubject($subject);
750
        $mail->assign($tags);
751
        $mail->send();
752
        echo $mail->getErrors();
753
    }
754
755
    $tags                    = [];
756
    $tags['TITLE']           = $title;
757
    $tags['ADDED_TO_CAT']    = _AM_ADSLIGHT_ADDED_TO_CAT;
758
    $tags['RECIEVING_NOTIF'] = _AM_ADSLIGHT_RECIEVING_NOTIF;
759
    $tags['ERROR_NOTIF']     = _AM_ADSLIGHT_ERROR_NOTIF;
760
    $tags['WEBMASTER']       = _AM_ADSLIGHT_WEBMASTER;
761
    $tags['HELLO']           = _AM_ADSLIGHT_HELLO;
762
    $tags['FOLLOW_LINK']     = _AM_ADSLIGHT_FOLLOW_LINK;
763
    $tags['TYPE']            = Utility::getNameType($type);
764
    $tags['LINK_URL']        = XOOPS_URL . "/modules/adslight/viewads.php?&lid={$lid}";
765
766
    $sql                    = 'SELECT title FROM ' . $xoopsDB->prefix('adslight_categories') . " WHERE cid={$cat}";
767
    $result                 = $xoopsDB->query($sql);
768
    $row                    = $xoopsDB->fetchArray($result);
769
    $tags['CATEGORY_TITLE'] = $row['title'];
770
    $tags['CATEGORY_URL']   = XOOPS_URL . "/modules/adslight/viewcats.php?cid={$cat}";
771
    /** @var \XoopsNotificationHandler $notificationHandler */
772
    $notificationHandler = xoops_getHandler('notification');
773
    $notificationHandler->triggerEvent('global', 0, 'new_listing', $tags);
774
    $notificationHandler->triggerEvent('category', $cat, 'new_listing', $tags);
775
    $notificationHandler->triggerEvent('listing', $lid, 'new_listing', $tags);
776
777
    $helper->redirect('admin/view_ads.php', 3, _AM_ADSLIGHT_ANNVALID);
778
}
779
780
#####################################################
781
#####################################################
782
783
foreach ($_POST as $k => $v) {
784
    ${$k} = $v;
785
}
786
787
//$pa  = Request::getString('pa', '', 'GET');
788
//$lid = Request::getInt('lid', 0);
789
//$op  = Request::getString('op', '');
790
791
$pa  = Request::getInt('pa', '', 'GET');
0 ignored issues
show
Bug introduced by
'' of type string is incompatible with the type integer expected by parameter $default of Xmf\Request::getInt(). ( Ignorable by Annotation )

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

791
$pa  = Request::getInt('pa', /** @scrutinizer ignore-type */ '', 'GET');
Loading history...
792
$lid = 0;
793
if (!Request::hasVar('lid', 'POST') && Request::hasVar('lid', 'GET')) {
794
    $lid = Request::getInt('lid', 0, 'GET');
795
}
796
797
//if (!Request::hasVar('op', 'POST') && Request::hasVar('op', 'GET')) {
798
//    $op = Request::getString('op', '', 'GET');
799
//}
800
$op = Request::getString('op', '');
801
802
if (!isset($op)) {
803
    $op = '';
804
}
805
806
switch ($op) {
807
    case 'indexView':
808
        indexView($lid);
809
        break;
810
    case 'listingDel':
811
        listingDel($lid, $photo);
812
        break;
813
    case 'listingValid':
814
        listingValid(
815
            $lid,
816
            $cid,
817
            $title,
818
            $status,
819
            $expire,
820
            $type,
821
            $desctext,
822
            $tel,
823
            $price,
824
            $typeprice,
825
            $typecondition,
826
            $date_created,
827
            $email,
828
            $submitter,
829
            $town,
830
            $country,
831
            $contactby,
832
            $premium,
833
            $valid,
834
            $photo
835
        );
836
        break;
837
    case 'modifyAds':
838
        modifyAds($lid);
839
        break;
840
    case 'modifyAdsS':
841
        modifyAdsS(
842
            $lid,
843
            $cid,
844
            $title,
845
            $status,
846
            $expire,
847
            $type,
848
            $desctext,
849
            $tel,
850
            $price,
851
            $typeprice,
852
            $typecondition,
853
            $date_created,
854
            $email,
855
            $submitter,
856
            $town,
857
            $country,
858
            $contactby,
859
            $premium,
860
            $valid,
861
            $photo
862
        );
863
        break;
864
    default:
865
        index();
866
        break;
867
}
868