Passed
Push — master ( 9d155f...5e790e )
by Michael
02:23
created

members.php (1 issue)

Labels
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
//include 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 ClassifiedsTree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid');
0 ignored issues
show
The type ClassifiedsTree 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...
35
$GLOBALS['xoopsOption']['template_main'] = 'adslight_members.tpl';
36
include XOOPS_ROOT_PATH . '/header.php';
37
include 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 $gpermHandler */
48
$gpermHandler = xoops_getHandler('groupperm');
49
$perm_itemid  = Request::getInt('item_id', 0, 'POST');
50
51
//If no access
52
$permit = (!$gpermHandler->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 !== (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))) {
141
        $newitem   = '';
142
        $newcount  = $GLOBALS['xoopsModuleConfig']['adslight_countday'];
143
        $startdate = (time() - (86400 * $newcount));
144
        if ($startdate < $date) {
145
            //@todo move "New" alt text to language file
146
            $newitem = '<img src="' . XOOPS_URL . '/modules/adslight/assets/images/newred.gif" alt="New" >';
147
        }
148
149
        if (0 == $status) {
150
            $status_is = _ADSLIGHT_ACTIVE;
151
        }
152
        if (1 == $status) {
153
            $status_is = _ADSLIGHT_INACTIVE;
154
        }
155
        if (2 == $status) {
156
            $status_is = _ADSLIGHT_SOLD;
157
        }
158
        $countresult = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_replies') . " WHERE lid='" . $xoopsDB->escape($lid) . "'");
159
        list($rrow) = $xoopsDB->fetchRow($countresult);
160
        $rrows = $rrow;
161
        $GLOBALS['xoopsTpl']->assign('reply_count', $rrows);
162
163
        $result2 = $xoopsDB->query('SELECT r_lid, lid, date, submitter, message, email, r_usid FROM ' . $xoopsDB->prefix('adslight_replies') . ' WHERE lid =' . $xoopsDB->escape($lid));
164
        list($r_lid, $rlid, $rdate, $rsubmitter, $message, $remail, $r_usid) = $xoopsDB->fetchRow($result2);
165
166
        if ($isadmin) {
167
            $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>';
168
            $GLOBALS['xoopsTpl']->assign('isadmin', $isadmin);
169
        } else {
170
            $adminlink = '';
171
        }
172
        $modify_link = '';
173
        if ($GLOBALS['xoopsUser'] instanceof \XoopsUser) {
174
            $member_usid = $GLOBALS['xoopsUser']->getVar('uid', 'E');
175
            if ($usid == $member_usid) {
176
                $istheirs = true;
177
                $GLOBALS['xoopsTpl']->assign('istheirs', $istheirs);
178
                $modify_link = "<a href='modify.php?op=ModAd&amp;lid=" . $lid . "'><img src='" . $pathIcon16 . "/edit.png'  border=0 alt=\"" . _ADSLIGHT_MODADMIN . '" ></a>';
179
            } else {
180
                $istheirs = false;
181
                $GLOBALS['xoopsTpl']->assign('istheirs', '');
182
            }
183
        }
184
185
        $GLOBALS['xoopsTpl']->assign('submitter', $submitter);
186
        $GLOBALS['xoopsTpl']->assign('usid', $usid);
187
        $GLOBALS['xoopsTpl']->assign('read', "$hits " . _ADSLIGHT_VIEW2);
188
        $GLOBALS['xoopsTpl']->assign('rating', number_format($user_rating, 2));
189
        $GLOBALS['xoopsTpl']->assign('status_head', _ADSLIGHT_STATUS);
190
        $tempXoopsLocal = new \XoopsLocal;
191
        //  For US currency with 2 numbers after the decimal comment out if you dont want 2 numbers after decimal
192
        $price = $tempXoopsLocal->number_format($price, 2, ',', ' ');
193
        //  For other countries uncomment the below line and comment out the above line
194
        //      $price = $tempXoopsLocal->number_format($price);
195
        $GLOBALS['xoopsTpl']->assign('price', '<strong>' . _ADSLIGHT_PRICE . "</strong>$price" . $GLOBALS['xoopsModuleConfig']['adslight_currency_symbol'] . " - $typeprice");
196
        $GLOBALS['xoopsTpl']->assign('price_head', _ADSLIGHT_PRICE);
197
        $GLOBALS['xoopsTpl']->assign('money_sign', '' . $GLOBALS['xoopsModuleConfig']['adslight_currency_symbol']);
198
        $GLOBALS['xoopsTpl']->assign('price_typeprice', $typeprice);
199
        $GLOBALS['xoopsTpl']->assign('local_town', "$town");
200
        $GLOBALS['xoopsTpl']->assign('local_country', "$country");
201
        $GLOBALS['xoopsTpl']->assign('local_head', _ADSLIGHT_LOCAL2);
202
        $GLOBALS['xoopsTpl']->assign('edit_ad', _ADSLIGHT_EDIT);
203
204
        $usid       = addslashes($usid);
205
        $votestring = (1 == $user_votes) ? _ADSLIGHT_ONEVOTE : sprintf(_ADSLIGHT_NUMVOTES, $user_votes);
206
207
        $GLOBALS['xoopsTpl']->assign('user_votes', $votestring);
208
        $date2 = $date + ($expire * 86400);
209
        $date  = formatTimestamp($date, 's');
210
        $date2 = formatTimestamp($date2, 's');
211
        $path  = $mytree->getPathFromId($cid, 'title');
212
        $path  = substr($path, 1);
213
        $path  = str_replace('/', ' - ', $path);
214
        if ($rrows >= 1) {
215
            $view_now = "<a href='replies.php?lid=" . $lid . "'>" . _ADSLIGHT_VIEWNOW . '</a>';
216
        } else {
217
            $view_now = '';
218
        }
219
        $sold = '';
220
        if (2 == $status) {
221
            $sold = _ADSLIGHT_RESERVEDMEMBER;
222
        }
223
224
        $GLOBALS['xoopsTpl']->assign('xoops_pagetitle', '' . _ADSLIGHT_ALL_USER_LISTINGS . ' ' . $submitter);
225
        $updir   = $GLOBALS['xoopsModuleConfig']['adslight_link_upload'];
226
        $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';
227
        $resultp = $xoopsDB->query($sql);
228
        while (false !== (list($cod_img, $pic_lid, $uid_owner, $url) = $xoopsDB->fetchRow($resultp))) {
229
            if ($photo) {
230
                $photo = "<a href='viewads.php?lid=" . $lid . "'><img class=\"thumb\" src=\"$updir/thumbs/thumb_$url\" align=\"left\" width=\"100px\" alt=\"$title\" ></a>";
231
            }
232
        }
233
        $no_photo = "<a href='viewads.php?lid=" . $lid . "'><img class=\"thumb\" src=\"assets/images/nophoto.jpg\" align=\"left\" width=\"100px\" alt=\"$title\" ></a>";
234
235
        $GLOBALS['xoopsTpl']->append('items', [
236
            'id'          => $lid,
237
            'cid'         => $cid,
238
            'title'       => $myts->htmlSpecialChars($title),
239
            'status'      => $myts->htmlSpecialChars($status_is),
240
            'expire'      => $myts->htmlSpecialChars($expire),
241
            'type'        => $myts->htmlSpecialChars($type),
242
            'desctext'    => $myts->displayTarea($desctext),
243
            'tel'         => $myts->htmlSpecialChars($tel),
244
            'price'       => $myts->htmlSpecialChars($price),
245
            'typeprice'   => $myts->htmlSpecialChars($typeprice),
246
            'date'        => $myts->htmlSpecialChars($date),
247
            'email'       => $myts->htmlSpecialChars($email),
248
            'submitter'   => $myts->htmlSpecialChars($submitter),
249
            'usid'        => $myts->htmlSpecialChars($usid),
250
            'town'        => $myts->htmlSpecialChars($town),
251
            'country'     => $myts->htmlSpecialChars($country),
252
            'contactby'   => $myts->htmlSpecialChars($contactby),
253
            'premium'     => $myts->htmlSpecialChars($premium),
254
            'valid'       => $myts->htmlSpecialChars($valid),
255
            'hits'        => $hits,
256
            'rlid'        => $myts->htmlSpecialChars($rlid),
257
            'rdate'       => $myts->htmlSpecialChars($rdate),
258
            'rsubmitter'  => $myts->htmlSpecialChars($rsubmitter),
259
            'message'     => $myts->htmlSpecialChars($message),
260
            'remail'      => $myts->htmlSpecialChars($remail),
261
            'rrows'       => $rrows,
262
            'expires'     => $myts->htmlSpecialChars($date2),
263
            'view_now'    => $view_now,
264
            'modify_link' => $modify_link,
265
            'photo'       => $photo,
266
            'no_photo'    => $no_photo,
267
            'adminlink'   => $adminlink,
268
            'new'         => $newitem,
269
            'sold'        => $sold
270
        ]);
271
    }
