Passed
Push — master ( d50017...68c32a )
by Michael
02:26
created

admin/view_ads.php (1 issue)

Labels
Severity
1
<?php
2
/*
3
-------------------------------------------------------------------------
4
                     ADSLIGHT 2 : Module for Xoops
5
6
        Redesigned and ameliorate By Luc Bizet user at www.frxoops.org
7
        Started with the Classifieds module and made MANY changes
8
        Website : http://www.luc-bizet.fr
9
        Contact : [email protected]
10
-------------------------------------------------------------------------
11
             Original credits below Version History
12
##########################################################################
13
#                    Classified Module for Xoops                         #
14
#  By John Mordo user jlm69 at www.xoops.org and www.jlmzone.com         #
15
#      Started with the MyAds module and made MANY changes               #
16
##########################################################################
17
 Original Author: Pascal Le Boustouller
18
 Author Website : [email protected]
19
 Licence Type   : GPL
20
-------------------------------------------------------------------------
21
*/
22
23
use Xmf\Request;
24
use XoopsModules\Adslight;
25
26
require_once __DIR__ . '/admin_header.php';
27
28
$op = Request::getString('op', 'list');
29
30
#  function index
31
#####################################################
32
function index()
33
{
34
    global $xoopsDB, $myts, $desctext, $admin_lang;
35
36
    //    $mytree = new Adslight\ClassifiedsTree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid');
37
    $photo3 = $photo4 = '';
38
    xoops_cp_header();
39
    //    loadModuleAdminMenu(0, '');
40
41
    // photo dir setting checker
42
    $photo_dir         = $GLOBALS['xoopsModuleConfig']['adslight_path_upload'];
43
    $photo_thumb_dir   = $GLOBALS['xoopsModuleConfig']['adslight_path_upload'] . '/thumbs';
44
    $photo_resized_dir = $GLOBALS['xoopsModuleConfig']['adslight_path_upload'] . '/midsize';
45
    if (!is_dir($photo_dir)) {
46
        if (!mkdir($photo_dir) && !is_dir($photo_dir)) {
47
            throw new \RuntimeException(sprintf('Directory "%s" was not created', $photo_dir));
48
        }
49
    }
50
    if (!is_dir($photo_thumb_dir)) {
51
        if (!mkdir($photo_thumb_dir) && !is_dir($photo_thumb_dir)) {
52
            throw new \RuntimeException(sprintf('Directory "%s" was not created', $photo_thumb_dir));
53
        }
54
    }
55
    if (!is_dir($photo_resized_dir)) {
56
        if (!mkdir($photo_resized_dir) && !is_dir($photo_resized_dir)) {
57
            throw new \RuntimeException(sprintf('Directory "%s" was not created', $photo_resized_dir));
58
        }
59
    }
60
    if (!is_writable($photo_dir) || !is_readable($photo_dir)) {
61
        echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_CHECKER . '</legend><br>';
62
        echo "<span style='color: #FF0000;'><b>" . _AM_ADSLIGHT_DIRPERMS . '' . $photo_dir . "</b></span><br><br>\n";
63
        echo '</fieldset><br>';
64
    }
65
66
    if (!is_writable($photo_thumb_dir) || !is_readable($photo_thumb_dir)) {
67
        echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_CHECKER . '</legend><br>';
68
        echo "<span style='color: #FF0000;'><b>" . _AM_ADSLIGHT_DIRPERMS . '' . $photo_thumb_dir . "</b></span><br><br>\n";
69
        echo '</fieldset><br>';
70
    }
71
72
    if (!is_writable($photo_resized_dir) || !is_readable($photo_resized_dir)) {
73
        echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_CHECKER . '</legend><br>';
74
        echo "<span style='color: #FF0000;'><b>" . _AM_ADSLIGHT_DIRPERMS . '' . $photo_resized_dir . "</b></span><br><br>\n";
75
        echo '</fieldset><br>';
76
    }
77
78
    $sql  = 'SELECT lid, cid, title, status, expire, type, desctext, tel, price, typeprice, typeusure, date, email, submitter, town, country, contactby, premium, photo, usid FROM ' . $xoopsDB->prefix('adslight_listing') . " WHERE valid='Yes' ORDER BY lid";
79
    $result = $xoopsDB->query($sql);
80
    $numrows = $xoopsDB->getRowsNum($result);
81
    if ($numrows > 0) {
82
        // Il y a [..] Annonces en attente d'être approuvées //////
83
        echo "<table class='outer bnone' cellspacing=5 cellpadding=0><tr><td width=40>";
84
        echo "<img src='../assets/images/admin/error_button.png' border=0 ></td><td>";
85
        echo "<span style='color:#00B4C4;'><b>" . _AM_ADSLIGHT_THEREIS . "</b></span> <b>$numrows</b> <b><span style='color:#00B4C4;'>" . _AM_ADSLIGHT_ADSVALIDE . '</b></span>';
86
        echo '</td></tr></table><br>';
87
88
        // Liste des ID  ///// Soumis par /////  Titre   /////  Description  /////  Date d'ajout
89
        echo "<table class='outer width100 bnone'>";
90
        $rank = 1;
91
92
        while (false !== (list($lid, $cid, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $typeusure, $date, $email, $submitter, $town, $country, $contactby, $premium, $photo, $usid) = $xoopsDB->fetchRow($result))) {
93
            $title    = $myts->htmlSpecialChars($title);
94
            $desctext = $myts->displayTarea($desctext, 1, 0, 1, 1, 1);
95
96
            if (mb_strlen($desctext) >= 200) {
97
                $desctext = mb_substr($desctext, 0, 199) . '...';
98
            } else {
99
                $desctext = $myts->displayTarea($desctext, 1, 1, 1);
100
            }
101
            $date2  = formatTimestamp($date, 's');
102
            $color  = is_int($rank / 2) ? '#ffffff' : 'head';
103
            $status = $myts->htmlSpecialChars($status);
104
            $expire = $myts->htmlSpecialChars($expire);
105
            $type   = $myts->htmlSpecialChars($type);
106
            $tel    = $myts->htmlSpecialChars($tel);
107
            //            $price = number_format($price, 2, ',', ' ');
108
            $typeprice = $myts->htmlSpecialChars($typeprice);
109
            $typeusure = $myts->htmlSpecialChars($typeusure);
110
            $submitter = $myts->htmlSpecialChars($submitter);
111
            $town      = $myts->htmlSpecialChars($town);
112
            $country   = $myts->htmlSpecialChars($country);
113
            $contactby = $myts->htmlSpecialChars($contactby);
114
            $premium   = $myts->htmlSpecialChars($premium);
115
116
            $updir   = $GLOBALS['xoopsModuleConfig']['adslight_link_upload'];
117
            $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";
118
            $resultp = $xoopsDB->query($sql);
119
            while (false !== (list($cod_img, $pic_lid, $uid_owner, $url) = $xoopsDB->fetchRow($resultp))) {
120
                if ($photo) {
121
                    $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>";
122
                }
123
            }
124
            if ($photo <= 0) {
125
                $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>";
126
            } else {
127
                $photo4 = (string)$photo;
128
            }
129
130
            $result7 = $xoopsDB->query('SELECT nom_type FROM ' . $xoopsDB->prefix('adslight_type') . ' WHERE id_type=' . (int)$type);
131
            list($nom_type) = $xoopsDB->fetchRow($result7);
132
133
            $result8 = $xoopsDB->query('SELECT nom_price FROM ' . $xoopsDB->prefix('adslight_price') . ' WHERE id_price=' . (int)$typeprice);
134
            list($nom_price) = $xoopsDB->fetchRow($result8);
135
136
            echo '<form action="view_ads.php" method="post">';
137
            echo $GLOBALS['xoopsSecurity']->getTokenHTML();
138
            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>';
139
140
            echo "<tr><td class='even width3'></td>";
141
            echo "<td class='odd width10' >{$photo3}</td>";
142
            echo "<td class='even width20'><b>{$title}</b><br><br>{$nom_type}<br>{$price} " . $GLOBALS['xoopsModuleConfig']['adslight_currency_symbol'] . " $nom_price<br>";
143
            echo "$town - $country<br>";
144
            echo '<b>' . _AM_ADSLIGHT_SUBMITTER . ":</b> {$submitter}<br>";
145
            echo '<b>' . _AM_ADSLIGHT_DATE . ":</b> {$date2}</td>";
146
            echo "<td class='even width='35%'>{$desctext}</td><td class='even right width2'></td>";
147
            echo "</tr><tr><td width='5%'></td><td>";
148
149
            echo '<select name="op">
150
        <option value="modifyAds"> ' . _AM_ADSLIGHT_MODIF . '
151
        <option value="listingDel"> ' . _AM_ADSLIGHT_DEL . '
152
               </select><input type="submit" value="' . _AM_ADSLIGHT_GO . '">';
153
154
            echo '<input type="hidden" name="valid" value="Yes">';
155
            echo "<input type=\"hidden\" name=\"lid\" value=\"{$lid}\">";
156
            echo "<input type=\"hidden\" name=\"cid\" value=\"{$cid}\">";
157
            echo "<input type=\"hidden\" name=\"title\" value=\"{$title}\">";
158
            echo "<input type=\"hidden\" name=\"status\" value=\"{$status}\">";
159
            echo "<input type=\"hidden\" name=\"expire\" value=\"{$expire}\">";
160
            echo "<input type=\"hidden\" name=\"type\" value=\"{$type}\">";
161
            echo "<input type=\"hidden\" name=\"desctext\" value=\"{$desctext}\">";
162
            echo "<input type=\"hidden\" name=\"tel\" value=\"{$tel}\">";
163
            echo "<input type=\"hidden\" name=\"price\" value=\"{$price}\">";
164
            echo "<input type=\"hidden\" name=\"typeprice\" value=\"{$typeprice}\">";
165
            echo "<input type=\"hidden\" name=\"typeusure\" value=\"{$typeusure}\">";
166
            echo "<input type=\"hidden\" name=\"date\" value=\"{$date}\">";
167
            echo "<input type=\"hidden\" name=\"email\" value=\"{$email}\">";
168
            echo "<input type=\"hidden\" name=\"submitter\" value=\"{$submitter}\">";
169
            echo "<input type=\"hidden\" name=\"town\" value=\"{$town}\">";
170
            echo "<input type=\"hidden\" name=\"country\" value=\"{$country}\">";
171
            echo "<input type=\"hidden\" name=\"contactby\" value=\"{$contactby}\">";
172
            echo "<input type=\"hidden\" name=\"premium\" value=\"{$premium}\">";
173
            echo "<input type=\"hidden\" name=\"photo\" value=\"{$photo}\">";
174
            echo '</form><br></td></tr>';
175
            ++$rank;
176
        }
177
178
        echo '</td></tr></table>
179
              <br><br>';
180
    } else {
181
        echo "<table class='outer width50 bnone'><tr><td class='width40'>";
182
        echo "<img src='../assets/images/admin/search_button_green_32.png' border=0 ></td><td>";
183
        echo "<span style='color: #00B4C4;'><b>" . _AM_ADSLIGHT_NOANNVALADS . '</b></span>';
184
        echo '</td></tr></table><br>';
185
    }
186
187
    xoops_cp_footer();
188
}
189
190
#  function indexView
191
#####################################################
192
/**
193
 * @param null $lid
194
 */
