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
|
|||
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 | if (is_object($xoopsUser)) { |
||
39 | $groups = $xoopsUser->getGroups(); |
||
40 | } else { |
||
41 | $groups = XOOPS_GROUP_ANONYMOUS; |
||
42 | } |
||
43 | $gperm_handler = xoops_getHandler('groupperm'); |
||
44 | $perm_itemid = XoopsRequest::getInt('item_id', 0, 'POST'); |
||
45 | |||
46 | //If no access |
||
47 | $permit = (!$gperm_handler->checkRight('adslight_premium', $perm_itemid, $groups, $module_id)) ? '0' : '1'; |
||
48 | |||
49 | $xoopsTpl->assign('permit', $permit); |
||
50 | $isadmin = (($xoopsUser instanceof XoopsUser) && $xoopsUser->isAdmin($xoopsModule->mid())) ? true : false; |
||
0 ignored issues
–
show
The class
XoopsUser does not exist. Did you forget a USE statement, or did you not list all dependencies?
This error could be the result of: 1. Missing dependenciesPHP Analyzer uses your Are you sure this class is defined by one of your dependencies, or did you maybe
not list a dependency in either the 2. Missing use statementPHP does not complain about undefined classes in if ($x instanceof DoesNotExist) {
// Do something.
}
If you have not tested against this specific condition, such errors might go unnoticed. ![]() |
|||
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 | //@todo move from ./style/*.css to /assets/css/*.css (don't forget to modify upgrade to delete old ./style/*.* files and folder |
||
68 | $xoopsTpl->assign('xoops_module_header', '<link rel="stylesheet" href="' . XOOPS_URL . '/modules/adslight/style/adslight.css" type="text/css" media="all" />'); |
||
69 | |||
70 | $xoopsTpl->assign('adslight_active_menu', $xoopsModuleConfig['adslight_active_menu']); |
||
71 | $xoopsTpl->assign('adslight_active_rss', $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' == $xoopsModuleConfig['adslight_rate_user']) ? '1' : '0'; |
||
81 | $xoopsTpl->assign('rate', $rate); |
||
82 | |||
83 | if ($xoopsUser) { |
||
84 | $member_usid = $xoopsUser->getVar('uid', 'E'); |
||
85 | $istheirs = ($usid == $member_usid) ? 1 : ''; |
||
86 | } |
||
87 | |||
88 | $cat_perms = ''; |
||
89 | $categories = adslight_MygetItemIds('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 = $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&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 ($xoopsUser instanceof XoopsUser) { |
||
0 ignored issues
–
show
The class
XoopsUser does not exist. Did you forget a USE statement, or did you not list all dependencies?
This error could be the result of: 1. Missing dependenciesPHP Analyzer uses your Are you sure this class is defined by one of your dependencies, or did you maybe
not list a dependency in either the 2. Missing use statementPHP does not complain about undefined classes in if ($x instanceof DoesNotExist) {
// Do something.
}
If you have not tested against this specific condition, such errors might go unnoticed. ![]() |
|||
177 | $member_usid = $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&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 | // For US currency with 2 numbers after the decimal comment out if you dont want 2 numbers after decimal |
||
194 | $price = number_format($price, 2, ',', ' '); |
||
195 | // For other countries uncomment the below line and comment out the above line |
||
196 | // $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. ![]() |
|||
197 | $xoopsTpl->assign('price', '<strong>' . _ADSLIGHT_PRICE . "</strong>$price" . $xoopsModuleConfig['adslight_money'] . " - $typeprice"); |
||
198 | $xoopsTpl->assign('price_head', _ADSLIGHT_PRICE); |
||
199 | $xoopsTpl->assign('money_sign', '' . $xoopsModuleConfig['adslight_money'] . ''); |
||
200 | $xoopsTpl->assign('price_typeprice', $typeprice); |
||
201 | $xoopsTpl->assign('local_town', "$town"); |
||
202 | $xoopsTpl->assign('local_country', "$country"); |
||
203 | $xoopsTpl->assign('local_head', _ADSLIGHT_LOCAL2); |
||
204 | $xoopsTpl->assign('edit_ad', _ADSLIGHT_EDIT); |
||
205 | |||
206 | $usid = addslashes($usid); |
||
207 | $votestring = (1 == $user_votes) ? _ADSLIGHT_ONEVOTE : sprintf(_ADSLIGHT_NUMVOTES, $user_votes); |
||
208 | |||
209 | $xoopsTpl->assign('user_votes', $votestring); |
||
210 | $date2 = $date + ($expire * 86400); |
||
211 | $date = formatTimestamp($date, 's'); |
||
212 | $date2 = formatTimestamp($date2, 's'); |
||
213 | $path = $mytree->getPathFromId($cid, 'title'); |
||
214 | $path = substr($path, 1); |
||
215 | $path = str_replace('/', ' - ', $path); |
||
216 | if ($rrows >= 1) { |
||
217 | $view_now = "<a href='replies.php?lid=" . $lid . "'>" . _ADSLIGHT_VIEWNOW . '</a>'; |
||
218 | } else { |
||
219 | $view_now = ''; |
||
220 | } |
||
221 | $sold = ''; |
||
222 | if (2 == $status) { |
||
223 | $sold = _ADSLIGHT_RESERVEDMEMBER; |
||
224 | } |
||
225 | |||
226 | $xoopsTpl->assign('xoops_pagetitle', '' . _ADSLIGHT_ALL_USER_LISTINGS . ' ' . $submitter . ''); |
||
227 | $updir = $xoopsModuleConfig['adslight_link_upload']; |
||
228 | $sql = 'SELECT cod_img, lid, uid_owner, url FROM ' |
||
229 | . $xoopsDB->prefix('adslight_pictures') |
||
230 | . ' WHERE uid_owner=' |
||
231 | . $xoopsDB->escape($usid) |
||
232 | . ' AND lid=' |
||
233 | . $xoopsDB->escape($lid) |
||
234 | . ' ORDER BY date_added ASC limit 1'; |
||
235 | $resultp = $xoopsDB->query($sql); |
||
236 | 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. ![]() |
|||
237 | if ($photo) { |
||
238 | $photo = "<a href='viewads.php?lid=" . $lid . "'><img class=\"thumb\" src=\"$updir/thumbs/thumb_$url\" align=\"left\" width=\"100px\" alt=\"$title\" /></a>"; |
||
239 | } |
||
240 | } |
||
241 | $no_photo = "<a href='viewads.php?lid=" . $lid . "'><img class=\"thumb\" src=\"assets/images/nophoto.jpg\" align=\"left\" width=\"100px\" alt=\"$title\" /></a>"; |
||
242 | |||
243 | $xoopsTpl->append('items', array( |
||
244 | 'id' => $lid, |
||
245 | 'cid' => $cid, |
||
246 | 'title' => $myts->htmlSpecialChars($title), |
||
247 | 'status' => $myts->htmlSpecialChars($status_is), |
||
248 | 'expire' => $myts->htmlSpecialChars($expire), |
||
249 | 'type' => $myts->htmlSpecialChars($type), |
||
250 | 'desctext' => $myts->displayTarea($desctext), |
||
251 | 'tel' => $myts->htmlSpecialChars($tel), |
||
252 | 'price' => $myts->htmlSpecialChars($price), |
||
253 | 'typeprice' => $myts->htmlSpecialChars($typeprice), |
||
254 | 'date' => $myts->htmlSpecialChars($date), |
||
255 | 'email' => $myts->htmlSpecialChars($email), |
||
256 | 'submitter' => $myts->htmlSpecialChars($submitter), |
||
257 | 'usid' => $myts->htmlSpecialChars($usid), |
||
258 | 'town' => $myts->htmlSpecialChars($town), |
||
259 | 'country' => $myts->htmlSpecialChars($country), |
||
260 | 'contactby' => $myts->htmlSpecialChars($contactby), |
||
261 | 'premium' => $myts->htmlSpecialChars($premium), |
||
262 | 'valid' => $myts->htmlSpecialChars($valid), |
||
263 | 'hits' => $hits, |
||
264 | 'rlid' => $myts->htmlSpecialChars($rlid), |
||
265 | 'rdate' => $myts->htmlSpecialChars($rdate), |
||
266 | 'rsubmitter' => $myts->htmlSpecialChars($rsubmitter), |
||
267 | 'message' => $myts->htmlSpecialChars($message), |
||
268 | 'remail' => $myts->htmlSpecialChars($remail), |
||
269 | 'rrows' => $rrows, |
||
270 | 'expires' => $myts->htmlSpecialChars($date2), |
||
271 | 'view_now' => $view_now, |
||
272 | 'modify_link' => $modify_link, |
||
273 | 'photo' => $photo, |
||
274 | 'no_photo' => $no_photo, |
||
275 | 'adminlink' => $adminlink, |
||
276 | 'new' => $newitem, |
||
277 | 'sold' => $sold |
||
278 | )); |
||
279 | } |
||
280 | $usid = XoopsRequest::getInt('usid', 0, 'GET'); |
||
281 | |||
282 | //Calculates how many pages exist. Which page one should be on, etc... |
||
283 | $linkpages = ceil($trows / $show); |
||
284 | //Page Numbering |
||
285 | View Code Duplication | if (1 != $linkpages && 0 != $linkpages) { |
|
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. ![]() |
|||
286 | $prev = $min - $show; |
||
287 | if ($prev >= 0) { |
||
288 | $pagenav .= "<a href='members.php?usid=$usid&min=$prev&show=$show'><strong><u>«</u></strong></a> "; |
||
289 | } |
||
290 | $counter = 1; |
||
291 | $currentpage = ($max / $show); |
||
292 | while ($counter <= $linkpages) { |
||
293 | $mintemp = ($show * $counter) - $show; |
||
294 | if ($counter == $currentpage) { |
||
295 | $pagenav .= "<strong>($counter)</strong> "; |
||
296 | } else { |
||
297 | $pagenav .= "<a href='members.php?usid=$usid&min=$mintemp&show=$show'>$counter</a> "; |
||
298 | } |
||
299 | ++$counter; |
||
300 | } |
||
301 | if ($trows > $max) { |
||
302 | $pagenav .= "<a href='members.php?usid=$usid&min=$max&show=$show'>"; |
||
303 | $pagenav .= '<strong><u>»</u></strong></a>'; |
||
304 | } |
||
305 | $xoopsTpl->assign('nav_page', '<strong>' . _ADSLIGHT_PAGES . "</strong> $pagenav"); |
||
306 | } |
||
307 | } |
||
308 | |||
309 | include XOOPS_ROOT_PATH . '/footer.php'; |
||
310 |
Instead of relying on
global
state, we recommend one of these alternatives:1. Pass all data via parameters
2. Create a class that maintains your state