Code Duplication    Length = 171-174 lines in 2 locations

admin/modify_ads.php 1 location

@@ 122-292 (lines=171) @@
119
/**
120
 * @param $lid
121
 */
122
function modifyAds($lid)
123
{
124
    global $xoopsDB, $xoopsModule, $xoopsConfig, $myts, $desctext, $moduleDirName, $admin_lang;
125
126
    $mytree = new ClassifiedsTree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid');
127
128
    include_once __DIR__ . '/header.php';
129
    xoops_cp_header();
130
    //    loadModuleAdminMenu(0, "");
131
    $id_price  = '';
132
    $nom_price = '';
133
    $lid       = (int)$lid;
134
135
    echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_MODANN . '</legend>';
136
137
    $result = $xoopsDB->query('SELECT lid, cid, title, status, expire, type, desctext, tel, price, typeprice, typeusure, date, email, submitter, town, country, contactby, premium, valid, photo FROM '
138
                              . $xoopsDB->prefix('adslight_listing')
139
                              . " WHERE lid=$lid");
140
141
    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)) {
142
        $title     = $myts->htmlSpecialChars($title);
143
        $status    = $myts->htmlSpecialChars($status);
144
        $expire    = $myts->htmlSpecialChars($expire);
145
        $type      = $myts->htmlSpecialChars($type);
146
        $desctext  = $myts->displayTarea($desctext, 1, 1, 1);
147
        $tel       = $myts->htmlSpecialChars($tel);
148
        $price     = number_format($price, 2, ',', ' ');
149
        $typeprice = $myts->htmlSpecialChars($typeprice);
150
        $typeusure = $myts->htmlSpecialChars($typeusure);
151
        $submitter = $myts->htmlSpecialChars($submitter);
152
        $town      = $myts->htmlSpecialChars($town);
153
        $country   = $myts->htmlSpecialChars($country);
154
        $contactby = $myts->htmlSpecialChars($contactby);
155
        $premium   = $myts->htmlSpecialChars($premium);
156
157
        $date2 = formatTimestamp($date, 's');
158
159
        echo "<form action=\"modify_ads.php\" method=post>
160
            <table border=0><tr class='head' border='1'>
161
            <td>" . _AM_ADSLIGHT_NUMANN . " </td><td>$lid &nbsp;" . _AM_ADSLIGHT_ADDED_ON . "&nbsp; $date2</td>
162
            </tr><tr class='head' border='1'>
163
            <td>" . _AM_ADSLIGHT_SENDBY . " </td><td>$submitter</td>
164
            </tr><tr class='head' border='1'>
165
            <td>" . _AM_ADSLIGHT_EMAIL . " </td><td><input type=\"text\" name=\"email\" size=\"40\" value=\"$email\"></td>
166
            </tr><tr class='head' border='1'>
167
            <td>" . _AM_ADSLIGHT_TEL . " </td><td><input type=\"text\" name=\"tel\" size=\"50\" value=\"$tel\"></td>
168
            </tr><tr class='head' border='1'>
169
            <td>" . _AM_ADSLIGHT_TOWN . " </td><td><input type=\"text\" name=\"town\" size=\"40\" value=\"$town\"></td>
170
            </tr><tr class='head' border='1'>
171
            <td>" . _AM_ADSLIGHT_COUNTRY . " </td><td><input type=\"text\" name=\"country\" size=\"40\" value=\"$country\"></td>
172
            </tr></tr><tr class='head' border='1'>";
173
174
        if ($contactby == 1) {
175
            $contactselect = _AM_ADSLIGHT_CONTACT_BY_EMAIL;
176
        }
177
        if ($contactby == 2) {
178
            $contactselect = _AM_ADSLIGHT_CONTACT_BY_PM;
179
        }
180
        if ($contactby == 3) {
181
            $contactselect = _AM_ADSLIGHT_CONTACT_BY_BOTH;
182
        }
183
        if ($contactby == 4) {
184
            $contactselect = _AM_ADSLIGHT_CONTACT_BY_PHONE;
185
        }
186
187
        echo " <td class='head'>" . _AM_ADSLIGHT_CONTACTBY . " </td><td class='head'><select name=\"contactby\">
188
    <option value=\"" . $contactby . "\">" . $contactselect . "</option>
189
    <option value=\"1\">" . _AM_ADSLIGHT_CONTACT_BY_EMAIL . "</option>
190
    <option value=\"2\">" . _AM_ADSLIGHT_CONTACT_BY_PM . "</option>
191
    <option value=\"3\">" . _AM_ADSLIGHT_CONTACT_BY_BOTH . "</option>
192
    <option value=\"4\">" . _AM_ADSLIGHT_CONTACT_BY_PHONE . '</option></select></td></tr>';
193
194
        echo "<tr><td class='head'>" . _AM_ADSLIGHT_STATUS . "</td><td class='head'><input type=\"radio\" name=\"status\" value=\"0\"";
195
        if ($status == '0') {
196
            echo 'checked';
197
        }
198
        echo '>' . _AM_ADSLIGHT_ACTIVE . "&nbsp;&nbsp; <input type=\"radio\" name=\"status\" value=\"1\"";
199
        if ($status == '1') {
200
            echo 'checked';
201
        }
202
        echo '>' . _AM_ADSLIGHT_INACTIVE . "&nbsp;&nbsp; <input type=\"radio\" name=\"status\" value=\"2\"";
203
        if ($status == '2') {
204
            echo 'checked';
205
        }
206
        echo '>' . _AM_ADSLIGHT_SOLD . '</td></tr>';
207
208
        echo "<tr class='head' border='1'>
209
            <td>" . _AM_ADSLIGHT_TITLE2 . " </td><td><input type=\"text\" name=\"title\" size=\"40\" value=\"$title\"></td>
210
            </tr><tr class='head' border='1'>
211
            <td>" . _AM_ADSLIGHT_PREMIUM . " </td><td><input type=\"text\" name=\"premium\" size=\"3\" value=\"$premium\"></td>
212
            </tr><tr class='head' border='1'>
213
            <td>" . _AM_ADSLIGHT_EXPIRE . " </td><td><input type=\"text\" name=\"expire\" size=\"40\" value=\"$expire\"></td>
214
            </tr>";
215
        ////// Type d'annonce
216
        echo "<tr class='head' border='1'>
217
            <td>" . _AM_ADSLIGHT_TYPE . " </td><td><select name=\"type\">";
218
219
        $result5 = $xoopsDB->query('SELECT nom_type, id_type FROM ' . $xoopsDB->prefix('adslight_type') . ' ORDER BY nom_type');
220
        while (list($nom_type, $id_type) = $xoopsDB->fetchRow($result5)) {
221
            $sel = '';
222
            if ($id_type == $type) {
223
                $sel = 'selected';
224
            }
225
            echo "<option value=\"{$id_type}\"{$sel}>{$nom_type}</option>";
226
        }
227
        echo '</select></td></tr>';
228
229
        ////// Etat d'usure
230
        echo "<tr class='head' border='1'>
231
            <td>" . _AM_ADSLIGHT_TYPE_USURE . " </td><td><select name=\"typeusure\">";
232
233
        $result6 = $xoopsDB->query('SELECT nom_usure, id_usure FROM ' . $xoopsDB->prefix('adslight_usure') . ' ORDER BY nom_usure');
234
        while (list($nom_usure, $id_usure) = $xoopsDB->fetchRow($result6)) {
235
            $sel = '';
236
            if ($id_usure == $typeusure) {
237
                $sel = 'selected';
238
            }
239
            echo "<option value=\"{$id_usure}\"{$sel}>{$nom_usure}</option>";
240
        }
241
        echo '</select></td></tr>';
242
243
        /////// Price
244
        echo "<tr class='head' border='1'><td>" . _AM_ADSLIGHT_PRICE2 . " </td><td><input type=\"text\" name=\"price\" size=\"20\" value=\"$price\"> " . $GLOBALS['xoopsModuleConfig']['adslight_money'] . '';
245
246
        //////// Price type
247
248
        $resultx = $xoopsDB->query('SELECT nom_price, id_price FROM ' . $xoopsDB->prefix('adslight_price') . ' ORDER BY nom_price');
249
250
        echo " <select name=\"typeprice\"><option value=\"$id_price\">$nom_price</option>";
251
        while (list($nom_price, $id_price) = $xoopsDB->fetchRow($resultx)) {
252
            $sel = '';
253
            if ($id_price == $typeprice) {
254
                $sel = 'selected';
255
            }
256
            echo "<option value=\"{$id_price}\"{$sel}>{$nom_price}</option>";
257
        }
258
        echo '</select></td>';
259
260
        /////// Category
261
262
        echo "<tr class='head' border='1'>
263
            <td>" . _AM_ADSLIGHT_CAT2 . ' </td><td>';
264
        $mytree->makeMySelBox('title', 'title', $cid);
265
        echo "</td>
266
            </tr><tr class='head' border='1'>
267
            <td>" . _AM_ADSLIGHT_DESC . ' </td><td>';
268
269
        $wysiwyg_text_area = AdslightUtilities::getEditor('', 'desctext', $desctext, '100%', '200px', 'small');
270
        echo $wysiwyg_text_area->render();
271
272
        echo '</td></tr>';
273
274
        echo "<tr class='head' border='1'>
275
            <td>" . _AM_ADSLIGHT_PHOTO1 . " </td><td><input type=\"text\" name=\"photo\" size=\"50\" value=\"$photo\"></td>
276
            </tr><tr>";
277
        $time = time();
278
        echo "</tr><tr class='head' border='1'>
279
            <td>&nbsp;</td><td><select name=\"op\">
280
            <option value=\"ModifyAdsS\"> " . _AM_ADSLIGHT_MODIF . "
281
            <option value=\"ListingDel\"> " . _AM_ADSLIGHT_DEL . "
282
            </select><input type=\"submit\" value=\"" . _AM_ADSLIGHT_GO . "\"></td>
283
            </tr></table>";
284
        echo "<input type=\"hidden\" name=\"valid\" value=\"Yes\">";
285
        echo "<input type=\"hidden\" name=\"lid\" value=\"$lid\">";
286
        echo "<input type=\"hidden\" name=\"date\" value=\"$time\">";
287
        echo "<input type=\"hidden\" name=\"submitter\" value=\"$submitter\">
288
        </form><br>";
289
        echo '</fieldset><br>';
290
        xoops_cp_footer();
291
    }