195
function indexView($lid = null)
196
{
197
    global $xoopsDB, $myts, $desctext, $admin_lang;
198
199
    $mytree = new Adslight\ClassifiedsTree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid');
200
201
    require_once __DIR__ . '/admin_header.php';
202
    xoops_cp_header();
203
    //    loadModuleAdminMenu(0, '');
204
205
    $sql  = '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}'";
206
    $result = $xoopsDB->query($sql);
207
    $numrows = $xoopsDB->getRowsNum($result);
208
    if ($numrows > 0) {
209
        echo "<table class='width100' cellspacing='1' cellpadding='8' style='border: 2px solid #DFE0E0;'><tr class='bg4'><td class='top'>";
210
        echo '<b>' . _AM_ADSLIGHT_WAIT . '</b><br><br>';
211
212
        list($lid, $cid, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $typeusure, $date, $email, $submitter, $town, $country, $contactby, $premium, $photo) = $xoopsDB->fetchRow($result);
213
214
        $lid      = (int)$lid;
215
        $cid      = (int)$cid;
216
        $date2    = formatTimestamp($date, 's');
217
        $title    = $myts->htmlSpecialChars($title);
218
        $status   = $myts->htmlSpecialChars($status);
219
        $expire   = $myts->htmlSpecialChars($expire);
220
        $type     = $myts->htmlSpecialChars($type);
221
        $desctext = $myts->displayTarea($desctext, 1, 1, 1);
222
        $tel      = $myts->htmlSpecialChars($tel);
223
        //        $price = number_format($price, 2, ',', ' ');
224
        $typeprice = $myts->htmlSpecialChars($typeprice);
225
        $typeusure = $myts->htmlSpecialChars($typeusure);
226
        $submitter = $myts->htmlSpecialChars($submitter);
227
        $town      = $myts->htmlSpecialChars($town);
228
        $country   = $myts->htmlSpecialChars($country);
229
        $contactby = $myts->htmlSpecialChars($contactby);
230
        $premium   = $myts->htmlSpecialChars($premium);
231
232
        echo '<form action="index.php" method="post">';
233
        echo $GLOBALS['xoopsSecurity']->getTokenHTML();
234
        echo "<table><tr class='head' border='1'>
235
            <td>" . _AM_ADSLIGHT_NUMANN . " </td><td>{$lid} &nbsp;&nbsp;&nbsp;&nbsp;   " . _AM_ADSLIGHT_ADDED_ON . " &nbsp;&nbsp;&nbsp;&nbsp; {$date2}</td>
236
            </tr><tr class='head' border='1'>
237
        <td>" . _AM_ADSLIGHT_SENDBY . " </td><td>{$submitter}</td>
238
            </tr><tr class='head' border='1'>
239
        <td>" . _AM_ADSLIGHT_EMAIL . " </td><td><input type=\"text\" name=\"email\" size=\"40\" value=\"{$email}\"></td>
240
            </tr><tr class='head' border='1'>
241
        <td>" . _AM_ADSLIGHT_TEL . " </td><td><input type=\"text\" name=\"tel\" size=\"50\" value=\"{$tel}\"></td>
242
            </tr><tr class='head' border='1'>
243
        <td>" . _AM_ADSLIGHT_TOWN . " </td><td><input type=\"text\" name=\"town\" size=\"40\" value=\"{$town}\"></td>
244
            </tr><tr class='head' border='1'>
245
        <td>" . _AM_ADSLIGHT_COUNTRY . " </td><td><input type=\"text\" name=\"country\" size=\"40\" value=\"{$country}\"></td>
246
            </tr><tr class='head' border='1'>
247
        <td>" . _AM_ADSLIGHT_CONTACTBY . " </td><td><input type=\"text\" name=\"contactby\" size=\"40\" value=\"{$contactby}\"></td>
248
            </tr>";
249
250
        echo "<tr>
251
            <td class='head'>" . _AM_ADSLIGHT_STATUS . "</td><td class='head'><input type=\"radio\" name=\"status\" value=\"0\"";
252
        if ('0' == $status) {
253
            echo 'checked';
254
        }
255
        echo '>' . _AM_ADSLIGHT_ACTIVE . '&nbsp;&nbsp; <input type="radio" name="status" value="1"';
256
        if ('1' == $status) {
257
            echo 'checked';
258
        }
259
        echo '>' . _AM_ADSLIGHT_INACTIVE . '&nbsp;&nbsp; <input type="radio" name="status" value="2"';
260
        if ('2' == $status) {
261
            echo 'checked';
262
        }
263
        echo '>' . _AM_ADSLIGHT_SOLD . '</td></tr>';
264
265
        echo "<tr class='head' border='1'>
266
           <td>" . _AM_ADSLIGHT_TITLE2 . " </td><td><input type=\"text\" name=\"title\" size=\"40\" value=\"{$title}\"></td>
267
            </tr><tr class='head' border='1'>
268
           <td>" . _AM_ADSLIGHT_PREMIUM . " </td><td><input type=\"text\" name=\"premium\" size=\"3\" value=\"{$premium}\"></td>
269
            </tr><tr class='head' border='1'>
270
           <td>" . _AM_ADSLIGHT_EXPIRE . " </td><td><input type=\"text\" name=\"expire\" size=\"40\" value=\"{$expire}\"></td>
271
            </tr><tr class='head' border='1'>
272
            <td>" . _AM_ADSLIGHT_TYPE . ' </td><td><select name="type">';
273
274
        $result5 = $xoopsDB->query('SELECT nom_type FROM ' . $xoopsDB->prefix('adslight_type') . ' ORDER BY nom_type');
275
        while (false !== (list($nom_type) = $xoopsDB->fetchRow($result5))) {
276
            $sel = '';
277
            if ($nom_type == $type) {
278
                $sel = 'selected';
279
            }
280
            echo "<option value=\"{$nom_type}\"{$sel}>{$nom_type}</option>";
281
        }
282
283
        echo '</select></td></tr>';
284
285
        ////// Etat d'usure
286
        echo "<tr class='head' border='1'>
287
            <td>" . _AM_ADSLIGHT_TYPE_USURE . ' </td><td><select name="typeusure">';
288
289
        $result6 = $xoopsDB->query('SELECT nom_usure FROM ' . $xoopsDB->prefix('adslight_usure') . ' ORDER BY nom_usure');
290
        while (false !== (list($nom_usure) = $xoopsDB->fetchRow($result6))) {
291
            $sel = '';
292
            if ($nom_usure == $typeusure) {
293
                $sel = 'selected';
294
            }
295
            echo "<option value=\"{$nom_usure}\"{$sel}>{$nom_usure}</option>";
296
        }
297
        echo '</select></td></tr>';
298
299
        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'] . '';
300
        $result3 = $xoopsDB->query('SELECT nom_price FROM ' . $xoopsDB->prefix('adslight_price') . ' ORDER BY id_price');
301
        echo " <select name=\"typeprice\"><option value=\"{$typeprice}\">{$typeprice}</option>";
302
        while (false !== (list($nom_price) = $xoopsDB->fetchRow($result3))) {
303
            echo "<option value=\"${nom_price}\">${nom_price}</option>";
304
        }
305
        echo '</select></td></tr>';
306
307
        echo "<tr class='head' border='1'>
308
           <td>" . _AM_ADSLIGHT_PHOTO1 . " </td><td><input type=\"text\" name=\"photo\" size=\"40\" value=\"{$photo}\"></td>
309
            </tr>";
310
        echo "<tr class='head' border='1'><td>" . _AM_ADSLIGHT_DESC . '</td><td>';
311
        $wysiwyg_text_area = Adslight\Utility::getEditor(_AM_ADSLIGHT_DESC, 'desctext', $desctext, '100%', '200px', 'small');
312
        echo $wysiwyg_text_area->render();
313
        echo '</td></tr>';
314
        echo "<tr class='head' border='1'><td>" . _AM_ADSLIGHT_CAT . ' </td><td>';
315
        $mytree->makeMySelBox('title', 'title', $cid);
316
        echo "</td>
317
        </tr><tr class='head' border='1'>
318
        <td>&nbsp;</td><td><select name=\"op\">
319
        <option value=\"listingValid\"> " . _AM_ADSLIGHT_OK . '
320
        <option value="listingDel"> ' . _AM_ADSLIGHT_DEL . '
321
        </select><input type="submit" value="' . _AM_ADSLIGHT_GO . '"></td>
322
        </tr></table>';
323
        echo '<input type="hidden" name="valid" value="Yes">';
324
        echo "<input type=\"hidden\" name=\"lid\" value=\"{$lid}\">";
325
        echo "<input type=\"hidden\" name=\"date\" value=\"{$date}\">";
326
        echo "<input type=\"hidden\" name=\"submitter\" value=\"{$submitter}\">
327
            </form>";
328
329
        echo '</td></tr></table>';
330
        echo '<br>';
331
    }
332
333
    require_once __DIR__ . '/admin_footer.php';
334
}
335
336
#  function modifyAds
337
#####################################################
338
/**
339
 * @param $lid
340
 */
