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

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