Completed
Branch master (a25b3b)
by Michael
03:43 queued 01:22
created

viewads.php (1 issue)

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