Passed
Push — master ( 5e790e...222087 )
by Michael
03:14
created

viewcats.php (29 issues)

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 64 and the first side effect is on line 26.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
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
use Xmf\Request;
0 ignored issues
show
The type Xmf\Request was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
24
use XoopsModules\Adslight;
25
26
require_once __DIR__ . '/header.php';
27
//require XOOPS_ROOT_PATH . '/modules/adslight/include/gtickets.php';
0 ignored issues
show
Unused Code Comprehensibility introduced by
38% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
28
xoops_load('XoopsLocal');
0 ignored issues
show
The function xoops_load was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

28
/** @scrutinizer ignore-call */ 
29
xoops_load('XoopsLocal');
Loading history...
29
$tempXoopsLocal = new \XoopsLocal;
0 ignored issues
show
The type XoopsLocal was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
30
$myts           = \MyTextSanitizer::getInstance();
0 ignored issues
show
The type MyTextSanitizer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
31
$module_id      = $xoopsModule->getVar('mid');
32
33
if (is_object($GLOBALS['xoopsUser'])) {
34
    $groups = $GLOBALS['xoopsUser']->getGroups();
35
} else {
36
    $groups = XOOPS_GROUP_ANONYMOUS;
0 ignored issues
show
The constant XOOPS_GROUP_ANONYMOUS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
37
}
38
/** @var XoopsGroupPermHandler $gpermHandler */
39
$gpermHandler = xoops_getHandler('groupperm');
0 ignored issues
show
The function xoops_getHandler was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

39
$gpermHandler = /** @scrutinizer ignore-call */ xoops_getHandler('groupperm');
Loading history...
40
41
$perm_itemid = Request::getInt('item_id', 0, 'POST');
42
43
if (!$gpermHandler->checkRight('adslight_view', $perm_itemid, $groups, $module_id)) {
44
    redirect_header(XOOPS_URL . '/index.php', 3, _NOPERM);
0 ignored issues
show
The constant _NOPERM was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
The constant XOOPS_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
The function redirect_header was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

44
    /** @scrutinizer ignore-call */ 
45
    redirect_header(XOOPS_URL . '/index.php', 3, _NOPERM);
Loading history...
45
}
46
if (!$gpermHandler->checkRight('adslight_premium', $perm_itemid, $groups, $module_id)) {
47
    $prem_perm = '0';
48
} else {
49
    $prem_perm = '1';
50
}
51
52
include XOOPS_ROOT_PATH . '/modules/adslight/class/classifiedstree.php';
0 ignored issues
show
The constant XOOPS_ROOT_PATH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
53
//include XOOPS_ROOT_PATH . '/modules/adslight/class/Utility.php';
0 ignored issues
show
Unused Code Comprehensibility introduced by
38% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
54
$mytree = new Adslight\ClassifiedsTree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid');
55
56
#  function view (categories)
57
#####################################################
58
/**
59
 * @param int $cid
60
 * @param int $min
61
 * @param     $orderby
62
 * @param int $show
63
 */
