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 | * Module: XoopsTube |
||
5 | * |
||
6 | * You may not change or alter any portion of this comment or credits |
||
7 | * of supporting developers from this source code or any supporting source code |
||
8 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||
9 | * |
||
10 | * PHP version 5 |
||
11 | * |
||
12 | * @category Module |
||
13 | * @package Xoopstube |
||
14 | * @author XOOPS Development Team |
||
15 | * @copyright 2001-2013 The XOOPS Project |
||
16 | * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
||
17 | * @version $Id$ |
||
18 | * @link http://sourceforge.net/projects/xoops/ |
||
19 | * @since 1.0.6 |
||
20 | */ |
||
21 | |||
22 | include __DIR__ . '/header.php'; |
||
23 | |||
24 | // Begin Main page Heading etc |
||
25 | $cid = xtubeCleanRequestVars($_REQUEST, 'cid', 0); |
||
26 | $selectdate = xtubeCleanRequestVars($_REQUEST, 'selectdate', ''); |
||
27 | $list = xtubeCleanRequestVars($_REQUEST, 'list', ''); |
||
28 | $start = xtubeCleanRequestVars($_REQUEST, 'start', 0); |
||
29 | $start = intval($start); |
||
30 | $cid = intval($cid); |
||
31 | |||
32 | $catsort = $xoopsModuleConfig['sortcats']; |
||
33 | $mytree = new XoopstubeTree($xoopsDB->prefix('xoopstube_cat'), 'cid', 'pid'); |
||
34 | $arr = $mytree->getFirstChild($cid, $catsort); |
||
35 | |||
36 | if (is_array($arr) > 0 && !$list && !$selectdate) { |
||
37 | if (false == xtubeCheckGroups($cid)) { |
||
38 | redirect_header('index.php', 1, _MD_XOOPSTUBE_MUSTREGFIRST); |
||
39 | exit(); |
||
40 | } |
||
41 | } |
||
42 | |||
43 | $xoopsOption['template_main'] = 'xoopstube_viewcat.tpl'; |
||
44 | |||
45 | include XOOPS_ROOT_PATH . '/header.php'; |
||
46 | |||
47 | global $xoopsModuleConfig, $xoopsModule; |
||
0 ignored issues
–
show
|
|||
48 | $catarray['letters'] = xtubeGetLetters(); |
||
49 | $catarray['imageheader'] = xtubeRenderImageHeader(); |
||
50 | $xoopsTpl->assign('catarray', $catarray); |
||
51 | |||
52 | $catArray['letters'] = xtubeLettersChoice(); |
||
53 | //$catArray['toolbar'] = xoopstube_toolbar(); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
64% 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. ![]() |
|||
54 | $xoopsTpl->assign('catarray', $catArray); |
||
55 | |||
56 | // Breadcrumb |
||
57 | $pathstring = '<a href="index.php">' . _MD_XOOPSTUBE_MAIN . '</a> : '; |
||
58 | $pathstring .= $mytree->getNicePathFromId($cid, 'title', 'viewcat.php?op='); |
||
59 | $xoopsTpl->assign('category_path', $pathstring); |
||
60 | $xoopsTpl->assign('category_id', $cid); |
||
61 | |||
62 | // Display Sub-categories for selected Category |
||
63 | if (is_array($arr) > 0 && !$list && !$selectdate) { |
||
64 | $scount = 1; |
||
65 | foreach ($arr as $ele) { |
||
66 | if (xtubeCheckGroups($ele['cid']) == false) { |
||
67 | continue; |
||
68 | } |
||
69 | $sub_arr = array(); |
||
70 | $sub_arr = $mytree->getFirstChild($ele['cid'], $catsort); |
||
71 | $space = 1; |
||
72 | $chcount = 1; |
||
73 | $infercategories = ''; |
||
74 | foreach ($sub_arr as $sub_ele) { |
||
75 | // Subitem file count |
||
76 | $hassubitems = xtubeGetTotalItems($sub_ele['cid']); |
||
77 | // Filter group permissions |
||
78 | if (true == xtubeCheckGroups($sub_ele['cid'])) { |
||
79 | // If subcategory count > 5 then finish adding subcats to $infercategories and end |
||
80 | if ($chcount > 5) { |
||
81 | $infercategories .= '...'; |
||
82 | break; |
||
83 | } |
||
84 | if ($space > 0) { |
||
85 | $infercategories .= ', '; |
||
86 | } |
||
87 | |||
88 | $infercategories |
||
89 | .= '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewcat.php?cid=' . $sub_ele['cid'] . '">' . $xtubemyts->htmlSpecialCharsStrip($sub_ele['title']) |
||
90 | . '</a> (' . $hassubitems['count'] . ')'; |
||
91 | ++$space; |
||
92 | ++$chcount; |
||
93 | } |
||
94 | } |
||
95 | $totalvideos = xtubeGetTotalItems($ele['cid']); |
||
96 | $indicator = xtubeIsNewImage($totalvideos['published']); |
||
97 | |||
98 | // This code is copyright WF-Projects |
||
99 | // Using this code without our permission or removing this code voids the license agreement |
||
100 | |||
101 | $_image = ($ele['imgurl']) ? urldecode($ele['imgurl']) : ''; |
||
102 | View Code Duplication | if ($_image != '' && $xoopsModuleConfig['usethumbs']) { |
|
103 | $_thumb_image = new XtubeThumbsNails($_image, $xoopsModuleConfig['catimage'], 'thumbs'); |
||
104 | if ($_thumb_image) { |
||
105 | $_thumb_image->setUseThumbs(1); |
||
106 | $_thumb_image->setImageType('gd2'); |
||
107 | $_image = $_thumb_image->createThumbnail( |
||
108 | $xoopsModuleConfig['shotwidth'], |
||
109 | $xoopsModuleConfig['shotheight'], |
||
110 | $xoopsModuleConfig['imagequality'], |
||
111 | $xoopsModuleConfig['updatethumbs'], |
||
112 | $xoopsModuleConfig['keepaspect'] |
||
113 | ); |
||
114 | } |
||
115 | } |
||
116 | |||
117 | View Code Duplication | if (empty($_image) || $_image == '') { |
|
0 ignored issues
–
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. ![]() |
|||
118 | $imgurl = $indicator['image']; |
||
119 | $_width = 33; |
||
120 | $_height = 24; |
||
121 | } else { |
||
122 | $imgurl = "{$xoopsModuleConfig['catimage']}/$_image"; |
||
123 | $_width = $xoopsModuleConfig['shotwidth']; |
||
124 | $_height = $xoopsModuleConfig['shotheight']; |
||
125 | } |
||
126 | /* |
||
127 | * End |
||
128 | */ |
||
129 | |||
130 | $xoopsTpl->append( |
||
131 | 'subcategories', |
||
132 | array( |
||
133 | 'title' => $xtubemyts->htmlSpecialCharsStrip($ele['title']), |
||
134 | 'id' => $ele['cid'], |
||
135 | 'image' => XOOPS_URL . "/$imgurl", |
||
136 | 'width' => $_width, |
||
137 | 'height' => $_height, |
||
138 | 'infercategories' => $infercategories, |
||
139 | 'totalvideos' => $totalvideos['count'], |
||
140 | 'count' => $scount, |
||
141 | 'alttext' => $ele['description'] |
||
142 | ) |
||
143 | ); |
||
144 | ++$scount; |
||
145 | } |
||
146 | } |
||
147 | |||
148 | // Show Description for Category listing |
||
149 | $sql = 'SELECT * FROM ' . $xoopsDB->prefix('xoopstube_cat') . ' WHERE cid=' . intval($cid); |
||
150 | $head_arr = $xoopsDB->fetchArray($xoopsDB->query($sql)); |
||
151 | $html = ($head_arr['nohtml']) ? 0 : 1; |
||
152 | $smiley = ($head_arr['nosmiley']) ? 0 : 1; |
||
153 | $xcodes = ($head_arr['noxcodes']) ? 0 : 1; |
||
154 | $images = ($head_arr['noimages']) ? 0 : 1; |
||
155 | $breaks = ($head_arr['nobreak']) ? 1 : 0; |
||
156 | $description = $xtubemyts->displayTarea($head_arr['description'], $html, $smiley, $xcodes, $images, $breaks); |
||
157 | $xoopsTpl->assign('description', $description); |
||
158 | $module_handler = & xoops_gethandler('module'); |
||
159 | $versioninfo = & $module_handler->get($xoopsModule->getVar('mid')); |
||
160 | if ($head_arr['title'] > '') { |
||
161 | $xoopsTpl->assign('xoops_pagetitle', $versioninfo->getInfo('name') . ': ' . $head_arr['title']); |
||
162 | } else { |
||
163 | $xoopsTpl->assign('xoops_pagetitle', $versioninfo->getInfo('name')); |
||
164 | } |
||
165 | |||
166 | if ($head_arr['client_id'] > 0) { |
||
167 | $catarray['imageheader'] = xtubeGetBannerFromClientId($head_arr['client_id']); |
||
168 | } elseif ($head_arr['banner_id'] > 0) { |
||
169 | $catarray['imageheader'] = xtubeGetBannerFromBannerId($head_arr['banner_id']); |
||
170 | } else { |
||
171 | $catarray['imageheader'] = xtubeRenderImageHeader(); |
||
172 | } |
||
173 | $xoopsTpl->assign('catarray', $catarray); |
||
174 | // Extract linkload information from database |
||
175 | $xoopsTpl->assign('show_categort_title', true); |
||
176 | |||
177 | $orderby = (isset($_REQUEST['orderby']) && !empty($_REQUEST['orderby'])) ? xtubeConvertOrderByIn(htmlspecialchars($_REQUEST['orderby'])) : xtubeConvertOrderByIn($xoopsModuleConfig['linkxorder']); |
||
178 | |||
179 | if ($selectdate) { |
||
180 | |||
181 | $d = date('j', $selectdate); |
||
182 | $m = date('m', $selectdate); |
||
183 | $y = date('Y', $selectdate); |
||
184 | |||
185 | $stat_begin = mktime(0, 0, 0, $m, $d, $y); |
||
186 | $stat_end = mktime(23, 59, 59, $m, $d, $y); |
||
187 | |||
188 | $query |
||
189 | = ' WHERE published>=' . $stat_begin . ' AND published<=' . $stat_end . ' AND (expired=0 OR expired>' . time() . ') AND offline=0 AND cid>0'; |
||
190 | |||
191 | $sql = 'SELECT * FROM ' . $xoopsDB->prefix('xoopstube_videos') . $query . ' ORDER BY ' . $orderby; |
||
192 | $result = $xoopsDB->query($sql, $xoopsModuleConfig['perpage'], $start); |
||
193 | |||
194 | $sql = 'SELECT COUNT(*) FROM ' . $xoopsDB->prefix('xoopstube_videos') . $query; |
||
195 | list($count) = $xoopsDB->fetchRow($xoopsDB->query($sql)); |
||
196 | |||
197 | $list_by = 'selectdate=' . $selectdate; |
||
198 | |||
199 | } elseif ($list) { |
||
200 | |||
201 | $query |
||
202 | = " WHERE title LIKE '$list%' AND (published>0 AND published<=" . time() . ") AND (expired=0 OR expired>" . time() . ") AND offline=0 AND cid>0"; |
||
203 | |||
204 | $sql = 'SELECT * FROM ' . $xoopsDB->prefix('xoopstube_videos') . $query . ' ORDER BY ' . $orderby; |
||
205 | $result = $xoopsDB->query($sql, $xoopsModuleConfig['perpage'], $start); |
||
206 | |||
207 | $sql = 'SELECT COUNT(*) FROM ' . $xoopsDB->prefix('xoopstube_videos') . $query; |
||
208 | list($count) = $xoopsDB->fetchRow($xoopsDB->query($sql)); |
||
209 | $list_by = "list=$list"; |
||
210 | |||
211 | } else { |
||
212 | |||
213 | $query = 'WHERE a.published>0 AND a.published<=' . time() . ' AND (a.expired=0 OR a.expired>' . time() . ') AND a.offline=0' . ' AND (b.cid=a.cid OR (a.cid=' . $cid . ' OR b.cid=' . $cid . '))'; |
||
214 | |||
215 | $sql = 'SELECT DISTINCT a.* FROM ' . $xoopsDB->prefix('xoopstube_videos') . ' a LEFT JOIN ' . $xoopsDB->prefix( |
||
216 | 'xoopstube_altcat' |
||
217 | ) . ' b ON b.lid=a.lid ' . $query . ' ORDER BY ' . $orderby; |
||
218 | $result = $xoopsDB->query($sql, $xoopsModuleConfig['perpage'], $start); |
||
219 | |||
220 | $sql2 = 'SELECT COUNT(*) FROM ' . $xoopsDB->prefix('xoopstube_videos') . ' a LEFT JOIN ' . $xoopsDB->prefix( |
||
221 | 'xoopstube_altcat' |
||
222 | ) . ' b ON b.lid=a.lid ' . $query; |
||
223 | list($count) = $xoopsDB->fetchRow($xoopsDB->query($sql2)); |
||
224 | $order = xtubeConvertOrderByOut($orderby); |
||
225 | $list_by = 'cid=' . $cid . '&orderby=' . $order; |
||
226 | $xoopsTpl->assign('show_categort_title', false); |
||
227 | |||
228 | } |
||
229 | $pagenav = new XoopsPageNav($count, $xoopsModuleConfig['perpage'], $start, 'start', $list_by); |
||
230 | |||
231 | // Show links |
||
232 | if ($count > 0) { |
||
233 | $moderate = 0; |
||
234 | while ($video_arr = $xoopsDB->fetchArray($result)) { |
||
235 | if (xtubeCheckGroups($video_arr['cid']) == true) { |
||
236 | require XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/videoloadinfo.php'; |
||
237 | $xoopsTpl->append('video', $video); |
||
238 | } |
||
239 | } |
||
240 | |||
241 | unset($video_arr); |
||
242 | |||
243 | // Show order box |
||
244 | $xoopsTpl->assign('show_videos', false); |
||
245 | if ($count > 1 && $cid != 0) { |
||
246 | $xoopsTpl->assign('show_videos', true); |
||
247 | $orderbyTrans = xtubeConvertOrderByTrans($orderby); |
||
248 | $xoopsTpl->assign('lang_cursortedby', sprintf(_MD_XOOPSTUBE_CURSORTBY, xtubeConvertOrderByTrans($orderby))); |
||
249 | $orderby = xtubeConvertOrderByOut($orderby); |
||
250 | } |
||
251 | |||
252 | // Screenshots display |
||
253 | $xoopsTpl->assign('show_screenshot', false); |
||
254 | View Code Duplication | if (isset($xoopsModuleConfig['screenshot']) && $xoopsModuleConfig['screenshot'] == 1) { |
|
0 ignored issues
–
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. ![]() |
|||
255 | $xoopsTpl->assign('shotwidth', $xoopsModuleConfig['shotwidth']); |
||
256 | $xoopsTpl->assign('shotheight', $xoopsModuleConfig['shotheight']); |
||
257 | $xoopsTpl->assign('show_screenshot', true); |
||
258 | } |
||
259 | |||
260 | // Nav page render |
||
261 | $page_nav = $pagenav->renderNav(); |
||
262 | $istrue = (isset($page_nav) && !empty($page_nav)) ? true : false; |
||
263 | $xoopsTpl->assign('page_nav', $istrue); |
||
264 | $xoopsTpl->assign('pagenav', $page_nav); |
||
265 | $xoopsTpl->assign('module_dir', $xoopsModule->getVar('dirname')); |
||
266 | } |
||
267 | |||
268 | $xoopsTpl->assign('cat_columns', $xoopsModuleConfig['catcolumns']); |
||
269 | |||
270 | include XOOPS_ROOT_PATH . '/footer.php'; |
||
271 |
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