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
29
include_once XOOPS_ROOT_PATH . '/modules/adslight/class/classifiedstree.php';
30
$mytree                                  = new ClassifiedsTree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid');
31
$GLOBALS['xoopsOption']['template_main'] = 'adslight_members.tpl';
32
include XOOPS_ROOT_PATH . '/header.php';
33
include XOOPS_ROOT_PATH . '/include/comment_view.php';
34
35
$lid       = XoopsRequest::getInt('lid', 0, 'GET');
36
$usid      = XoopsRequest::getInt('usid', 0, 'GET');
37
$module_id = $xoopsModule->getVar('mid');
38 View Code Duplication
if (is_object($GLOBALS['xoopsUser'])) {
39
    $groups = $GLOBALS['xoopsUser']->getGroups();
40
} else {
41
    $groups = XOOPS_GROUP_ANONYMOUS;
42
}
43
$gpermHandler = xoops_getHandler('groupperm');
44
$perm_itemid   = XoopsRequest::getInt('item_id', 0, 'POST');
45
46
//If no access
47
$permit = (!$gpermHandler->checkRight('adslight_premium', $perm_itemid, $groups, $module_id)) ? '0' : '1';
48
49
$xoopsTpl->assign('permit', $permit);
50
$isadmin = (($GLOBALS['xoopsUser'] instanceof XoopsUser) && $GLOBALS['xoopsUser']->isAdmin($xoopsModule->mid())) ? true : false;
51
52
$xoopsTpl->assign('add_from', _ADSLIGHT_ADDFROM . ' ' . $xoopsConfig['sitename']);
53
$xoopsTpl->assign('add_from_title', _ADSLIGHT_ADDFROM);
54
$xoopsTpl->assign('add_from_sitename', $xoopsConfig['sitename']);
55
$xoopsTpl->assign('mydirname', $moduleDirName);
56
$xoopsTpl->assign('comments_head', _ADSLIGHT_COMMENTS_HEAD);
57
$xoopsTpl->assign('lang_user_rating', _ADSLIGHT_USER_RATING);
58
$xoopsTpl->assign('lang_ratethisuser', _ADSLIGHT_RATETHISUSER);
59
$xoopsTpl->assign('title_head', _ADSLIGHT_TITLE);
60
$xoopsTpl->assign('date_head', _ADSLIGHT_ADDED_ON);
61
$xoopsTpl->assign('views_head', _ADSLIGHT_VIEW2);
62
$xoopsTpl->assign('replies_head', _ADSLIGHT_REPLIES);
63
$xoopsTpl->assign('expires_head', _ADSLIGHT_EXPIRES_ON);
64
$xoopsTpl->assign('all_user_listings', _ADSLIGHT_ALL_USER_LISTINGS);
65
$xoopsTpl->assign('nav_main', '<a href="index.php">' . _ADSLIGHT_MAIN . '</a>');
66
$xoopsTpl->assign('mydirname', $moduleDirName);
67
$xoopsTpl->assign('xoops_module_header', '<link rel="stylesheet" href="' . XOOPS_URL . '/modules/adslight/assets/css/adslight.css" type="text/css" media="all" />');
68
69
$xoopsTpl->assign('adslight_active_menu', $GLOBALS['xoopsModuleConfig']['adslight_active_menu']);
70
$xoopsTpl->assign('adslight_active_rss', $GLOBALS['xoopsModuleConfig']['adslight_active_rss']);
71
$xoTheme->addMeta('meta', 'robots', 'noindex, nofollow');
72
73
$show = 4;
74
$min  = XoopsRequest::getInt('min', 0, 'GET');
75
if (!isset($max)) {
76
    $max = $min + $show;
77
}
78
$orderby = 'date ASC';
79
$rate    = ('1' == $GLOBALS['xoopsModuleConfig']['adslight_rate_user']) ? '1' : '0';
80
$xoopsTpl->assign('rate', $rate);
81
82
if ($GLOBALS['xoopsUser']) {
83
    $member_usid = $GLOBALS['xoopsUser']->getVar('uid', 'E');
84
    $istheirs    = ($usid == $member_usid) ? 1 : '';
85
}
86
87
$cat_perms  = '';
88
$categories = AdslightUtilities::getMyItemIds('adslight_view');
89
if (is_array($categories) && count($categories) > 0) {
90
    $cat_perms .= ' AND cid IN (' . implode(',', $categories) . ') ';
91
}
92
93
if (1 == $istheirs) {
94
    $countresult = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE usid=' . $xoopsDB->escape($usid) . " AND valid='Yes' $cat_perms");
95
    list($trow) = $xoopsDB->fetchRow($countresult);
96
97
    $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 '
98
              . $xoopsDB->prefix('adslight_listing')
99
              . ' WHERE usid = '
100
              . $xoopsDB->escape($usid)
101
              . " AND valid='Yes' $cat_perms ORDER BY $orderby";
102
    $result = $xoopsDB->query($sql, $show, $min);
103
} else {
104
    $countresult = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE usid=' . $xoopsDB->escape($usid) . " AND valid='Yes' AND status!='1' $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' AND status!='1' $cat_perms ORDER BY $orderby";
112
    $result = $xoopsDB->query($sql, $show, $min);
113
}
114
115
$trows   = $trow;
116
$pagenav = '';
117
if ($trows > '0') {
118
    $xoopsTpl->assign('min', $min);
119
    $rank = 1;
120
121
    if ($trows > '1') {
122
        $xoopsTpl->assign('show_nav', true);
123
        $xoopsTpl->assign('lang_sortby', _ADSLIGHT_SORTBY);
124
        $xoopsTpl->assign('lang_title', _ADSLIGHT_TITLE);
125
        $xoopsTpl->assign('lang_titleatoz', _ADSLIGHT_TITLEATOZ);
126
        $xoopsTpl->assign('lang_titleztoa', _ADSLIGHT_TITLEZTOA);
127
        $xoopsTpl->assign('lang_date', _ADSLIGHT_DATE);
128
        $xoopsTpl->assign('lang_dateold', _ADSLIGHT_DATEOLD);
129
        $xoopsTpl->assign('lang_datenew', _ADSLIGHT_DATENEW);
130
        $xoopsTpl->assign('lang_popularity', _ADSLIGHT_POPULARITY);
131
        $xoopsTpl->assign('lang_popularityleast', _ADSLIGHT_POPULARITYLTOM);
132
        $xoopsTpl->assign('lang_popularitymost', _ADSLIGHT_POPULARITYMTOL);
133
    }
134
    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)) {
135
        $newitem   = '';
136
        $newcount  = $GLOBALS['xoopsModuleConfig']['adslight_countday'];
137
        $startdate = (time() - (86400 * $newcount));
138
        if ($startdate < $date) {
139
            //@todo move "New" alt text to language file
140
            $newitem = '<img src="' . XOOPS_URL . '/modules/adslight/assets/images/newred.gif" alt="New" />';
141
        }
142
143
        if (0 == $status) {
144
            $status_is = _ADSLIGHT_ACTIVE;
145
        }
146
        if (1 == $status) {
147
            $status_is = _ADSLIGHT_INACTIVE;
148
        }
149
        if (2 == $status) {
150
            $status_is = _ADSLIGHT_SOLD;
151
        }
152
        $countresult = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_replies') . " WHERE lid='" . $xoopsDB->escape($lid) . "'");
153
        list($rrow) = $xoopsDB->fetchRow($countresult);
154
        $rrows = $rrow;
155
        $xoopsTpl->assign('reply_count', $rrows);
156
157
        $result2 = $xoopsDB->query('SELECT r_lid, lid, date, submitter, message, email, r_usid FROM ' . $xoopsDB->prefix('adslight_replies') . ' WHERE lid =' . $xoopsDB->escape($lid) );
158
        list($r_lid, $rlid, $rdate, $rsubmitter, $message, $remail, $r_usid) = $xoopsDB->fetchRow($result2);
159
160
        if ($isadmin) {
161
            $adminlink = "<a href='"
162
                         . XOOPS_URL
163
                         . '/modules/adslight/admin/validate_ads.php?op=ModifyAds&amp;lid='
164
                         . $lid
165
                         . "'><img src='"
166
                         . $pathIcon16
167
                         . "/edit.png' border=0 alt=\""
168
                         . _ADSLIGHT_MODADMIN
169
                         . "\" /></a>";
170
            $xoopsTpl->assign('isadmin', $isadmin);
171
        } else {
172
            $adminlink = '';
173
        }
174
        $modify_link = '';
175
        if ($GLOBALS['xoopsUser'] instanceof XoopsUser) {
176
            $member_usid = $GLOBALS['xoopsUser']->getVar('uid', 'E');
177
            if ($usid == $member_usid) {
178
                $istheirs = true;
179
                $xoopsTpl->assign('istheirs', $istheirs);
180
                $modify_link = "<a href='modify.php?op=ModAd&amp;lid=" . $lid . "'><img src='" . $pathIcon16 . "/edit.png'  border=0 alt=\"" . _ADSLIGHT_MODADMIN . "\" /></a>";
181
            } else {
182
                $istheirs = false;
183
                $xoopsTpl->assign('istheirs', '');
184
            }
185
        }
186
187
        $xoopsTpl->assign('submitter', $submitter);
188
        $xoopsTpl->assign('usid', $usid);
189
        $xoopsTpl->assign('read', "$hits " . _ADSLIGHT_VIEW2);
190
        $xoopsTpl->assign('rating', number_format($user_rating, 2));
191
        $xoopsTpl->assign('status_head', _ADSLIGHT_STATUS);
192
        //  For US currency with 2 numbers after the decimal comment out if you dont want 2 numbers after decimal
193
        $price = number_format($price, 2, ',', ' ');
194
        //  For other countries uncomment the below line and comment out the above line
195
        //      $price = number_format($price);
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% 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...
196
        $xoopsTpl->assign('price', '<strong>' . _ADSLIGHT_PRICE . "</strong>$price" . $GLOBALS['xoopsModuleConfig']['adslight_money'] . " - $typeprice");
197
        $xoopsTpl->assign('price_head', _ADSLIGHT_PRICE);
198
        $xoopsTpl->assign('money_sign', '' . $GLOBALS['xoopsModuleConfig']['adslight_money']);
199
        $xoopsTpl->assign('price_typeprice', $typeprice);
200
        $xoopsTpl->assign('local_town', "$town");
201
        $xoopsTpl->assign('local_country', "$country");
202
        $xoopsTpl->assign('local_head', _ADSLIGHT_LOCAL2);
203
        $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
        $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  = 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
        $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 '
228
                   . $xoopsDB->prefix('adslight_pictures')
229
                   . ' WHERE  uid_owner='
230
                   . $xoopsDB->escape($usid)
231
                   . ' AND lid='
232
                   . $xoopsDB->escape($lid)
233
                   . ' ORDER BY date_added ASC limit 1';
234
        $resultp = $xoopsDB->query($sql);
235 View Code Duplication
        while (list($cod_img, $pic_lid, $uid_owner, $url) = $xoopsDB->fetchRow($resultp)) {
236
            if ($photo) {
237
                $photo = "<a href='viewads.php?lid=" . $lid . "'><img class=\"thumb\" src=\"$updir/thumbs/thumb_$url\" align=\"left\" width=\"100px\" alt=\"$title\" /></a>";
238
            }
239
        }
240
        $no_photo = "<a href='viewads.php?lid=" . $lid . "'><img class=\"thumb\" src=\"assets/images/nophoto.jpg\" align=\"left\" width=\"100px\" alt=\"$title\" /></a>";
241
242
        $xoopsTpl->append('items', array(
243
            'id'          => $lid,
244
            'cid'         => $cid,
245
            'title'       => $myts->htmlSpecialChars($title),
246
            'status'      => $myts->htmlSpecialChars($status_is),
247
            'expire'      => $myts->htmlSpecialChars($expire),
248
            'type'        => $myts->htmlSpecialChars($type),
249
            'desctext'    => $myts->displayTarea($desctext),
250
            'tel'         => $myts->htmlSpecialChars($tel),
251
            'price'       => $myts->htmlSpecialChars($price),
252
            'typeprice'   => $myts->htmlSpecialChars($typeprice),
253
            'date'        => $myts->htmlSpecialChars($date),
254
            'email'       => $myts->htmlSpecialChars($email),
255
            'submitter'   => $myts->htmlSpecialChars($submitter),
256
            'usid'        => $myts->htmlSpecialChars($usid),
257
            'town'        => $myts->htmlSpecialChars($town),
258
            'country'     => $myts->htmlSpecialChars($country),
259
            'contactby'   => $myts->htmlSpecialChars($contactby),
260
            'premium'     => $myts->htmlSpecialChars($premium),
261
            'valid'       => $myts->htmlSpecialChars($valid),
262
            'hits'        => $hits,
263
            'rlid'        => $myts->htmlSpecialChars($rlid),
264
            'rdate'       => $myts->htmlSpecialChars($rdate),
265
            'rsubmitter'  => $myts->htmlSpecialChars($rsubmitter),
266
            'message'     => $myts->htmlSpecialChars($message),
267
            'remail'      => $myts->htmlSpecialChars($remail),
268
            'rrows'       => $rrows,
269
            'expires'     => $myts->htmlSpecialChars($date2),
270
            'view_now'    => $view_now,
271
            'modify_link' => $modify_link,
272
            'photo'       => $photo,
273
            'no_photo'    => $no_photo,
274
            'adminlink'   => $adminlink,
275
            'new'         => $newitem,
276
            'sold'        => $sold
277
        ));
278
    }
