Passed
Push — master ( e8b784...3aca22 )
by Michael
15:11 queued 10:10
created

members.php (1 issue)

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
require_once __DIR__ . '/header.php';
34
35
$myts = \MyTextSanitizer::getInstance(); // MyTextSanitizer object
36
global $xoopsModule;
37
$pathIcon16 = Admin::iconUrl('', 16);
38
xoops_load('XoopsLocal');
39
$moduleDirName = \basename(__DIR__);
40
41
$helper                                  = Helper::getInstance();
42
$mytree                                  = new Tree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid');
43
$GLOBALS['xoopsOption']['template_main'] = 'adslight_members.tpl';
44
require_once XOOPS_ROOT_PATH . '/header.php';
45
require_once XOOPS_ROOT_PATH . '/include/comment_view.php';
46
47
$lid       = Request::getInt('lid', 0, 'GET');
48
$usid      = Request::getInt('usid', 0, 'GET');
49
$module_id = $xoopsModule->getVar('mid');
50
if (is_object($GLOBALS['xoopsUser'])) {
51
    $groups = $GLOBALS['xoopsUser']->getGroups();
52
} else {
53
    $groups = XOOPS_GROUP_ANONYMOUS;
54
}
55
/** @var \XoopsGroupPermHandler $grouppermHandler */
56
$grouppermHandler = xoops_getHandler('groupperm');
57
$perm_itemid      = Request::getInt('item_id', 0, 'POST');
58
59
//If no access
60
$permit = (!$grouppermHandler->checkRight('adslight_premium', $perm_itemid, $groups, $module_id)) ? '0' : '1';
61
62
$GLOBALS['xoopsTpl']->assign('permit', $permit);
63
$isadmin = (($GLOBALS['xoopsUser'] instanceof \XoopsUser)
64
            && $GLOBALS['xoopsUser']->isAdmin($xoopsModule->mid()));
