Completed
Push — master ( 5d8d4f...0424ea )
by Michael
10:03
created

members.php (4 issues)

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/include/functions.php");
25
$myts =& MyTextSanitizer::getInstance(); // MyTextSanitizer object
26
global $xoopsModule;
1 ignored issue
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
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
$xoopsOption['template_main'] = "adslight_members.tpl";
32
include XOOPS_ROOT_PATH."/header.php";
33
include XOOPS_ROOT_PATH.'/include/comment_view.php';
34
    $lid = isset($_GET['lid']) ? intval($_GET['lid']) : 0;
35
    $usid = isset($_GET['usid']) ? intval($_GET['usid']) : 0;
36
$module_id = $xoopsModule->getVar('mid');
37
if (is_object($xoopsUser)) {
38
    $groups = $xoopsUser->getGroups();
39
} else {
40
    $groups = XOOPS_GROUP_ANONYMOUS;
41
}
42
$gperm_handler =& xoops_gethandler('groupperm');
43 View Code Duplication
if (isset($_POST['item_id'])) {
1 ignored issue
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
44
    $perm_itemid = intval($_POST['item_id']);
45
} else {
46
    $perm_itemid = 0;
47
}
48
//If no access
49
if (!$gperm_handler->checkRight("adslight_premium", $perm_itemid, $groups, $module_id)) {
50
    $permit = "0";
51
} else {
52
    $permit = "1";
53
    }
54
55
$xoopsTpl->assign('permit', $permit);
56
if ($xoopsUser && $xoopsUser->isAdmin($xoopsModule->mid())) {
57
    $isadmin = true;
58
} else {
59
    $isadmin = false;
60
}
61
    $xoopsTpl->assign('add_from', _ADSLIGHT_ADDFROM." ".$xoopsConfig['sitename']);
62
    $xoopsTpl->assign('add_from_title', _ADSLIGHT_ADDFROM );
63
    $xoopsTpl->assign('add_from_sitename', $xoopsConfig['sitename']);
64
    $xoopsTpl->assign('mydirname', $moduleDirName);
65
    $xoopsTpl->assign('comments_head', _ADSLIGHT_COMMENTS_HEAD);
66
    $xoopsTpl->assign('lang_user_rating', _ADSLIGHT_USER_RATING);
67
    $xoopsTpl->assign('lang_ratethisuser', _ADSLIGHT_RATETHISUSER);
68
    $xoopsTpl->assign('title_head', _ADSLIGHT_TITLE);
69
    $xoopsTpl->assign('date_head', _ADSLIGHT_ADDED_ON);
70
    $xoopsTpl->assign('views_head', _ADSLIGHT_VIEW2);
71
    $xoopsTpl->assign('replies_head', _ADSLIGHT_REPLIES);
72
    $xoopsTpl->assign('expires_head', _ADSLIGHT_EXPIRES_ON);
73
    $xoopsTpl->assign('all_user_listings', _ADSLIGHT_ALL_USER_LISTINGS);
74
    $xoopsTpl->assign('nav_main', '<a href="index.php">'._ADSLIGHT_MAIN.'</a>');
75
    $xoopsTpl->assign('mydirname', $moduleDirName);
76
77
    $xoopsTpl->assign('xoops_module_header', '<link rel="stylesheet" href="'.XOOPS_URL.'/modules/adslight/style/adslight.css" type="text/css" media="all" />');
78
79
    $xoopsTpl->assign('adslight_active_menu', $xoopsModuleConfig['adslight_active_menu']);
80
    $xoopsTpl->assign('adslight_active_rss', $xoopsModuleConfig['adslight_active_rss']);
81
    $xoTheme -> addMeta ( 'meta', 'robots', 'noindex, nofollow');
82
83
    $show = 4;
84
    $min = isset($_GET['min']) ? intval($_GET['min']) : 0;
85
    if (!isset($max)) {
86
        $max = $min + $show;
87
    }
88
        $orderby = 'date ASC';
89
if ($xoopsModuleConfig["adslight_rate_user"] == '1') {
90
        $rate = '1';
91
    } else {
92
        $rate = '0';
93
    }
