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