341
function modifyAds($lid)
342
{
343
    global $xoopsDB, $myts, $desctext, $admin_lang;
344
345
    $mytree = new Adslight\ClassifiedsTree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid');
346
347
//    require_once __DIR__ . '/admin_header.php';
348
    xoops_cp_header();
349
    //    loadModuleAdminMenu(0, '');
350
351
    $lid           = (int)$lid;
352
    $id_price      = '';
353
    $nom_price     = '';
354
    $contactselect = '';
355
356
    echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_MODANN . '</legend>';
357
358
    $sql = '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}";
359
    $result = $xoopsDB->query($sql);
360
361
    while (false !== (list($lid, $cid, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $typeusure, $date, $email, $submitter, $town, $country, $contactby, $premium, $valid, $photo) = $xoopsDB->fetchRow($result))) {
362
        $title = $myts->htmlSpecialChars($title);
363
        //        $status    = $myts->htmlSpecialChars($status);
364
        $status   = (int)$status;
365
        $expire   = $myts->htmlSpecialChars($expire);
366
        $type     = $myts->htmlSpecialChars($type);
367
        $desctext = $myts->displayTarea($desctext, 1, 1, 1);
368
        $tel      = $myts->htmlSpecialChars($tel);
369
        //        $price     = number_format($price, 2, ',', ' ');
370
        $typeprice = $myts->htmlSpecialChars($typeprice);
371
        $typeusure = $myts->htmlSpecialChars($typeusure);
372
        $submitter = $myts->htmlSpecialChars($submitter);
373
        $town      = $myts->htmlSpecialChars($town);
374
        $country   = $myts->htmlSpecialChars($country);
375
        $contactby = $myts->htmlSpecialChars($contactby);
376
        $premium   = $myts->htmlSpecialChars($premium);
377
378
        $date2 = formatTimestamp($date, 's');
379
380
        echo '<form action="view_ads.php" method="post">';
381
        echo $GLOBALS['xoopsSecurity']->getTokenHTML();
382
        echo "<table border=0><tr class='head' border='1'>
383
           <td>" . _AM_ADSLIGHT_NUMANN . " </td><td>{$lid} &nbsp;" . _AM_ADSLIGHT_ADDED_ON . "&nbsp; {$date2}</td>
384
            </tr><tr class='head' border='1'>
385
           <td>" . _AM_ADSLIGHT_SENDBY . " </td><td>{$submitter}</td>
386
            </tr><tr class='head' border='1'>
387
           <td>" . _AM_ADSLIGHT_EMAIL . " </td><td><input type=\"text\" name=\"email\" size=\"40\" value=\"{$email}\"></td>
388
            </tr><tr class='head' border='1'>
389
           <td>" . _AM_ADSLIGHT_TEL . " </td><td><input type=\"text\" name=\"tel\" size=\"50\" value=\"{$tel}\"></td>
390
            </tr><tr class='head' border='1'>
391
           <td>" . _AM_ADSLIGHT_TOWN . " </td><td><input type=\"text\" name=\"town\" size=\"40\" value=\"{$town}\"></td>
392
            </tr><tr class='head' border='1'>
393
           <td>" . _AM_ADSLIGHT_COUNTRY . " </td><td><input type=\"text\" name=\"country\" size=\"40\" value=\"{$country}\"></td>
394
            </tr>
395
            <tr class='head' border='1'>";
396
397
        $contactSel1 = $contactSel2 = $contactSel3 = $contactSel4 = '';
398
        $selected    = 'contactSel' . (int)$contactby;
399
        $$selected   = ' selected';
400
401
        echo " <td class='head'>"
402
             . _AM_ADSLIGHT_CONTACTBY
403
             . " </td><td class='head'><select name=\"contactby\">\n"
404
             //           . "  <option value=\"{$contactby}\">{$contactselect}</option>\n"
405
             . "  <option value=\"1\"{$contactSel1}>"
406
             . _AM_ADSLIGHT_CONTACT_BY_EMAIL
407
             . "</option>\n"
408
             . "  <option value=\"2\"{$contactSel2}>"
409
             . _AM_ADSLIGHT_CONTACT_BY_PM
410
             . "</option>\n"
411
             . "  <option value=\"3\"{$contactSel3}>"
412
             . _AM_ADSLIGHT_CONTACT_BY_BOTH
413
             . "</option>\n"
414
             . "  <option value=\"4\"{$contactSel4}>"
415
             . _AM_ADSLIGHT_CONTACT_BY_PHONE
416
             . "</option></select>\n"
417
             . " </td>\n"
418
             . '</tr>';
419
420
        echo "<tr><td class='head'>" . _AM_ADSLIGHT_STATUS . "</td><td class='head'><input type=\"radio\" name=\"status\" value=\"0\"";
421
        if ('0' == $status) {
422
            echo 'checked';
423
        }
424
        echo '>' . _AM_ADSLIGHT_ACTIVE . '&nbsp;&nbsp; <input type="radio" name="status" value="1"';
425
        if ('1' == $status) {
426
            echo 'checked';
427
        }
428
        echo '>' . _AM_ADSLIGHT_INACTIVE . '&nbsp;&nbsp; <input type="radio" name="status" value="2"';
429
        if ('2' == $status) {
430
            echo 'checked';
431
        }
432
        echo '>' . _AM_ADSLIGHT_SOLD . '</td></tr>';
433
434
        echo "<tr class='head' border='1'>
435
           <td>" . _AM_ADSLIGHT_TITLE2 . " </td><td><input type=\"text\" name=\"title\" size=\"40\" value=\"{$title}\"></td>
436
            </tr><tr class='head' border='1'>
437
           <td>" . _AM_ADSLIGHT_PREMIUM . " </td><td><input type=\"text\" name=\"premium\" size=\"3\" value=\"{$premium}\"></td>
438
            </tr><tr class='head' border='1'>
439
           <td>" . _AM_ADSLIGHT_EXPIRE . " </td><td><input type=\"text\" name=\"expire\" size=\"40\" value=\"{$expire}\"></td>
440
            </tr>";
441
        // Type d'annonce
442
        echo "<tr class='head' border='1'>
443
            <td>" . _AM_ADSLIGHT_TYPE . ' </td><td><select name="type">';
444
445
        $result5 = $xoopsDB->query('SELECT nom_type, id_type FROM ' . $xoopsDB->prefix('adslight_type') . ' ORDER BY nom_type');
446
        while (false !== (list($nom_type, $id_type) = $xoopsDB->fetchRow($result5))) {
447
            $sel = '';
448
            if ($id_type == $type) {
449
                $sel = 'selected';
450
            }
451
            echo "<option value=\"{$id_type}\"{$sel}>{$nom_type}</option>";
452
        }
453
        echo '</select></td></tr>';
454
455
        // Etat d'usure
456
        echo "<tr class='head' border='1'>
457
            <td>" . _AM_ADSLIGHT_TYPE_USURE . ' </td><td><select name="typeusure">';
458
459
        $result6 = $xoopsDB->query('SELECT nom_usure, id_usure FROM ' . $xoopsDB->prefix('adslight_usure') . ' ORDER BY nom_usure');
460
        while (false !== (list($nom_usure, $id_usure) = $xoopsDB->fetchRow($result6))) {
461
            $sel = '';
462
            if ($id_usure == $typeusure) {
463
                $sel = 'selected';
464
            }
465
            echo "<option value=\"{$id_usure}\"{$sel}>{$nom_usure}</option>";
466
        }
467
        echo '</select></td></tr>';
468
469
        /////// Price
470
        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']}";
471
472
        // Price type
473
        $resultx = $xoopsDB->query('SELECT nom_price, id_price FROM ' . $xoopsDB->prefix('adslight_price') . ' ORDER BY nom_price');
474
475
        echo " <select name=\"typeprice\"><option value=\"{$id_price}\">{$nom_price}</option>";
476
        while (false !== (list($nom_price, $id_price) = $xoopsDB->fetchRow($resultx))) {
477
            $sel = '';
478
            if ($id_price == $typeprice) {
479
                $sel = 'selected';
480
            }
481
482
            echo "<option value=\"{$id_price}\"{$sel}>{$nom_price}</option>";
483
        }
484
        echo '</select></td>';
485
486
        // Category
487
        echo "<tr class='head' border='1'>
488
            <td>" . _AM_ADSLIGHT_CAT2 . ' </td><td>';
489
        $mytree->makeMySelBox('title', 'title', $cid);
490
        echo "</td>
491
            </tr><tr class='head' border='1'>
492
            <td>" . _AM_ADSLIGHT_DESC . ' </td><td>';
493
494
        $wysiwyg_text_area = Adslight\Utility::getEditor('', 'desctext', $desctext, '100%', '200px', 'small');
495
        echo $wysiwyg_text_area->render();
496
497
        echo '</td></tr>';
498
499
        echo "<tr class='head' border='1'>
500
            <td>" . _AM_ADSLIGHT_PHOTO1 . " </td><td><input type=\"text\" name=\"photo\" size=\"50\" value=\"{$photo}\"></td>
501
            </tr><tr>";
502
        $time = time();
503
        echo "</tr><tr class='head' border='1'>
504
            <td>&nbsp;</td><td><select name=\"op\">
505
            <option value=\"modifyAdsS\"> " . _AM_ADSLIGHT_MODIF . '
506
            <option value="listingDel"> ' . _AM_ADSLIGHT_DEL . '
507
            </select><input type="submit" value="' . _AM_ADSLIGHT_GO . '"></td>
508
            </tr></table>';
509
        echo '<input type="hidden" name="valid" value="Yes">';
510
        echo "<input type=\"hidden\" name=\"lid\" value=\"{$lid}\">";
511
        echo "<input type=\"hidden\" name=\"date\" value=\"{$time}\">";
512
        echo "<input type=\"hidden\" name=\"submitter\" value=\"{$submitter}\">
513
              </form><br>";
514
        echo '</fieldset><br>';
515
        xoops_cp_footer();
516
    }
517
}
518
519
#  function modifyAdsS
520
#####################################################
521
522
/**
523
 * @param $lid
524
 * @param $cat
525
 * @param $title
526
 * @param $status
527
 * @param $expire
528
 * @param $type
529
 * @param $desctext
530
 * @param $tel
531
 * @param $price
532
 * @param $typeprice
533
 * @param $typeusure
534
 * @param $date
535
 * @param $email
536
 * @param $submitter
537
 * @param $town
538
 * @param $country
539
 * @param $contactby
540
 * @param $premium
541
 * @param $valid
542
 * @param $photo
543
 */