65
66
$GLOBALS['xoopsTpl']->assign('add_from', _ADSLIGHT_ADDFROM . ' ' . $xoopsConfig['sitename']);
67
$GLOBALS['xoopsTpl']->assign('add_from_title', _ADSLIGHT_ADDFROM);
68
$GLOBALS['xoopsTpl']->assign('add_from_sitename', $xoopsConfig['sitename']);
69
$GLOBALS['xoopsTpl']->assign('mydirname', $moduleDirName);
70
$GLOBALS['xoopsTpl']->assign('comments_head', _ADSLIGHT_COMMENTS_HEAD);
71
$GLOBALS['xoopsTpl']->assign('lang_user_rating', _ADSLIGHT_USER_RATING);
72
$GLOBALS['xoopsTpl']->assign('lang_ratethisuser', _ADSLIGHT_RATETHISUSER);
73
$GLOBALS['xoopsTpl']->assign('title_head', _ADSLIGHT_TITLE);
74
$GLOBALS['xoopsTpl']->assign('date_head', _ADSLIGHT_ADDED_ON);
75
$GLOBALS['xoopsTpl']->assign('views_head', _ADSLIGHT_VIEW2);
76
$GLOBALS['xoopsTpl']->assign('replies_head', _ADSLIGHT_REPLIES);
77
$GLOBALS['xoopsTpl']->assign('expires_head', _ADSLIGHT_EXPIRES_ON);
78
$GLOBALS['xoopsTpl']->assign('all_user_listings', _ADSLIGHT_ALL_USER_LISTINGS);
79
$GLOBALS['xoopsTpl']->assign('nav_main', '<a href="index.php">' . _ADSLIGHT_MAIN . '</a>');
80
$GLOBALS['xoopsTpl']->assign('mydirname', $moduleDirName);
81
$GLOBALS['xoopsTpl']->assign('xoops_module_header', '<link rel="stylesheet" href="' . XOOPS_URL . '/modules/adslight/assets/css/adslight.css" type="text/css" media="all" >');
82
83
$GLOBALS['xoopsTpl']->assign('adslight_active_menu', $GLOBALS['xoopsModuleConfig']['adslight_active_menu']);
84
$GLOBALS['xoopsTpl']->assign('adslight_active_rss', $GLOBALS['xoopsModuleConfig']['adslight_active_rss']);
85
$GLOBALS['xoTheme']->addMeta('meta', 'robots', 'noindex, nofollow');
86
87
$show = 4;
88
$min  = Request::getInt('min', 0, 'GET');
89
if (!isset($max)) {
90
    $max = $min + $show;
91
}
92
$orderby = 'date_created ASC';
93
$rate    = ('1' == $GLOBALS['xoopsModuleConfig']['adslight_rate_user']) ? '1' : '0';
94
$GLOBALS['xoopsTpl']->assign('rate', $rate);
95
96
if ($GLOBALS['xoopsUser']) {
97
    $member_usid = $GLOBALS['xoopsUser']->getVar('uid', 'E');
98
    $istheirs    = ($usid == $member_usid) ? 1 : '';
99
}
100
101
$cat_perms  = '';
102
$categories = Utility::getMyItemIds('adslight_view');
103
if (is_array($categories) && count($categories) > 0) {
104
    $cat_perms .= ' AND cid IN (' . implode(',', $categories) . ') ';
105
}
106
107
if (1 == $istheirs) {
108
    $countresult = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE usid=' . $xoopsDB->escape($usid) . " AND valid='Yes' $cat_perms");
109
    [$trow] = $xoopsDB->fetchRow($countresult);
110
111
    $sql    = 'SELECT lid, cid, title, status, expire, type, desctext, tel, price, typeprice, date_created, email, submitter, usid, town, country, contactby, premium, valid, photo, hits, item_rating, item_votes, user_rating, user_votes, comments FROM '
112
              . $xoopsDB->prefix('adslight_listing')
113
              . ' WHERE usid = '
114
              . $xoopsDB->escape($usid)
115
              . " AND valid='Yes' $cat_perms ORDER BY $orderby";
116
    $result = $xoopsDB->query($sql, $show, $min);
117
} else {
118
    $countresult = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE usid=' . $xoopsDB->escape($usid) . " AND valid='Yes' AND status!='1' $cat_perms");
119
    [$trow] = $xoopsDB->fetchRow($countresult);
120
121
    $sql    = 'SELECT lid, cid, title, status, expire, type, desctext, tel, price, typeprice, date_created, email, submitter, usid, town, country, contactby, premium, valid, photo, hits, item_rating, item_votes, user_rating, user_votes, comments FROM '
122
              . $xoopsDB->prefix('adslight_listing')
123
              . ' WHERE usid = '
124
              . $xoopsDB->escape($usid)
125
              . " AND valid='Yes' AND status!='1' $cat_perms ORDER BY $orderby";
126
    $result = $xoopsDB->query($sql, $show, $min);
127
}
128
129
$trows   = $trow;
130
$pagenav = '';
131
if ($trows > '0') {
132
    $GLOBALS['xoopsTpl']->assign('min', $min);
133
    $rank = 1;
134
135
    if ($trows > '1') {
136
        $GLOBALS['xoopsTpl']->assign('show_nav', true);
137
        $GLOBALS['xoopsTpl']->assign('lang_sortby', _ADSLIGHT_SORTBY);
138
        $GLOBALS['xoopsTpl']->assign('lang_title', _ADSLIGHT_TITLE);
139
        $GLOBALS['xoopsTpl']->assign('lang_titleatoz', _ADSLIGHT_TITLEATOZ);
140
        $GLOBALS['xoopsTpl']->assign('lang_titleztoa', _ADSLIGHT_TITLEZTOA);
141
        $GLOBALS['xoopsTpl']->assign('lang_date', _ADSLIGHT_DATE);
142
        $GLOBALS['xoopsTpl']->assign('lang_dateold', _ADSLIGHT_DATEOLD);
143
        $GLOBALS['xoopsTpl']->assign('lang_datenew', _ADSLIGHT_DATENEW);
144
        $GLOBALS['xoopsTpl']->assign('lang_popularity', _ADSLIGHT_POPULARITY);
145
        $GLOBALS['xoopsTpl']->assign('lang_popularityleast', _ADSLIGHT_POPULARITYLTOM);
146
        $GLOBALS['xoopsTpl']->assign('lang_popularitymost', _ADSLIGHT_POPULARITYMTOL);
147
    }
148
    while (false !== (list($lid, $cid, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $date_created, $email, $submitter, $usid, $town, $country, $contactby, $premium, $valid, $photo, $hits, $item_rating, $item_votes, $user_rating, $user_votes, $comments) = $xoopsDB->fetchRow(
149
            $result
150
        ))) {
151
        $newitem   = '';
152
        $newcount  = $GLOBALS['xoopsModuleConfig']['adslight_countday'];
153
        $startdate = (time() - (86400 * $newcount));
154
        if ($startdate < $date_created) {
155
            //@todo move "New" alt text to language file
156
            $newitem = '<img src="' . XOOPS_URL . '/modules/adslight/assets/images/newred.gif" alt="New" >';
157
        }
158
159
        if (0 == $status) {
160
            $status_is = _ADSLIGHT_ACTIVE;
161
        }
162
        if (1 == $status) {
163
            $status_is = _ADSLIGHT_INACTIVE;
164
        }
165
        if (2 == $status) {
166
            $status_is = _ADSLIGHT_SOLD;
167
        }
168
        $countresult = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_replies') . " WHERE lid='" . $xoopsDB->escape($lid) . "'");
169
        [$rrow] = $xoopsDB->fetchRow($countresult);
170
        $rrows = $rrow;
171
        $GLOBALS['xoopsTpl']->assign('reply_count', $rrows);
172
173
        $result2 = $xoopsDB->query('SELECT r_lid, lid, date_created, submitter, message, email, r_usid FROM ' . $xoopsDB->prefix('adslight_replies') . ' WHERE lid =' . $xoopsDB->escape($lid));
174
        [$r_lid, $rlid, $rdate, $rsubmitter, $message, $remail, $r_usid] = $xoopsDB->fetchRow($result2);
175
176
        //Fix bug for type and typeprice
177
        $result7 = $xoopsDB->query('SELECT nom_type FROM ' . $xoopsDB->prefix('adslight_type') . ' WHERE id_type=' . (int)$type);
178
        [$nom_type] = $xoopsDB->fetchRow($result7);
179
180
        //        $result8 = $xoopsDB->query('SELECT nom_price FROM ' . $xoopsDB->prefix('adslight_price') . " WHERE id_price='" . $xoopsDB->escape($typeprice) . "'");
181
        //        [$nom_price] = $xoopsDB->fetchRow($result8);
182
183
        $result8 = $xoopsDB->query('SELECT nom_price FROM ' . $xoopsDB->prefix('adslight_price') . ' WHERE id_price=' . (int)$typeprice);
184
        [$nom_price] = $xoopsDB->fetchRow($result8);
185
186
        if ($isadmin) {
187
            $adminlink = "<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 . '" ></a>';
188
            $GLOBALS['xoopsTpl']->assign('isadmin', $isadmin);
189
        } else {
190
            $adminlink = '';
191
        }
192
        $modify_link = '';
193
        if ($GLOBALS['xoopsUser'] instanceof \XoopsUser) {
194
            $member_usid = $GLOBALS['xoopsUser']->getVar('uid', 'E');
195
            if ($usid == $member_usid) {
196
                $istheirs = true;
197
                $GLOBALS['xoopsTpl']->assign('istheirs', $istheirs);
198
                $modify_link = "<a href='modify.php?op=ModAd&amp;lid=" . $lid . "'><img src='" . $pathIcon16 . "/edit.png'  border=0 alt=\"" . _ADSLIGHT_MODADMIN . '" ></a>';
199
            } else {
200
                $istheirs = false;
201
                $GLOBALS['xoopsTpl']->assign('istheirs', '');
202
            }
203
        }
204
205
        $GLOBALS['xoopsTpl']->assign('submitter', $submitter);
206
        $GLOBALS['xoopsTpl']->assign('usid', $usid);
207
        $GLOBALS['xoopsTpl']->assign('read', "$hits " . _ADSLIGHT_VIEW2);
208
        $GLOBALS['xoopsTpl']->assign('rating', number_format((float)$user_rating, 2));
209
        $GLOBALS['xoopsTpl']->assign('status_head', _ADSLIGHT_STATUS);
210
        $tempXoopsLocal = new \XoopsLocal();
211
        //  For US currency with 2 numbers after the decimal comment out if you dont want 2 numbers after decimal
212
        $price2 = $tempXoopsLocal->number_format($price, 2, ',', ' ');
0 ignored issues
show
The call to XoopsLocal::number_format() has too many arguments starting with 2. ( Ignorable by Annotation )

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

212
        /** @scrutinizer ignore-call */ 
213
        $price2 = $tempXoopsLocal->number_format($price, 2, ',', ' ');

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
213
        //  For other countries uncomment the below line and comment out the above line
214
        //      $price = $tempXoopsLocal->number_format($price);
215
216
        //        $GLOBALS['xoopsTpl']->assign('price', '<strong>' . _ADSLIGHT_PRICE . "</strong>$price" . $GLOBALS['xoopsModuleConfig']['adslight_currency_symbol'] . " - $typeprice");
217
218
        $currencyCode                 = $helper->getConfig('adslight_currency_code');
219
        $currencySymbol               = $helper->getConfig('adslight_currency_symbol');
220
        $currencyPosition             = $helper->getConfig('currency_position');
221
        $formattedCurrencyUtilityTemp = Utility::formatCurrencyTemp($price, $currencyCode, $currencySymbol, $currencyPosition);
222
        $priceHtml                    = '<strong>' . _ADSLIGHT_PRICE2 . '</strong>' . $formattedCurrencyUtilityTemp . ' - ' . $typeprice;
223
        $GLOBALS['xoopsTpl']->assign('price', $priceHtml);
224
225
        $GLOBALS['xoopsTpl']->assign('price_head', _ADSLIGHT_PRICE);
226
        $GLOBALS['xoopsTpl']->assign('money_sign', '' . $GLOBALS['xoopsModuleConfig']['adslight_currency_symbol']);
227
        $GLOBALS['xoopsTpl']->assign('price_typeprice', $typeprice);
228
229
        $GLOBALS['xoopsTpl']->assign('type', htmlspecialchars($nom_type, ENT_QUOTES | ENT_HTML5));
230
231
        $priceTypeprice = \htmlspecialchars($nom_price, ENT_QUOTES | ENT_HTML5);
232
        $priceCurrency  = $GLOBALS['xoopsModuleConfig']['adslight_currency_code'];
233
234
        $currencyCode                 = $helper->getConfig('adslight_currency_code');
235
        $currencySymbol               = $helper->getConfig('adslight_currency_symbol');
236
        $currencyPosition             = $helper->getConfig('currency_position');
237
        $formattedCurrencyUtilityTemp = Utility::formatCurrencyTemp($price, $currencyCode, $currencySymbol, $currencyPosition);
238
        $priceHtml                    = '<strong>' . _ADSLIGHT_PRICE2 . '</strong>' . $formattedCurrencyUtilityTemp . ' - ' . $priceTypeprice;
239
240
        $GLOBALS['xoopsTpl']->assign('price_head', _ADSLIGHT_PRICE2);
241
        $GLOBALS['xoopsTpl']->assign('price_price', $priceFormatted);
242
        $GLOBALS['xoopsTpl']->assign('price_typeprice', $priceTypeprice);
243
        $GLOBALS['xoopsTpl']->assign('price_currency', $priceCurrency);
244
        $GLOBALS['xoopsTpl']->assign('price', $priceHtml);
245
        $GLOBALS['xoopsTpl']->assign('priceHtml', $priceHtml);
246
247
        $GLOBALS['xoopsTpl']->assign('local_town', (string)$town);
248
        $GLOBALS['xoopsTpl']->assign('local_country', (string)$country);
249
        $GLOBALS['xoopsTpl']->assign('local_head', _ADSLIGHT_LOCAL2);
250
        $GLOBALS['xoopsTpl']->assign('edit_ad', _ADSLIGHT_EDIT);
251
252
        $usid       = addslashes($usid);
253
        $votestring = (1 == $user_votes) ? _ADSLIGHT_ONEVOTE : sprintf(_ADSLIGHT_NUMVOTES, $user_votes);
254
255
        $GLOBALS['xoopsTpl']->assign('user_votes', $votestring);
256
        $date2 = $date_created + ($expire * 86400);
257
        $date_created  = formatTimestamp($date_created, 's');
258
        $date2 = formatTimestamp($date2, 's');
259
        $path  = $mytree->getPathFromId($cid, 'title');
260
        $path  = mb_substr($path, 1);
261
        $path  = str_replace('/', ' - ', $path);
262
        if ($rrows >= 1) {
263
            $view_now = "<a href='replies.php?lid=" . $lid . "'>" . _ADSLIGHT_VIEWNOW . '</a>';
264
        } else {
265
            $view_now = '';
266
        }
267
        $sold = '';
268
        if (2 == $status) {
269
            $sold = _ADSLIGHT_RESERVEDMEMBER;
270
        }
271
272
        $GLOBALS['xoopsTpl']->assign('xoops_pagetitle', '' . _ADSLIGHT_ALL_USER_LISTINGS . ' ' . $submitter);
273
        $updir   = $GLOBALS['xoopsModuleConfig']['adslight_link_upload'];
274
        $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';
275
        $resultp = $xoopsDB->query($sql);
276
        while (false !== (list($cod_img, $pic_lid, $uid_owner, $url) = $xoopsDB->fetchRow($resultp))) {
277
            if ($photo) {
278
                $photo = "<a href='viewads.php?lid=" . $lid . "'><img class=\"thumb\" src=\"$updir/thumbs/thumb_$url\" align=\"left\" width=\"100px\" alt=\"$title\" ></a>";
279
            }
280
        }
281
        $no_photo = "<a href='viewads.php?lid=" . $lid . "'><img class=\"thumb\" src=\"assets/images/nophoto.jpg\" align=\"left\" width=\"100px\" alt=\"$title\" ></a>";
282
283
        $GLOBALS['xoopsTpl']->append('items', [
284
            'id'          => $lid,
285
            'cid'         => $cid,
286
            'title'       => htmlspecialchars($title, ENT_QUOTES | ENT_HTML5),
287
            'status'      => htmlspecialchars($status_is, ENT_QUOTES | ENT_HTML5),
288
            'expire'      => htmlspecialchars($expire, ENT_QUOTES | ENT_HTML5),
289
            'type'        => htmlspecialchars($type, ENT_QUOTES | ENT_HTML5),
290
            'desctext'    => $myts->displayTarea($desctext),
291
            'tel'         => htmlspecialchars($tel, ENT_QUOTES | ENT_HTML5),
292
            'price'       => htmlspecialchars($price, ENT_QUOTES | ENT_HTML5),
293
            'typeprice'   => htmlspecialchars($typeprice, ENT_QUOTES | ENT_HTML5),
294
            'date_created'        => htmlspecialchars($date_created??'', ENT_QUOTES | ENT_HTML5),
295
            'email'       => htmlspecialchars($email, ENT_QUOTES | ENT_HTML5),
296
            'submitter'   => htmlspecialchars($submitter, ENT_QUOTES | ENT_HTML5),
297
            'usid'        => htmlspecialchars($usid, ENT_QUOTES | ENT_HTML5),
298
            'town'        => htmlspecialchars($town, ENT_QUOTES | ENT_HTML5),
299
            'country'     => htmlspecialchars($country, ENT_QUOTES | ENT_HTML5),
300
            'contactby'   => htmlspecialchars($contactby, ENT_QUOTES | ENT_HTML5),
301
            'premium'     => htmlspecialchars($premium, ENT_QUOTES | ENT_HTML5),
302
            'valid'       => htmlspecialchars($valid, ENT_QUOTES | ENT_HTML5),
303
            'hits'        => $hits,
304
            'rlid'        => htmlspecialchars($rlid??'', ENT_QUOTES | ENT_HTML5),
305
            'rdate'       => htmlspecialchars($rdate??'', ENT_QUOTES | ENT_HTML5),
306
            'rsubmitter'  => htmlspecialchars($rsubmitter??'', ENT_QUOTES | ENT_HTML5),
307
            'message'     => htmlspecialchars($message??'', ENT_QUOTES | ENT_HTML5),
308
            'remail'      => htmlspecialchars($remail??'', ENT_QUOTES | ENT_HTML5),
309
            'rrows'       => $rrows,
310
            'expires'     => htmlspecialchars($date2, ENT_QUOTES | ENT_HTML5),
311
            'view_now'    => $view_now,
312
            'modify_link' => $modify_link,
313
            'photo'       => $photo,
314
            'no_photo'    => $no_photo,
315
            'adminlink'   => $adminlink,
316
            'new'         => $newitem,
317
            'sold'        => $sold,
318
        ]);
319
    }
320
    $usid = Request::getInt('usid', 0, 'GET');
321
322
    //Calculates how many pages exist.  Which page one should be on, etc...
323
    $linkpages = ceil($trows / $show);
324
    //Page Numbering
325
    if (1 != $linkpages && 0 != $linkpages) {
326
        $prev = $min - $show;
327
        if ($prev >= 0) {
328
            $pagenav .= "<a href='members.php?usid=$usid&min=$prev&show=$show'><strong><u>&laquo;</u></strong></a> ";
329
        }
330
        $counter     = 1;
331
        $currentpage = ($max / $show);
332
        while ($counter <= $linkpages) {
333
            $mintemp = ($show * $counter) - $show;
334
            if ($counter == $currentpage) {
335
                $pagenav .= "<strong>($counter)</strong> ";
336
            } else {
337
                $pagenav .= "<a href='members.php?usid=$usid&min=$mintemp&show=$show'>$counter</a> ";
338
            }
339
            ++$counter;
340
        }
341
        if ($trows > $max) {
342
            $pagenav .= "<a href='members.php?usid=$usid&min=$max&show=$show'>";
343
            $pagenav .= '<strong><u>&raquo;</u></strong></a>';
344
        }
345
        $GLOBALS['xoopsTpl']->assign('nav_page', '<strong>' . _ADSLIGHT_PAGES . "</strong>&nbsp;&nbsp; $pagenav");
346
    }
347
}
348
349
require_once XOOPS_ROOT_PATH . '/footer.php';
350