Passed
Push — master ( 34ef5d...2f53de )
by Michael
04:04 queued 19s
created

viewcats.php (1 issue)

Labels
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
    Tree,
30
    Utility
31
};
32
33
/** @var Helper $helper */
34
35
require_once __DIR__ . '/header.php';
36
//require_once XOOPS_ROOT_PATH . '/modules/adslight/include/gtickets.php';
37
xoops_load('XoopsLocal');
38
$tempXoopsLocal = new \XoopsLocal();
39
$myts           = \MyTextSanitizer::getInstance();
40
$module_id      = $xoopsModule->getVar('mid');
41
42
if (is_object($GLOBALS['xoopsUser'])) {
43
    $groups = $GLOBALS['xoopsUser']->getGroups();
44
} else {
45
    $groups = XOOPS_GROUP_ANONYMOUS;
46
}
47
/** @var \XoopsGroupPermHandler $grouppermHandler */
48
$grouppermHandler = xoops_getHandler('groupperm');
49
50
$perm_itemid = Request::getInt('item_id', 0, 'POST');
51
52
if (!$grouppermHandler->checkRight('adslight_view', $perm_itemid, $groups, $module_id)) {
53
    redirect_header(XOOPS_URL . '/index.php', 3, _NOPERM);
54
}
55
if ($grouppermHandler->checkRight('adslight_premium', $perm_itemid, $groups, $module_id)) {
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 view (categories)
64
#####################################################
65
/**
66
 * @param int|null $cid
67
 * @param int|null $min
68
 * @param string   $orderby
69
 * @param int|null $show
70
 */
71
function adsView($cid, $min, $orderby, $show = 0): void
72
{
73
    global $xoopsDB, $xoopsTpl, $xoopsConfig, $myts, $mytree, $imagecat, $meta, $mid, $prem_perm, $xoopsModule;
74
75
    $helper     = Helper::getInstance();
76
    $pathIcon16 = Admin::iconUrl('', 16);
77
78
    $GLOBALS['xoopsOption']['template_main'] = 'adslight_category.tpl';
79
    require_once XOOPS_ROOT_PATH . '/header.php';
80
81
    $GLOBALS['xoopsTpl']->assign('xmid', $xoopsModule->getVar('mid'));
82
    $GLOBALS['xoopsTpl']->assign('add_from', _ADSLIGHT_ADDFROM . ' ' . $xoopsConfig['sitename']);
83
    $GLOBALS['xoopsTpl']->assign('add_from_title', _ADSLIGHT_ADDFROM);
84
    $GLOBALS['xoopsTpl']->assign('add_from_sitename', $xoopsConfig['sitename']);
85
    $GLOBALS['xoopsTpl']->assign('only_pix', _ADSLIGHT_ONLYPIX);
86
    $GLOBALS['xoopsTpl']->assign('adslight_logolink', _ADSLIGHT_LOGOLINK);
87
    $GLOBALS['xoopsTpl']->assign('permit', $prem_perm);
88
89
    $GLOBALS['xoopsTpl']->assign('xoops_module_header', '<link rel="stylesheet" href="' . XOOPS_URL . '/modules/adslight/assets/css/adslight.css" type="text/css" media="all" >');
90
91
    // $adslight_use_catscode = $GLOBALS['xoopsModuleConfig']['adslight_use_catscode'];
92
    // $adslight_cats_code = $GLOBALS['xoopsModuleConfig']['adslight_cats_code'];
93
94
    $GLOBALS['xoopsTpl']->assign('adslight_use_catscode', $GLOBALS['xoopsModuleConfig']['adslight_use_catscode']);
95
    $GLOBALS['xoopsTpl']->assign('adslight_cats_code', $GLOBALS['xoopsModuleConfig']['adslight_cats_code']);
96
97
    $banner = xoops_getbanner();
98
    $GLOBALS['xoopsTpl']->assign('banner', $banner);
99
    // $index_code_place = $GLOBALS['xoopsModuleConfig']['adslight_index_code_place'];
100
    // $use_extra_code = $GLOBALS['xoopsModuleConfig']['adslight_use_index_code'];
101
    // $adslight_use_banner = $GLOBALS['xoopsModuleConfig']['adslight_use_banner'];
102
    // $index_extra_code = $GLOBALS['xoopsModuleConfig']['adslight_index_code'];
103
104
    $GLOBALS['xoopsTpl']->assign('use_extra_code', $GLOBALS['xoopsModuleConfig']['adslight_use_index_code']);
105
    $GLOBALS['xoopsTpl']->assign('adslight_use_banner', $GLOBALS['xoopsModuleConfig']['adslight_use_banner']);
106
    $GLOBALS['xoopsTpl']->assign('index_extra_code', $GLOBALS['xoopsModuleConfig']['adslight_index_code']);
107
    $GLOBALS['xoopsTpl']->assign('index_code_place', $GLOBALS['xoopsModuleConfig']['adslight_index_code_place']);
108
109
    // adslight 2
110
    $GLOBALS['xoopsTpl']->assign('adslight_active_menu', $GLOBALS['xoopsModuleConfig']['adslight_active_menu']);
111
    $GLOBALS['xoopsTpl']->assign('adslight_active_rss', $GLOBALS['xoopsModuleConfig']['adslight_active_rss']);
112
113
    /// No Adds in this Cat ///
114
    $submit_perms = Utility::getMyItemIds('adslight_submit');
115
116
    if (is_array($submit_perms) && $GLOBALS['xoopsUser']
117
        && count($submit_perms) > 0) {
118
        $GLOBALS['xoopsTpl']->assign('not_adds_in_this_cat', '' . _ADSLIGHT_ADD_LISTING_NOTADDSINTHISCAT . '<a href="addlisting.php?cid=' . addslashes((string)$cid) . '">' . _ADSLIGHT_ADD_LISTING_NOTADDSSUBMIT . '</a>');
119
    } else {
120
        $GLOBALS['xoopsTpl']->assign('not_adds_in_this_cat', '' . _ADSLIGHT_ADD_LISTING_NOTADDSINTHISCAT . '<br>' . _ADSLIGHT_ADD_LISTING_BULL . '<a href="' . XOOPS_URL . '/register.php">' . _ADSLIGHT_ADD_LISTING_SUB . '</a>.');
121
    }
122
123
    $GLOBALS['xoopsTpl']->assign('Feed_RSS_cat', '&nbsp;&nbsp;&nbsp;<a href="rss.php?cid=' . addslashes((string)$cid) . '"><img border="0" alt="Feed RSS" src="assets/images/rssfeed_buttons.png" ></a>');
124
125
    if ($GLOBALS['xoopsUser']) {
126
        $member_usid = $GLOBALS['xoopsUser']->getVar('uid');
127
        if ($usid = $member_usid) {
128
            $GLOBALS['xoopsTpl']->assign('istheirs', true);
129
130
            [$show_user] = $xoopsDB->fetchRow($xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE usid=' . $member_usid . ' '));
131
132
            $GLOBALS['xoopsTpl']->assign('show_user', $show_user);
133
            $GLOBALS['xoopsTpl']->assign('show_user_link', 'members.php?usid=' . $member_usid);
134
        }
135
    }
136
137
    $default_sort = $GLOBALS['xoopsModuleConfig']['adslight_lsort_order'];
138
139
    $cid = (int) $cid > 0 ? (int) $cid : 0;
140
    $min = (int) $min > 0 ? (int) $min : 0;
141
    $show = (int) $show > 0 ? (int) $show : $GLOBALS['xoopsModuleConfig']['adslight_perpage'];
142
    $max     = $min + $show;
143
    $orderby = isset($orderby) ? Utility::convertOrderByIn($orderby) : $default_sort;
144
145
    $updir = $GLOBALS['xoopsModuleConfig']['adslight_link_upload'];
146
    $GLOBALS['xoopsTpl']->assign('add_from', _ADSLIGHT_ADDFROM . ' ' . $xoopsConfig['sitename']);
147
    $GLOBALS['xoopsTpl']->assign('add_from_title', _ADSLIGHT_ADDFROM);
148
    $GLOBALS['xoopsTpl']->assign('add_from_sitename', $xoopsConfig['sitename']);
149
    $GLOBALS['xoopsTpl']->assign('subcat_title2', _ADSLIGHT_ANNONCES);
150
151
    $categories = Utility::getMyItemIds('adslight_view');
152
153
    //TO DO - check on permissions here
154
    //    if ($categories && is_array($categories)) {
155
    //        if (!in_array($cid, $categories)) {
156
    //            $helper->redirect('index.php', 3, _NOPERM);
157
    //        }
158
    //    } else {    // User can't see any category
159
    //        redirect_header(XOOPS_URL . '/index.php', 3, _NOPERM);
160
    //    }
161
162
    $arrow = '<img src="' . XOOPS_URL . '/modules/adslight/assets/images/arrow.gif" alt="&raquo;" >';
163
164
    $pathstring = '<a href="index.php">' . _ADSLIGHT_MAIN . '</a>';
165
    $pathstring .= $mytree->getNicePathFromId($cid, 'title', 'viewcats.php?');
166
    $GLOBALS['xoopsTpl']->assign('module_name', $xoopsModule->getVar('name'));
167
    $GLOBALS['xoopsTpl']->assign('category_path', $pathstring);
168
    $GLOBALS['xoopsTpl']->assign('category_id', $cid);
169
170
    $countresult = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE  cid=' . $xoopsDB->escape($cid) . ' AND valid="Yes" AND status!="1"');
171
    [$trow] = $xoopsDB->fetchRow($countresult);
172
    $trows = $trow;
173
174
    $cat_perms = '';
175
    if (is_iterable($categories) && count($categories) > 0) {
176
        $cat_perms .= ' AND cid IN (' . implode(',', $categories) . ') ';
177
    }
178
179
    $result = $xoopsDB->query('SELECT cid, pid, title, cat_desc, cat_keywords FROM ' . $xoopsDB->prefix('adslight_categories') . ' WHERE cid=' . $xoopsDB->escape($cid) . ' ' . $cat_perms);
180
    [$cid, $pid, $title, $cat_desc, $cat_keywords] = $xoopsDB->fetchRow($result);
181
182
    $GLOBALS['xoopsTpl']->assign('cat_desc', $cat_desc);
183
    $GLOBALS['xoopsTpl']->assign('cat_title', _ADSLIGHT_ANNONCES . ' ' . $title);
184
    $GLOBALS['xoopsTpl']->assign('cat_keywords', $cat_keywords);
185
    $GLOBALS['xoopsTpl']->assign('xoops_pagetitle', $title);
186
187
    if ($cat_desc > '0') {
188
        // meta description & keywords tags for categories
189
        $cat_desc_clean     = strip_tags($cat_desc, '<span><img><strong><i><u>');
190
        $cat_keywords_clean = strip_tags($cat_keywords, '<span><img><strong><i><u><br><li>');
191
192
        $GLOBALS['xoTheme']->addMeta('meta', 'description', '' . mb_substr($cat_desc_clean, 0, 200));
193
        $GLOBALS['xoTheme']->addMeta('meta', 'keywords', '' . mb_substr($cat_keywords_clean, 0, 1000));
194
    }
195
196
    $submit_perms = Utility::getMyItemIds('adslight_submit');
197
    if (is_array($submit_perms) && $GLOBALS['xoopsUser']
198
        && count($submit_perms) > 0) {
199
        $add_listing = '' . _ADSLIGHT_ADD_LISTING_BULLCATS . '<a href="addlisting.php?cid=' . addslashes($cid) . '">' . _ADSLIGHT_ADD_LISTING_SUBOK . '</a>';
200
    } else {    // User can't see any category
201
        $add_listing = '' . _ADSLIGHT_ADD_LISTING_BULLCATSOK . '<a href="' . XOOPS_URL . '/register.php">' . _ADSLIGHT_ADD_LISTING_SUB . '</a>.';
202
    }
203
204
    if (0 !== (int)$pid || 1 === $GLOBALS['xoopsModuleConfig']['adslight_main_cat']) {
205
        $GLOBALS['xoopsTpl']->assign('bullinfotext', $add_listing);
206
    }
207
208
    $arr = [];
209
    $arr = $mytree->getFirstChild($cid, 'title');
210
211
    if (count($arr) > 0) {
212
        $scount = 1;
213
        foreach ($arr as $ele) {
214
            if (in_array($ele['cid'], $categories, true)) {
215
                $sub_arr         = [];
216
                $sub_arr         = $mytree->getFirstChild($ele['cid'], 'title');
217
                $space           = 0;
218
                $chcount         = 0;
219
                $infercategories = '';
220
                $totallisting    = Utility::getTotalItems($ele['cid'], 1);
221
                foreach ($sub_arr as $sub_ele) {
222
                    if (in_array($sub_ele['cid'], $categories, true)) {
223
                        $chtitle = \htmlspecialchars($sub_ele['title'], ENT_QUOTES | ENT_HTML5);
224
225
                        if ($chcount > 5) {
226
                            $infercategories .= '...';
227
                            break;
228
                        }
229
                        if ($space > 0) {
230
                            $infercategories .= ', ';
231
                        }
232
                        $infercategories .= '<a href="' . XOOPS_URL . '/modules/adslight/viewcats.php?cid=' . $sub_ele['cid'] . '">' . $chtitle . '</a>';
233
234
                        $infercategories .= '&nbsp;(' . Utility::getTotalItems($sub_ele['cid']) . ')';
235
                        $infercategories .= '&nbsp;' . categorynewgraphic($sub_ele['cid']) . '';
0 ignored issues
show
Are you sure categorynewgraphic($sub_ele['cid']) of type void can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

235
                        $infercategories .= '&nbsp;' . /** @scrutinizer ignore-type */ categorynewgraphic($sub_ele['cid']) . '';
Loading history...
236
                        ++$space;
237
                        ++$chcount;
238
                    }
239
                }
240
241
                $GLOBALS['xoopsTpl']->append('subcategories', [
242
                    'title'           => htmlspecialchars($ele['title'], ENT_QUOTES | ENT_HTML5),
243
                    'id'              => $ele['cid'],
244
                    'infercategories' => $infercategories,
245
                    'totallisting'    => $totallisting,
246
                    '',
247
                ]);
248
249
                ++$scount;
250
                $GLOBALS['xoopsTpl']->assign('lang_subcat', _ADSLIGHT_AVAILAB);
251
            }
252
        }
253
    }
254
255
    $pagenav = '';
256
    if ($trows > '0') {
257
        $GLOBALS['xoopsTpl']->assign('last_head', _ADSLIGHT_THE . ' ' . $GLOBALS['xoopsModuleConfig']['adslight_newcount'] . ' ' . _ADSLIGHT_LASTADD);
258
        $GLOBALS['xoopsTpl']->assign('last_head_title', _ADSLIGHT_TITLE);
259
        $GLOBALS['xoopsTpl']->assign('last_head_price', _ADSLIGHT_PRICE);
260
        $GLOBALS['xoopsTpl']->assign('last_head_date', _ADSLIGHT_DATE);
261
        $GLOBALS['xoopsTpl']->assign('last_head_local', _ADSLIGHT_LOCAL2);
262
        $GLOBALS['xoopsTpl']->assign('last_head_hits', _ADSLIGHT_VIEW);
263
        $GLOBALS['xoopsTpl']->assign('last_head_photo', _ADSLIGHT_PHOTO);
264
        $GLOBALS['xoopsTpl']->assign('cat', $cid);
265
        $GLOBALS['xoopsTpl']->assign('min', $min);
266
        $rank = 1;
267
268
        $cat_perms = '';
269
        if (is_iterable($categories) && count($categories) > 0) {
270
            $cat_perms .= ' AND cid IN (' . implode(',', $categories) . ') ';
271
        }
272
273
        $sql     = 'SELECT lid, title, status, type, price, typeprice, date_created, town, country, contactby, usid, premium, valid, photo, hits FROM '
274
                   . $xoopsDB->prefix('adslight_listing')
275
                   . ' WHERE valid="Yes" AND cid='
276
                   . $xoopsDB->escape($cid)
277
                   . ' AND status!="1" '
278
                   . $cat_perms
279
                   . ' ORDER BY '
280
                   . $orderby
281
                   . '';
282
        $result1 = $xoopsDB->query($sql, $show, $min);
283
        if ($trows > '1') {
284
            $GLOBALS['xoopsTpl']->assign('show_nav', true);
285
            $orderbyTrans = Utility::convertOrderByTrans($orderby);
286
            $GLOBALS['xoopsTpl']->assign('lang_sortby', _ADSLIGHT_SORTBY);
287
            $GLOBALS['xoopsTpl']->assign('lang_title', _ADSLIGHT_TITLE);
288
            $GLOBALS['xoopsTpl']->assign('lang_titleatoz', _ADSLIGHT_TITLEATOZ);
289
            $GLOBALS['xoopsTpl']->assign('lang_titleztoa', _ADSLIGHT_TITLEZTOA);
290
            $GLOBALS['xoopsTpl']->assign('lang_date', _ADSLIGHT_DATE);
291
            $GLOBALS['xoopsTpl']->assign('lang_dateold', _ADSLIGHT_DATEOLD);
292
            $GLOBALS['xoopsTpl']->assign('lang_datenew', _ADSLIGHT_DATENEW);
293
            $GLOBALS['xoopsTpl']->assign('lang_price', _ADSLIGHT_PRICE);
294
            $GLOBALS['xoopsTpl']->assign('lang_priceltoh', _ADSLIGHT_PRICELTOH);
295
            $GLOBALS['xoopsTpl']->assign('lang_pricehtol', _ADSLIGHT_PRICEHTOL);
296
            $GLOBALS['xoopsTpl']->assign('lang_popularity', _ADSLIGHT_POPULARITY);
297
            $GLOBALS['xoopsTpl']->assign('lang_popularityleast', _ADSLIGHT_POPULARITYLTOM);
298
            $GLOBALS['xoopsTpl']->assign('lang_popularitymost', _ADSLIGHT_POPULARITYMTOL);
299
            $GLOBALS['xoopsTpl']->assign('lang_cursortedby', sprintf(_ADSLIGHT_CURSORTEDBY, Utility::convertOrderByTrans($orderby)));
300
        }
301
        while ([$lid, $title, $status, $type, $price, $typeprice, $date_created, $town, $country, $contactby, $usid, $premium, $valid, $photo, $hits] = $xoopsDB->fetchRow($result1)) {
302
            $a_item = [];
303
            $title  = \htmlspecialchars($title, ENT_QUOTES | ENT_HTML5);
304
            $type   = \htmlspecialchars($type, ENT_QUOTES | ENT_HTML5);
305
            //      $price = number_format($price, 2, ',', ' ');
306
            $town       = \htmlspecialchars($town, ENT_QUOTES | ENT_HTML5);
307
            $country    = \htmlspecialchars($country, ENT_QUOTES | ENT_HTML5);
308
            $contactby  = \htmlspecialchars($contactby, ENT_QUOTES | ENT_HTML5);
309
            $useroffset = '';
310
311
            $newcount  = $GLOBALS['xoopsModuleConfig']['adslight_countday'];
312
            $startdate = time() - (86400 * $newcount);
313
            if ($startdate < $date_created) {
314
                $newitem       = '<img src="' . XOOPS_URL . '/modules/adslight/assets/images/newred.gif" >';
315
                $a_item['new'] = $newitem;
316
            }
317
            if ($GLOBALS['xoopsUser']) {
318
                $timezone = $GLOBALS['xoopsUser']->timezone();
319
                if (isset($timezone)) {
320
                    $useroffset = $GLOBALS['xoopsUser']->timezone();
321
                } else {
322
                    $useroffset = $xoopsConfig['default_TZ'];
323
                }
324
            }
325
            $date_created = ($useroffset * 3600) + $date_created;
326
            $date_created = formatTimestamp($date_created, 's');
327
            if ($GLOBALS['xoopsUser']) {
328
                if ($GLOBALS['xoopsUser']->isAdmin()) {
329
                    $a_item['admin'] = '<a href="' . XOOPS_URL . '/modules/adslight/admin/validate_ads.php?op=modifyAds&amp;lid=' . $lid . '"><img src="' . $pathIcon16 . '/edit.png' . '" border=0 alt="' . _ADSLIGHT_MODADMIN . '" title="' . _ADSLIGHT_MODADMIN . '"></a>';
330
                }
331
            }
332
333
            $result7 = $xoopsDB->query('SELECT nom_type FROM ' . $xoopsDB->prefix('adslight_type') . " WHERE id_type='" . $xoopsDB->escape($type) . "'");
334
            [$nom_type] = $xoopsDB->fetchRow($result7);
335
336
            $result8 = $xoopsDB->query('SELECT nom_price FROM ' . $xoopsDB->prefix('adslight_price') . " WHERE id_price='" . $xoopsDB->escape($typeprice) . "'");
337
            [$nom_price] = $xoopsDB->fetchRow($result8);
338
339
            $a_item['type']   = \htmlspecialchars($nom_type, ENT_QUOTES | ENT_HTML5);
340
            $a_item['title']  = '<a href="viewads.php?lid=' . $lid . '"><strong>' . $title . '</strong></a>';
341
            $a_item['status'] = $status;
342
            if ($price > 0) {
343
                $currencyCode                 = $helper->getConfig('adslight_currency_code');
344
                $currencySymbol               = $helper->getConfig('adslight_currency_symbol');
345
                $currencyPosition             = $helper->getConfig('currency_position');
346
                $formattedCurrencyUtilityTemp = Utility::formatCurrencyTemp($price, $currencyCode, $currencySymbol, $currencyPosition);
347
                $priceHtml                    = '<strong>' . _ADSLIGHT_PRICE2 . '</strong>' . $formattedCurrencyUtilityTemp . ' - ' . $nom_price;
348
349
                $a_item['price'] = $priceHtml;
350
351
                $a_item['price_typeprice'] = \htmlspecialchars($nom_price, ENT_QUOTES | ENT_HTML5);
352
            }
353
            $a_item['date_created'] = $date_created;
354
            $a_item['local']        = '';
355
            if ($town) {
356
                $a_item['local'] .= $town;
357
            }
358
            $a_item['country'] = '';
359
            if ($country) {
360
                $a_item['country'] = $country;
361
            }
362
363
            $cat = addslashes($cid);
364
            if (2 === $status) {
365
                $a_item['sold'] = _ADSLIGHT_RESERVEDMEMBER;
366
            }
367
368
            if ($GLOBALS['xoopsModuleConfig']['active_thumbscats'] > 0) {
369
                $a_item['no_photo'] = '<a href="' . XOOPS_URL . '/modules/adslight/viewads.php?lid=' . $lid . '"><img class="thumb" src="' . XOOPS_URL . '/modules/adslight/assets/images/nophoto.jpg" align="left" width="100px" alt="' . $title . '" ></a>';
370
371
                $updir   = $GLOBALS['xoopsModuleConfig']['adslight_link_upload'];
372
                $sql     = 'SELECT cod_img, lid, uid_owner, url FROM ' . $xoopsDB->prefix('adslight_pictures') . ' WHERE  uid_owner=' . $xoopsDB->escape($usid) . ' AND lid=' . $xoopsDB->escape($lid) . ' ORDER BY date_created ASC LIMIT 1';
373
                $resultp = $xoopsDB->query($sql);
374
                while ([$cod_img, $pic_lid, $uid_owner, $url] = $xoopsDB->fetchRow($resultp)) {
375
                    if ($photo) {
376
                        $a_item['photo'] = '<a href="' . XOOPS_URL . '/modules/adslight/viewads.php?lid=' . $lid . '"><img class="thumb" src="' . $updir . '/thumbs/thumb_' . $url . '" align="left" width="100px" alt="' . $title . '" ></a>';
377
                    }
378
                }
379
            } else {
380
                $a_item['no_photo'] = '<p><img src="' . XOOPS_URL . '/modules/adslight/assets/images/camera_nophoto.png" align="left" width="24" alt="' . $title . '" ></p>';
381
                $updir              = $GLOBALS['xoopsModuleConfig']['adslight_link_upload'];
382
                $sql                = 'SELECT cod_img, lid, uid_owner, url FROM ' . $xoopsDB->prefix('adslight_pictures') . ' WHERE  uid_owner=' . $xoopsDB->escape($usid) . ' AND lid=' . $xoopsDB->escape($lid) . ' ORDER BY date_created ASC LIMIT 1';
383
                $resultp            = $xoopsDB->query($sql);
384
                while ([$cod_img, $pic_lid, $uid_owner, $url] = $xoopsDB->fetchRow($resultp)) {
385
                    if ($photo) {
386
                        $a_item['photo'] = '<p><img src="' . XOOPS_URL . '/modules/adslight/assets/images/camera_photo.png" align="left" width="24" alt="' . $title . '" ></p>';
387
                    }
388
                }
389
            }
390
391
            $a_item['hits'] = $hits;
392
            ++$rank;
393
            $GLOBALS['xoopsTpl']->append('items', $a_item);
394
        }
395
396
        $cid = (int)$cid > 0 ? (int)$cid : 0;
397
398
        $orderby   = Utility::convertOrderByOut($orderby);
399
        $linkpages = ceil($trows / $show);
400
401
        //Page Numbering
402
        if (1 !== (int)$linkpages && 0 !== (int)$linkpages) {
403
            $prev = $min - $show;
404
            if ($prev >= 0) {
405
                $pagenav .= "<a href='viewcats.php?cid=${cid}&min=${prev}&orderby=${orderby}&show=${show}'><strong><u>&laquo;</u></strong></a> ";
406
            }
407
            $counter     = 1;
408
            $currentpage = $max / $show;
409
            while ($counter <= $linkpages) {
410
                $mintemp = ($show * $counter) - $show;
411
                if ($counter === $currentpage) {
412
                    $pagenav .= "<strong>(${counter})</strong> ";
413
                } else {
414
                    $pagenav .= "<a href='viewcats.php?cid=${cid}&min=${mintemp}&orderby=${orderby}&show=${show}'>${counter}</a> ";
415
                }
416
                ++$counter;
417
            }
418
            if ($trows > $max) {
419
                $pagenav .= "<a href='viewcats.php?cid=${cid}&min=${max}&orderby=${orderby}&show=${show}'>";
420
                $pagenav .= '<strong><u>&raquo;</u></strong></a>';
421
            }
422
        }
423
    }
424
425
    $GLOBALS['xoopsTpl']->assign('nav_page', $pagenav);
426
427
    if (!$GLOBALS['xoopsUser']) {
428
        global $xoopsDB;
429
430
        $xoopsTree = new \XoopsTree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid');
431
        $jump      = XOOPS_URL . '/modules/adslight/viewcats.php?cid=';
432
        ob_start();
433
        $xoopsTree->makeMySelBox('title', 'title', $cid, 1, 'pid', 'location="' . $jump . '"+this.options[this.selectedIndex].value');
434
        $select_go_cats = ob_get_clean();
435
        $GLOBALS['xoopsTpl']->assign('select_go_cats', $select_go_cats);
436
    }
437
}
438
439
#  function categorynewgraphic
440
#####################################################
441
/**
442
 * @param $cid
443
 */
444
function categorynewgraphic($cid): void
445
{
446
    //global $xoopsDB;
447
}
448
449
######################################################
450
451
$pa      = Request::getInt('pa', null, 'GET');
452
$lid     = Request::getInt('lid', null, 'GET');
453
$cid     = Request::getInt('cid', null, 'GET');
454
$usid    = Request::getString('usid', '', 'GET');
455
$min     = Request::getInt('min', null, 'GET');
456
$show    = Request::getInt('show', null, 'GET');
457
$orderby = Request::getString('orderby', '', 'GET');
458
459
switch ($pa) {
460
    default:
461
        $GLOBALS['xoopsOption']['template_main'] = 'adslight_category.tpl';
462
        adsView($cid, $min, $orderby, $show);
463
        break;
464
}
465
require_once XOOPS_ROOT_PATH . '/footer.php';
466