Passed
Push — master ( 1a0aae...3beb71 )
by Michael
03:11
created

viewads.php (8 issues)

Severity
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * You may not change or alter any portion of this comment or credits
7
 * of supporting developers from this source code or any supporting source code
8
 * which is considered copyrighted (c) material of the original comment or credit authors.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
 */
14
15
/**
16
 * @copyright    XOOPS Project (https://xoops.org)
17
 * @license      GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
18
 * @author       XOOPS Development Team
19
 * @author       Pascal Le Boustouller: original author ([email protected])
20
 * @author       Luc Bizet (www.frxoops.org)
21
 * @author       jlm69 (www.jlmzone.com)
22
 * @author       mamba (www.xoops.org)
23
 */
24
25
use Xmf\Module\Admin;
26
use Xmf\Request;
27
use XoopsModules\Adslight\{
28
    Helper,
29
    PicturesHandler,
30
    Tree,
31
    Utility
32
};
33
34
/** @var Helper $helper */
35
36
require_once __DIR__ . '/header.php';
37
//require_once XOOPS_ROOT_PATH . '/modules/adslight/include/gtickets.php';
38
xoops_load('XoopsLocal');
39
40
$myts      = \MyTextSanitizer::getInstance();
41
$moduleId = $xoopsModule->getVar('mid');
42
43
if (is_object($GLOBALS['xoopsUser'])) {
44
    $groups = $GLOBALS['xoopsUser']->getGroups();
45
} else {
46
    $groups = XOOPS_GROUP_ANONYMOUS;
47
}
48
/** @var \XoopsGroupPermHandler $grouppermHandler */
49
$grouppermHandler = xoops_getHandler('groupperm');
50
$perm_itemid      = Request::getInt('item_id', 0, 'POST');
51
//If no access
52
if (!$grouppermHandler->checkRight('adslight_view', $perm_itemid, $groups, $moduleId)) {
53
    redirect_header(XOOPS_URL . '/index.php', 3, _NOPERM);
54
}
55
if ($grouppermHandler->checkRight('adslight_premium', $perm_itemid, $groups, $moduleId)) {
56
    $prem_perm = '1';
57
} else {
58
    $prem_perm = '0';
59
}
60
61
$mytree = new Tree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid');
62
63
#  function viewads
64
#####################################################
65
/**
66
 * @param int $lid
67
 */
68
function viewAds($lid = 0): void
69
{
70
    global $xoopsDB, $xoopsConfig, $xoopsModule, $xoopsTpl, $myts, $meta, $prem_perm, $xoopsUser;
71
72
    $helper = Helper::getInstance();
73
74
    $moduleDirName = \basename(__DIR__);
75
76
    $pathIcon16     = Admin::iconUrl('', '16');
77
    $contact_pm     = $contact = '';
78
    $picturesArray = [];
79
    $cid            = 0;
80
81
    $tempXoopsLocal                          = new \XoopsLocal();
82
    $GLOBALS['xoopsOption']['template_main'] = 'adslight_item.tpl';
83
    require_once XOOPS_ROOT_PATH . '/header.php';
84
    //    require_once XOOPS_ROOT_PATH . '/include/comment_view.php';
85
    $lid  = max((int)$lid, 0);
86
    $rate = '1' === $helper->getConfig('adslight_rate_item') ? '1' : '0';
87
    $GLOBALS['xoopsTpl']->assign('rate', $rate);
88
    $GLOBALS['xoopsTpl']->assign('xmid', $xoopsModule->getVar('mid'));
89
    $GLOBALS['xoopsTpl']->assign('adslight_logolink', _ADSLIGHT_LOGOLINK);
90
91
    // Hack redirection erreur 404  si lid=null
92
    if ('' === $lid) {
93
        header('Status: 301 Moved Permanently', false, 301);
94
        //        header('Location: '.XOOPS_URL.'/modules/adslight/404.php');
95
        //        exit();
96
        $helper->redirect('404.php', 1);
97
    }
98
99
    $GLOBALS['xoopsTpl']->assign('adslight_active_bookmark', $helper->getConfig('adslight_active_bookmark'));
100
    $GLOBALS['xoopsTpl']->assign('adslight_style_bookmark', $helper->getConfig('adslight_style_bookmark'));
101
    //    $GLOBALS['xoopsTpl']->assign('adslight_active_xpayement', $helper->getConfig('adslight_active_xpayment'));
102
103
    // adslight 2
104
    $GLOBALS['xoopsTpl']->assign('adslight_active_menu', $helper->getConfig('adslight_active_menu'));
105
    $GLOBALS['xoopsTpl']->assign('adslight_active_rss', $helper->getConfig('adslight_active_rss'));
106
107
    if ($GLOBALS['xoopsUser']) {
108
        $member_usid = $GLOBALS['xoopsUser']->getVar('uid');
109
        if ($usid = $member_usid) {
0 ignored issues
show
The assignment to $usid is dead and can be removed.
Loading history...
110
            $GLOBALS['xoopsTpl']->assign('istheirs', true);
111
112
            if ('' !== $GLOBALS['xoopsUser']->getVar('name')) {
113
                $GLOBALS['xoopsTpl']->assign('user_name', $GLOBALS['xoopsUser']->getVar('name') . ' (' . $GLOBALS['xoopsUser']->getVar('uname') . ')');
114
            } else {
115
                $GLOBALS['xoopsTpl']->assign('user_name', $GLOBALS['xoopsUser']->getVar('uname'));
116
            }
117
118
            $GLOBALS['xoopsTpl']->assign('user_email', $GLOBALS['xoopsUser']->getVar('email'));
119
120
            $sql = 'SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_listing') . " WHERE usid=${member_usid}";
121
            [$show_user] = $xoopsDB->fetchRow($xoopsDB->query($sql));
122
123
            $GLOBALS['xoopsTpl']->assign('show_user', $show_user);
124
            $GLOBALS['xoopsTpl']->assign('show_user_link', 'members.php?uid=' . $member_usid);
125
        }
126
    }