544
function modifyAdsS($lid, $cat, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $typeusure, $date, $email, $submitter, $town, $country, $contactby, $premium, $valid, $photo)
545
{
546
    global $xoopsDB, $myts, $admin_lang;
547
548
    $lid   = (int)$lid;
549
    $cat   = (int)$cat;
550
    $title = $myts->htmlSpecialChars($title);
551
    //    $status    = $myts->htmlSpecialChars($status);
552
    $status    = (int)$status;
553
    $expire    = $myts->htmlSpecialChars($expire);
554
    $type      = $myts->htmlSpecialChars($type);
555
    $desctext  = $myts->displayTarea($desctext, 1, 1, 1);
556
    $tel       = $myts->htmlSpecialChars($tel);
557
    $price     = str_replace([' '], '', $price);
558
    $typeprice = $myts->htmlSpecialChars($typeprice);
559
    $typeusure = $myts->htmlSpecialChars($typeusure);
560
    $submitter = $myts->htmlSpecialChars($submitter);
561
    $town      = $myts->htmlSpecialChars($town);
562
    $country   = $myts->htmlSpecialChars($country);
563
    $contactby = $myts->htmlSpecialChars($contactby);
564
    $premium   = $myts->htmlSpecialChars($premium);
565
566
    $xoopsDB->query('UPDATE '
567
                    . $xoopsDB->prefix('adslight_listing')
568
                    . " 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}");
569
570
    redirect_header('view_ads.php', 1, _AM_ADSLIGHT_ANNMOD);
571
}
572
573
#  function listingDel
574
#####################################################
575
/**
576
 * @param $lid
577
 * @param $photo
578
 */
