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

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