127
128
    if ($GLOBALS['xoopsUser']) {
129
        $currentid = $GLOBALS['xoopsUser']->getVar('uid', 'E');
0 ignored issues
show
The assignment to $currentid is dead and can be removed.
Loading history...
130
    }
131
132
    $cat_perms  = '';
133
    $categories = Utility::getMyItemIds('adslight_view');
134
    if (is_array($categories) && count($categories) > 0) {
135
        $cat_perms .= ' AND cid IN (' . implode(',', $categories) . ') ';
136
    }
137
138
    $result      = $xoopsDB->query(
139
        'SELECT l.lid, l.cid, l.title, l.status, l.expire, l.type, l.desctext, l.tel, l.price, l.typeprice, l.typecondition, l.date_created, l.email, l.submitter, l.usid, l.town, l.country, l.contactby, l.premium, l.valid, l.photo, l.hits, l.item_rating, l.item_votes, l.user_rating, l.user_votes, l.comments, p.cod_img, p.lid, p.uid_owner, p.url FROM '
140
        . $xoopsDB->prefix('adslight_listing')
141
        . ' l LEFT JOIN '
142
        . $xoopsDB->prefix('adslight_pictures')
143
        . " p ON l.lid=p.lid  WHERE l.valid='Yes' AND l.lid = "
144
        . $xoopsDB->escape($lid)
145
        . " and l.status!='1' ${cat_perms}"
146
    );
147
    $recordexist = $xoopsDB->getRowsNum($result);
148
149
    // Hack redirection erreur 404  si recordexist=null
150
    if ('' === $recordexist) {
151
        header('Status: 301 Moved Permanently', false, 301);
152
        //        header('Location: '.XOOPS_URL.'/modules/adslight/404.php');
153
        //        exit();
154
        $helper->redirect('404.php', 1);
155
    }