292
}
293
294
#  function modifyAdsS
295
#####################################################

admin/validate_ads.php 1 location

@@ 391-564 (lines=174) @@
388
/**
389
 * @param $lid
390
 */
391
function modifyAds($lid)
392
{
393
    global $xoopsDB, $xoopsModule, $xoopsConfig, $myts, $desctext, $moduleDirName, $admin_lang;
394
395
    $mytree = new ClassifiedsTree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid');
396
397
    $id_price  = '';
398
    $nom_price = '';
399
400
    include_once __DIR__ . '/header.php';
401
    xoops_cp_header();
402
    //    loadModuleAdminMenu(0, "");
403
404
    echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_MODANN . '</legend>';
405
406
    $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 '
407
                              . $xoopsDB->prefix('adslight_listing')
408
                              . " WHERE lid=$lid");
409
410
    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)) {
411
        $title     = $myts->htmlSpecialChars($title);
412
        $status    = $myts->htmlSpecialChars($status);
413
        $expire    = $myts->htmlSpecialChars($expire);
414
        $type      = $myts->htmlSpecialChars($type);
415
        $desctext  = $myts->displayTarea($desctext, 1, 1, 1);
416
        $tel       = $myts->htmlSpecialChars($tel);
417
        $price     = number_format($price, 2, ',', ' ');
418
        $typeprice = $myts->htmlSpecialChars($typeprice);
419
        $typeusure = $myts->htmlSpecialChars($typeusure);
420
        $submitter = $myts->htmlSpecialChars($submitter);
421
        $town      = $myts->htmlSpecialChars($town);
422
        $country   = $myts->htmlSpecialChars($country);
423
        $contactby = $myts->htmlSpecialChars($contactby);
424
        $premium   = $myts->htmlSpecialChars($premium);
425
426
        $date2 = formatTimestamp($date, 's');
427
428
        echo "<form action=\"validate_ads.php\" method=post>
429
            <table border=0><tr class='head' border='1'>
430
            <td>" . _AM_ADSLIGHT_NUMANN . " </td><td>$lid &nbsp;" . _AM_ADSLIGHT_ADDED_ON . "&nbsp; $date2</td>
431
            </tr><tr class='head' border='1'>
432
            <td>" . _AM_ADSLIGHT_SENDBY . " </td><td>$submitter</td>
433
            </tr><tr class='head' border='1'>
434
            <td>" . _AM_ADSLIGHT_EMAIL . " </td><td><input type=\"text\" name=\"email\" size=\"40\" value=\"$email\"></td>
435
            </tr><tr class='head' border='1'>
436
            <td>" . _AM_ADSLIGHT_TEL . " </td><td><input type=\"text\" name=\"tel\" size=\"50\" value=\"$tel\"></td>
437
            </tr><tr class='head' border='1'>
438
            <td>" . _AM_ADSLIGHT_TOWN . " </td><td><input type=\"text\" name=\"town\" size=\"40\" value=\"$town\"></td>
439
            </tr><tr class='head' border='1'>
440
            <td>" . _AM_ADSLIGHT_COUNTRY . " </td><td><input type=\"text\" name=\"country\" size=\"40\" value=\"$country\"></td>
441
            </tr>
442
            <tr class='head' border='1'>";
443
444
        if ($contactby == 1) {
445
            $contactselect = _AM_ADSLIGHT_CONTACT_BY_EMAIL;
446
        }
447
        if ($contactby == 2) {
448
            $contactselect = _AM_ADSLIGHT_CONTACT_BY_PM;
449
        }
450
        if ($contactby == 3) {
451
            $contactselect = _AM_ADSLIGHT_CONTACT_BY_BOTH;
452
        }
453
        if ($contactby == 4) {
454
            $contactselect = _AM_ADSLIGHT_CONTACT_BY_PHONE;
455
        }
456
457
        echo " <td class='head'>" . _AM_ADSLIGHT_CONTACTBY . " </td><td class='head'><select name=\"contactby\">
458
           <option value=\"" . $contactby . "\">" . $contactselect . "</option>
459
           <option value=\"1\">" . _AM_ADSLIGHT_CONTACT_BY_EMAIL . "</option>
460
           <option value=\"2\">" . _AM_ADSLIGHT_CONTACT_BY_PM . "</option>
461
           <option value=\"3\">" . _AM_ADSLIGHT_CONTACT_BY_BOTH . "</option>
462
           <option value=\"4\">" . _AM_ADSLIGHT_CONTACT_BY_PHONE . '</option></select></td></tr>';
463
464
        echo "<tr><td class='head'>" . _AM_ADSLIGHT_STATUS . "</td><td class='head'><input type=\"radio\" name=\"status\" value=\"0\"";
465
        if ($status == '0') {
466
            echo 'checked';
467
        }
468
        echo '>' . _AM_ADSLIGHT_ACTIVE . "&nbsp;&nbsp; <input type=\"radio\" name=\"status\" value=\"1\"";
469
        if ($status == '1') {
470
            echo 'checked';
471
        }
472
        echo '>' . _AM_ADSLIGHT_INACTIVE . "&nbsp;&nbsp; <input type=\"radio\" name=\"status\" value=\"2\"";
473
        if ($status == '2') {
474
            echo 'checked';
475
        }
476
        echo '>' . _AM_ADSLIGHT_SOLD . '</td></tr>';
477
478
        echo "<tr class='head' border='1'>
479
            <td>" . _AM_ADSLIGHT_TITLE2 . " </td><td><input type=\"text\" name=\"title\" size=\"40\" value=\"$title\"></td>
480
            </tr><tr class='head' border='1'>
481
            <td>" . _AM_ADSLIGHT_PREMIUM . " </td><td><input type=\"text\" name=\"premium\" size=\"3\" value=\"$premium\"></td>
482
            </tr><tr class='head' border='1'>
483
            <td>" . _AM_ADSLIGHT_EXPIRE . " </td><td><input type=\"text\" name=\"expire\" size=\"40\" value=\"$expire\"></td>
484
            </tr>";
485
        ////// Type d'annonce
486
        echo "<tr class='head' border='1'>
487
                 <td>" . _AM_ADSLIGHT_TYPE . " </td><td><select name=\"type\">";
488
489
        $result5 = $xoopsDB->query('SELECT nom_type, id_type FROM ' . $xoopsDB->prefix('adslight_type') . ' ORDER BY nom_type');
490
        while (list($nom_type, $id_type) = $xoopsDB->fetchRow($result5)) {
491
            $sel = '';
492
            if ($id_type == $type) {
493
                $sel = 'selected';
494
            }
495
            echo "<option value=\"$id_type\" $sel>$nom_type</option>";
496
        }
497
        echo '</select></td></tr>';
498
499
        ////// Etat d'usure
500
501
        echo "<tr class='head' border='1'>
502
                 <td>" . _AM_ADSLIGHT_TYPE_USURE . " </td><td><select name=\"typeusure\">";
503
504
        $result6 = $xoopsDB->query('SELECT nom_usure, id_usure FROM ' . $xoopsDB->prefix('adslight_usure') . ' ORDER BY nom_usure');
505
        while (list($nom_usure, $id_usure) = $xoopsDB->fetchRow($result6)) {
506
            $sel = '';
507
            if ($id_usure == $typeusure) {
508
                $sel = 'selected';
509
            }
510
            echo "<option value=\"$id_usure\" $sel>$nom_usure</option>";
511
        }
512
        echo '</select></td></tr>';
513
514
        //////// Price
515
516
        echo "<tr class='head' border='1'><td>" . _AM_ADSLIGHT_PRICE2 . " </td><td><input type=\"text\" name=\"price\" size=\"20\" value=\"$price\"> " . $GLOBALS['xoopsModuleConfig']['adslight_money'] . '';
517
518
        //////// Price type
519
520
        $resultx = $xoopsDB->query('SELECT nom_price, id_price FROM ' . $xoopsDB->prefix('adslight_price') . ' ORDER BY nom_price');
521
522
        echo " <select name=\"typeprice\"><option value=\"$id_price\">$nom_price</option>";
523
        while (list($nom_price, $id_price) = $xoopsDB->fetchRow($resultx)) {
524
            $sel = '';
525
            if ($id_price == $typeprice) {
526
                $sel = 'selected';
527
            }
528
529
            echo "<option value=\"$id_price\" $sel>$nom_price</option>";
530
        }
531
        echo '</select></td>';
532
533
        /////// Category
534
        echo "<tr class='head' border='1'>
535
            <td>" . _AM_ADSLIGHT_CAT2 . ' </td><td>';
536
        $mytree->makeMySelBox('title', 'title', $cid);
537
        echo "</td>
538
            </tr><tr class='head' border='1'>
539
            <td>" . _AM_ADSLIGHT_DESC . ' </td><td>';
540
541
        $wysiwyg_text_area = AdslightUtilities::getEditor('', 'desctext', $desctext, '100%', '200px', 'small');
542
        echo $wysiwyg_text_area->render();
543
544
        echo '</td></tr>';
545
546
        echo "<tr class='head' border='1'>
547
            <td>" . _AM_ADSLIGHT_PHOTO1 . " </td><td><input type=\"text\" name=\"photo\" size=\"50\" value=\"$photo\"></td>
548
            </tr><tr>";
549
        $time = time();
550
        echo "</tr><tr class='head' border='1'>
551
            <td>&nbsp;</td><td><select name=\"op\">
552
            <option value=\"ModifyAdsS\"> " . _AM_ADSLIGHT_MODIF . "
553
            <option value=\"ListingDel\"> " . _AM_ADSLIGHT_DEL . "
554
            </select><input type=\"submit\" value=\"" . _AM_ADSLIGHT_GO . "\"></td>
555
            </tr></table>";
556
        echo "<input type=\"hidden\" name=\"valid\" value=\"Yes\">";
557
        echo "<input type=\"hidden\" name=\"lid\" value=\"$lid\">";
558
        echo "<input type=\"hidden\" name=\"date\" value=\"$time\">";
559
        echo "<input type=\"hidden\" name=\"submitter\" value=\"$submitter\">
560
        </form><br>";
561
        echo '</fieldset><br>';
562
        xoops_cp_footer();
563
    }
564
}
565
566
#  function modifyAdsS
567
#####################################################