272
    $usid = Request::getInt('usid', 0, 'GET');
273
274
    //Calculates how many pages exist.  Which page one should be on, etc...
275
    $linkpages = ceil($trows / $show);
276
    //Page Numbering
277
    if (1 != $linkpages && 0 != $linkpages) {
278
        $prev = $min - $show;
279
        if ($prev >= 0) {
280
            $pagenav .= "<a href='members.php?usid=$usid&min=$prev&show=$show'><strong><u>&laquo;</u></strong></a> ";
281
        }
282
        $counter     = 1;
283
        $currentpage = ($max / $show);
284
        while ($counter <= $linkpages) {
285
            $mintemp = ($show * $counter) - $show;
286
            if ($counter == $currentpage) {
287
                $pagenav .= "<strong>($counter)</strong> ";
288
            } else {
289
                $pagenav .= "<a href='members.php?usid=$usid&min=$mintemp&show=$show'>$counter</a> ";
290
            }
291
            ++$counter;
292
        }
293
        if ($trows > $max) {
294
            $pagenav .= "<a href='members.php?usid=$usid&min=$max&show=$show'>";
295
            $pagenav .= '<strong><u>&raquo;</u></strong></a>';
296
        }
297
        $GLOBALS['xoopsTpl']->assign('nav_page', '<strong>' . _ADSLIGHT_PAGES . "</strong>&nbsp;&nbsp; $pagenav");
298
    }
299
}
300
301
include XOOPS_ROOT_PATH . '/footer.php';
302