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 | require XOOPS_ROOT_PATH . '/modules/adslight/include/gtickets.php'; |
||
25 | xoops_load('XoopsLocal'); |
||
26 | $tempXoopsLocal = new XoopsLocal; |
||
27 | $myts = MyTextSanitizer::getInstance(); |
||
28 | $module_id = $xoopsModule->getVar('mid'); |
||
29 | |||
30 | View Code Duplication | if (is_object($GLOBALS['xoopsUser'])) { |
|
31 | $groups = $GLOBALS['xoopsUser']->getGroups(); |
||
32 | } else { |
||
33 | $groups = XOOPS_GROUP_ANONYMOUS; |
||
34 | } |
||
35 | $gpermHandler = xoops_getHandler('groupperm'); |
||
36 | |||
37 | $perm_itemid = XoopsRequest::getInt('item_id', 0, 'POST'); |
||
38 | |||
39 | View Code Duplication | if (!$gpermHandler->checkRight('adslight_view', $perm_itemid, $groups, $module_id)) { |
|
40 | redirect_header(XOOPS_URL . '/index.php', 3, _NOPERM); |
||
41 | } |
||
42 | if (!$gpermHandler->checkRight('adslight_premium', $perm_itemid, $groups, $module_id)) { |
||
43 | $prem_perm = '0'; |
||
44 | } else { |
||
45 | $prem_perm = '1'; |
||
46 | } |
||
47 | |||
48 | include XOOPS_ROOT_PATH . '/modules/adslight/class/classifiedstree.php'; |
||
49 | //include XOOPS_ROOT_PATH . '/modules/adslight/class/utilities.php'; |
||
50 | $mytree = new ClassifiedsTree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid'); |
||
51 | |||
52 | # function view (categories) |
||
53 | ##################################################### |
||
54 | /** |
||
55 | * @param int $cid |
||
56 | * @param int $min |
||
57 | * @param $orderby |
||
58 | * @param int $show |
||
59 | */ |
||
60 | function adsView($cid = 0, $min = 0, $orderby, $show = 0) |
||
1 ignored issue
–
show
|
|||
61 | { |
||
62 | global $xoopsDB, $xoopsTpl, $xoopsConfig, $myts, $mytree, $imagecat, $meta, $moduleDirName, $main_lang, $mid, $prem_perm, $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 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
![]() |
|||
63 | $pathIcon16 = $xoopsModule->getInfo('icons16'); |
||
64 | |||
65 | $GLOBALS['xoopsOption']['template_main'] = 'adslight_category.tpl'; |
||
66 | include XOOPS_ROOT_PATH . '/header.php'; |
||
67 | |||
68 | $xoopsTpl->assign('xmid', $xoopsModule->getVar('mid')); |
||
69 | $xoopsTpl->assign('add_from', _ADSLIGHT_ADDFROM . ' ' . $xoopsConfig['sitename']); |
||
70 | $xoopsTpl->assign('add_from_title', _ADSLIGHT_ADDFROM); |
||
71 | $xoopsTpl->assign('add_from_sitename', $xoopsConfig['sitename']); |
||
72 | $xoopsTpl->assign('only_pix', _ADSLIGHT_ONLYPIX); |
||
73 | $xoopsTpl->assign('adslight_logolink', _ADSLIGHT_LOGOLINK); |
||
74 | $xoopsTpl->assign('permit', $prem_perm); |
||
75 | |||
76 | $xoopsTpl->assign('xoops_module_header', '<link rel="stylesheet" href="' . XOOPS_URL . '/modules/adslight/assets/css/adslight.css" type="text/css" media="all" />'); |
||
77 | |||
78 | // $adslight_use_catscode = $GLOBALS['xoopsModuleConfig']['adslight_use_catscode']; |
||
79 | // $adslight_cats_code = $GLOBALS['xoopsModuleConfig']['adslight_cats_code']; |
||
80 | |||
81 | $xoopsTpl->assign('adslight_use_catscode', $GLOBALS['xoopsModuleConfig']['adslight_use_catscode']); |
||
82 | $xoopsTpl->assign('adslight_cats_code', $GLOBALS['xoopsModuleConfig']['adslight_cats_code']); |
||
83 | |||
84 | $banner = xoops_getbanner(); |
||
85 | $xoopsTpl->assign('banner', $banner); |
||
86 | // $index_code_place = $GLOBALS['xoopsModuleConfig']['adslight_index_code_place']; |
||
87 | // $use_extra_code = $GLOBALS['xoopsModuleConfig']['adslight_use_index_code']; |
||
88 | // $adslight_use_banner = $GLOBALS['xoopsModuleConfig']['adslight_use_banner']; |
||
89 | // $index_extra_code = $GLOBALS['xoopsModuleConfig']['adslight_index_code']; |
||
90 | |||
91 | $xoopsTpl->assign('use_extra_code', $GLOBALS['xoopsModuleConfig']['adslight_use_index_code']); |
||
92 | $xoopsTpl->assign('adslight_use_banner', $GLOBALS['xoopsModuleConfig']['adslight_use_banner']); |
||
93 | $xoopsTpl->assign('index_extra_code', $GLOBALS['xoopsModuleConfig']['adslight_index_code']); |
||
94 | $xoopsTpl->assign('index_code_place', $GLOBALS['xoopsModuleConfig']['adslight_index_code_place']); |
||
95 | |||
96 | // adslight 2 |
||
97 | $xoopsTpl->assign('adslight_active_menu', $GLOBALS['xoopsModuleConfig']['adslight_active_menu']); |
||
98 | $xoopsTpl->assign('adslight_active_rss', $GLOBALS['xoopsModuleConfig']['adslight_active_rss']); |
||
99 | |||
100 | /// No Adds in this Cat /// |
||
101 | $submit_perms = AdslightUtilities::getMyItemIds('adslight_submit'); |
||
102 | |||
103 | if ($GLOBALS['xoopsUser'] && is_array($submit_perms) && count($submit_perms) > 0) { |
||
104 | $xoopsTpl->assign('not_adds_in_this_cat', |
||
105 | '' . _ADSLIGHT_ADD_LISTING_NOTADDSINTHISCAT . '<a href="addlisting.php?cid=' . addslashes($cid) . '">' . _ADSLIGHT_ADD_LISTING_NOTADDSSUBMIT . '</a>'); |
||
106 | } else { |
||
107 | $xoopsTpl->assign('not_adds_in_this_cat', |
||
108 | '' . _ADSLIGHT_ADD_LISTING_NOTADDSINTHISCAT . '<br>' . _ADSLIGHT_ADD_LISTING_BULL . '<a href="' . XOOPS_URL . '/register.php">' . _ADSLIGHT_ADD_LISTING_SUB . '</a>.'); |
||
109 | } |
||
110 | |||
111 | $xoopsTpl->assign('Feed_RSS_cat', ' <a href="rss.php?cid=' . addslashes($cid) . '"><img border="0" alt="Feed RSS" src="assets/images/rssfeed_buttons.png" /></a>'); |
||
112 | |||
113 | if ($GLOBALS['xoopsUser']) { |
||
114 | $member_usid = $GLOBALS['xoopsUser']->getVar('uid'); |
||
115 | if ($usid = $member_usid) { |
||
116 | $xoopsTpl->assign('istheirs', true); |
||
117 | |||
118 | list($show_user) = $xoopsDB->fetchRow($xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE usid=' . $member_usid . '')); |
||
119 | |||
120 | $xoopsTpl->assign('show_user', $show_user); |
||
121 | $xoopsTpl->assign('show_user_link', 'members.php?usid=' . $member_usid); |
||
122 | } |
||
123 | } |
||
124 | |||
125 | $default_sort = $GLOBALS['xoopsModuleConfig']['adslight_lsort_order']; |
||
126 | |||
127 | $cid = ((int)$cid > 0) ? (int)$cid : 0; |
||
128 | $min = ((int)$min > 0) ? (int)$min : 0; |
||
129 | $show = ((int)$show > 0) ? (int)$show : $GLOBALS['xoopsModuleConfig']['adslight_perpage']; |
||
130 | $max = $min + $show; |
||
131 | $orderby = isset($orderby) ? AdslightUtilities::convertOrderByIn($orderby) : $default_sort; |
||
132 | |||
133 | $updir = $GLOBALS['xoopsModuleConfig']['adslight_link_upload']; |
||
134 | $xoopsTpl->assign('add_from', _ADSLIGHT_ADDFROM . ' ' . $xoopsConfig['sitename']); |
||
135 | $xoopsTpl->assign('add_from_title', _ADSLIGHT_ADDFROM); |
||
136 | $xoopsTpl->assign('add_from_sitename', $xoopsConfig['sitename']); |
||
137 | $xoopsTpl->assign('subcat_title2', _ADSLIGHT_ANNONCES); |
||
138 | |||
139 | $categories = AdslightUtilities::getMyItemIds('adslight_view'); |
||
140 | View Code Duplication | if (is_array($categories) && count($categories) > 0) { |
|
141 | if (!in_array($cid, $categories)) { |
||
142 | redirect_header(XOOPS_URL . '/modules/adslight/index.php', 3, _NOPERM); |
||
143 | } |
||
144 | } else { // User can't see any category |
||
145 | redirect_header(XOOPS_URL . '/index.php', 3, _NOPERM); |
||
146 | } |
||
147 | |||
148 | $arrow = '<img src="' . XOOPS_URL . '/modules/adslight/assets/images/arrow.gif" alt="»" />'; |
||
149 | |||
150 | $pathstring = '<a href="index.php">' . _ADSLIGHT_MAIN . '</a>'; |
||
151 | $pathstring .= $mytree->getNicePathFromId($cid, 'title', 'viewcats.php?'); |
||
152 | $xoopsTpl->assign('module_name', $xoopsModule->getVar('name')); |
||
153 | $xoopsTpl->assign('category_path', $pathstring); |
||
154 | $xoopsTpl->assign('category_id', $cid); |
||
155 | |||
156 | $countresult = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE cid=' . $xoopsDB->escape($cid) . ' AND valid="Yes" AND status!="1"'); |
||
157 | list($trow) = $xoopsDB->fetchRow($countresult); |
||
158 | $trows = $trow; |
||
159 | |||
160 | $cat_perms = ''; |
||
161 | if (is_array($categories) && count($categories) > 0) { |
||
162 | $cat_perms .= ' AND cid IN (' . implode(',', $categories) . ') '; |
||
163 | } |
||
164 | |||
165 | $result = $xoopsDB->query('SELECT cid, pid, title, cat_desc, cat_keywords FROM ' . $xoopsDB->prefix('adslight_categories') . ' WHERE cid=' . $xoopsDB->escape($cid) . ' ' . $cat_perms); |
||
166 | list($cid, $pid, $title, $cat_desc, $cat_keywords) = $xoopsDB->fetchRow($result); |
||
167 | |||
168 | $xoopsTpl->assign('cat_desc', $cat_desc); |
||
169 | $xoopsTpl->assign('cat_title', _ADSLIGHT_ANNONCES . ' ' . $title); |
||
170 | $xoopsTpl->assign('cat_keywords', $cat_keywords); |
||
171 | $xoopsTpl->assign('xoops_pagetitle', $title); |
||
172 | |||
173 | if ($cat_desc > '0') { |
||
174 | // meta description & keywords tags for categories |
||
175 | $cat_desc_clean = strip_tags($cat_desc, '<font><img><strong><i><u>'); |
||
176 | $cat_keywords_clean = strip_tags($cat_keywords, '<font><img><strong><i><u><br><li>'); |
||
177 | |||
178 | $xoTheme->addMeta('meta', 'description', '' . substr($cat_desc_clean, 0, 200)); |
||
0 ignored issues
–
show
|
|||
179 | $xoTheme->addMeta('meta', 'keywords', '' . substr($cat_keywords_clean, 0, 1000)); |
||
180 | } |
||
181 | |||
182 | $submit_perms = AdslightUtilities::getMyItemIds('adslight_submit'); |
||
183 | if ($GLOBALS['xoopsUser'] && is_array($submit_perms) && count($submit_perms) > 0) { |
||
184 | $add_listing = '' . _ADSLIGHT_ADD_LISTING_BULLCATS . '<a href="addlisting.php?cid=' . addslashes($cid) . '">' . _ADSLIGHT_ADD_LISTING_SUBOK . '</a> |
||
185 | '; |
||
186 | } else { // User can't see any category |
||
187 | $add_listing = '' . _ADSLIGHT_ADD_LISTING_BULLCATSOK . '<a href="' . XOOPS_URL . '/register.php">' . _ADSLIGHT_ADD_LISTING_SUB . '</a>. |
||
188 | '; |
||
189 | } |
||
190 | |||
191 | if ($GLOBALS['xoopsModuleConfig']['adslight_main_cat'] == 1 || $pid != 0) { |
||
192 | $xoopsTpl->assign('bullinfotext', $add_listing); |
||
193 | } |
||
194 | |||
195 | $arr = array(); |
||
196 | $arr = $mytree->getFirstChild($cid, 'title'); |
||
197 | |||
198 | if (count($arr) > 0) { |
||
199 | $scount = 1; |
||
200 | foreach ($arr as $ele) { |
||
201 | if (in_array($ele['cid'], $categories)) { |
||
202 | $sub_arr = array(); |
||
203 | $sub_arr = $mytree->getFirstChild($ele['cid'], 'title'); |
||
204 | $space = 0; |
||
205 | $chcount = 0; |
||
206 | $infercategories = ''; |
||
207 | $totallisting = AdslightUtilities::getTotalItems($ele['cid'], 1); |
||
208 | foreach ($sub_arr as $sub_ele) { |
||
209 | if (in_array($sub_ele['cid'], $categories)) { |
||
210 | $chtitle = $myts->htmlSpecialChars($sub_ele['title']); |
||
211 | |||
212 | if ($chcount > 5) { |
||
213 | $infercategories .= '...'; |
||
214 | break; |
||
215 | } |
||
216 | if ($space > 0) { |
||
217 | $infercategories .= ', '; |
||
218 | } |
||
219 | $infercategories .= '<a href="' . XOOPS_URL . '/modules/adslight/viewcats.php?cid=' . $sub_ele['cid'] . '">' . $chtitle . '</a>'; |
||
220 | |||
221 | $infercategories .= ' (' . AdslightUtilities::getTotalItems($sub_ele['cid']) . ')'; |
||
222 | $infercategories .= ' ' . categorynewgraphic($sub_ele['cid']) . ''; |
||
223 | ++$space; |
||
224 | ++$chcount; |
||
225 | } |
||
226 | } |
||
227 | |||
228 | $xoopsTpl->append('subcategories', array( |
||
229 | 'title' => $myts->htmlSpecialChars($ele['title']), |
||
230 | 'id' => $ele['cid'], |
||
231 | 'infercategories' => $infercategories, |
||
232 | 'totallisting' => $totallisting, |
||
233 | '' |
||
234 | )); |
||
235 | |||
236 | ++$scount; |
||
237 | $xoopsTpl->assign('lang_subcat', _ADSLIGHT_AVAILAB); |
||
238 | } |
||
239 | } |
||
240 | } |
||
241 | |||
242 | $pagenav = ''; |
||
243 | if ($trows > '0') { |
||
244 | $xoopsTpl->assign('last_head', _ADSLIGHT_THE . ' ' . $GLOBALS['xoopsModuleConfig']['adslight_newcount'] . ' ' . _ADSLIGHT_LASTADD); |
||
245 | $xoopsTpl->assign('last_head_title', _ADSLIGHT_TITLE); |
||
246 | $xoopsTpl->assign('last_head_price', _ADSLIGHT_PRICE); |
||
247 | $xoopsTpl->assign('last_head_date', _ADSLIGHT_DATE); |
||
248 | $xoopsTpl->assign('last_head_local', _ADSLIGHT_LOCAL2); |
||
249 | $xoopsTpl->assign('last_head_hits', _ADSLIGHT_VIEW); |
||
250 | $xoopsTpl->assign('last_head_photo', _ADSLIGHT_PHOTO); |
||
251 | $xoopsTpl->assign('cat', $cid); |
||
252 | $xoopsTpl->assign('min', $min); |
||
253 | $rank = 1; |
||
254 | |||
255 | $cat_perms = ''; |
||
256 | if (is_array($categories) && count($categories) > 0) { |
||
257 | $cat_perms .= ' AND cid IN (' . implode(',', $categories) . ') '; |
||
258 | } |
||
259 | |||
260 | $sql = 'SELECT lid, title, status, type, price, typeprice, date, town, country, contactby, usid, premium, valid, photo, hits FROM ' |
||
261 | . $xoopsDB->prefix('adslight_listing') |
||
262 | . ' WHERE valid="Yes" and cid=' |
||
263 | . $xoopsDB->escape($cid) |
||
264 | . ' AND status!="1" ' |
||
265 | . $cat_perms |
||
266 | . ' ORDER BY ' |
||
267 | . $orderby |
||
268 | . ''; |
||
269 | $result1 = $xoopsDB->query($sql, $show, $min); |
||
270 | if ($trows > '1') { |
||
271 | $xoopsTpl->assign('show_nav', true); |
||
272 | $orderbyTrans = AdslightUtilities::convertOrderByTrans($orderby); |
||
273 | $xoopsTpl->assign('lang_sortby', _ADSLIGHT_SORTBY); |
||
274 | $xoopsTpl->assign('lang_title', _ADSLIGHT_TITLE); |
||
275 | $xoopsTpl->assign('lang_titleatoz', _ADSLIGHT_TITLEATOZ); |
||
276 | $xoopsTpl->assign('lang_titleztoa', _ADSLIGHT_TITLEZTOA); |
||
277 | $xoopsTpl->assign('lang_date', _ADSLIGHT_DATE); |
||
278 | $xoopsTpl->assign('lang_dateold', _ADSLIGHT_DATEOLD); |
||
279 | $xoopsTpl->assign('lang_datenew', _ADSLIGHT_DATENEW); |
||
280 | $xoopsTpl->assign('lang_price', _ADSLIGHT_PRICE); |
||
281 | $xoopsTpl->assign('lang_priceltoh', _ADSLIGHT_PRICELTOH); |
||
282 | $xoopsTpl->assign('lang_pricehtol', _ADSLIGHT_PRICEHTOL); |
||
283 | $xoopsTpl->assign('lang_popularity', _ADSLIGHT_POPULARITY); |
||
284 | $xoopsTpl->assign('lang_popularityleast', _ADSLIGHT_POPULARITYLTOM); |
||
285 | $xoopsTpl->assign('lang_popularitymost', _ADSLIGHT_POPULARITYMTOL); |
||
286 | $xoopsTpl->assign('lang_cursortedby', sprintf(_ADSLIGHT_CURSORTEDBY, AdslightUtilities::convertOrderByTrans($orderby))); |
||
287 | } |
||
288 | |||
289 | while (list($lid, $title, $status, $type, $price, $typeprice, $date, $town, $country, $contactby, $usid, $premium, $valid, $photo, $hits) = $xoopsDB->fetchRow($result1)) { |
||
290 | $a_item = array(); |
||
291 | $title = $myts->htmlSpecialChars($title); |
||
292 | $type = $myts->htmlSpecialChars($type); |
||
293 | // $price = number_format($price, 2, ',', ' '); |
||
294 | $town = $myts->htmlSpecialChars($town); |
||
295 | $country = $myts->htmlSpecialChars($country); |
||
296 | $contactby = $myts->htmlSpecialChars($contactby); |
||
297 | $useroffset = ''; |
||
298 | |||
299 | $newcount = $GLOBALS['xoopsModuleConfig']['adslight_countday']; |
||
300 | $startdate = (time() - (86400 * $newcount)); |
||
301 | View Code Duplication | if ($startdate < $date) { |
|
302 | $newitem = '<img src="' . XOOPS_URL . '/modules/adslight/assets/images/newred.gif" />'; |
||
303 | $a_item['new'] = $newitem; |
||
304 | } |
||
305 | if ($GLOBALS['xoopsUser']) { |
||
306 | $timezone = $GLOBALS['xoopsUser']->timezone(); |
||
307 | if (isset($timezone)) { |
||
308 | $useroffset = $GLOBALS['xoopsUser']->timezone(); |
||
309 | } else { |
||
310 | $useroffset = $xoopsConfig['default_TZ']; |
||
311 | } |
||
312 | } |
||
313 | $date = ($useroffset * 3600) + $date; |
||
314 | $date = formatTimestamp($date, 's'); |
||
315 | View Code Duplication | if ($GLOBALS['xoopsUser']) { |
|
316 | if ($GLOBALS['xoopsUser']->isAdmin()) { |
||
317 | $a_item['admin'] = '<a href="' |
||
318 | . XOOPS_URL |
||
319 | . '/modules/adslight/admin/validate_ads.php?op=ModifyAds&lid=' |
||
320 | . $lid |
||
321 | . '"><img src="' |
||
322 | . $pathIcon16 |
||
323 | . '/edit.png' |
||
324 | . '" border=0 alt="' |
||
325 | . _ADSLIGHT_MODADMIN |
||
326 | . '" title="' |
||
327 | . _ADSLIGHT_MODADMIN |
||
328 | . '"/></a>'; |
||
329 | } |
||
330 | } |
||
331 | |||
332 | $result7 = $xoopsDB->query('SELECT nom_type FROM ' . $xoopsDB->prefix('adslight_type') . " WHERE id_type='" . $xoopsDB->escape($type) . "'"); |
||
333 | list($nom_type) = $xoopsDB->fetchRow($result7); |
||
334 | |||
335 | $result8 = $xoopsDB->query('SELECT nom_price FROM ' . $xoopsDB->prefix('adslight_price') . " WHERE id_price='" . $xoopsDB->escape($typeprice) . "'"); |
||
336 | list($nom_price) = $xoopsDB->fetchRow($result8); |
||
337 | |||
338 | $a_item['type'] = $myts->htmlSpecialChars($nom_type); |
||
339 | $a_item['title'] = '<a href="viewads.php?lid=' . $lid . '"><strong>' . $title . '</strong></a>'; |
||
340 | $a_item['status'] = $status; |
||
341 | if ($price > 0) { |
||
342 | |||
343 | // $a_item['price'] = $price. ' '. $GLOBALS['xoopsModuleConfig']['adslight_money'].''; |
||
344 | $a_item['price'] = AdslightUtilities::getMoneyFormat('%.2n', $price); |
||
345 | $a_item['price_typeprice'] = $myts->htmlSpecialChars($nom_price); |
||
346 | } |
||
347 | $a_item['date'] = $date; |
||
348 | $a_item['local'] = ''; |
||
349 | if ($town) { |
||
350 | $a_item['local'] .= $town; |
||
351 | } |
||
352 | $a_item['country'] = ''; |
||
353 | if ($country) { |
||
354 | $a_item['country'] = $country; |
||
355 | } |
||
356 | |||
357 | $cat = addslashes($cid); |
||
358 | if ($status == 2) { |
||
359 | $a_item['sold'] = _ADSLIGHT_RESERVEDMEMBER; |
||
360 | } |
||
361 | |||
362 | View Code Duplication | if ($GLOBALS['xoopsModuleConfig']['active_thumbscats'] > 0) { |
|
363 | $a_item['no_photo'] = '<a href="' |
||
364 | . XOOPS_URL |
||
365 | . '/modules/adslight/viewads.php?lid=' |
||
366 | . $lid |
||
367 | . '"><img class="thumb" src="' |
||
368 | . XOOPS_URL |
||
369 | . '/modules/adslight/assets/images/nophoto.jpg" align="left" width="100px" alt="' |
||
370 | . $title |
||
371 | . '" /></a>'; |
||
372 | |||
373 | $updir = $GLOBALS['xoopsModuleConfig']['adslight_link_upload']; |
||
374 | $sql = 'SELECT cod_img, lid, uid_owner, url FROM ' |
||
375 | . $xoopsDB->prefix('adslight_pictures') |
||
376 | . ' WHERE uid_owner=' |
||
377 | . $xoopsDB->escape($usid) |
||
378 | . ' AND lid=' |
||
379 | . $xoopsDB->escape($lid) |
||
380 | . ' ORDER BY date_added ASC limit 1'; |
||
381 | $resultp = $xoopsDB->query($sql); |
||
382 | |||
383 | while (list($cod_img, $pic_lid, $uid_owner, $url) = $xoopsDB->fetchRow($resultp)) { |
||
384 | if ($photo) { |
||
385 | $a_item['photo'] = '<a href="' |
||
386 | . XOOPS_URL |
||
387 | . '/modules/adslight/viewads.php?lid=' |
||
388 | . $lid |
||
389 | . '"><img class="thumb" src="' |
||
390 | . $updir |
||
391 | . '/thumbs/thumb_' |
||
392 | . $url |
||
393 | . '" align="left" width="100px" alt="' |
||
394 | . $title |
||
395 | . '" /></a>'; |
||
396 | } |
||
397 | } |
||
398 | } else { |
||
399 | $a_item['no_photo'] = '<p><img src="' . XOOPS_URL . '/modules/adslight/assets/images/camera_nophoto.png" align="left" width="24" alt="' . $title . '" /></p>'; |
||
400 | $updir = $GLOBALS['xoopsModuleConfig']['adslight_link_upload']; |
||
401 | $sql = 'SELECT cod_img, lid, uid_owner, url FROM ' |
||
402 | . $xoopsDB->prefix('adslight_pictures') |
||
403 | . ' WHERE uid_owner=' |
||
404 | . $xoopsDB->escape($usid) |
||
405 | . ' AND lid=' |
||
406 | . $xoopsDB->escape($lid) |
||
407 | . ' ORDER BY date_added ASC limit 1'; |
||
408 | $resultp = $xoopsDB->query($sql); |
||
409 | while (list($cod_img, $pic_lid, $uid_owner, $url) = $xoopsDB->fetchRow($resultp)) { |
||
410 | if ($photo) { |
||
411 | $a_item['photo'] = '<p><img src="' . XOOPS_URL . '/modules/adslight/assets/images/camera_photo.png" align="left" width="24" alt="' . $title . '" /></p>'; |
||
412 | } |
||
413 | } |
||
414 | } |
||
415 | |||
416 | $a_item['hits'] = $hits; |
||
417 | ++$rank; |
||
418 | $xoopsTpl->append('items', $a_item); |
||
419 | } |
||
420 | |||
421 | $cid = ((int)$cid > 0) ? (int)$cid : 0; |
||
422 | |||
423 | $orderby = AdslightUtilities::convertOrderByOut($orderby); |
||
424 | $linkpages = ceil($trows / $show); |
||
425 | |||
426 | //Page Numbering |
||
427 | if ($linkpages != 1 && $linkpages != 0) { |
||
428 | $prev = $min - $show; |
||
429 | if ($prev >= 0) { |
||
430 | $pagenav .= "<a href='viewcats.php?cid=$cid&min=$prev&orderby=$orderby&show=$show'><strong><u>«</u></strong></a> "; |
||
431 | } |
||
432 | $counter = 1; |
||
433 | $currentpage = ($max / $show); |
||
434 | while ($counter <= $linkpages) { |
||
435 | $mintemp = ($show * $counter) - $show; |
||
436 | if ($counter == $currentpage) { |
||
437 | $pagenav .= "<strong>($counter)</strong> "; |
||
438 | } else { |
||
439 | $pagenav .= "<a href='viewcats.php?cid=$cid&min=$mintemp&orderby=$orderby&show=$show'>$counter</a> "; |
||
440 | } |
||
441 | ++$counter; |
||
442 | } |
||
443 | if ($trows > $max) { |
||
444 | $pagenav .= "<a href='viewcats.php?cid=$cid&min=$max&orderby=$orderby&show=$show'>"; |
||
445 | $pagenav .= '<strong><u>»</u></strong></a>'; |
||
446 | } |
||
447 | } |
||
448 | } |
||
449 | |||
450 | $xoopsTpl->assign('nav_page', $pagenav); |
||
451 | |||
452 | if (!$GLOBALS['xoopsUser']) { |
||
453 | global $xoopsDB; |
||
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 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
![]() |
|||
454 | |||
455 | $xt = new XoopsTree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid'); |
||
456 | $jump = XOOPS_URL . '/modules/adslight/viewcats.php?cid='; |
||
457 | ob_start(); |
||
458 | $xt->makeMySelBox('title', 'title', $cid, 1, 'pid', "location=\"" . $jump . "\"+this.options[this.selectedIndex].value"); |
||
459 | $select_go_cats = ob_get_contents(); |
||
460 | ob_end_clean(); |
||
461 | $xoopsTpl->assign('select_go_cats', $select_go_cats); |
||
462 | } |
||
463 | } |
||
464 | |||
465 | # function categorynewgraphic |
||
466 | ##################################################### |
||
467 | /** |
||
468 | * @param $cid |
||
469 | */ |
||
470 | function categorynewgraphic($cid) |
||
471 | { |
||
472 | global $xoopsDB; |
||
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 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
![]() |
|||
473 | } |
||
474 | |||
475 | ###################################################### |
||
476 | |||
477 | $pa = XoopsRequest::getInt('pa', null, 'GET'); |
||
478 | $lid = XoopsRequest::getInt('lid', null, 'GET'); |
||
479 | $cid = XoopsRequest::getInt('cid', null, 'GET'); |
||
480 | $usid = XoopsRequest::getString('usid', '', 'GET'); |
||
481 | $min = XoopsRequest::getInt('min', null, 'GET'); |
||
482 | $show = XoopsRequest::getInt('show', null, 'GET'); |
||
483 | $orderby = XoopsRequest::getInt('orderby', null, 'GET'); |
||
484 | |||
485 | switch ($pa) { |
||
486 | default: |
||
487 | $GLOBALS['xoopsOption']['template_main'] = 'adslight_category.tpl'; |
||
488 | adsView($cid, $min, $orderby, $show); |
||
489 | break; |
||
490 | } |
||
491 | include XOOPS_ROOT_PATH . '/footer.php'; |
||
492 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: