Completed
Push — master ( 923121...f83415 )
by Michael
02:52
created

admin/view_ads.php (6 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
include_once __DIR__ . '/admin_header.php';
24
25
$op = XoopsRequest::getInt('op', 'liste');
26
27
#  function Index
28
#####################################################
29
function Index()
30
{
31
    global $xoopsDB, $xoopsConfig, $xoopsModule, $xoopsModuleConfig, $myts, $desctext, $moduleDirName, $admin_lang;
1 ignored issue
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
32
33
    //  $mytree = new ClassifiedsTree($xoopsDB->prefix("adslight_categories"),"cid","pid");
34
35
    include_once __DIR__ . '/header.php';
36
    xoops_cp_header();
37
    //    loadModuleAdminMenu(0, "");
38
39
    // photo dir setting checker
40
    $photo_dir         = $xoopsModuleConfig['adslight_path_upload'];
41
    $photo_thumb_dir   = $xoopsModuleConfig['adslight_path_upload'] . '/thumbs';
42
    $photo_resized_dir = $xoopsModuleConfig['adslight_path_upload'] . '/midsize';
43
    if (!is_dir($photo_dir)) {
44
        mkdir($photo_dir);
45
    }
46
    if (!is_dir($photo_thumb_dir)) {
47
        mkdir($photo_thumb_dir);
48
    }
49
    if (!is_dir($photo_resized_dir)) {
50
        mkdir($photo_resized_dir);
51
    }
52 View Code Duplication
    if (!is_writable($photo_dir) || !is_readable($photo_dir)) {
53
        echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_CHECKER . '</legend><br>';
54
        echo "<font color='#FF0000'><b>" . _AM_ADSLIGHT_DIRPERMS . '' . $photo_dir . "</b></font><br><br>\n";
55
        echo '</fieldset><br>';
56
    }
57
58 View Code Duplication
    if (!is_writable($photo_thumb_dir) || !is_readable($photo_thumb_dir)) {
59
        echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_CHECKER . '</legend><br>';
60
        echo "<font color='#FF0000'><b>" . _AM_ADSLIGHT_DIRPERMS . '' . $photo_thumb_dir . "</b></font><br><br>\n";
61
        echo '</fieldset><br>';
62
    }
63
64 View Code Duplication
    if (!is_writable($photo_resized_dir) || !is_readable($photo_resized_dir)) {
65
        echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_CHECKER . '</legend><br>';
66
        echo "<font color='#FF0000'><b>" . _AM_ADSLIGHT_DIRPERMS . '' . $photo_resized_dir . "</b></font><br><br>\n";
67
        echo '</fieldset><br>';
68
    }
69
70
    $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 '
71
                               . $xoopsDB->prefix('adslight_listing')
72
                               . " WHERE valid='Yes' ORDER BY lid");
73
    $numrows = $xoopsDB->getRowsNum($result);
74
    if ($numrows > 0) {
75
76
        // Il y a [..] Annonces en attente d'être approuvées //////
77
        echo "<table class='outer' border=0 cellspacing=5 cellpadding=0><tr><td width=40>";
78
        echo "<img src='../assets/images/admin/error_button.png' border=0 /></td><td>";
79
        echo "<font color=\"#00B4C4\"><b>" . _AM_ADSLIGHT_THEREIS . "</b></font> <b>$numrows</b> <b><font color=\"#00B4C4\">" . _AM_ADSLIGHT_ADSVALIDE . '</b></font>';
80
        echo '</td></tr></table><br>';
81
82
        // Liste des ID  ///// Soumis par /////  Titre   /////  Description  /////  Date d'ajout
83
        echo "<table width='100%' border='0' class='outer'>";
84
        $rank = 1;
85
86
        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)) {
87
            $title    = $myts->htmlSpecialChars($title);
88
            $desctext = $myts->displayTarea($desctext, 1, 0, 1, 1, 1);
89
90 View Code Duplication
            if (strlen($desctext) >= 200) {
91
                $desctext = substr($desctext, 0, 199) . '...';
92
            } else {
93
                $desctext = $myts->displayTarea($desctext, 1, 1, 1);
94
            }
95
            $date2 = formatTimestamp($date, 's');
96
97
            if (is_int($rank / 2)) {
98
                $color = '#ffffff';
99
            } else {
100
                $color = 'head';
101
            }
102
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   = $xoopsModuleConfig['adslight_link_upload'];
117
            $sql     = 'SELECT cod_img, lid, uid_owner, url FROM '
118
                       . $xoopsDB->prefix('adslight_pictures')
119
                       . ' WHERE  uid_owner='
120
                       . $xoopsDB->escape($usid)
121
                       . ' AND lid='
122
                       . $xoopsDB->escape($lid)
123
                       . ' ORDER BY date_added ASC LIMIT 1';
124
            $resultp = $xoopsDB->query($sql);
125 View Code Duplication
            while (list($cod_img, $pic_lid, $uid_owner, $url) = $xoopsDB->fetchRow($resultp)) {
126
                if ($photo) {
127
                    $photo3 = "<a href='"
128
                              . XOOPS_URL
129
                              . '/modules/adslight/viewads.php?lid='
130
                              . $lid
131
                              . "'><img class=\"thumb\" src=\"$updir/thumbs/thumb_$url\" align=\"left\" width=\"100px\" alt=\"$title\"></a>";
132
                }
133
            }
134
            if ($photo > 0) {
135
            } else {
136
                $photo3 = "<a href=\"index.php?op=IndexView&lid=$lid\"><img class=\"thumb\" src=\""
137
                          . XOOPS_URL
138
                          . "/modules/adslight/assets/images/nophoto.jpg\" align=\"left\" width=\"100px\" alt=\"$title\"></a>";
139
            }
140
141
            if ($photo > 0) {
142
                $photo4 = "$photo";
143
            } else {
144
                $photo4 = '0';
145
            }
146
147
            $result7 = $xoopsDB->query('SELECT nom_type FROM ' . $xoopsDB->prefix('adslight_type') . ' WHERE id_type=' . $xoopsDB->escape($type) . '');
148
            list($nom_type) = $xoopsDB->fetchRow($result7);
149
150
            $result8 = $xoopsDB->query('SELECT nom_price FROM ' . $xoopsDB->prefix('adslight_price') . ' WHERE id_price=' . $xoopsDB->escape($typeprice) . '');
151
            list($nom_price) = $xoopsDB->fetchRow($result8);
152
153
            echo "<form action=\"view_ads.php\" method=\"post\">";
154
            echo "<tr><th align='left'>"
155
                 . _AM_ADSLIGHT_LID
156
                 . ": $lid</th><th align='left'>$photo4 "
157
                 . _AM_ADSLIGHT_NBR_PHOTO
158
                 . "</th><th align='left'>"
159
                 . _AM_ADSLIGHT_TITLE
160
                 . ":</th><th align='left'>"
161
                 . _AM_ADSLIGHT_DESC
162
                 . "</th><th align='left'><!--"
163
                 . _AM_ADSLIGHT_ACTIONS
164
                 . '--></th></tr>';
165
166
            echo "<tr><td class='even' width='3%'></td>";
167
            echo "<td class='odd' width='10%' >$photo3</td>";
168
            echo "<td class='even' width='20%'><b>$title</b><br><br>$nom_type<br>$price " . $xoopsModuleConfig['adslight_money'] . " $nom_price<br>";
169
            echo "$town - $country<br>";
170
            echo '<b>' . _AM_ADSLIGHT_SUBMITTER . ":</b> $submitter<br>";
171
            echo '<b>' . _AM_ADSLIGHT_DATE . ":</b> $date2</td>";
172
            echo "<td class='even' width='35%'>$desctext</td><td class='even' width='2%' align=right></td>";
173
            echo "</tr><tr><td width='5%'></td><td>";
174
175
            echo "<select name=\"op\">
176
        <option value=\"ModifyAds\"> " . _AM_ADSLIGHT_MODIF . "
177
        <option value=\"ListingDel\"> " . _AM_ADSLIGHT_DEL . "
178
        </select><input type=\"submit\" value=\"" . _AM_ADSLIGHT_GO . "\">";
179
180
            echo "<input type=\"hidden\" name=\"valid\" value=\"Yes\">";
181
            echo "<input type=\"hidden\" name=\"lid\" value=\"$lid\">";
182
            echo "<input type=\"hidden\" name=\"cid\" value=\"$cid\">";
183
            echo "<input type=\"hidden\" name=\"title\" value=\"$title\">";
184
            echo "<input type=\"hidden\" name=\"status\" value=\"$status\">";
185
            echo "<input type=\"hidden\" name=\"expire\" value=\"$expire\">";
186
            echo "<input type=\"hidden\" name=\"type\" value=\"$type\">";
187
            echo "<input type=\"hidden\" name=\"desctext\" value=\"$desctext\">";
188
            echo "<input type=\"hidden\" name=\"tel\" value=\"$tel\">";
189
            echo "<input type=\"hidden\" name=\"price\" value=\"$price\">";
190
            echo "<input type=\"hidden\" name=\"typeprice\" value=\"$typeprice\">";
191
            echo "<input type=\"hidden\" name=\"typeusure\" value=\"$typeusure\">";
192
            echo "<input type=\"hidden\" name=\"date\" value=\"$date\">";
193
            echo "<input type=\"hidden\" name=\"email\" value=\"$email\">";
194
            echo "<input type=\"hidden\" name=\"submitter\" value=\"$submitter\">";
195
            echo "<input type=\"hidden\" name=\"town\" value=\"$town\">";
196
            echo "<input type=\"hidden\" name=\"country\" value=\"$country\">";
197
            echo "<input type=\"hidden\" name=\"contactby\" value=\"$contactby\">";
198
            echo "<input type=\"hidden\" name=\"premium\" value=\"$premium\">";
199
            echo "<input type=\"hidden\" name=\"photo\" value=\"$photo\">";
200
            echo '</form><br></td></tr>';
201
            ++$rank;
202
        }
203
204
        echo '</td></tr></table>
205
              <br><br>';
206
    } else {
207
        echo "<table class='outer' width='50%' border='0'><tr><td width=40>";
208
        echo "<img src='../assets/images/admin/search_button_green_32.png' border=0 /></td><td>";
209
        echo "<font color='#00B4C4'><b>" . _AM_ADSLIGHT_NOANNVALADS . '</b></font>';
210
        echo '</td></tr></table><br>';
211
    }
212
213
    xoops_cp_footer();
214
}
215
216
#  function IndexView
217
#####################################################
218
/**
219
 * @param $lid
220
 */
221
function IndexView($lid)
222
{
223
    global $xoopsDB, $xoopsModule, $xoopsConfig, $xoopsModuleConfig, $myts, $desctext, $moduleDirName, $admin_lang;
224
225
    $mytree = new ClassifiedsTree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid');
226
227
    include_once __DIR__ . '/header.php';
228
    xoops_cp_header();
229
    //    loadModuleAdminMenu(0, "");
230
231
    $result  = $xoopsDB->query('SELECT lid, cid, title, status, expire, type, desctext, tel, price, typeprice, typeusure, date, email, submitter, town, country, contactby, premium, photo FROM '
232
                               . $xoopsDB->prefix('adslight_listing')
233
                               . " WHERE valid='No' AND lid='$lid'");
234
    $numrows = $xoopsDB->getRowsNum($result);
235
    if ($numrows > 0) {
236
        echo "<table width='100%' border='0' cellspacing='1' cellpadding='8' style='border: 2px solid #DFE0E0;'><tr class='bg4'><td valign='top'>";
237
        echo '<b>' . _AM_ADSLIGHT_WAIT . '</b><br><br>';
238
239
        list($lid, $cid, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $typeusure, $date, $email, $submitter, $town, $country, $contactby, $premium, $photo) = $xoopsDB->fetchRow($result);
240
241
        $date2    = formatTimestamp($date, 's');
242
        $title    = $myts->htmlSpecialChars($title);
243
        $status   = $myts->htmlSpecialChars($status);
244
        $expire   = $myts->htmlSpecialChars($expire);
245
        $type     = $myts->htmlSpecialChars($type);
246
        $desctext = $myts->displayTarea($desctext, 1, 1, 1);
247
        $tel      = $myts->htmlSpecialChars($tel);
248
        //      $price = number_format($price, 2, ",", " ");
249
        $typeprice = $myts->htmlSpecialChars($typeprice);
250
        $typeusure = $myts->htmlSpecialChars($typeusure);
251
        $submitter = $myts->htmlSpecialChars($submitter);
252
        $town      = $myts->htmlSpecialChars($town);
253
        $country   = $myts->htmlSpecialChars($country);
254
        $contactby = $myts->htmlSpecialChars($contactby);
255
        $premium   = $myts->htmlSpecialChars($premium);
256
257
        echo "<form action=\"index.php\" method=\"post\">
258
            <table><tr class='head' border='1'>
259
            <td>" . _AM_ADSLIGHT_NUMANN . " </td><td>$lid &nbsp;&nbsp;&nbsp;&nbsp;   " . _AM_ADSLIGHT_ADDED_ON . " &nbsp;&nbsp;&nbsp;&nbsp; $date2</td>
260
            </tr><tr class='head' border='1'>
261
            <td>" . _AM_ADSLIGHT_SENDBY . " </td><td>$submitter</td>
262
            </tr><tr class='head' border='1'>
263
            <td>" . _AM_ADSLIGHT_EMAIL . " </td><td><input type=\"text\" name=\"email\" size=\"40\" value=\"$email\"></td>
264
            </tr><tr class='head' border='1'>
265
            <td>" . _AM_ADSLIGHT_TEL . " </td><td><input type=\"text\" name=\"tel\" size=\"50\" value=\"$tel\"></td>
266
            </tr><tr class='head' border='1'>
267
            <td>" . _AM_ADSLIGHT_TOWN . " </td><td><input type=\"text\" name=\"town\" size=\"40\" value=\"$town\"></td>
268
            </tr><tr class='head' border='1'>
269
            <td>" . _AM_ADSLIGHT_COUNTRY . " </td><td><input type=\"text\" name=\"country\" size=\"40\" value=\"$country\"></td>
270
            </tr><tr class='head' border='1'>
271
            <td>" . _AM_ADSLIGHT_CONTACTBY . " </td><td><input type=\"text\" name=\"contactby\" size=\"40\" value=\"$contactby\"></td>
272
            </tr>";
273
274
        echo "<tr>
275
            <td class='head'>" . _AM_ADSLIGHT_STATUS . "</td><td class='head'><input type=\"radio\" name=\"status\" value=\"0\"";
276
        if ($status == '0') {
277
            echo 'checked';
278
        }
279
        echo '>' . _AM_ADSLIGHT_ACTIVE . "&nbsp;&nbsp; <input type=\"radio\" name=\"status\" value=\"1\"";
280
        if ($status == '1') {
281
            echo 'checked';
282
        }
283
        echo '>' . _AM_ADSLIGHT_INACTIVE . "&nbsp;&nbsp; <input type=\"radio\" name=\"status\" value=\"2\"";
284
        if ($status == '2') {
285
            echo 'checked';
286
        }
287
        echo '>' . _AM_ADSLIGHT_SOLD . '</td></tr>';
288
289
        echo "<tr class='head' border='1'>
290
            <td>" . _AM_ADSLIGHT_TITLE2 . " </td><td><input type=\"text\" name=\"title\" size=\"40\" value=\"$title\"></td>
291
            </tr><tr class='head' border='1'>
292
            <td>" . _AM_ADSLIGHT_PREMIUM . " </td><td><input type=\"text\" name=\"premium\" size=\"3\" value=\"$premium\"></td>
293
            </tr><tr class='head' border='1'>
294
            <td>" . _AM_ADSLIGHT_EXPIRE . " </td><td><input type=\"text\" name=\"expire\" size=\"40\" value=\"$expire\"></td>
295
            </tr><tr class='head' border='1'>
296
            <td>" . _AM_ADSLIGHT_TYPE . " </td><td><select name=\"type\">";
297
298
        $result5 = $xoopsDB->query('SELECT nom_type FROM ' . $xoopsDB->prefix('adslight_type') . ' ORDER BY nom_type');
299
        while (list($nom_type) = $xoopsDB->fetchRow($result5)) {
300
            $sel = '';
301
            if ($nom_type == $type) {
302
                $sel = 'selected';
303
            }
304
            echo "<option value=\"$nom_type\" $sel>$nom_type</option>";
305
        }
306
307
        echo '</select></td></tr>';
308
309
        ////// Etat d'usure
310
        echo "<tr class='head' border='1'>
311
            <td>" . _AM_ADSLIGHT_TYPE_USURE . " </td><td><select name=\"typeusure\">";
312
313
        $result6 = $xoopsDB->query('SELECT nom_usure FROM ' . $xoopsDB->prefix('adslight_usure') . ' ORDER BY nom_usure');
314
        while (list($nom_usure) = $xoopsDB->fetchRow($result6)) {
315
            $sel = '';
316
            if ($nom_usure == $typeusure) {
317
                $sel = 'selected';
318
            }
319
            echo "<option value=\"$nom_usure\" $sel>$nom_usure</option>";
320
        }
321
        echo '</select></td></tr>';
322
323
        echo "<tr class='head' border='1'><td>" . _AM_ADSLIGHT_PRICE2 . " </td><td><input type=\"text\" name=\"price\" size=\"20\" value=\"$price\"> " . $xoopsModuleConfig['adslight_money'] . '';
324
        $result3 = $xoopsDB->query('SELECT nom_price FROM ' . $xoopsDB->prefix('adslight_price') . ' ORDER BY id_price');
325
        echo " <select name=\"typeprice\"><option value=\"$typeprice\">$typeprice</option>";
326
        while (list($nom_price) = $xoopsDB->fetchRow($result3)) {
327
            echo "<option value=\"$nom_price\">$nom_price</option>";
328
        }
329
        echo '</select></td></tr>';
330
331
        echo "<tr class='head' border='1'>
332
            <td>" . _AM_ADSLIGHT_PHOTO1 . " </td><td><input type=\"text\" name=\"photo\" size=\"40\" value=\"$photo\"></td>
333
            </tr>";
334
        echo "<tr class='head' border='1'><td>" . _AM_ADSLIGHT_DESC . '</td><td>';
335
        $wysiwyg_text_area = adslight_adminEditor(_AM_ADSLIGHT_DESC, 'desctext', $desctext, '100%', '200px', 'small');
336
        echo $wysiwyg_text_area->render();
337
        echo '</td></tr>';
338
        echo "<tr class='head' border='1'><td>" . _AM_ADSLIGHT_CAT . ' </td><td>';
339
        $mytree->makeMySelBox('title', 'title', $cid);
340
        echo "</td>
341
        </tr><tr class='head' border='1'>
342
        <td>&nbsp;</td><td><select name=\"op\">
343
        <option value=\"ListingValid\"> " . _AM_ADSLIGHT_OK . "
344
        <option value=\"ListingDel\"> " . _AM_ADSLIGHT_DEL . "
345
        </select><input type=\"submit\" value=\"" . _AM_ADSLIGHT_GO . "\"></td>
346
        </tr></table>";
347
        echo "<input type=\"hidden\" name=\"valid\" value=\"Yes\">";
348
        echo "<input type=\"hidden\" name=\"lid\" value=\"$lid\">";
349
        echo "<input type=\"hidden\" name=\"date\" value=\"$date\">";
350
        echo "<input type=\"hidden\" name=\"submitter\" value=\"$submitter\">
351
            </form>";
352
353
        echo '</td></tr></table>';
354
        echo '<br>';
355
    }
356
357
    xoops_cp_footer();
358
}
359
360
#  function ModifyAds
361
#####################################################
362
/**
363
 * @param $lid
364
 */
365
function ModifyAds($lid)
366
{
367
    global $xoopsDB, $xoopsModule, $xoopsConfig, $xoopsModuleConfig, $myts, $desctext, $moduleDirName, $admin_lang;
368
369
    $mytree = new ClassifiedsTree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid');
370
371
    include_once __DIR__ . '/header.php';
372
    xoops_cp_header();
373
    //    loadModuleAdminMenu(0, "");
374
    $id_price  = '';
375
    $nom_price = '';
376
377
    echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_MODANN . '</legend>';
378
379
    $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 '
380
                              . $xoopsDB->prefix('adslight_listing')
381
                              . " WHERE lid=$lid");
382
383
    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)) {
384
        $title    = $myts->htmlSpecialChars($title);
385
        $status   = $myts->htmlSpecialChars($status);
386
        $expire   = $myts->htmlSpecialChars($expire);
387
        $type     = $myts->htmlSpecialChars($type);
388
        $desctext = $myts->displayTarea($desctext, 1, 1, 1);
389
        $tel      = $myts->htmlSpecialChars($tel);
390
        //      $price = number_format($price, 2, ",", " ");
391
        $typeprice = $myts->htmlSpecialChars($typeprice);
392
        $typeusure = $myts->htmlSpecialChars($typeusure);
393
        $submitter = $myts->htmlSpecialChars($submitter);
394
        $town      = $myts->htmlSpecialChars($town);
395
        $country   = $myts->htmlSpecialChars($country);
396
        $contactby = $myts->htmlSpecialChars($contactby);
397
        $premium   = $myts->htmlSpecialChars($premium);
398
399
        $date2 = formatTimestamp($date, 's');
400
401
        echo "<form action=\"view_ads.php\" method=post>
402
            <table border=0><tr class='head' border='1'>
403
            <td>" . _AM_ADSLIGHT_NUMANN . " </td><td>$lid &nbsp;" . _AM_ADSLIGHT_ADDED_ON . "&nbsp; $date2</td>
404
            </tr><tr class='head' border='1'>
405
            <td>" . _AM_ADSLIGHT_SENDBY . " </td><td>$submitter</td>
406
            </tr><tr class='head' border='1'>
407
            <td>" . _AM_ADSLIGHT_EMAIL . " </td><td><input type=\"text\" name=\"email\" size=\"40\" value=\"$email\"></td>
408
            </tr><tr class='head' border='1'>
409
            <td>" . _AM_ADSLIGHT_TEL . " </td><td><input type=\"text\" name=\"tel\" size=\"50\" value=\"$tel\"></td>
410
            </tr><tr class='head' border='1'>
411
            <td>" . _AM_ADSLIGHT_TOWN . " </td><td><input type=\"text\" name=\"town\" size=\"40\" value=\"$town\"></td>
412
            </tr><tr class='head' border='1'>
413
            <td>" . _AM_ADSLIGHT_COUNTRY . " </td><td><input type=\"text\" name=\"country\" size=\"40\" value=\"$country\"></td>
414
            </tr>
415
            <tr class='head' border='1'>";
416
417
        if ($contactby == 1) {
418
            $contactselect = _AM_ADSLIGHT_CONTACT_BY_EMAIL;
419
        }
420
        if ($contactby == 2) {
421
            $contactselect = _AM_ADSLIGHT_CONTACT_BY_PM;
422
        }
423
        if ($contactby == 3) {
424
            $contactselect = _AM_ADSLIGHT_CONTACT_BY_BOTH;
425
        }
426
        if ($contactby == 4) {
427
            $contactselect = _AM_ADSLIGHT_CONTACT_BY_PHONE;
428
        }
429
430
        echo " <td class='head'>" . _AM_ADSLIGHT_CONTACTBY . " </td><td class='head'><select name=\"contactby\">
431
           <option value=\"" . $contactby . "\">" . $contactselect . "</option>
432
           <option value=\"1\">" . _AM_ADSLIGHT_CONTACT_BY_EMAIL . "</option>
433
           <option value=\"2\">" . _AM_ADSLIGHT_CONTACT_BY_PM . "</option>
434
           <option value=\"3\">" . _AM_ADSLIGHT_CONTACT_BY_BOTH . "</option>
435
           <option value=\"4\">" . _AM_ADSLIGHT_CONTACT_BY_PHONE . '</option></select></td></tr>';
436
437
        echo "<tr><td class='head'>" . _AM_ADSLIGHT_STATUS . "</td><td class='head'><input type=\"radio\" name=\"status\" value=\"0\"";
438
        if ($status == '0') {
439
            echo 'checked';
440
        }
441
        echo '>' . _AM_ADSLIGHT_ACTIVE . "&nbsp;&nbsp; <input type=\"radio\" name=\"status\" value=\"1\"";
442
        if ($status == '1') {
443
            echo 'checked';
444
        }
445
        echo '>' . _AM_ADSLIGHT_INACTIVE . "&nbsp;&nbsp; <input type=\"radio\" name=\"status\" value=\"2\"";
446
        if ($status == '2') {
447
            echo 'checked';
448
        }
449
        echo '>' . _AM_ADSLIGHT_SOLD . '</td></tr>';
450
451
        echo "<tr class='head' border='1'>
452
            <td>" . _AM_ADSLIGHT_TITLE2 . " </td><td><input type=\"text\" name=\"title\" size=\"40\" value=\"$title\"></td>
453
            </tr><tr class='head' border='1'>
454
            <td>" . _AM_ADSLIGHT_PREMIUM . " </td><td><input type=\"text\" name=\"premium\" size=\"3\" value=\"$premium\"></td>
455
            </tr><tr class='head' border='1'>
456
            <td>" . _AM_ADSLIGHT_EXPIRE . " </td><td><input type=\"text\" name=\"expire\" size=\"40\" value=\"$expire\"></td>
457
            </tr>";
458
        ////// Type d'annonce
459
        echo "<tr class='head' border='1'>
460
            <td>" . _AM_ADSLIGHT_TYPE . " </td><td><select name=\"type\">";
461
462
        $result5 = $xoopsDB->query('SELECT nom_type, id_type FROM ' . $xoopsDB->prefix('adslight_type') . ' ORDER BY nom_type');
463
        while (list($nom_type, $id_type) = $xoopsDB->fetchRow($result5)) {
464
            $sel = '';
465
            if ($id_type == $type) {
466
                $sel = 'selected';
467
            }
468
            echo "<option value=\"$id_type\" $sel>$nom_type</option>";
469
        }
470
        echo '</select></td></tr>';
471
472
        ////// Etat d'usure
473
        echo "<tr class='head' border='1'>
474
            <td>" . _AM_ADSLIGHT_TYPE_USURE . " </td><td><select name=\"typeusure\">";
475
476
        $result6 = $xoopsDB->query('SELECT nom_usure, id_usure FROM ' . $xoopsDB->prefix('adslight_usure') . ' ORDER BY nom_usure');
477
        while (list($nom_usure, $id_usure) = $xoopsDB->fetchRow($result6)) {
478
            $sel = '';
479
            if ($id_usure == $typeusure) {
480
                $sel = 'selected';
481
            }
482
            echo "<option value=\"$id_usure\" $sel>$nom_usure</option>";
483
        }
484
        echo '</select></td></tr>';
485
486
        /////// Price
487
        echo "<tr class='head' border='1'><td>" . _AM_ADSLIGHT_PRICE2 . " </td><td><input type=\"text\" name=\"price\" size=\"20\" value=\"$price\"> " . $xoopsModuleConfig['adslight_money'] . '';
488
489
        //////// Price type
490
491
        $resultx = $xoopsDB->query('SELECT nom_price, id_price FROM ' . $xoopsDB->prefix('adslight_price') . ' ORDER BY nom_price');
492
493
        echo " <select name=\"typeprice\"><option value=\"$id_price\">$nom_price</option>";
494
        while (list($nom_price, $id_price) = $xoopsDB->fetchRow($resultx)) {
495
            $sel = '';
496
            if ($id_price == $typeprice) {
497
                $sel = 'selected';
498
            }
499
500
            echo "<option value=\"$id_price\" $sel>$nom_price</option>";
501
        }
502
        echo '</select></td>';
503
504
        /////// Category
505
506
        echo "<tr class='head' border='1'>
507
            <td>" . _AM_ADSLIGHT_CAT2 . ' </td><td>';
508
        $mytree->makeMySelBox('title', 'title', $cid);
509
        echo "</td>
510
            </tr><tr class='head' border='1'>
511
            <td>" . _AM_ADSLIGHT_DESC . ' </td><td>';
512
513
        $wysiwyg_text_area = adslight_adminEditor('', 'desctext', $desctext, '100%', '200px', 'small');
514
        echo $wysiwyg_text_area->render();
515
516
        echo '</td></tr>';
517
518
        echo "<tr class='head' border='1'>
519
            <td>" . _AM_ADSLIGHT_PHOTO1 . " </td><td><input type=\"text\" name=\"photo\" size=\"50\" value=\"$photo\"></td>
520
            </tr><tr>";
521
        $time = time();
522
        echo "</tr><tr class='head' border='1'>
523
            <td>&nbsp;</td><td><select name=\"op\">
524
            <option value=\"ModifyAdsS\"> " . _AM_ADSLIGHT_MODIF . "
525
            <option value=\"ListingDel\"> " . _AM_ADSLIGHT_DEL . "
526
            </select><input type=\"submit\" value=\"" . _AM_ADSLIGHT_GO . "\"></td>
527
            </tr></table>";
528
        echo "<input type=\"hidden\" name=\"valid\" value=\"Yes\">";
529
        echo "<input type=\"hidden\" name=\"lid\" value=\"$lid\">";
530
        echo "<input type=\"hidden\" name=\"date\" value=\"$time\">";
531
        echo "<input type=\"hidden\" name=\"submitter\" value=\"$submitter\">
532
        </form><br>";
533
        echo '</fieldset><br>';
534
        xoops_cp_footer();
535
    }
536
}
537
538
#  function ModifyAdsS
539
#####################################################
540
541
/**
542
 * @param $lid
543
 * @param $cat
544
 * @param $title
545
 * @param $status
546
 * @param $expire
547
 * @param $type
548
 * @param $desctext
549
 * @param $tel
550
 * @param $price
551
 * @param $typeprice
552
 * @param $typeusure
553
 * @param $date
554
 * @param $email
555
 * @param $submitter
556
 * @param $town
557
 * @param $country
558
 * @param $contactby
559
 * @param $premium
560
 * @param $valid
561
 * @param $photo
562
 */
563 View Code Duplication
function ModifyAdsS(
0 ignored issues
show
The function ModifyAdsS() has been defined more than once; this definition is ignored, only the first definition in admin/modify_ads.php (L319-366) is considered.

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

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

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

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
This function seems to be duplicated in your project.

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

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

Loading history...
564
    $lid,
565
    $cat,
566
    $title,
567
    $status,
568
    $expire,
569
    $type,
570
    $desctext,
571
    $tel,
572
    $price,
573
    $typeprice,
574
    $typeusure,
575
    $date,
576
    $email,
577
    $submitter,
578
    $town,
579
    $country,
580
    $contactby,
581
    $premium,
582
    $valid,
583
    $photo
584
) {
585
    global $xoopsDB, $xoopsConfig, $myts, $moduleDirName, $admin_lang;
586
587
    $title     = $myts->htmlSpecialChars($title);
588
    $status    = $myts->htmlSpecialChars($status);
589
    $expire    = $myts->htmlSpecialChars($expire);
590
    $type      = $myts->htmlSpecialChars($type);
591
    $desctext  = $myts->displayTarea($desctext, 1, 1, 1);
592
    $tel       = $myts->htmlSpecialChars($tel);
593
    $price     = str_replace(array(' '), '', $price);
594
    $typeprice = $myts->htmlSpecialChars($typeprice);
595
    $typeusure = $myts->htmlSpecialChars($typeusure);
596
    $submitter = $myts->htmlSpecialChars($submitter);
597
    $town      = $myts->htmlSpecialChars($town);
598
    $country   = $myts->htmlSpecialChars($country);
599
    $contactby = $myts->htmlSpecialChars($contactby);
600
    $premium   = $myts->htmlSpecialChars($premium);
601
602
    $xoopsDB->query('UPDATE '
603
                    . $xoopsDB->prefix('adslight_listing')
604
                    . " 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");
605
606
    redirect_header('view_ads.php', 1, _AM_ADSLIGHT_ANNMOD);
607
}
608
609
#  function ListingDel
610
#####################################################
611
/**
612
 * @param $lid
613
 * @param $photo
614
 */
615 View Code Duplication
function ListingDel($lid, $photo)
616
{
617
    global $xoopsDB, $moduleDirName, $admin_lang;
618
619
    $result2 = $xoopsDB->query('SELECT p.url FROM '
620
                               . $xoopsDB->prefix('adslight_listing')
621
                               . ' l LEFT JOIN '
622
                               . $xoopsDB->prefix('adslight_pictures')
623
                               . ' p  ON l.lid=p.lid WHERE l.lid='
624
                               . $xoopsDB->escape($lid)
625
                               . '');
626
627
    while (list($purl) = $xoopsDB->fetchRow($result2)) {
628
        if ($purl) {
629
            $destination = XOOPS_ROOT_PATH . '/uploads/AdsLight';
630
            if (file_exists("$destination/$purl")) {
631
                unlink("$destination/$purl");
632
            }
633
            $destination2 = XOOPS_ROOT_PATH . '/uploads/AdsLight/thumbs';
634
            if (file_exists("$destination2/thumb_$purl")) {
635
                unlink("$destination2/thumb_$purl");
636
            }
637
            $destination3 = XOOPS_ROOT_PATH . '/uploads/AdsLight/midsize';
638
            if (file_exists("$destination3/resized_$purl")) {
639
                unlink("$destination3/resized_$purl");
640
            }
641
            $xoopsDB->query('DELETE FROM ' . $xoopsDB->prefix('adslight_pictures') . " WHERE lid=$lid");
642
        }
643
    }
644
645
    $xoopsDB->query('DELETE FROM ' . $xoopsDB->prefix('adslight_listing') . " WHERE lid=$lid");
646
647
    redirect_header('view_ads.php', 1, _AM_ADSLIGHT_ANNDEL);
648
}
649
650
#  function ListingValid
651
#####################################################
652
/**
653
 * @param $lid
654
 * @param $cat
655
 * @param $title
656
 * @param $status
657
 * @param $expire
658
 * @param $type
659
 * @param $desctext
660
 * @param $tel
661
 * @param $price
662
 * @param $typeprice
663
 * @param $typeusure
664
 * @param $date
665
 * @param $email
666
 * @param $submitter
667
 * @param $town
668
 * @param $country
669
 * @param $contactby
670
 * @param $premium
671
 * @param $valid
672
 * @param $photo
673
 */
674 View Code Duplication
function ListingValid(
0 ignored issues
show
The function ListingValid() has been defined more than once; this definition is ignored, only the first definition in admin/validate_ads.php (L702-803) is considered.

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

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

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

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
This function seems to be duplicated in your project.

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

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

Loading history...
675
    $lid,
676
    $cat,
677
    $title,
678
    $status,
679
    $expire,
680
    $type,
681
    $desctext,
682
    $tel,
683
    $price,
684
    $typeprice,
685
    $typeusure,
686
    $date,
0 ignored issues
show
The parameter $date is not used and could be removed.

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

Loading history...
687
    $email,
688
    $submitter,
689
    $town,
690
    $country,
691
    $contactby,
692
    $premium,
693
    $valid,
694
    $photo
695
) {
696
    global $xoopsDB, $xoopsConfig, $xoopsModule, $myts, $meta, $moduleDirName, $admin_lang;
697
698
    $title     = $myts->htmlSpecialChars($title);
699
    $status    = $myts->htmlSpecialChars($status);
700
    $expire    = $myts->htmlSpecialChars($expire);
701
    $type      = $myts->htmlSpecialChars($type);
702
    $desctext  = $myts->displayTarea($desctext, 1, 1, 1);
703
    $tel       = $myts->htmlSpecialChars($tel);
704
    $price     = str_replace(array(' '), '', $price);
705
    $typeprice = $myts->htmlSpecialChars($typeprice);
706
    $typeusure = $myts->htmlSpecialChars($typeusure);
707
    $submitter = $myts->htmlSpecialChars($submitter);
708
    $town      = $myts->htmlSpecialChars($town);
709
    $country   = $myts->htmlSpecialChars($country);
710
    $contactby = $myts->htmlSpecialChars($contactby);
711
    $premium   = $myts->htmlSpecialChars($premium);
712
    $now       = time();
713
    $xoopsDB->query('UPDATE '
714
                    . $xoopsDB->prefix('adslight_listing')
715
                    . " 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");
716
717
    if ($email == '') {
718
    } else {
719
        $tags               = array();
720
        $tags['TITLE']      = $title;
721
        $tags['TYPE']       = adslight_NameType($type);
722
        $tags['SUBMITTER']  = $submitter;
723
        $tags['DESCTEXT']   = stripslashes($desctext);
724
        $tags['EMAIL']      = _AM_ADSLIGHT_EMAIL;
725
        $tags['TEL']        = _AM_ADSLIGHT_TEL;
726
        $tags['HELLO']      = _AM_ADSLIGHT_HELLO;
727
        $tags['VEDIT_AD']   = _AM_ADSLIGHT_VEDIT_AD;
728
        $tags['ANNACCEPT']  = _AM_ADSLIGHT_ANNACCEPT;
729
        $tags['CONSULTTO']  = _AM_ADSLIGHT_CONSULTTO;
730
        $tags['THANKS']     = _ADSLIGHT_THANKS;
731
        $tags['TEAMOF']     = _AM_ADSLIGHT_TEAMOF;
732
        $tags['META_TITLE'] = $meta['title'];
733
        $tags['LINK_URL']   = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewads.php?lid=' . $lid . '';
734
        $tags['YOUR_AD']    = _AM_ADSLIGHT_YOUR_AD;
735
        $tags['WEBMASTER']  = _AM_ADSLIGHT_WEBMASTER;
736
        $tags['YOUR_AD_ON'] = _AM_ADSLIGHT_YOUR_AD_ON;
737
        $tags['APPROVED']   = _AM_ADSLIGHT_APPROVED;
738
739
        $subject = '' . _AM_ADSLIGHT_ANNACCEPT . '';
740
        $mail    =& getMailer();
741
        $mail->setTemplateDir(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/mail_template/');
742
        $mail->setTemplate('listing_approve.tpl');
743
        $mail->useMail();
744
        $mail->multimailer->isHTML(true);
745
        $mail->setFromName($meta['title']);
746
        $mail->setFromEmail($xoopsConfig['adminmail']);
747
        $mail->setToEmails($email);
748
        $mail->setSubject($subject);
749
        $mail->assign($tags);
750
        $mail->send();
751
        echo $mail->getErrors();
752
    }
753
754
    $tags                    = array();
755
    $tags['TITLE']           = $title;
756
    $tags['ADDED_TO_CAT']    = _AM_ADSLIGHT_ADDED_TO_CAT;
757
    $tags['RECIEVING_NOTIF'] = _AM_ADSLIGHT_RECIEVING_NOTIF;
758
    $tags['ERROR_NOTIF']     = _AM_ADSLIGHT_ERROR_NOTIF;
759
    $tags['WEBMASTER']       = _AM_ADSLIGHT_WEBMASTER;
760
    $tags['HELLO']           = _AM_ADSLIGHT_HELLO;
761
    $tags['FOLLOW_LINK']     = _AM_ADSLIGHT_FOLLOW_LINK;
762
    $tags['TYPE']            = adslight_NameType($type);
763
    $tags['LINK_URL']        = XOOPS_URL . '/modules/adslight/viewads.php?' . '&lid=' . $lid;
764
    $sql                     = 'SELECT title FROM ' . $xoopsDB->prefix('adslight_categories') . ' WHERE cid=' . addslashes($cat);
765
    $result                  = $xoopsDB->query($sql);
766
    $row                     = $xoopsDB->fetchArray($result);
767
    $tags['CATEGORY_TITLE']  = $row['title'];
768
    $tags['CATEGORY_URL']    = XOOPS_URL . '/modules/adslight/viewcats.php?cid="' . addslashes($cat);
769
    $notification_handler    = xoops_getHandler('notification');
770
    $notification_handler->triggerEvent('global', 0, 'new_listing', $tags);
771
    $notification_handler->triggerEvent('category', $cat, 'new_listing', $tags);
772
    $notification_handler->triggerEvent('listing', $lid, 'new_listing', $tags);
773
774
    redirect_header('view_ads.php', 3, _AM_ADSLIGHT_ANNVALID);
775
}
776
777
#####################################################
778
#####################################################
779
780
foreach ($_POST as $k => $v) {
781
    ${$k} = $v;
782
}
783
784
$pa = isset($_GET['pa']) ? $_GET['pa'] : '';
785
786
if (!isset($_POST['lid']) && isset($_GET['lid'])) {
787
    $lid = $_GET['lid'];
788
}
789
if (!isset($_POST['op']) && isset($_GET['op'])) {
790
    $op = $_GET['op'];
791
}
792
if (!isset($op)) {
793
    $op = '';
794
}
795
796 View Code Duplication
switch ($op) {
797
798
    case 'IndexView':
799
        IndexView($lid);
800
        break;
801
802
    case 'ListingDel':
803
        ListingDel($lid, $photo);
804
        break;
805
806
    case 'ListingValid':
807
        ListingValid($lid, $cid, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $typeusure, $date, $email, $submitter, $town, $country, $contactby, $premium, $valid, $photo);
808
        break;
809
810
    case 'ModifyAds':
811
        ModifyAds($lid);
812
        break;
813
814
    case 'ModifyAdsS':
815
        ModifyAdsS($lid, $cid, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $typeusure, $date, $email, $submitter, $town, $country, $contactby, $premium, $valid, $photo);
816
        break;
817
818
    default:
819
        Index();
820
        break;
821
822
}
823