Passed
Push — master ( 978347...893ae4 )
by Michael
02:45
created

members.php (1 issue)

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

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