1 | <?php |
||||
2 | /** |
||||
3 | * File: viewcat.php |
||||
4 | * Module: WF-Links |
||||
5 | * Developer: John N |
||||
6 | * Team: WF-Projects |
||||
7 | * Licence: GNU |
||||
8 | */ |
||||
9 | |||||
10 | use XoopsModules\Wflinks; |
||||
11 | |||||
12 | require_once __DIR__ . '/header.php'; |
||||
13 | |||||
14 | /** @var Wflinks\Helper $helper */ |
||||
15 | $helper = Wflinks\Helper::getInstance(); |
||||
16 | |||||
17 | // Begin Main page Heading etc |
||||
18 | $cid = Wflinks\Utility::cleanRequestVars($_REQUEST, 'cid', 0); |
||||
19 | $selectdate = Wflinks\Utility::cleanRequestVars($_REQUEST, 'selectdate', ''); |
||||
20 | $list = Wflinks\Utility::cleanRequestVars($_REQUEST, 'list', ''); |
||||
21 | $cid = (int)$cid; |
||||
22 | $catsort = $helper->getConfig('sortcats'); |
||||
23 | |||||
24 | $mytree = new Wflinks\Tree($xoopsDB->prefix('wflinks_cat'), 'cid', 'pid'); |
||||
25 | $arr = $mytree->getFirstChild($cid, $catsort); |
||||
26 | |||||
27 | if (is_array($arr) > 0 && !$list && !$selectdate) { |
||||
28 | if (false === Wflinks\Utility::checkGroups($cid)) { |
||||
29 | redirect_header('index.php', 1, _MD_WFL_MUSTREGFIRST); |
||||
30 | } |
||||
31 | } |
||||
32 | $GLOBALS['xoopsOption']['template_main'] = 'wflinks_viewcat.tpl'; |
||||
33 | require XOOPS_ROOT_PATH . '/header.php'; |
||||
34 | |||||
35 | // Breadcrumb |
||||
36 | $pathstring = '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/index.php">' . _MD_WFL_MAIN . '</a> : '; |
||||
37 | $pathstring .= $mytree->getNicePathFromId($cid, 'title', 'viewcat.php?op='); |
||||
38 | $xoopsTpl->assign('category_path', $pathstring); |
||||
39 | $xoopsTpl->assign('category_id', $cid); |
||||
40 | |||||
41 | $time = time(); |
||||
42 | |||||
43 | // Display Sub-categories for selected Category |
||||
44 | if (is_array($arr) > 0 && !$list && !$selectdate) { |
||||
45 | $scount = 1; |
||||
46 | foreach ($arr as $ele) { |
||||
47 | if (false === Wflinks\Utility::checkGroups($ele['cid'])) { |
||||
48 | continue; |
||||
49 | } |
||||
50 | $sub_arr = []; |
||||
51 | $sub_arr = $mytree->getFirstChild($ele['cid'], 'title'); |
||||
52 | $space = 1; |
||||
53 | $chcount = 1; |
||||
54 | $infercategories = ''; |
||||
55 | foreach ($sub_arr as $sub_ele) { |
||||
56 | // Subitem file count |
||||
57 | $hassubitems = Wflinks\Utility::getTotalItems($sub_ele['cid']); |
||||
58 | // Filter group permissions |
||||
59 | if (true === Wflinks\Utility::checkGroups($sub_ele['cid'])) { |
||||
60 | // If subcategory count > 5 then finish adding subcats to $infercategories and end |
||||
61 | if ($chcount > 5) { |
||||
62 | $infercategories .= '...'; |
||||
63 | break; |
||||
64 | } |
||||
65 | if ($space > 0) { |
||||
66 | $infercategories .= ', '; |
||||
67 | } |
||||
68 | $infercategories .= "<a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewcat.php?cid=' . $sub_ele['cid'] . "'>" . htmlspecialchars($sub_ele['title']) . '</a> (' . $hassubitems['count'] . ')'; |
||||
69 | ++$space; |
||||
70 | ++$chcount; |
||||
71 | } |
||||
72 | } |
||||
73 | $totallinks = Wflinks\Utility::getTotalItems($ele['cid']); |
||||
74 | $indicator = Wflinks\Utility::isNewImage($totallinks['published']); |
||||
75 | |||||
76 | // This code is copyright WF-Projects |
||||
77 | // Using this code without our permission or removing this code voids the license agreement |
||||
78 | $_image = $ele['imgurl'] ? urldecode($ele['imgurl']) : ''; |
||||
79 | if ('' !== $_image && $helper->getConfig('usethumbs')) { |
||||
80 | $_thumb_image = new Wflinks\ThumbsNails($_image, $helper->getConfig('catimage'), 'thumbs'); |
||||
81 | if ($_thumb_image) { |
||||
82 | $_thumb_image->setUseThumbs(1); |
||||
83 | $_thumb_image->setImageType('gd2'); |
||||
84 | $_image = $_thumb_image->createThumb($helper->getConfig('shotwidth'), $helper->getConfig('shotheight'), $helper->getConfig('imagequality'), $helper->getConfig('updatethumbs'), $helper->getConfig('keepaspect')); |
||||
85 | } |
||||
86 | } |
||||
87 | $imgurl = "{$helper->getConfig('catimage')}/$_image"; |
||||
88 | if (empty($_image) || '' === $_image) { |
||||
89 | $imgurl = $indicator['image']; |
||||
90 | } |
||||
91 | // End |
||||
92 | $xoopsTpl->append( |
||||
93 | 'subcategories', |
||||
94 | [ |
||||
95 | 'title' => htmlspecialchars($ele['title']), |
||||
96 | 'id' => $ele['cid'], |
||||
97 | 'image' => XOOPS_URL . "/$imgurl", |
||||
98 | 'infercategories' => $infercategories, |
||||
99 | 'totallinks' => $totallinks['count'], |
||||
100 | 'count' => $scount, |
||||
101 | 'alttext' => $ele['description'], |
||||
102 | ] |
||||
103 | ); |
||||
104 | ++$scount; |
||||
105 | } |
||||
106 | } |
||||
107 | |||||
108 | // Show Description for Category listing |
||||
109 | $sql = 'SELECT title, description, nohtml, nosmiley, noxcodes, noimages, nobreak, imgurl, client_id, banner_id FROM ' . $xoopsDB->prefix('wflinks_cat') . ' WHERE cid =' . $cid; |
||||
110 | $head_arr = $xoopsDB->fetchArray($xoopsDB->query($sql)); |
||||
111 | $html = $head_arr['nohtml'] ? 0 : 1; |
||||
112 | $smiley = $head_arr['nosmiley'] ? 0 : 1; |
||||
113 | $xcodes = $head_arr['noxcodes'] ? 0 : 1; |
||||
114 | $images = $head_arr['noimages'] ? 0 : 1; |
||||
115 | $breaks = $head_arr['nobreak'] ? 1 : 0; |
||||
116 | |||||
117 | $description = $myts->displayTarea($head_arr['description'], $html, $smiley, $xcodes, $images, $breaks); |
||||
118 | $xoopsTpl->assign('description', $description); |
||||
119 | $xoopsTpl->assign('xoops_pagetitle', $head_arr['title']); |
||||
120 | //$xoopsTpl -> assign( 'client_banner', Wflinks\Utility::getBannerFromIdClient($head_arr['client_id']) ); |
||||
121 | |||||
122 | if ($head_arr['client_id'] > 0) { |
||||
123 | $catarray['imageheader'] = Wflinks\Utility::getBannerFromIdClient($head_arr['client_id']); |
||||
124 | } elseif ($head_arr['banner_id'] > 0) { |
||||
125 | $catarray['imageheader'] = Wflinks\Utility::getBannerFromIdBanner($head_arr['banner_id']); |
||||
126 | } else { |
||||
127 | $catarray['imageheader'] = Wflinks\Utility::getImageHeader(); |
||||
128 | } |
||||
129 | $catarray['letters'] = Wflinks\Utility::getLetters(); |
||||
130 | $catarray['toolbar'] = Wflinks\Utility::getToolbar(); |
||||
131 | $xoopsTpl->assign('catarray', $catarray); |
||||
132 | |||||
133 | // Extract linkload information from database |
||||
134 | $xoopsTpl->assign('show_categort_title', true); |
||||
135 | |||||
136 | $start = Wflinks\Utility::cleanRequestVars($_REQUEST, 'start', 0); |
||||
137 | $orderby = (isset($_REQUEST['orderby']) |
||||
138 | && !empty($_REQUEST['orderby'])) ? Wflinks\Utility::convertOrderByIn(htmlspecialchars($_REQUEST['orderby'], ENT_QUOTES | ENT_HTML5)) : Wflinks\Utility::convertOrderByIn($helper->getConfig('linkxorder')); |
||||
139 | |||||
140 | if ($selectdate) { |
||||
141 | $d = date('j', $selectdate); |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
142 | $m = date('m', $selectdate); |
||||
143 | $y = date('Y', $selectdate); |
||||
144 | |||||
145 | $stat_begin = mktime(0, 0, 0, $m, $d, $y); |
||||
146 | $stat_end = mktime(23, 59, 59, $m, $d, $y); |
||||
147 | |||||
148 | $query = ' WHERE published >= ' . $stat_begin . ' AND published <= ' . $stat_end . ' |
||||
149 | AND (expired = 0 OR expired > ' . $time . ') |
||||
150 | AND offline = 0 |
||||
151 | AND cid > 0'; |
||||
152 | |||||
153 | $sql = 'SELECT * FROM ' . $xoopsDB->prefix('wflinks_links') . $query . ' ORDER BY ' . $orderby; |
||||
154 | $result = $xoopsDB->query($sql, $helper->getConfig('perpage'), $start); |
||||
155 | |||||
156 | $sql = 'SELECT COUNT(*) FROM ' . $xoopsDB->prefix('wflinks_links') . $query; |
||||
157 | list($count) = $xoopsDB->fetchRow($xoopsDB->query($sql)); |
||||
158 | |||||
159 | $list_by = 'selectdate=' . $selectdate; |
||||
160 | } elseif ($list) { |
||||
161 | $query = " WHERE title LIKE '$list%' AND (published > 0 AND published <= " . $time . ') AND (expired = 0 OR expired > ' . $time . ') AND offline = 0 AND cid > 0'; |
||||
162 | |||||
163 | $sql = 'SELECT * FROM ' . $xoopsDB->prefix('wflinks_links') . $query . ' ORDER BY ' . $orderby; |
||||
164 | $result = $xoopsDB->query($sql, $helper->getConfig('perpage'), $start); |
||||
165 | |||||
166 | $sql = 'SELECT COUNT(*) FROM ' . $xoopsDB->prefix('wflinks_links') . $query; |
||||
167 | list($count) = $xoopsDB->fetchRow($xoopsDB->query($sql)); |
||||
168 | $list_by = 'list=' . $list; |
||||
169 | } else { |
||||
170 | $sql = 'SELECT DISTINCT a.* FROM ' |
||||
171 | . $xoopsDB->prefix('wflinks_links') |
||||
172 | . ' a LEFT JOIN ' |
||||
173 | . $xoopsDB->prefix('wflinks_altcat') |
||||
174 | . ' b ' |
||||
175 | . ' ON b.lid = a.lid' |
||||
176 | . ' WHERE a.published > 0 AND a.published <= ' |
||||
177 | . $time |
||||
178 | . ' AND (a.expired = 0 OR a.expired > ' |
||||
179 | . $time |
||||
180 | . ') AND a.offline = 0' |
||||
181 | . ' AND (b.cid=a.cid OR (a.cid=' |
||||
182 | . $cid |
||||
183 | . ' OR b.cid=' |
||||
184 | . $cid |
||||
185 | . '))' |
||||
186 | . ' ORDER BY ' |
||||
187 | . $orderby; |
||||
188 | $result = $xoopsDB->query($sql, $helper->getConfig('perpage'), $start); |
||||
189 | $xoopsTpl->assign('show_categort_title', false); |
||||
190 | |||||
191 | $sql2 = 'SELECT COUNT(*) FROM ' |
||||
192 | . $xoopsDB->prefix('wflinks_links') |
||||
193 | . ' a LEFT JOIN ' |
||||
194 | . $xoopsDB->prefix('wflinks_altcat') |
||||
195 | . ' b ' |
||||
196 | . ' ON b.lid = a.lid' |
||||
197 | . ' WHERE a.published > 0 AND a.published <= ' |
||||
198 | . $time |
||||
199 | . ' AND (a.expired = 0 OR a.expired > ' |
||||
200 | . $time |
||||
201 | . ') AND a.offline = 0' |
||||
202 | . ' AND (b.cid=a.cid OR (a.cid=' |
||||
203 | . $cid |
||||
204 | . ' OR b.cid=' |
||||
205 | . $cid |
||||
206 | . '))'; |
||||
207 | list($count) = $xoopsDB->fetchRow($xoopsDB->query($sql2)); |
||||
208 | $order = Wflinks\Utility::convertOrderByOut($orderby); |
||||
209 | $cid = $cid; |
||||
210 | $list_by = 'cid=' . $cid . '&orderby=' . $order; |
||||
211 | } |
||||
212 | $pagenav = new \XoopsPageNav($count, $helper->getConfig('perpage'), $start, 'start', $list_by); |
||||
0 ignored issues
–
show
It seems like
$start can also be of type string ; however, parameter $current_start of XoopsPageNav::__construct() does only seem to accept integer , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
213 | $page_nav = $pagenav->renderNav(); |
||||
214 | $istrue = (isset($page_nav) && !empty($page_nav)); |
||||
215 | $xoopsTpl->assign('page_nav', $istrue); |
||||
216 | $xoopsTpl->assign('pagenav', $page_nav); |
||||
217 | $xoopsTpl->assign('module_dir', $xoopsModule->getVar('dirname')); |
||||
218 | |||||
219 | // Show links |
||||
220 | if ($count > 0) { |
||||
221 | $moderate = 0; |
||||
222 | while (false !== ($link_arr = $xoopsDB->fetchArray($result))) { |
||||
223 | $res_type = 0; |
||||
224 | require XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/linkloadinfo.php'; |
||||
225 | $xoopsTpl->append('wfllink', $link); |
||||
226 | } |
||||
227 | |||||
228 | // Show order box |
||||
229 | $xoopsTpl->assign('show_links', false); |
||||
230 | if ($count > 1 && 0 != $cid) { |
||||
231 | $xoopsTpl->assign('show_links', true); |
||||
232 | $orderbyTrans = Wflinks\Utility::convertOrderByTrans($orderby); |
||||
233 | $xoopsTpl->assign('lang_cursortedby', sprintf(_MD_WFL_CURSORTBY, Wflinks\Utility::convertOrderByTrans($orderby))); |
||||
234 | $orderby = Wflinks\Utility::convertOrderByOut($orderby); |
||||
235 | } |
||||
236 | |||||
237 | // Screenshots display |
||||
238 | $xoopsTpl->assign('show_screenshot', false); |
||||
239 | if (null !== $helper->getConfig('screenshot') && 1 == $helper->getConfig('screenshot')) { |
||||
240 | $xoopsTpl->assign('shots_dir', $helper->getConfig('screenshots')); |
||||
241 | $xoopsTpl->assign('shotwidth', $helper->getConfig('shotwidth')); |
||||
242 | $xoopsTpl->assign('shotheight', $helper->getConfig('shotheight')); |
||||
243 | $xoopsTpl->assign('show_screenshot', true); |
||||
244 | } |
||||
245 | } |
||||
246 | unset($link_arr); |
||||
247 | |||||
248 | require XOOPS_ROOT_PATH . '/footer.php'; |
||||
249 |