94
    $xoopsTpl->assign('rate', $rate);
95
if ($xoopsUser) {
96
    $member_usid = $xoopsUser->getVar("uid", "E");
97
if ($usid == $member_usid) {
98
    $istheirs = 1;
99
100
        } else {
101
    $istheirs = '';
102
103
            }
104
        }
105
106
$cat_perms = "";
107
$categories = adslight_MygetItemIds("adslight_view");
108
if (is_array($categories) && count($categories) > 0) {
109
    $cat_perms .= ' AND cid IN ('.implode(',', $categories).') ';
110
}
111
112
if ($istheirs= 1) {
113
114
$countresult=$xoopsDB->query("select COUNT(*) FROM ".$xoopsDB->prefix("adslight_listing")." where usid=".mysql_real_escape_string($usid)." AND valid='Yes' $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 ".$xoopsDB->prefix("adslight_listing")." WHERE usid = ".mysql_real_escape_string($usid)." AND valid='Yes' $cat_perms ORDER BY $orderby";
118
$result=$xoopsDB->query($sql,$show,$min);
119
    } else {
120
121
$countresult=$xoopsDB->query("select COUNT(*) FROM ".$xoopsDB->prefix("adslight_listing")." where usid=".mysql_real_escape_string($usid)." AND valid='Yes' AND status!='1' $cat_perms");
122
        list($trow) = $xoopsDB->fetchRow($countresult);
123
124
$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 ".$xoopsDB->prefix("adslight_listing")." WHERE usid = ".mysql_real_escape_string($usid)." AND valid='Yes' AND status!='1' $cat_perms ORDER BY $orderby";
125
$result=$xoopsDB->query($sql,$show,$min);
126
}
127
128
$trows = $trow;
129
        $pagenav = '';
130
        if ($trows > "0") {
131
        $xoopsTpl->assign('min', $min);
132
    $rank = 1;
133
134
    if ($trows > "1") {
135
    $xoopsTpl->assign('show_nav', true);
136
        $xoopsTpl->assign('lang_sortby', _ADSLIGHT_SORTBY);
137
        $xoopsTpl->assign('lang_title', _ADSLIGHT_TITLE);
138
    $xoopsTpl->assign('lang_titleatoz', _ADSLIGHT_TITLEATOZ);
139
    $xoopsTpl->assign('lang_titleztoa', _ADSLIGHT_TITLEZTOA);
140
        $xoopsTpl->assign('lang_date', _ADSLIGHT_DATE);
141
    $xoopsTpl->assign('lang_dateold', _ADSLIGHT_DATEOLD);
142
    $xoopsTpl->assign('lang_datenew', _ADSLIGHT_DATENEW);
143
        $xoopsTpl->assign('lang_popularity', _ADSLIGHT_POPULARITY);
144
    $xoopsTpl->assign('lang_popularityleast', _ADSLIGHT_POPULARITYLTOM);
145
    $xoopsTpl->assign('lang_popularitymost', _ADSLIGHT_POPULARITYMTOL);
146
147
        }
148
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)) {
149
150
        $newitem = '';
151
        $newcount = $xoopsModuleConfig['adslight_countday'];
152
        $startdate = (time()-(86400 * $newcount));
153
        if ($startdate < $date) {
154
        $newitem = '<img src="'.XOOPS_URL.'/modules/adslight/assets/images/newred.gif" alt="New" />';
155
            }
156
157
if ($status == 0) {
158
$status_is = _ADSLIGHT_ACTIVE;
159
    }
160
if ($status == 1) {
161
$status_is = _ADSLIGHT_INACTIVE;
162
    }
163
if ($status == 2) {
164
$status_is = _ADSLIGHT_SOLD;
165
    }
166
    $countresult=$xoopsDB->query("select COUNT(*) FROM ".$xoopsDB->prefix("adslight_replies")." where lid=".mysql_real_escape_string($lid)."");
167
        list($rrow) = $xoopsDB->fetchRow($countresult);
168
        $rrows = $rrow;
169
    $xoopsTpl->assign('reply_count', $rrows);
170
171
    $result2=$xoopsDB->query("select r_lid, lid, date, submitter, message, email, r_usid FROM ".$xoopsDB->prefix("adslight_replies")." where lid =".mysql_real_escape_string($lid)."");
172
    list($r_lid, $rlid, $rdate, $rsubmitter, $message, $remail, $r_usid )=$xoopsDB->fetchRow($result2);
173
174
    if ($isadmin) {
175
    $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>";
176
    $xoopsTpl->assign('isadmin', $isadmin);
177
    } else {
178
        $adminlink = '';
179
    }
180
    $modify_link = '';
181
    if ($xoopsUser) {
182
        $member_usid = $xoopsUser->getVar("uid", "E");
183
        if ($usid == $member_usid) {
184
            $istheirs = true;
185
            $xoopsTpl->assign('istheirs', $istheirs);
186
            $modify_link = "<a href='modify.php?op=ModAd&amp;lid=" . $lid . "'><img src='" . $pathIcon16 . "/edit.png'  border=0 alt=\"" . _ADSLIGHT_MODADMIN . "\" /></a>";
187
        } else {
188
            $istheirs = false;
189
            $xoopsTpl->assign('istheirs', '');
190
        }
191
    }
192
193
        $xoopsTpl->assign('submitter',$submitter);
194
        $xoopsTpl->assign('usid', $usid);
195
        $xoopsTpl->assign('read', "$hits "._ADSLIGHT_VIEW2);
196
        $xoopsTpl->assign('rating', number_format($user_rating, 2));
197
        $xoopsTpl->assign('status_head', _ADSLIGHT_STATUS);
198
//  For US currency with 2 numbers after the decimal comment out if you dont want 2 numbers after decimal
199
        $price = number_format($price, 2, ",", " ");
200
//  For other countries uncomment the below line and comment out the above line
201
//		$price = number_format($price);
202
        $xoopsTpl->assign('price', '<strong>'._ADSLIGHT_PRICE . "</strong>$price".$xoopsModuleConfig["adslight_money"]." - $typeprice");
203
        $xoopsTpl->assign('price_head', _ADSLIGHT_PRICE );
204
        $xoopsTpl->assign('money_sign', "".$xoopsModuleConfig["adslight_money"]."");
205
        $xoopsTpl->assign('price_typeprice', $typeprice);
206
        $xoopsTpl->assign('local_town', "$town");
207
        $xoopsTpl->assign('local_country', "$country");
208
        $xoopsTpl->assign('local_head', _ADSLIGHT_LOCAL2);
209
        $xoopsTpl->assign('edit_ad', _ADSLIGHT_EDIT);
210
211
        $usid = addslashes($usid);
212
if ($user_votes == 1) {
213
        $votestring = _ADSLIGHT_ONEVOTE;
214
        } else {
215
        $votestring = sprintf(_ADSLIGHT_NUMVOTES,$user_votes);
216
            }
217
        $xoopsTpl->assign('user_votes', $votestring);
218
        $date2 = $date + ($expire*86400);
219
        $date = formatTimestamp($date,"s");
220
        $date2 = formatTimestamp($date2,"s");
221
    $path = $mytree->getPathFromId($cid, "title");
222
    $path = substr($path, 1);
223
    $path = str_replace("/"," - ",$path);
224
    if ($rrows >= 1) {
225
        $view_now = "<a href='replies.php?lid=".$lid."'>"._ADSLIGHT_VIEWNOW."</a>";
226
    } else {
227
        $view_now = '';
228
    }
229
        $sold = "";
230
        if ($status == 2) {
231
        $sold = _ADSLIGHT_RESERVEDMEMBER;
232
        }
233
234
            $xoopsTpl->assign('xoops_pagetitle',""._ADSLIGHT_ALL_USER_LISTINGS." ".$submitter."");
235
$updir = $xoopsModuleConfig['adslight_link_upload'];
236
    $sql = "select cod_img, lid, uid_owner, url from ".$xoopsDB->prefix("adslight_pictures")." where  uid_owner=".mysql_real_escape_string($usid)." and lid=".mysql_real_escape_string($lid)." order by date_added ASC limit 1";
237
        $resultp = $xoopsDB->query($sql);
238 View Code Duplication
        while (list($cod_img, $pic_lid, $uid_owner, $url)=$xoopsDB->fetchRow($resultp)) {
1 ignored issue
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
239
        if ($photo) {
240
            $photo = "<a href='viewads.php?lid=".$lid."'><img class=\"thumb\" src=\"$updir/thumbs/thumb_$url\" align=\"left\" width=\"100px\" alt=\"$title\" /></a>";
241
                }
242
            }
243
        $no_photo = "<a href='viewads.php?lid=".$lid."'><img class=\"thumb\" src=\"assets/images/nophoto.jpg\" align=\"left\" width=\"100px\" alt=\"$title\" /></a>";
244
245
    $xoopsTpl->append('items', array('id' => $lid, 'cid' => $cid, 'title' => $myts->htmlSpecialChars($title), 'status' => $myts->htmlSpecialChars($status_is), 'expire' => $myts->htmlSpecialChars($expire), 'type' => $myts->htmlSpecialChars($type), 'desctext' => $myts->displayTarea($desctext), 'tel' => $myts->htmlSpecialChars($tel), 'price' => $myts->htmlSpecialChars($price), 'typeprice' => $myts->htmlSpecialChars($typeprice), 'date' => $myts->htmlSpecialChars($date), 'email' => $myts->htmlSpecialChars($email), 'submitter' => $myts->htmlSpecialChars($submitter), 'usid' => $myts->htmlSpecialChars($usid), 'town' => $myts->htmlSpecialChars($town), 'country' => $myts->htmlSpecialChars($country), 'contactby' => $myts->htmlSpecialChars($contactby), 'premium' => $myts->htmlSpecialChars($premium), 'valid' => $myts->htmlSpecialChars($valid), 'hits' => $hits, 'rlid' => $myts->htmlSpecialChars($rlid), 'rdate' => $myts->htmlSpecialChars($rdate), 'rsubmitter' => $myts->htmlSpecialChars($rsubmitter), 'message' => $myts->htmlSpecialChars($message), 'remail' => $myts->htmlSpecialChars($remail), 'rrows' => $rrows, 'expires' => $myts->htmlSpecialChars($date2), 'view_now' => $view_now, 'modify_link' => $modify_link, 'photo' => $photo, 'no_photo' => $no_photo, 'adminlink' => $adminlink, 'new' => $newitem, 'sold' => $sold));
246
}
247
        $usid = intval($_GET['usid']);
