Completed
Push — master ( a25b3b...67bb37 )
by Michael
02:44
created

members.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

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