579
function listingDel($lid, $photo)
580
{
581
    global $xoopsDB, $admin_lang;
582
583
    $lid     = (int)$lid;
584
    $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}");
585
586
    while (false !== (list($purl) = $xoopsDB->fetchRow($result2))) {
587
        if ($purl) {
588
            $destination = XOOPS_ROOT_PATH . '/uploads/adslight';
589
            if (file_exists("$destination/$purl")) {
590
                unlink("$destination/$purl");
591
            }
592
            $destination2 = XOOPS_ROOT_PATH . '/uploads/adslight/thumbs';
593
            if (file_exists("$destination2/thumb_$purl")) {
594
                unlink("$destination2/thumb_$purl");
595
            }
596
            $destination3 = XOOPS_ROOT_PATH . '/uploads/adslight/midsize';
597
            if (file_exists("$destination3/resized_$purl")) {
598
                unlink("$destination3/resized_$purl");
599
            }
600
            $xoopsDB->query('DELETE FROM ' . $xoopsDB->prefix('adslight_pictures') . " WHERE lid={$lid}");
601
        }
602
    }
603
604
    $xoopsDB->query('DELETE FROM ' . $xoopsDB->prefix('adslight_listing') . " WHERE lid={$lid}");
605
    redirect_header('view_ads.php', 1, _AM_ADSLIGHT_ANNDEL);