156
157
    if ($recordexist) {
158
        [
159
            $lid,
160
            $cid,
161
            $title,
162
            $status,
163
            $expire,
164
            $type,
165
            $desctext,
166
            $tel,
167
            $price,
168
            $typeprice,
169
            $typecondition,
170
            $date_created,
171
            $email,
172
            $submitter,
173
            $usid,
174
            $town,
175
            $country,
176
            $contactby,
177
            $premium,
178
            $valid,
179
            $photo,
180
            $hits,
181
            $item_rating,
182
            $item_votes,
183
            $user_rating,
184
            $user_votes,
185
            $comments,
186
            $cod_img,
187
            $pic_lid,
188
            $uid_owner,
189
            $url,
190
        ] = $xoopsDB->fetchRow($result);
191
192
        $newcount  = $helper->getConfig('adslight_countday');
193
        $startdate = time() - (86400 * $newcount);
194
        if ($startdate < $date_created) {
195
            $newitem = '<img src="' . XOOPS_URL . '/modules/adslight/assets/images/newred.gif" alt="new" >';
196
            $GLOBALS['xoopsTpl']->assign('new', $newitem);
197
        }
198
199
        $updir = $helper->getConfig('adslight_link_upload');
0 ignored issues
show
The assignment to $updir is dead and can be removed.
Loading history...
200
        $GLOBALS['xoopsTpl']->assign('add_from', _ADSLIGHT_ADDFROM . ' ' . $xoopsConfig['sitename']);
201
        $GLOBALS['xoopsTpl']->assign('add_from_title', _ADSLIGHT_ADDFROM);
202
        $GLOBALS['xoopsTpl']->assign('add_from_sitename', $xoopsConfig['sitename']);
203
        $GLOBALS['xoopsTpl']->assign('ad_exists', $recordexist);
204
        $GLOBALS['xoopsTpl']->assign('mydirname', $moduleDirName);
205
206
        $count   = 0;
0 ignored issues
show
The assignment to $count is dead and can be removed.
Loading history...
207
        $x       = 0;
208
        $i       = 0;
0 ignored issues
show
The assignment to $i is dead and can be removed.
Loading history...
209
        $sql     = 'SELECT cid, pid, title FROM ' . $xoopsDB->prefix('adslight_categories') . ' WHERE  cid=' . $xoopsDB->escape($cid);
210
        $result3 = $xoopsDB->query($sql);
211
        [$ccid, $pid, $ctitle] = $xoopsDB->fetchRow($result3);
212
213
        $GLOBALS['xoopsTpl']->assign('category_title', $ctitle);
214
215
        $moduleId = $xoopsModule->getVar('mid');
216
        if (is_object($GLOBALS['xoopsUser'])) {
217
            $groups = $GLOBALS['xoopsUser']->getGroups();
218
        } else {
219
            $groups = XOOPS_GROUP_ANONYMOUS;
220
        }
221
        /** @var \XoopsGroupPermHandler $grouppermHandler */
222
        $grouppermHandler = xoops_getHandler('groupperm');
223
        $GLOBALS['xoopsTpl']->assign('purchasable', $grouppermHandler->checkRight('adslight_purchase', $cid, $groups, $moduleId));
224
225
        $ctitle     = \htmlspecialchars($ctitle, ENT_QUOTES | ENT_HTML5);
226
        $varid[$x]  = $ccid;
227
        $varnom[$x] = $ctitle;
228
229
        $sql = 'SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE valid="Yes" AND cid=' . $xoopsDB->escape($cid) . ' AND status!="1"';
230
        [$nbe] = $xoopsDB->fetchRow($xoopsDB->query($sql));
231
        if (0 !== (int)$pid) {
232
            $x = 1;
233
            while (0 !== (int)$pid) {
234
                $sql     = 'SELECT cid, pid, title FROM ' . $xoopsDB->prefix('adslight_categories') . ' WHERE cid=' . $xoopsDB->escape($pid);
235
                $result4 = $xoopsDB->query($sql);
236
                [$ccid, $pid, $ctitle] = $xoopsDB->fetchRow($result4);
237
238
                $ctitle     = \htmlspecialchars($ctitle, ENT_QUOTES | ENT_HTML5);
239
                $varid[$x]  = $ccid;
240
                $varnom[$x] = $ctitle;
241
                ++$x;
242
            }
243
            --$x;
244
        }
245
        $subcats = '';
246
        $arrow   = '&nbsp;<img src="' . XOOPS_URL . '/modules/adslight/assets/images/arrow.gif" alt="&raquo;" >';
247
        while (-1 !== $x) {
248
            $subcats .= ' ' . $arrow . ' <a href="viewcats.php?cid=' . $varid[$x] . '">' . $varnom[$x] . '</a>';
249
            --$x;
250
        }
251
        $GLOBALS['xoopsTpl']->assign('nav_main', '<a href="index.php">' . _ADSLIGHT_MAIN . '</a>');
252
        $GLOBALS['xoopsTpl']->assign('nav_sub', $subcats);
253
        $GLOBALS['xoopsTpl']->assign('nav_subcount', $nbe);
254
        $viewcount_judge = true;
255
        $useroffset      = '';
256
        if ($GLOBALS['xoopsUser']) {
257
            $timezone = $GLOBALS['xoopsUser']->timezone();
258
            if (isset($timezone)) {
259
                $useroffset = $GLOBALS['xoopsUser']->timezone();
260
            } else {
261
                $useroffset = $xoopsConfig['default_TZ'];
262
            }
263
            if ($GLOBALS['xoopsUser']->isAdmin()) {
264
                $adslight_admin = true;
265
            } else {
266
                $adslight_admin = false;
267
            }
268
269
            if (($adslight_admin = true)
270
                || ($GLOBALS['xoopsUser']->getVar('uid') === $usid)) {
271
                $viewcount_judge = false;
272
            }
273
274
            $contact_pm = '<a href="' . XOOPS_URL . '/pmlite.php?send2=1&amp;to_userid=' . addslashes($usid) . '">&nbsp;' . _ADSLIGHT_CONTACT_BY_PM . '</a>';
275
        }
276
        if ($viewcount_judge) {
277
            $xoopsDB->queryF('UPDATE ' . $xoopsDB->prefix('adslight_listing') . ' SET hits=hits+1 WHERE lid = ' . $xoopsDB->escape($lid));
278
        }
279
        if (1 === $item_votes) {
280
            $votestring = _ADSLIGHT_ONEVOTE;
281
        } else {
282
            $votestring = sprintf(_ADSLIGHT_NUMVOTES, $item_votes);
283
        }
284
        $date_created = ((int)$useroffset * 3600) + $date_created;
285
        $date2        = $date_created + ($expire * 86400);
286
        $date_created = formatTimestamp($date_created, 's');
287
        $date2        = formatTimestamp($date2, 's');
288
289
        $title    = \htmlspecialchars($title, ENT_QUOTES | ENT_HTML5);
290
        $status   = \htmlspecialchars($status, ENT_QUOTES | ENT_HTML5);
291
        $expire   = \htmlspecialchars($expire, ENT_QUOTES | ENT_HTML5);
0 ignored issues
show
The assignment to $expire is dead and can be removed.
Loading history...
292
        $type     = \htmlspecialchars($type, ENT_QUOTES | ENT_HTML5);
293
        $desctext = $myts->displayTarea($desctext, 1, 1, 1);
294
        $tel      = \htmlspecialchars($tel, ENT_QUOTES | ENT_HTML5);
295
        //        $price = XoopsLocal::number_format($price, 2, ',', ' ');
296
        $typeprice     = \htmlspecialchars($typeprice, ENT_QUOTES | ENT_HTML5);
297
        $typecondition = \htmlspecialchars($typecondition, ENT_QUOTES | ENT_HTML5);
298
        $submitter     = \htmlspecialchars($submitter, ENT_QUOTES | ENT_HTML5);
299
        $usid          = \htmlspecialchars($usid, ENT_QUOTES | ENT_HTML5);
300
        $town          = \htmlspecialchars($town, ENT_QUOTES | ENT_HTML5);
301
        $country       = \htmlspecialchars($country, ENT_QUOTES | ENT_HTML5);
302
        $contactby     = \htmlspecialchars($contactby, ENT_QUOTES | ENT_HTML5);
303
        $premium       = \htmlspecialchars($premium, ENT_QUOTES | ENT_HTML5);
304
        if (2 === (int)$status) {
305
            $sold = _ADSLIGHT_RESERVED;
306
        } else {
307
            $sold = '';
308
        }
309
310
        $GLOBALS['xoopsTpl']->assign('printA', '<a href="print.php?op=PrintAd&amp;lid=' . $lid . '" ><img src="assets/images/print.gif" border=0 alt="' . _ADSLIGHT_PRINT . '" ></a>&nbsp;');
311
312
        if ($usid > 0) {
313
            $GLOBALS['xoopsTpl']->assign('submitter', '<img src="assets/images/lesannonces.png" border="0" alt="' . _ADSLIGHT_VIEW_MY_ADS . '" >&nbsp;&nbsp;<a href="members.php?usid=' . addslashes($usid) . '" >' . _ADSLIGHT_VIEW_MY_ADS . ' ' . $submitter . '</a>');
314
        } else {
315
            $GLOBALS['xoopsTpl']->assign('submitter', _ADSLIGHT_VIEW_MY_ADS . ' $submitter');
316
        }
317
        $GLOBALS['xoopsTpl']->assign('lid', $lid);
318
        $GLOBALS['xoopsTpl']->assign('read', "${hits} " . _ADSLIGHT_VIEW2);
319
        $GLOBALS['xoopsTpl']->assign('rating', $tempXoopsLocal->number_format($item_rating));
320
        $GLOBALS['xoopsTpl']->assign('votes', $votestring);
321
        $GLOBALS['xoopsTpl']->assign('lang_rating', _ADSLIGHT_RATINGC);
322
        $GLOBALS['xoopsTpl']->assign('lang_ratethisitem', _ADSLIGHT_RATETHISITEM);
323
        $GLOBALS['xoopsTpl']->assign('xoop_user', false);
324
        $isOwner = '';
0 ignored issues
show
The assignment to $isOwner is dead and can be removed.
Loading history...
325
        if ($GLOBALS['xoopsUser']) {
326
            $GLOBALS['xoopsTpl']->assign('xoop_user', true);
327
            $currentid = $GLOBALS['xoopsUser']->getVar('uid', 'E');
328
            if ($usid == $currentid) {
329
                $GLOBALS['xoopsTpl']->assign('modifyads', '<img src=' . $pathIcon16 . '/edit.png border="0" alt="' . _ADSLIGHT_MODIFANN . '" >&nbsp;&nbsp;<a href="modify.php?op=modad&amp;lid=' . $lid . '">' . _ADSLIGHT_MODIFANN . '</a>');
330
                $GLOBALS['xoopsTpl']->assign('deleteads', '<img src=' . $pathIcon16 . '/delete.png  border="0" alt="' . _ADSLIGHT_SUPPRANN . '" >&nbsp;&nbsp;<a href="modify.php?op=ListingDel&amp;lid=' . $lid . '">' . _ADSLIGHT_SUPPRANN . '</a>');
331
                $GLOBALS['xoopsTpl']->assign('add_photos', '<img src="assets/images/shape_square_add.png" border="0" alt="' . _ADSLIGHT_SUPPRANN . '" >&nbsp;&nbsp;<a href="view_photos.php?lid=' . $lid . '&uid=' . $usid . '">' . _ADSLIGHT_ADD_PHOTOS . '</a>');
332
333
                $isOwner = true;
334
                $GLOBALS['xoopsTpl']->assign('isOwner', $isOwner);
335
            }
336
            if ($GLOBALS['xoopsUser']->isAdmin()) {
337
                $GLOBALS['xoopsTpl']->assign('admin', '<a href="' . XOOPS_URL . '/modules/adslight/admin/modify_ads.php?op=modifyAds&amp;lid=' . $lid . '"><img src=' . $pathIcon16 . '/edit.png  border=0 alt="' . _ADSLIGHT_MODADMIN . '" ></a>');
338
            }
339
        }
340
341
        $sql     = 'SELECT nom_type FROM ' . $xoopsDB->prefix('adslight_type') . " WHERE id_type='" . $xoopsDB->escape($type) . "'";
342
        $result7 = $xoopsDB->query($sql);
343
        [$nom_type] = $xoopsDB->fetchRow($result7);
344
345
        $sql     = 'SELECT nom_price FROM ' . $xoopsDB->prefix('adslight_price') . " WHERE id_price='" . $xoopsDB->escape($typeprice) . "'";
346
        $result8 = $xoopsDB->query($sql);
347
        [$nom_price] = $xoopsDB->fetchRow($result8);
348
349
        $sql     = 'SELECT nom_condition FROM ' . $xoopsDB->prefix('adslight_condition') . " WHERE id_condition='" . $xoopsDB->escape($typecondition) . "'";
350
        $result9 = $xoopsDB->query($sql);
351
        [$nom_condition] = $xoopsDB->fetchRow($result9);
352
353
        $GLOBALS['xoopsTpl']->assign('type', htmlspecialchars($nom_type, ENT_QUOTES | ENT_HTML5));
354
        $GLOBALS['xoopsTpl']->assign('title', $title);
355
        $GLOBALS['xoopsTpl']->assign('status', $status);
356
        $GLOBALS['xoopsTpl']->assign('desctext', $desctext);
357
        $GLOBALS['xoopsTpl']->assign('xoops_pagetitle', $title . ' - ' . $town . ': ' . $country . ' - ' . $ctitle);
358
359
        // meta description tags for ads
360
        $desctextclean = strip_tags($desctext, '<span><img><strong><i><u>');
361
        $GLOBALS['xoTheme']->addMeta('meta', 'description', "${title} - " . mb_substr($desctextclean, 0, 150));
362
363
        $currencyCode                 = $helper->getConfig('adslight_currency_code');
364
        $currencySymbol               = $helper->getConfig('adslight_currency_symbol');
365
        $currencyPosition             = $helper->getConfig('currency_position');
366
        $formattedCurrencyUtilityTemp = Utility::formatCurrencyTemp($price, $currencyCode, $currencySymbol, $currencyPosition);
367
368
        if ($price > 0) {
369
            $GLOBALS['xoopsTpl']->assign('price', '<strong>' . _ADSLIGHT_PRICE2 . '</strong>' . $price . ' ' . $helper->getConfig('adslight_currency_symbol') . ' - ' . $typeprice);
370
            $GLOBALS['xoopsTpl']->assign('price_head', _ADSLIGHT_PRICE2);
371
            $GLOBALS['xoopsTpl']->assign('price_price', $formattedCurrencyUtilityTemp);
372
373
            $priceTypeprice = \htmlspecialchars($nom_price, ENT_QUOTES | ENT_HTML5);
374
            $GLOBALS['xoopsTpl']->assign('price_typeprice', $priceTypeprice);
375
            $priceCurrency = $helper->getConfig('adslight_currency_code');
376
            $GLOBALS['xoopsTpl']->assign('price_currency', $priceCurrency);
377
378
            //            $priceHtml = '<strong>' . _ADSLIGHT_PRICE2 . '</strong>' . $price . ' ' . $helper->getConfig('adslight_currency_symbol') . ' - ' . $typeprice;
379
380
            $priceHtml = '<strong>' . _ADSLIGHT_PRICE2 . '</strong>' . $formattedCurrencyUtilityTemp . ' - ' . $priceTypeprice;
381
382
            $GLOBALS['xoopsTpl']->assign('price', $priceHtml);
383
384
            $GLOBALS['xoopsTpl']->assign('price_amount', $price);
385
        }
386
387
        $GLOBALS['xoopsTpl']->assign('condition_typecondition', $nom_condition);
388
        $GLOBALS['xoopsTpl']->assign('premium', $premium);
389
390
        // $GLOBALS['xoopsTpl']->assign('mustlogin', _ADSLIGHT_MUSTLOGIN);
391
        $GLOBALS['xoopsTpl']->assign('redirect', '' . '?xoops_redirect=/modules/adslight/index.php');
392
393
        if ($town) {
394
            $GLOBALS['xoopsTpl']->assign('local_town', $town);
395
        }
396
        if (1 === $helper->getConfig('adslight_use_country')) {
397
            if ($country) {
398
                $GLOBALS['xoopsTpl']->assign('local_country', $country);
399
                $GLOBALS['xoopsTpl']->assign('country_head', '<img src="assets/images/world_go.png" border="0" alt="country" >&nbsp;&nbsp;' . _ADSLIGHT_COUNTRY);
400
            }
401
        }
402
403
        $tphon = '';
404
        if ($tel) {
405
            $tphon = '<br>' . _ADSLIGHT_ORBY . '&nbsp;<strong>' . _ADSLIGHT_TEL . '</strong> ' . $tel;
406
        }
407
        if (1 === (int)$contactby) {
408
            $contact = '<a rel="nofollow" href="contact.php?lid=' . $lid . '">' . _ADSLIGHT_BYMAIL2 . '</a>' . $tphon . '';
409
        }
410
        if (2 === (int)$contactby) {
411
            $contact = $contact_pm . '' . $tphon;
412
        }
413
        if (3 === (int)$contactby) {
414
            $contact = '<a rel="nofollow" href="contact.php?lid=' . $lid . '">' . _ADSLIGHT_BYMAIL2 . '</a>' . $tphon . '<br>' . _ADSLIGHT_ORBY . '' . $contact_pm;
415
        }
416
        if (4 === (int)$contactby) {
417
            $contact = '<br><strong>' . _ADSLIGHT_TEL . '</strong> ' . $tel;
418
        }
419
        // $GLOBALS['xoopsTpl']->assign('contact', $contact);
420
        $GLOBALS['xoopsTpl']->assign('local_head', '<img src="assets/images/house.png" border="0" alt="local_head" >&nbsp;&nbsp;' . _ADSLIGHT_LOCAL);
421
422
        if ($lid) {
423
            if ($sold) {
424
                $GLOBALS['xoopsTpl']->assign('bullinfotext', $sold);
425
            } elseif ($GLOBALS['xoopsUser']) {
426
                $GLOBALS['xoopsTpl']->assign('bullinfotext', _ADSLIGHT_CONTACT_SUBMITTER . ' ' . $submitter . ' ' . _ADSLIGHT_CONTACTBY2 . ' ' . $contact);
427
            } else {
428
                $GLOBALS['xoopsTpl']->assign('bullinfotext', '<span style="color: #de090e;"><b>' . _ADSLIGHT_MUSTLOGIN . '</b></span>');
429
            }
430
        }
431
432
        $user_profile = \XoopsUser::getUnameFromId($usid);
433
        $GLOBALS['xoopsTpl']->assign('user_profile', '<img src="assets/images/profil.png" border="0" alt="' . _ADSLIGHT_PROFILE . '" >&nbsp;&nbsp;<a rel="nofollow" href="' . XOOPS_URL . '/user.php?usid=' . addslashes($usid) . '">' . _ADSLIGHT_PROFILE . ' ' . $user_profile . '</a>');
434
        if ('' !== $photo) {
435
            $criteria_lid          = new \Criteria('lid', $lid);
436
            $criteria_uid          = new \Criteria('uid', $usid);
437
            $picturesHandler         = $helper->getHandler('Pictures');
438
            $pictures_object_array = $picturesHandler->getObjects($criteria_lid, $criteria_uid);
439
            $pictures_number       = $picturesHandler->getCount($criteria_lid);
440
            if (0 === $pictures_number) {
441
                $nopicturesyet = _ADSLIGHT_NOTHINGYET;
442
                $GLOBALS['xoopsTpl']->assign('lang_nopicyet', $nopicturesyet);
443
            } else {
444
                /**
445
                 * Let's populate an array with the data from the pictures
446
                 */
447
                $i = 0;
448
                foreach ($pictures_object_array as $picture) {
449
                    $picturesArray[$i]['url']     = $picture->getVar('url', 's');
450
                    $picturesArray[$i]['desc']    = $picture->getVar('title', 's');
451
                    $picturesArray[$i]['cod_img'] = $picture->getVar('cod_img', 's');
452
                    $picturesArray[$i]['lid']     = $picture->getVar('lid', 's');
453
                    $GLOBALS['xoopsTpl']->assign('pics_array', $picturesArray);
454
455
                    ++$i;
456
                }
457
            }
458
            $owner      = new \XoopsUser();
459
            $identifier = $owner::getUnameFromId($usid);
0 ignored issues
show
The assignment to $identifier is dead and can be removed.
Loading history...
460
461
            Utility::loadLightbox(); // JJDai
462
            /*
463
                        if (1 === $helper->getConfig('adslight_lightbox')) {
464
465
                            $header_lightbox = '<link rel="stylesheet" href="' . XOOPS_URL . '/modules/adslight/assets/css/adslight.css" type="text/css" media="all" >
466
            <script type="text/javascript" src="assets/lightbox/js/jquery-1.7.2.min.js"></script>
467
            <script type="text/javascript" src="assets/lightbox/js/jquery-ui-1.8.18.custom.min"></script>
468
            <script type="text/javascript" src="assets/lightbox/js/jquery.smooth-scroll.min.js"></script>
469
            <script type="text/javascript" src="assets/lightbox/js/lightbox.js"></script>
470
            <link rel="stylesheet" href="assets/css/galery.css" type="text/css" media="screen" >
471
            <link rel="stylesheet" type="text/css" media="screen" href="assets/lightbox/css/lightbox.css"></link>';
472
                        } else {
473
                            $header_lightbox = '<link rel="stylesheet" href="' . XOOPS_URL . '/modules/adslight/assets/css/adslight.css" type="text/css" media="all" >
474
            <link rel="stylesheet" href="assets/css/galery.css" type="text/css" media="screen" >';
475
                        }
476
            */
477
478
            $GLOBALS['xoopsTpl']->assign('path_uploads', $helper->getConfig('adslight_link_upload'));
479
480
            $GLOBALS['xoopsTpl']->assign('permit', $prem_perm);
481
            if ($helper->getConfig('active_rewriteurl') > 0) {
482
                /*  ici le meta Canonicale pour le Rewrite */
483
                //$GLOBALS['xoopsTpl']->assign('xoops_module_header', $header_lightbox);
484
            }
485
            //$GLOBALS['xoopsTpl']->assign('xoops_module_header', $header_lightbox);
486
487
            $GLOBALS['xoopsTpl']->assign('photo', $photo);
488
            $GLOBALS['xoopsTpl']->assign('pic_lid', $pic_lid);
489
            $GLOBALS['xoopsTpl']->assign('pic_owner', $uid_owner);
490
        } else {
491
            $GLOBALS['xoopsTpl']->assign('photo', '');
492
        }
493
        $GLOBALS['xoopsTpl']->assign(
494
            'date_created',
495
            '<img alt="date_created" border="0" src="assets/images/date.png" >&nbsp;&nbsp;<strong>' . _ADSLIGHT_DATE2 . ':</strong> ' . $date_created . '<br><img alt="date_error" border="0" src="assets/images/date_error.png" >&nbsp;&nbsp;<strong>' . _ADSLIGHT_DISPO . ':</strong> ' . $date2
496
        );
497
    } else {
498
        $GLOBALS['xoopsTpl']->assign('no_ad', _ADSLIGHT_NOCLAS);
499
    }
500
    $sql     = 'SELECT title FROM ' . $xoopsDB->prefix('adslight_categories') . ' WHERE cid=' . $xoopsDB->escape($cid);
501
    $result8 = $xoopsDB->query($sql);
502
503
    [$ctitle] = $xoopsDB->fetchRow($result8);
504
    $GLOBALS['xoopsTpl']->assign('friend', '<img src="assets/images/friend.gif" border="0" alt="' . _ADSLIGHT_SENDFRIENDS . '" >&nbsp;&nbsp;<a rel="nofollow" href="sendfriend.php?op=SendFriend&amp;lid=' . $lid . '">' . _ADSLIGHT_SENDFRIENDS . '</a>');
505
506
    $GLOBALS['xoopsTpl']->assign('alerteabus', '<img src="assets/images/error.png" border="0" alt="' . _ADSLIGHT_ALERTEABUS . '" >&nbsp;&nbsp;<a rel="nofollow" href="report-abuse.php?op=ReportAbuse&amp;lid=' . $lid . '">' . _ADSLIGHT_ALERTEABUS . '</a>');
507
508
    $GLOBALS['xoopsTpl']->assign('link_main', '<a href="../adslight/">' . _ADSLIGHT_MAIN . '</a>');
509
    $GLOBALS['xoopsTpl']->assign('link_cat', '<a href="viewcats.php?cid=' . addslashes($cid) . '">' . _ADSLIGHT_GORUB . ' ' . $ctitle . '</a>');
