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; |
||
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']) ? (int)$_GET['lid'] : 0; |
||
35 | $usid = isset($_GET['usid']) ? (int)$_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 | if (isset($_POST['item_id'])) { |
||
44 | $perm_itemid = (int)$_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']) ? (int)$_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 | } else { |
||
100 | $istheirs = ''; |
||
101 | } |
||
102 | } |
||
103 | |||
104 | $cat_perms = ''; |
||
105 | $categories = adslight_MygetItemIds('adslight_view'); |
||
106 | if (is_array($categories) && count($categories) > 0) { |
||
107 | $cat_perms .= ' AND cid IN (' . implode(',', $categories) . ') '; |
||
108 | } |
||
109 | |||
110 | if ($istheirs = 1) { |
||
111 | $countresult = $xoopsDB->query('select COUNT(*) FROM ' . $xoopsDB->prefix('adslight_listing') . ' where usid=' . $xoopsDB->escape($usid) . " AND valid='Yes' $cat_perms"); |
||
112 | list($trow) = $xoopsDB->fetchRow($countresult); |
||
113 | |||
114 | $sql = |
||
115 | '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 ' . |
||
116 | $xoopsDB->prefix('adslight_listing') . |
||
117 | ' WHERE usid = ' . |
||
118 | $xoopsDB->escape($usid) . |
||
119 | " AND valid='Yes' $cat_perms ORDER BY $orderby"; |
||
120 | $result = $xoopsDB->query($sql, $show, $min); |
||
121 | } else { |
||
122 | $countresult = $xoopsDB->query('select COUNT(*) FROM ' . $xoopsDB->prefix('adslight_listing') . ' where usid=' . $xoopsDB->escape($usid) . " AND valid='Yes' AND status!='1' $cat_perms"); |
||
123 | list($trow) = $xoopsDB->fetchRow($countresult); |
||
124 | |||
125 | $sql = |
||
126 | '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 ' . |
||
127 | $xoopsDB->prefix('adslight_listing') . |
||
128 | ' WHERE usid = ' . |
||
129 | $xoopsDB->escape($usid) . |
||
130 | " AND valid='Yes' AND status!='1' $cat_perms ORDER BY $orderby"; |
||
131 | $result = $xoopsDB->query($sql, $show, $min); |
||
132 | } |
||
133 | |||
134 | $trows = $trow; |
||
135 | $pagenav = ''; |
||
136 | if ($trows > '0') { |
||
137 | $xoopsTpl->assign('min', $min); |
||
138 | $rank = 1; |
||
139 | |||
140 | if ($trows > '1') { |
||
141 | $xoopsTpl->assign('show_nav', true); |
||
142 | $xoopsTpl->assign('lang_sortby', _ADSLIGHT_SORTBY); |
||
143 | $xoopsTpl->assign('lang_title', _ADSLIGHT_TITLE); |
||
144 | $xoopsTpl->assign('lang_titleatoz', _ADSLIGHT_TITLEATOZ); |
||
145 | $xoopsTpl->assign('lang_titleztoa', _ADSLIGHT_TITLEZTOA); |
||
146 | $xoopsTpl->assign('lang_date', _ADSLIGHT_DATE); |
||
147 | $xoopsTpl->assign('lang_dateold', _ADSLIGHT_DATEOLD); |
||
148 | $xoopsTpl->assign('lang_datenew', _ADSLIGHT_DATENEW); |
||
149 | $xoopsTpl->assign('lang_popularity', _ADSLIGHT_POPULARITY); |
||
150 | $xoopsTpl->assign('lang_popularityleast', _ADSLIGHT_POPULARITYLTOM); |
||
151 | $xoopsTpl->assign('lang_popularitymost', _ADSLIGHT_POPULARITYMTOL); |
||
152 | } |
||
153 | while (list($lid, $cid, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $date, $email, $submitter, $usid, $town, $country, $contactby, $premium, $valid, $photo, $hits, |
||
154 | $item_rating, $item_votes, $user_rating, $user_votes, $comments) = $xoopsDB->fetchRow($result)) { |
||
155 | $newitem = ''; |
||
156 | $newcount = $xoopsModuleConfig['adslight_countday']; |
||
157 | $startdate = (time() - (86400 * $newcount)); |
||
158 | if ($startdate < $date) { |
||
159 | $newitem = '<img src="' . XOOPS_URL . '/modules/adslight/assets/images/newred.gif" alt="New" />'; |
||
160 | } |
||
161 | |||
162 | if ($status == 0) { |
||
163 | $status_is = _ADSLIGHT_ACTIVE; |
||
164 | } |
||
165 | if ($status == 1) { |
||
166 | $status_is = _ADSLIGHT_INACTIVE; |
||
167 | } |
||
168 | if ($status == 2) { |
||
169 | $status_is = _ADSLIGHT_SOLD; |
||
170 | } |
||
171 | $countresult = $xoopsDB->query('select COUNT(*) FROM ' . $xoopsDB->prefix('adslight_replies') . ' where lid=' . $xoopsDB->escape($lid) . ''); |
||
172 | list($rrow) = $xoopsDB->fetchRow($countresult); |
||
173 | $rrows = $rrow; |
||
174 | $xoopsTpl->assign('reply_count', $rrows); |
||
175 | |||
176 | $result2 = $xoopsDB->query('select r_lid, lid, date, submitter, message, email, r_usid FROM ' . $xoopsDB->prefix('adslight_replies') . ' where lid =' . $xoopsDB->escape($lid) . ''); |
||
177 | list($r_lid, $rlid, $rdate, $rsubmitter, $message, $remail, $r_usid) = $xoopsDB->fetchRow($result2); |
||
178 | |||
179 | if ($isadmin) { |
||
180 | $adminlink = "<a href='" . |
||
181 | XOOPS_URL . |
||
182 | '/modules/adslight/admin/validate_ads.php?op=ModifyAds&lid=' . |
||
183 | $lid . |
||
184 | "'><img src='" . |
||
185 | $pathIcon16 . |
||
186 | "/edit.png' border=0 alt=\"" . |
||
187 | _ADSLIGHT_MODADMIN . |
||
188 | "\" /></a>"; |
||
189 | $xoopsTpl->assign('isadmin', $isadmin); |
||
190 | } else { |
||
191 | $adminlink = ''; |
||
192 | } |
||
193 | $modify_link = ''; |
||
194 | if ($xoopsUser) { |
||
195 | $member_usid = $xoopsUser->getVar('uid', 'E'); |
||
196 | if ($usid == $member_usid) { |
||
197 | $istheirs = true; |
||
198 | $xoopsTpl->assign('istheirs', $istheirs); |
||
199 | $modify_link = "<a href='modify.php?op=ModAd&lid=" . $lid . "'><img src='" . $pathIcon16 . "/edit.png' border=0 alt=\"" . _ADSLIGHT_MODADMIN . "\" /></a>"; |
||
200 | } else { |
||
201 | $istheirs = false; |
||
202 | $xoopsTpl->assign('istheirs', ''); |
||
203 | } |
||
204 | } |
||
205 | |||
206 | $xoopsTpl->assign('submitter', $submitter); |
||
207 | $xoopsTpl->assign('usid', $usid); |
||
208 | $xoopsTpl->assign('read', "$hits " . _ADSLIGHT_VIEW2); |
||
209 | $xoopsTpl->assign('rating', number_format($user_rating, 2)); |
||
210 | $xoopsTpl->assign('status_head', _ADSLIGHT_STATUS); |
||
211 | // For US currency with 2 numbers after the decimal comment out if you dont want 2 numbers after decimal |
||
212 | $price = number_format($price, 2, ',', ' '); |
||
213 | // For other countries uncomment the below line and comment out the above line |
||
214 | // $price = number_format($price); |
||
215 | $xoopsTpl->assign('price', '<strong>' . _ADSLIGHT_PRICE . "</strong>$price" . $xoopsModuleConfig['adslight_money'] . " - $typeprice"); |
||
216 | $xoopsTpl->assign('price_head', _ADSLIGHT_PRICE); |
||
217 | $xoopsTpl->assign('money_sign', '' . $xoopsModuleConfig['adslight_money'] . ''); |
||
218 | $xoopsTpl->assign('price_typeprice', $typeprice); |
||
219 | $xoopsTpl->assign('local_town', "$town"); |
||
220 | $xoopsTpl->assign('local_country', "$country"); |
||
221 | $xoopsTpl->assign('local_head', _ADSLIGHT_LOCAL2); |
||
222 | $xoopsTpl->assign('edit_ad', _ADSLIGHT_EDIT); |
||
223 | |||
224 | $usid = addslashes($usid); |
||
225 | if ($user_votes == 1) { |
||
226 | $votestring = _ADSLIGHT_ONEVOTE; |
||
227 | } else { |
||
228 | $votestring = sprintf(_ADSLIGHT_NUMVOTES, $user_votes); |
||
229 | } |
||
230 | $xoopsTpl->assign('user_votes', $votestring); |
||
231 | $date2 = $date + ($expire * 86400); |
||
232 | $date = formatTimestamp($date, 's'); |
||
233 | $date2 = formatTimestamp($date2, 's'); |
||
234 | $path = $mytree->getPathFromId($cid, 'title'); |
||
235 | $path = substr($path, 1); |
||
236 | $path = str_replace('/', ' - ', $path); |
||
237 | if ($rrows >= 1) { |
||
238 | $view_now = "<a href='replies.php?lid=" . $lid . "'>" . _ADSLIGHT_VIEWNOW . '</a>'; |
||
239 | } else { |
||
240 | $view_now = ''; |
||
241 | } |
||
242 | $sold = ''; |
||
243 | if ($status == 2) { |
||
244 | $sold = _ADSLIGHT_RESERVEDMEMBER; |
||
245 | } |
||
246 | |||
247 | $xoopsTpl->assign('xoops_pagetitle', '' . _ADSLIGHT_ALL_USER_LISTINGS . ' ' . $submitter . ''); |
||
248 | $updir = $xoopsModuleConfig['adslight_link_upload']; |
||
249 | $sql = 'select cod_img, lid, uid_owner, url from ' . |
||
250 | $xoopsDB->prefix('adslight_pictures') . |
||
251 | ' where uid_owner=' . |
||
252 | $xoopsDB->escape($usid) . |
||
253 | ' and lid=' . |
||
254 | $xoopsDB->escape($lid) . |
||
255 | ' order by date_added ASC limit 1'; |
||
256 | $resultp = $xoopsDB->query($sql); |
||
257 | View Code Duplication | while (list($cod_img, $pic_lid, $uid_owner, $url) = $xoopsDB->fetchRow($resultp)) { |
|
258 | if ($photo) { |
||
259 | $photo = "<a href='viewads.php?lid=" . $lid . "'><img class=\"thumb\" src=\"$updir/thumbs/thumb_$url\" align=\"left\" width=\"100px\" alt=\"$title\" /></a>"; |
||
260 | } |
||
261 | } |
||
262 | $no_photo = "<a href='viewads.php?lid=" . $lid . "'><img class=\"thumb\" src=\"assets/images/nophoto.jpg\" align=\"left\" width=\"100px\" alt=\"$title\" /></a>"; |
||
263 | |||
264 | $xoopsTpl->append('items', array( |
||
265 | 'id' => $lid, |
||
266 | 'cid' => $cid, |
||
267 | 'title' => $myts->htmlSpecialChars($title), |
||
268 | 'status' => $myts->htmlSpecialChars($status_is), |
||
269 | 'expire' => $myts->htmlSpecialChars($expire), |
||
270 | 'type' => $myts->htmlSpecialChars($type), |
||
271 | 'desctext' => $myts->displayTarea($desctext), |
||
272 | 'tel' => $myts->htmlSpecialChars($tel), |
||
273 | 'price' => $myts->htmlSpecialChars($price), |
||
274 | 'typeprice' => $myts->htmlSpecialChars($typeprice), |
||
275 | 'date' => $myts->htmlSpecialChars($date), |
||
276 | 'email' => $myts->htmlSpecialChars($email), |
||
277 | 'submitter' => $myts->htmlSpecialChars($submitter), |
||
278 | 'usid' => $myts->htmlSpecialChars($usid), |
||
279 | 'town' => $myts->htmlSpecialChars($town), |
||
280 | 'country' => $myts->htmlSpecialChars($country), |
||
281 | 'contactby' => $myts->htmlSpecialChars($contactby), |
||
282 | 'premium' => $myts->htmlSpecialChars($premium), |
||
283 | 'valid' => $myts->htmlSpecialChars($valid), |
||
284 | 'hits' => $hits, |
||
285 | 'rlid' => $myts->htmlSpecialChars($rlid), |
||
286 | 'rdate' => $myts->htmlSpecialChars($rdate), |
||
287 | 'rsubmitter' => $myts->htmlSpecialChars($rsubmitter), |
||
288 | 'message' => $myts->htmlSpecialChars($message), |
||
289 | 'remail' => $myts->htmlSpecialChars($remail), |
||
290 | 'rrows' => $rrows, |
||
291 | 'expires' => $myts->htmlSpecialChars($date2), |
||
292 | 'view_now' => $view_now, |
||
293 | 'modify_link' => $modify_link, |
||
294 | 'photo' => $photo, |
||
295 | 'no_photo' => $no_photo, |
||
296 | 'adminlink' => $adminlink, |
||
297 | 'new' => $newitem, |
||
298 | 'sold' => $sold |
||
299 | )); |
||
300 | } |
||
301 | $usid = (int)$_GET['usid']; |
||
302 | |||
303 | //Calculates how many pages exist. Which page one should be on, etc... |
||
304 | $linkpages = ceil($trows / $show); |
||
305 | //Page Numbering |
||
306 | View Code Duplication | if ($linkpages != 1 && $linkpages != 0) { |
|
1 ignored issue
–
show
|
|||
307 | $prev = $min - $show; |
||
308 | if ($prev >= 0) { |
||
309 | $pagenav .= "<a href='members.php?usid=$usid&min=$prev&show=$show'><strong><u>«</u></strong></a> "; |
||
310 | } |
||
311 | $counter = 1; |
||
312 | $currentpage = ($max / $show); |
||
313 | while ($counter <= $linkpages) { |
||
314 | $mintemp = ($show * $counter) - $show; |
||
315 | if ($counter == $currentpage) { |
||
316 | $pagenav .= "<strong>($counter)</strong> "; |
||
317 | } else { |
||
318 | $pagenav .= "<a href='members.php?usid=$usid&min=$mintemp&show=$show'>$counter</a> "; |
||
319 | } |
||
320 | ++$counter; |
||
321 | } |
||
322 | if ($trows > $max) { |
||
323 | $pagenav .= "<a href='members.php?usid=$usid&min=$max&show=$show'>"; |
||
324 | $pagenav .= '<strong><u>»</u></strong></a>'; |
||
325 | } |
||
326 | $xoopsTpl->assign('nav_page', '<strong>' . _ADSLIGHT_PAGES . "</strong> $pagenav"); |
||
327 | } |
||
328 | } |
||
329 | |||
330 | include XOOPS_ROOT_PATH . '/footer.php'; |
||
331 |
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.