606
}
607
608
#  function listingValid
609
#####################################################
610
/**
611
 * @param $lid
612
 * @param $cat
613
 * @param $title
614
 * @param $status
615
 * @param $expire
616
 * @param $type
617
 * @param $desctext
618
 * @param $tel
619
 * @param $price
620
 * @param $typeprice
621
 * @param $typeusure
622
 * @param $date
623
 * @param $email
624
 * @param $submitter
625
 * @param $town
626
 * @param $country
627
 * @param $contactby
628
 * @param $premium
629
 * @param $valid
630
 * @param $photo
631
 */
632
function listingValid($lid, $cat, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $typeusure, $date, $email, $submitter, $town, $country, $contactby, $premium, $valid, $photo)
633
{
634
    global $xoopsDB, $xoopsConfig, $xoopsModule, $myts, $meta, $admin_lang;
635
636
    $lid       = (int)$lid;
637
    $cid       = (int)$cid;
638
    $title     = $myts->htmlSpecialChars($title);
639
    $status    = (int)$status;
640
    $expire    = $myts->htmlSpecialChars($expire);
641
    $type      = $myts->htmlSpecialChars($type);
642
    $desctext  = $myts->displayTarea($desctext, 1, 1, 1);
643
    $tel       = $myts->htmlSpecialChars($tel);
644
    $price     = str_replace([' '], '', $price);
645
    $typeprice = $myts->htmlSpecialChars($typeprice);
646
    $typeusure = $myts->htmlSpecialChars($typeusure);
647
    $submitter = $myts->htmlSpecialChars($submitter);
648
    $town      = $myts->htmlSpecialChars($town);
649
    $country   = $myts->htmlSpecialChars($country);
650
    $contactby = $myts->htmlSpecialChars($contactby);
651
    $premium   = $myts->htmlSpecialChars($premium);
652
    $valid     = $myts->htmlSpecialChars($valid);
653
    $photo     = $myts->htmlSpecialChars($photo);
654
    $now       = time();
655
    $xoopsDB->query('UPDATE '
656
                    . $xoopsDB->prefix('adslight_listing')
657
                    . " 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}");
658
659
    if ('' != $email) {
660
        $tags               = [];
661
        $tags['TITLE']      = $title;
662
        $tags['TYPE']       = Adslight\Utility::getNameType($type);
663
        $tags['SUBMITTER']  = $submitter;
664
        $tags['DESCTEXT']   = stripslashes($desctext);
665
        $tags['EMAIL']      = _AM_ADSLIGHT_EMAIL;
666
        $tags['TEL']        = _AM_ADSLIGHT_TEL;
667
        $tags['HELLO']      = _AM_ADSLIGHT_HELLO;
668
        $tags['VEDIT_AD']   = _AM_ADSLIGHT_VEDIT_AD;
669
        $tags['ANNACCEPT']  = _AM_ADSLIGHT_ANNACCEPT;
670
        $tags['CONSULTTO']  = _AM_ADSLIGHT_CONSULTTO;
671
        $tags['THANKS']     = _ADSLIGHT_THANKS;
672
        $tags['TEAMOF']     = _AM_ADSLIGHT_TEAMOF;
673
        $tags['META_TITLE'] = $meta['title'];
674
        $tags['LINK_URL']   = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/viewads.php?lid={$lid}";
675
        $tags['YOUR_AD']    = _AM_ADSLIGHT_YOUR_AD;
676
        $tags['WEBMASTER']  = _AM_ADSLIGHT_WEBMASTER;
677
        $tags['YOUR_AD_ON'] = _AM_ADSLIGHT_YOUR_AD_ON;
678
        $tags['APPROVED']   = _AM_ADSLIGHT_APPROVED;
679
680
        $subject = _AM_ADSLIGHT_ANNACCEPT;
681
        $mail    = &getMailer();
682
        $mail->setTemplateDir(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . "/language/{$xoopsConfig['language']}/mail_template/");
683
        $mail->setTemplate('listing_approve.tpl');
684
        $mail->useMail();
685
        $mail->multimailer->isHTML(true);
686
        $mail->setFromName($meta['title']);
687
        $mail->setFromEmail($xoopsConfig['adminmail']);
688
        $mail->setToEmails($email);
689
        $mail->setSubject($subject);
690
        $mail->assign($tags);
691
        $mail->send();
692
        echo $mail->getErrors();
693
    }
694
695
    $tags                    = [];
696
    $tags['TITLE']           = $title;
697
    $tags['ADDED_TO_CAT']    = _AM_ADSLIGHT_ADDED_TO_CAT;
698
    $tags['RECIEVING_NOTIF'] = _AM_ADSLIGHT_RECIEVING_NOTIF;
699
    $tags['ERROR_NOTIF']     = _AM_ADSLIGHT_ERROR_NOTIF;
700
    $tags['WEBMASTER']       = _AM_ADSLIGHT_WEBMASTER;
701
    $tags['HELLO']           = _AM_ADSLIGHT_HELLO;
702
    $tags['FOLLOW_LINK']     = _AM_ADSLIGHT_FOLLOW_LINK;
703
    $tags['TYPE']            = Adslight\Utility::getNameType($type);
704
    $tags['LINK_URL']        = XOOPS_URL . "/modules/adslight/viewads.php?&lid={$lid}";
705
706
    $sql                    = 'SELECT title FROM ' . $xoopsDB->prefix('adslight_categories') . " WHERE cid={$cat}";
707
    $result                 = $xoopsDB->query($sql);
708
    $row                    = $xoopsDB->fetchArray($result);
709
    $tags['CATEGORY_TITLE'] = $row['title'];
710
    $tags['CATEGORY_URL']   = XOOPS_URL . "/modules/adslight/viewcats.php?cid={$cat}";
711
    /** @var \XoopsNotificationHandler $notificationHandler */
712
    $notificationHandler = xoops_getHandler('notification');
713
    $notificationHandler->triggerEvent('global', 0, 'new_listing', $tags);
714
    $notificationHandler->triggerEvent('category', $cat, 'new_listing', $tags);
715
    $notificationHandler->triggerEvent('listing', $lid, 'new_listing', $tags);
716
717
    redirect_header('view_ads.php', 3, _AM_ADSLIGHT_ANNVALID);
718
}
719
720
#####################################################
721
#####################################################
722
723
foreach ($_POST as $k => $v) {
724
    ${$k} = $v;
725
}
726
727
//$pa  = Request::getString('pa', '', 'GET');
728
//$lid = Request::getInt('lid', 0);
729
//$op  = Request::getString('op', '');
730
731
$pa  = Request::getInt('pa', '', 'GET');
0 ignored issues
show
'' 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