248
249
//Calculates how many pages exist.  Which page one should be on, etc...
250
    $linkpages = ceil($trows / $show);
251
    //Page Numbering
252 View Code Duplication
    if ($linkpages!=1 && $linkpages!=0) {
1 ignored issue
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
253
       $prev = $min - $show;
254
       if ($prev>=0) {
255
            $pagenav .= "<a href='members.php?usid=$usid&min=$prev&show=$show'><strong><u>&laquo;</u></strong></a> ";
256
        }
257
        $counter = 1;
258
        $currentpage = ($max / $show);
259
        while ($counter<=$linkpages) {
260
            $mintemp = ($show * $counter) - $show;
261
            if ($counter == $currentpage) {
262
                $pagenav .= "<strong>($counter)</strong> ";
263
            } else {
264
                $pagenav .= "<a href='members.php?usid=$usid&min=$mintemp&show=$show'>$counter</a> ";
265
            }
266
            ++$counter;
267
        }
268
        if ($trows>$max) {
269
            $pagenav .= "<a href='members.php?usid=$usid&min=$max&show=$show'>";
270
            $pagenav .= "<strong><u>&raquo;</u></strong></a>";
271
                }$xoopsTpl->assign('nav_page', "<strong>"._ADSLIGHT_PAGES."</strong>&nbsp;&nbsp; $pagenav");
272
         }
273
    }
274
275
include XOOPS_ROOT_PATH.'/footer.php';
276