64
function adsView($cid = 0, $min = 0, $orderby, $show = 0)
65
{
66
    global $xoopsDB, $xoopsTpl, $xoopsConfig, $myts, $mytree, $imagecat, $meta, $moduleDirName, $main_lang, $mid, $prem_perm, $xoopsModule;
67
    $pathIcon16 = \Xmf\Module\Admin::iconUrl('', 16);
0 ignored issues
show
The type Xmf\Module\Admin was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
68
69
    $GLOBALS['xoopsOption']['template_main'] = 'adslight_category.tpl';
70
    include XOOPS_ROOT_PATH . '/header.php';
0 ignored issues
show
The constant XOOPS_ROOT_PATH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
71
72
    $GLOBALS['xoopsTpl']->assign('xmid', $xoopsModule->getVar('mid'));
73
    $GLOBALS['xoopsTpl']->assign('add_from', _ADSLIGHT_ADDFROM . ' ' . $xoopsConfig['sitename']);
74
    $GLOBALS['xoopsTpl']->assign('add_from_title', _ADSLIGHT_ADDFROM);
75
    $GLOBALS['xoopsTpl']->assign('add_from_sitename', $xoopsConfig['sitename']);
76
    $GLOBALS['xoopsTpl']->assign('only_pix', _ADSLIGHT_ONLYPIX);
77
    $GLOBALS['xoopsTpl']->assign('adslight_logolink', _ADSLIGHT_LOGOLINK);
78
    $GLOBALS['xoopsTpl']->assign('permit', $prem_perm);
79
80
    $GLOBALS['xoopsTpl']->assign('xoops_module_header', '<link rel="stylesheet" href="' . XOOPS_URL . '/modules/adslight/assets/css/adslight.css" type="text/css" media="all" >');
0 ignored issues
show
The constant XOOPS_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
81
82
    // $adslight_use_catscode = $GLOBALS['xoopsModuleConfig']['adslight_use_catscode'];
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
83
    // $adslight_cats_code = $GLOBALS['xoopsModuleConfig']['adslight_cats_code'];
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
84
85
    $GLOBALS['xoopsTpl']->assign('adslight_use_catscode', $GLOBALS['xoopsModuleConfig']['adslight_use_catscode']);
86
    $GLOBALS['xoopsTpl']->assign('adslight_cats_code', $GLOBALS['xoopsModuleConfig']['adslight_cats_code']);
87
88
    $banner = xoops_getbanner();
0 ignored issues
show
The function xoops_getbanner was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

88
    $banner = /** @scrutinizer ignore-call */ xoops_getbanner();
Loading history...
89
    $GLOBALS['xoopsTpl']->assign('banner', $banner);
90
    // $index_code_place = $GLOBALS['xoopsModuleConfig']['adslight_index_code_place'];
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
91
    // $use_extra_code = $GLOBALS['xoopsModuleConfig']['adslight_use_index_code'];
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
92
    // $adslight_use_banner = $GLOBALS['xoopsModuleConfig']['adslight_use_banner'];
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
93
    // $index_extra_code = $GLOBALS['xoopsModuleConfig']['adslight_index_code'];
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
94
95
    $GLOBALS['xoopsTpl']->assign('use_extra_code', $GLOBALS['xoopsModuleConfig']['adslight_use_index_code']);
96
    $GLOBALS['xoopsTpl']->assign('adslight_use_banner', $GLOBALS['xoopsModuleConfig']['adslight_use_banner']);
97
    $GLOBALS['xoopsTpl']->assign('index_extra_code', $GLOBALS['xoopsModuleConfig']['adslight_index_code']);
98
    $GLOBALS['xoopsTpl']->assign('index_code_place', $GLOBALS['xoopsModuleConfig']['adslight_index_code_place']);
99
100
    // adslight 2
101
    $GLOBALS['xoopsTpl']->assign('adslight_active_menu', $GLOBALS['xoopsModuleConfig']['adslight_active_menu']);
102
    $GLOBALS['xoopsTpl']->assign('adslight_active_rss', $GLOBALS['xoopsModuleConfig']['adslight_active_rss']);
103
104
    /// No Adds in this Cat ///
105
    $submit_perms = Adslight\Utility::getMyItemIds('adslight_submit');
106
107
    if ($GLOBALS['xoopsUser'] && is_array($submit_perms)
108
        && count($submit_perms) > 0) {
109
        $GLOBALS['xoopsTpl']->assign('not_adds_in_this_cat', '' . _ADSLIGHT_ADD_LISTING_NOTADDSINTHISCAT . '<a href="addlisting.php?cid=' . addslashes($cid) . '">' . _ADSLIGHT_ADD_LISTING_NOTADDSSUBMIT . '</a>');
110
    } else {
111
        $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>.');
112
    }
113
114
    $GLOBALS['xoopsTpl']->assign('Feed_RSS_cat', '&nbsp;&nbsp;&nbsp;<a href="rss.php?cid=' . addslashes($cid) . '"><img border="0" alt="Feed RSS" src="assets/images/rssfeed_buttons.png" ></a>');
115
116
    if ($GLOBALS['xoopsUser']) {
117
        $member_usid = $GLOBALS['xoopsUser']->getVar('uid');
118
        if ($usid = $member_usid) {
119
            $GLOBALS['xoopsTpl']->assign('istheirs', true);
120
121
            list($show_user) = $xoopsDB->fetchRow($xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE usid=' . $member_usid . ''));
122
123
            $GLOBALS['xoopsTpl']->assign('show_user', $show_user);
124
            $GLOBALS['xoopsTpl']->assign('show_user_link', 'members.php?usid=' . $member_usid);
125
        }
126
    }
127
128
    $default_sort = $GLOBALS['xoopsModuleConfig']['adslight_lsort_order'];
129
130
    $cid     = ((int)$cid > 0) ? (int)$cid : 0;
131
    $min     = ((int)$min > 0) ? (int)$min : 0;
132
    $show    = ((int)$show > 0) ? (int)$show : $GLOBALS['xoopsModuleConfig']['adslight_perpage'];
133
    $max     = $min + $show;
134
    $orderby = isset($orderby) ? Adslight\Utility::convertOrderByIn($orderby) : $default_sort;
135
136
    $updir = $GLOBALS['xoopsModuleConfig']['adslight_link_upload'];
137
    $GLOBALS['xoopsTpl']->assign('add_from', _ADSLIGHT_ADDFROM . ' ' . $xoopsConfig['sitename']);
138
    $GLOBALS['xoopsTpl']->assign('add_from_title', _ADSLIGHT_ADDFROM);
139
    $GLOBALS['xoopsTpl']->assign('add_from_sitename', $xoopsConfig['sitename']);
140
    $GLOBALS['xoopsTpl']->assign('subcat_title2', _ADSLIGHT_ANNONCES);
141
142
    $categories = Adslight\Utility::getMyItemIds('adslight_view');
143
    if (is_array($categories) && count($categories) > 0) {
144
        if (!in_array($cid, $categories)) {
145
            redirect_header(XOOPS_URL . '/modules/adslight/index.php', 3, _NOPERM);
0 ignored issues
show
The constant _NOPERM was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
The function redirect_header was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

145
            /** @scrutinizer ignore-call */ 
146
            redirect_header(XOOPS_URL . '/modules/adslight/index.php', 3, _NOPERM);
Loading history...
146
        }
147
    } else {    // User can't see any category
148
        redirect_header(XOOPS_URL . '/index.php', 3, _NOPERM);
149
    }
150
151
    $arrow = '<img src="' . XOOPS_URL . '/modules/adslight/assets/images/arrow.gif" alt="&raquo;" >';
152
153
    $pathstring = '<a href="index.php">' . _ADSLIGHT_MAIN . '</a>';
154
    $pathstring .= $mytree->getNicePathFromId($cid, 'title', 'viewcats.php?');
155
    $GLOBALS['xoopsTpl']->assign('module_name', $xoopsModule->getVar('name'));
156
    $GLOBALS['xoopsTpl']->assign('category_path', $pathstring);
157
    $GLOBALS['xoopsTpl']->assign('category_id', $cid);
158
159
    $countresult = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE  cid=' . $xoopsDB->escape($cid) . ' AND valid="Yes" AND status!="1"');
160
    list($trow) = $xoopsDB->fetchRow($countresult);
161
    $trows = $trow;
162
163
    $cat_perms = '';
164
    if (is_array($categories) && count($categories) > 0) {
165
        $cat_perms .= ' AND cid IN (' . implode(',', $categories) . ') ';
166
    }
167
168
    $result = $xoopsDB->query('SELECT cid, pid, title, cat_desc, cat_keywords FROM ' . $xoopsDB->prefix('adslight_categories') . ' WHERE cid=' . $xoopsDB->escape($cid) . ' ' . $cat_perms);
169
    list($cid, $pid, $title, $cat_desc, $cat_keywords) = $xoopsDB->fetchRow($result);
170
171
    $GLOBALS['xoopsTpl']->assign('cat_desc', $cat_desc);
172
    $GLOBALS['xoopsTpl']->assign('cat_title', _ADSLIGHT_ANNONCES . ' ' . $title);
173
    $GLOBALS['xoopsTpl']->assign('cat_keywords', $cat_keywords);
174
    $GLOBALS['xoopsTpl']->assign('xoops_pagetitle', $title);
175
176
    if ($cat_desc > '0') {
177
        // meta description & keywords tags for categories
178
        $cat_desc_clean     = strip_tags($cat_desc, '<font><img><strong><i><u>');
179
        $cat_keywords_clean = strip_tags($cat_keywords, '<font><img><strong><i><u><br><li>');
180
181
        $GLOBALS['xoTheme']->addMeta('meta', 'description', '' . substr($cat_desc_clean, 0, 200));
182
        $GLOBALS['xoTheme']->addMeta('meta', 'keywords', '' . substr($cat_keywords_clean, 0, 1000));
183
    }
184
185
    $submit_perms = Adslight\Utility::getMyItemIds('adslight_submit');
186
    if ($GLOBALS['xoopsUser'] && is_array($submit_perms)
187
        && count($submit_perms) > 0) {
188
        $add_listing = '' . _ADSLIGHT_ADD_LISTING_BULLCATS . '<a href="addlisting.php?cid=' . addslashes($cid) . '">' . _ADSLIGHT_ADD_LISTING_SUBOK . '</a>
189
';
190
    } else {    // User can't see any category
191
        $add_listing = '' . _ADSLIGHT_ADD_LISTING_BULLCATSOK . '<a href="' . XOOPS_URL . '/register.php">' . _ADSLIGHT_ADD_LISTING_SUB . '</a>.
192
';
193
    }
194
195
    if (1 == $GLOBALS['xoopsModuleConfig']['adslight_main_cat'] || 0 != $pid) {
196
        $GLOBALS['xoopsTpl']->assign('bullinfotext', $add_listing);
197
    }
198
199
    $arr = [];
200
    $arr = $mytree->getFirstChild($cid, 'title');
201
202
    if (count($arr) > 0) {
203
        $scount = 1;
204
        foreach ($arr as $ele) {
205
            if (in_array($ele['cid'], $categories)) {
206
                $sub_arr         = [];
207
                $sub_arr         = $mytree->getFirstChild($ele['cid'], 'title');
208
                $space           = 0;
209
                $chcount         = 0;
210
                $infercategories = '';
211
                $totallisting    = Adslight\Utility::getTotalItems($ele['cid'], 1);
212
                foreach ($sub_arr as $sub_ele) {
213
                    if (in_array($sub_ele['cid'], $categories)) {
214
                        $chtitle = $myts->htmlSpecialChars($sub_ele['title']);
215
216
                        if ($chcount > 5) {
217
                            $infercategories .= '...';
218
                            break;
219
                        }
220
                        if ($space > 0) {
221
                            $infercategories .= ', ';
222
                        }
223
                        $infercategories .= '<a href="' . XOOPS_URL . '/modules/adslight/viewcats.php?cid=' . $sub_ele['cid'] . '">' . $chtitle . '</a>';
224
225
                        $infercategories .= '&nbsp;(' . Adslight\Utility::getTotalItems($sub_ele['cid']) . ')';
226
                        $infercategories .= '&nbsp;' . categorynewgraphic($sub_ele['cid']) . '';
227
                        ++$space;
228
                        ++$chcount;
229
                    }
230
                }
231
232
                $GLOBALS['xoopsTpl']->append('subcategories', [
233
                    'title'           => $myts->htmlSpecialChars($ele['title']),
234
                    'id'              => $ele['cid'],
235
                    'infercategories' => $infercategories,
236
                    'totallisting'    => $totallisting,
237
                    ''
238
                ]);
239
240
                ++$scount;
241
                $GLOBALS['xoopsTpl']->assign('lang_subcat', _ADSLIGHT_AVAILAB);
242
            }
243
        }
244
    }
245
246
    $pagenav = '';
247
    if ($trows > '0') {
248
        $GLOBALS['xoopsTpl']->assign('last_head', _ADSLIGHT_THE . ' ' . $GLOBALS['xoopsModuleConfig']['adslight_newcount'] . ' ' . _ADSLIGHT_LASTADD);
249
        $GLOBALS['xoopsTpl']->assign('last_head_title', _ADSLIGHT_TITLE);
250
        $GLOBALS['xoopsTpl']->assign('last_head_price', _ADSLIGHT_PRICE);
251
        $GLOBALS['xoopsTpl']->assign('last_head_date', _ADSLIGHT_DATE);
252
        $GLOBALS['xoopsTpl']->assign('last_head_local', _ADSLIGHT_LOCAL2);
253
        $GLOBALS['xoopsTpl']->assign('last_head_hits', _ADSLIGHT_VIEW);
254
        $GLOBALS['xoopsTpl']->assign('last_head_photo', _ADSLIGHT_PHOTO);
255
        $GLOBALS['xoopsTpl']->assign('cat', $cid);
256
        $GLOBALS['xoopsTpl']->assign('min', $min);
257
        $rank = 1;
258
259
        $cat_perms = '';
260
        if (is_array($categories) && count($categories) > 0) {
261
            $cat_perms .= ' AND cid IN (' . implode(',', $categories) . ') ';
262
        }
263
264
        $sql     = 'SELECT lid, title, status, type, price, typeprice, date, town, country, contactby, usid, premium, valid, photo, hits FROM '
265
                   . $xoopsDB->prefix('adslight_listing')
266
                   . ' WHERE valid="Yes" AND cid='
267
                   . $xoopsDB->escape($cid)
268
                   . ' AND status!="1" '
269
                   . $cat_perms
270
                   . ' ORDER BY '
271
                   . $orderby
272
                   . '';
273
        $result1 = $xoopsDB->query($sql, $show, $min);
274
        if ($trows > '1') {
275
            $GLOBALS['xoopsTpl']->assign('show_nav', true);
276
            $orderbyTrans = Adslight\Utility::convertOrderByTrans($orderby);
277
            $GLOBALS['xoopsTpl']->assign('lang_sortby', _ADSLIGHT_SORTBY);
278
            $GLOBALS['xoopsTpl']->assign('lang_title', _ADSLIGHT_TITLE);
279
            $GLOBALS['xoopsTpl']->assign('lang_titleatoz', _ADSLIGHT_TITLEATOZ);
280
            $GLOBALS['xoopsTpl']->assign('lang_titleztoa', _ADSLIGHT_TITLEZTOA);
281
            $GLOBALS['xoopsTpl']->assign('lang_date', _ADSLIGHT_DATE);
282
            $GLOBALS['xoopsTpl']->assign('lang_dateold', _ADSLIGHT_DATEOLD);
283
            $GLOBALS['xoopsTpl']->assign('lang_datenew', _ADSLIGHT_DATENEW);
284
            $GLOBALS['xoopsTpl']->assign('lang_price', _ADSLIGHT_PRICE);
285
            $GLOBALS['xoopsTpl']->assign('lang_priceltoh', _ADSLIGHT_PRICELTOH);
286
            $GLOBALS['xoopsTpl']->assign('lang_pricehtol', _ADSLIGHT_PRICEHTOL);
287
            $GLOBALS['xoopsTpl']->assign('lang_popularity', _ADSLIGHT_POPULARITY);
288
            $GLOBALS['xoopsTpl']->assign('lang_popularityleast', _ADSLIGHT_POPULARITYLTOM);
289
            $GLOBALS['xoopsTpl']->assign('lang_popularitymost', _ADSLIGHT_POPULARITYMTOL);
290
            $GLOBALS['xoopsTpl']->assign('lang_cursortedby', sprintf(_ADSLIGHT_CURSORTEDBY, Adslight\Utility::convertOrderByTrans($orderby)));
291
        }
292
293
        while (false !== (list($lid, $title, $status, $type, $price, $typeprice, $date, $town, $country, $contactby, $usid, $premium, $valid, $photo, $hits) = $xoopsDB->fetchRow($result1))) {
294
            $a_item = [];
295
            $title  = $myts->htmlSpecialChars($title);
296
            $type   = $myts->htmlSpecialChars($type);
297
            //      $price = number_format($price, 2, ',', ' ');
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
298
            $town       = $myts->htmlSpecialChars($town);
299
            $country    = $myts->htmlSpecialChars($country);
300
            $contactby  = $myts->htmlSpecialChars($contactby);
301
            $useroffset = '';
302
303
            $newcount  = $GLOBALS['xoopsModuleConfig']['adslight_countday'];
304
            $startdate = (time() - (86400 * $newcount));
305
            if ($startdate < $date) {
306
                $newitem       = '<img src="' . XOOPS_URL . '/modules/adslight/assets/images/newred.gif" >';
307
                $a_item['new'] = $newitem;
308
            }
309
            if ($GLOBALS['xoopsUser']) {
310
                $timezone = $GLOBALS['xoopsUser']->timezone();
311
                if (isset($timezone)) {
312
                    $useroffset = $GLOBALS['xoopsUser']->timezone();
313
                } else {
314
                    $useroffset = $xoopsConfig['default_TZ'];
315
                }
316
            }
317
            $date = ($useroffset * 3600) + $date;
318
            $date = formatTimestamp($date, 's');
0 ignored issues
show
The function formatTimestamp was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

318
            $date = /** @scrutinizer ignore-call */ formatTimestamp($date, 's');
Loading history...
319
            if ($GLOBALS['xoopsUser']) {
320
                if ($GLOBALS['xoopsUser']->isAdmin()) {
321
                    $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>';
322
                }
323
            }
324
325
            $result7 = $xoopsDB->query('SELECT nom_type FROM ' . $xoopsDB->prefix('adslight_type') . " WHERE id_type='" . $xoopsDB->escape($type) . "'");
326
            list($nom_type) = $xoopsDB->fetchRow($result7);
327
328
            $result8 = $xoopsDB->query('SELECT nom_price FROM ' . $xoopsDB->prefix('adslight_price') . " WHERE id_price='" . $xoopsDB->escape($typeprice) . "'");
329
            list($nom_price) = $xoopsDB->fetchRow($result8);
330
331
            $a_item['type']   = $myts->htmlSpecialChars($nom_type);
332
            $a_item['title']  = '<a href="viewads.php?lid=' . $lid . '"><strong>' . $title . '</strong></a>';
333
            $a_item['status'] = $status;
334
            if ($price > 0) {
335
336
                //          $a_item['price'] = $price. ' '. $GLOBALS['xoopsModuleConfig']['adslight_currency_symbol'].'';
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
337
                $a_item['price']           = Adslight\Utility::getMoneyFormat('%.2n', $price);
338
                $a_item['price_typeprice'] = $myts->htmlSpecialChars($nom_price);
339
            }
340
            $a_item['date']  = $date;
341
            $a_item['local'] = '';
342
            if ($town) {
343
                $a_item['local'] .= $town;
344
            }
345
            $a_item['country'] = '';
346
            if ($country) {
347
                $a_item['country'] = $country;
348
            }
349
350
            $cat = addslashes($cid);
351
            if (2 == $status) {
352
                $a_item['sold'] = _ADSLIGHT_RESERVEDMEMBER;
353
            }
354
355
            if ($GLOBALS['xoopsModuleConfig']['active_thumbscats'] > 0) {
356
                $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>';
357
358
                $updir   = $GLOBALS['xoopsModuleConfig']['adslight_link_upload'];
359
                $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_added ASC LIMIT 1';
360
                $resultp = $xoopsDB->query($sql);
361
362
                while (false !== (list($cod_img, $pic_lid, $uid_owner, $url) = $xoopsDB->fetchRow($resultp))) {
363
                    if ($photo) {
364
                        $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>';
365
                    }
366
                }
367
            } else {
368
                $a_item['no_photo'] = '<p><img src="' . XOOPS_URL . '/modules/adslight/assets/images/camera_nophoto.png" align="left" width="24" alt="' . $title . '" ></p>';
369
                $updir              = $GLOBALS['xoopsModuleConfig']['adslight_link_upload'];
370
                $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_added ASC LIMIT 1';
371
                $resultp            = $xoopsDB->query($sql);
372
                while (false !== (list($cod_img, $pic_lid, $uid_owner, $url) = $xoopsDB->fetchRow($resultp))) {
373
                    if ($photo) {
374
                        $a_item['photo'] = '<p><img src="' . XOOPS_URL . '/modules/adslight/assets/images/camera_photo.png" align="left" width="24" alt="' . $title . '" ></p>';
375
                    }
376
                }
377
            }
378
379
            $a_item['hits'] = $hits;
380
            ++$rank;
381
            $GLOBALS['xoopsTpl']->append('items', $a_item);
382
        }
383
384
        $cid = ((int)$cid > 0) ? (int)$cid : 0;
385
386
        $orderby   = Adslight\Utility::convertOrderByOut($orderby);
387
        $linkpages = ceil($trows / $show);
388
389
        //Page Numbering
390
        if (1 != $linkpages && 0 != $linkpages) {
391
            $prev = $min - $show;
392
            if ($prev >= 0) {
393
                $pagenav .= "<a href='viewcats.php?cid=$cid&min=$prev&orderby=$orderby&show=$show'><strong><u>&laquo;</u></strong></a> ";
394
            }
395
            $counter     = 1;
396
            $currentpage = ($max / $show);
397
            while ($counter <= $linkpages) {
398
                $mintemp = ($show * $counter) - $show;
399
                if ($counter == $currentpage) {
400
                    $pagenav .= "<strong>($counter)</strong> ";
401
                } else {
402
                    $pagenav .= "<a href='viewcats.php?cid=$cid&min=$mintemp&orderby=$orderby&show=$show'>$counter</a> ";
403
                }
404
                ++$counter;
405
            }
406
            if ($trows > $max) {
407
                $pagenav .= "<a href='viewcats.php?cid=$cid&min=$max&orderby=$orderby&show=$show'>";
408
                $pagenav .= '<strong><u>&raquo;</u></strong></a>';
409
            }
410
        }
411
    }
412
413
    $GLOBALS['xoopsTpl']->assign('nav_page', $pagenav);
414
415
    if (!$GLOBALS['xoopsUser']) {
416
        global $xoopsDB;
417
418
        $xt   = new \XoopsTree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid');
0 ignored issues
show
The type XoopsTree was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
419
        $jump = XOOPS_URL . '/modules/adslight/viewcats.php?cid=';
420
        ob_start();
421
        $xt->makeMySelBox('title', 'title', $cid, 1, 'pid', 'location="' . $jump . '"+this.options[this.selectedIndex].value');
422
        $select_go_cats = ob_get_contents();
423
        ob_end_clean();
424
        $GLOBALS['xoopsTpl']->assign('select_go_cats', $select_go_cats);
425
    }
426
}
427
428
#  function categorynewgraphic
429
#####################################################
430
/**
431
 * @param $cid
432
 */
433
function categorynewgraphic($cid)
434
{
435
    global $xoopsDB;
436
}
437
438
######################################################
439
440
$pa      = Request::getInt('pa', null, 'GET');
441
$lid     = Request::getInt('lid', null, 'GET');
442
$cid     = Request::getInt('cid', null, 'GET');
443
$usid    = Request::getString('usid', '', 'GET');
444
$min     = Request::getInt('min', null, 'GET');
445
$show    = Request::getInt('show', null, 'GET');
446
$orderby = Request::getInt('orderby', null, 'GET');
447
448
switch ($pa) {
449
    default:
450
        $GLOBALS['xoopsOption']['template_main'] = 'adslight_category.tpl';
451
        adsView($cid, $min, $orderby, $show);
452
        break;
453
}
454
include XOOPS_ROOT_PATH . '/footer.php';
455