731
$pa  = Request::getInt('pa', /** @scrutinizer ignore-type */ '', 'GET');
Loading history...
732
$lid = 0;
733
if (!Request::hasVar('lid', 'POST') && Request::hasVar('lid', 'GET')) {
734
    $lid = Request::getInt('lid', 0, 'GET');
735
}
736
737
//if (!Request::hasVar('op', 'POST') && Request::hasVar('op', 'GET')) {
738
//    $op = Request::getString('op', '', 'GET');
739
//}
740
$op = Request::getString('op', '');
741
742
if (!isset($op)) {
743
    $op = '';
744
}
745
746
switch ($op) {
747
    case 'indexView':
748
        indexView($lid);
749
        break;
750
    case 'listingDel':
751
        listingDel($lid, $photo);
752
        break;
753
    case 'listingValid':
754
        listingValid($lid, $cid, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $typeusure, $date, $email, $submitter, $town, $country, $contactby, $premium, $valid, $photo);
755
        break;
756
    case 'modifyAds':
757
        modifyAds($lid);
758
        break;
759
    case 'modifyAdsS':
760
        modifyAdsS($lid, $cid, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $typeusure, $date, $email, $submitter, $town, $country, $contactby, $premium, $valid, $photo);
761
        break;
762
    default:
763
        index();
764
        break;
765
}
766