279
    $usid = XoopsRequest::getInt('usid', 0, 'GET');
280
281
    //Calculates how many pages exist.  Which page one should be on, etc...
282
    $linkpages = ceil($trows / $show);
283
    //Page Numbering
284 View Code Duplication
    if (1 != $linkpages && 0 != $linkpages) {
285
        $prev = $min - $show;
286
        if ($prev >= 0) {
287
            $pagenav .= "<a href='members.php?usid=$usid&min=$prev&show=$show'><strong><u>&laquo;</u></strong></a> ";
288
        }
289
        $counter     = 1;
290
        $currentpage = ($max / $show);
291
        while ($counter <= $linkpages) {
292
            $mintemp = ($show * $counter) - $show;
293
            if ($counter == $currentpage) {
294
                $pagenav .= "<strong>($counter)</strong> ";
295
            } else {
296
                $pagenav .= "<a href='members.php?usid=$usid&min=$mintemp&show=$show'>$counter</a> ";
297
            }
298
            ++$counter;
299
        }
300
        if ($trows > $max) {
301
            $pagenav .= "<a href='members.php?usid=$usid&min=$max&show=$show'>";
302
            $pagenav .= '<strong><u>&raquo;</u></strong></a>';
303
        }
304
        $xoopsTpl->assign('nav_page', '<strong>' . _ADSLIGHT_PAGES . "</strong>&nbsp;&nbsp; $pagenav");
305
    }
306
}
307
308
include XOOPS_ROOT_PATH . '/footer.php';
309