510
511
    $GLOBALS['xoopsTpl']->assign('printA', '<img src="assets/images/print.gif" border="0" alt="' . _ADSLIGHT_PRINT . '" >&nbsp;&nbsp;<a rel="nofollow" href="print.php?op=PrintAd&amp;lid=' . $lid . '">' . _ADSLIGHT_PRINT . '</a>');
512
}
513
514
#  function categorynewgraphic
515
#####################################################
516
/**
517
 * @param $cid
518
 * @return string
519
 */
520
function categorynewgraphic($cid): string
521
{
522
    global $xoopsDB;
523
    $helper = Helper::getInstance();
524
525
    $cat_perms  = '';
526
    $categories = Utility::getMyItemIds('adslight_view');
527
    if (is_array($categories) && count($categories) > 0) {
528
        $cat_perms .= ' AND cid IN (' . implode(',', $categories) . ') ';
529
    }
530
531
    $sql       = 'SELECT date_created FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE cid=' . $xoopsDB->escape($cid) . ' AND valid = "Yes" ' . $cat_perms . ' ORDER BY date_created DESC LIMIT 1';
532
    $newresult = $xoopsDB->query($sql);
533
    [$date_created] = $xoopsDB->fetchRow($newresult);
534
535
    $newcount  = $helper->getConfig('adslight_countday');
536
    $startdate = time() - (86400 * $newcount);
537
    if ($startdate < $date_created) {
538
        return '<img src="' . XOOPS_URL . '/modules/adslight/assets/images/newred.gif" alt="new" >';
539
    }
540
}
541
542
######################################################
543
544
$pa      = Request::getInt('pa', null, 'GET');
545
$lid     = Request::getInt('lid', null, 'GET');
546
$cid     = Request::getInt('cid', null, 'GET');
547
$usid    = Request::getString('usid', '', 'GET');
548
$min     = Request::getInt('min', null, 'GET');
549
$show    = Request::getInt('show', null, 'GET');
550
$orderby = Request::getInt('orderby', null, 'GET');
551
552
switch ($pa) {
553
    default:
554
        $GLOBALS['xoopsOption']['template_main'] = 'adslight_item.tpl';
555
556
        viewAds($lid);
557
        require XOOPS_ROOT_PATH . '/include/comment_view.php';
558
        break;
559
}
560
require_once XOOPS_ROOT_PATH . '/footer.php';
561