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-2016 XOOPS Project (http://xoops.org) |
||
16 | * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
||
17 | * @link http://xoops.org/ |
||
18 | * @since 1.0.6 |
||
19 | */ |
||
20 | |||
21 | include __DIR__ . '/header.php'; |
||
22 | |||
23 | $lid = XoopsRequest::getInt('lid', XoopsRequest::getInt('lid', '', 'POST'), 'GET'); |
||
24 | $cid = XoopsRequest::getInt('cid', XoopsRequest::getInt('cid', '', 'POST'), 'GET'); |
||
25 | |||
26 | $sql2 = 'SELECT count(*) FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' a LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('xoopstube_altcat') . ' b' . ' ON b.lid = a.lid' |
||
27 | . ' 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=' . (int)$cid . ' OR b.cid=' |
||
28 | . (int)$cid . '))'; |
||
29 | list($count) = $GLOBALS['xoopsDB']->fetchRow($GLOBALS['xoopsDB']->query($sql2)); |
||
30 | |||
31 | if (false === XoopstubeUtilities::xtubeCheckGroups($cid) || $count === 0) { |
||
32 | redirect_header('index.php', 1, _MD_XOOPSTUBE_MUSTREGFIRST); |
||
33 | } |
||
34 | |||
35 | $sql = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' WHERE lid=' . (int)$lid . ' |
||
36 | AND (published > 0 AND published <= ' . time() . ') |
||
37 | AND (expired = 0 OR expired > ' . time() . ') |
||
38 | AND offline = 0 |
||
39 | AND cid > 0'; |
||
40 | $result = $GLOBALS['xoopsDB']->query($sql); |
||
41 | $video_arr = $GLOBALS['xoopsDB']->fetchArray($result); |
||
42 | |||
43 | if (!is_array($video_arr)) { |
||
44 | redirect_header('index.php', 1, _MD_XOOPSTUBE_NOVIDEOLOAD); |
||
45 | } |
||
46 | |||
47 | $xoopsOption['template_main'] = 'xoopstube_singlevideo.tpl'; |
||
48 | |||
49 | include XOOPS_ROOT_PATH . '/header.php'; |
||
50 | |||
51 | // tags support |
||
52 | if (XoopstubeUtilities::xtubeIsModuleTagInstalled()) { |
||
53 | include_once XOOPS_ROOT_PATH . '/modules/tag/include/tagbar.php'; |
||
54 | $xoopsTpl->assign('tagbar', tagBar($video_arr['lid'], 0)); |
||
55 | } |
||
56 | |||
57 | $video['imageheader'] = XoopstubeUtilities::xtubeRenderImageHeader(); |
||
58 | $video['id'] = $video_arr['lid']; |
||
59 | $video['cid'] = $video_arr['cid']; |
||
60 | $video['vidid'] = $video_arr['vidid']; |
||
61 | $video['description2'] =& $xtubemyts->displayTarea($video_arr['description'], 1, 1, 1, 1, 1); |
||
62 | |||
63 | $mytree = new XoopstubeTree($GLOBALS['xoopsDB']->prefix('xoopstube_cat'), 'cid', 'pid'); |
||
64 | $pathstring = '<a href="index.php">' . _MD_XOOPSTUBE_MAIN . '</a> : '; |
||
65 | $pathstring .= $mytree->getNicePathFromId($cid, 'title', 'viewcat.php?op='); |
||
66 | $video['path'] = $pathstring; |
||
67 | // Get video from source |
||
68 | $video['showvideo'] = xtubeShowVideo($video_arr['vidid'], $video_arr['vidsource'], $video_arr['screenshot'], $video_arr['picurl']); |
||
69 | |||
70 | // Get Social Bookmarks |
||
71 | $video['sbmarks'] = getSocialBookmarks($video_arr['lid']); |
||
72 | |||
73 | // Start of meta tags |
||
74 | global $xoopsTpl, $xoTheme; |
||
0 ignored issues
–
show
|
|||
75 | |||
76 | $maxWords = 100; |
||
77 | $words = array(); |
||
78 | $words = explode(' ', XoopstubeUtilities::xtubeConvertHtml2Text($video_arr['description'])); |
||
79 | $newWords = array(); |
||
80 | $i = 0; |
||
81 | while ($i < $maxWords - 1 && $i < count($words)) { |
||
82 | if (isset($words[$i])) { |
||
83 | $newWords[] = trim($words[$i]); |
||
84 | } |
||
85 | ++$i; |
||
86 | } |
||
87 | $video_meta_description = implode(' ', $newWords); |
||
88 | |||
89 | if (is_object($GLOBALS['xoTheme'])) { |
||
90 | if ($video_arr['keywords']) { |
||
91 | $GLOBALS['xoTheme']->addMeta('meta', 'keywords', $video_arr['keywords']); |
||
92 | } |
||
93 | $GLOBALS['xoTheme']->addMeta('meta', 'title', $video_arr['title']); |
||
94 | if ($GLOBALS['xoopsModuleConfig']['usemetadescr'] == 1) { |
||
95 | $GLOBALS['xoTheme']->addMeta('meta', 'description', $video_meta_description); |
||
96 | } |
||
97 | } else { |
||
98 | if ($video_arr['keywords']) { |
||
99 | $xoopsTpl->assign('xoops_meta_keywords', $video_arr['keywords']); |
||
100 | } |
||
101 | if ($GLOBALS['xoopsModuleConfig']['usemetadescr'] == 1) { |
||
102 | $GLOBALS['xoTheme']->assign('xoops_meta_description', $video_meta_description); |
||
103 | } |
||
104 | } |
||
105 | $xoopsTpl->assign('xoops_pagetitle', $video_arr['title']); |
||
106 | // End of meta tags |
||
107 | |||
108 | $moderate = 0; |
||
109 | include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/videoloadinfo.php'; |
||
110 | |||
111 | $xoopsTpl->assign('show_screenshot', false); |
||
112 | View Code Duplication | if (isset($GLOBALS['xoopsModuleConfig']['screenshot']) && $GLOBALS['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. ![]() |
|||
113 | $xoopsTpl->assign('shotwidth', $GLOBALS['xoopsModuleConfig']['shotwidth']); |
||
114 | $xoopsTpl->assign('shotheight', $GLOBALS['xoopsModuleConfig']['shotheight']); |
||
115 | $xoopsTpl->assign('show_screenshot', true); |
||
116 | } |
||
117 | |||
118 | if (false === $video['isadmin']) { |
||
119 | $count = XoopstubeUtilities::xtubeUpdateCounter($lid); |
||
0 ignored issues
–
show
Are you sure the assignment to
$count is correct as \XoopstubeUtilities::xtubeUpdateCounter($lid) (which targets XoopstubeUtilities::xtubeUpdateCounter() ) seems to always return null.
This check looks for function or method calls that always return null and whose return value is assigned to a variable. class A
{
function getObject()
{
return null;
}
}
$a = new A();
$object = $a->getObject();
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||
120 | } |
||
121 | |||
122 | // Show other author videos |
||
123 | $sql = 'SELECT lid, cid, title, published FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' |
||
124 | WHERE submitter=' . $video_arr['submitter'] . ' |
||
125 | AND lid <> ' . $video_arr['lid'] . ' |
||
126 | AND published > 0 AND published <= ' . time() . ' AND (expired = 0 OR expired > ' . time() . ') |
||
127 | AND offline = 0 ORDER by published DESC'; |
||
128 | $result = $GLOBALS['xoopsDB']->query($sql, 10, 0); |
||
129 | |||
130 | while (false !== ($arr = $GLOBALS['xoopsDB']->fetchArray($result))) { |
||
131 | if (true === XoopstubeUtilities::xtubeCheckGroups($arr['cid'])) { |
||
132 | $videouid['title'] = $xtubemyts->htmlSpecialCharsStrip($arr['title']); |
||
133 | $videouid['lid'] = $arr['lid']; |
||
134 | $videouid['cid'] = $arr['cid']; |
||
135 | $videouid['published'] = XoopstubeUtilities::xtubeGetTimestamp(formatTimestamp($arr['published'], $GLOBALS['xoopsModuleConfig']['dateformat'])); |
||
136 | $xoopsTpl->append('video_uid', $videouid); |
||
137 | } |
||
138 | } |
||
139 | |||
140 | // Copyright notice |
||
141 | if (isset($GLOBALS['xoopsModuleConfig']['copyright']) && $GLOBALS['xoopsModuleConfig']['copyright'] == 1) { |
||
142 | $xoopsTpl->assign('lang_copyright', '' . $video['publisher'] . ' © ' . _MD_XOOPSTUBE_COPYRIGHT . ' ' . formatTimestamp(time(), 'Y') . ' - ' . XOOPS_URL); |
||
143 | } |
||
144 | |||
145 | // Show other videos by submitter |
||
146 | if (isset($GLOBALS['xoopsModuleConfig']['othervideos']) && $GLOBALS['xoopsModuleConfig']['othervideos'] == 1) { |
||
147 | $xoopsTpl->assign('other_videos', '<b>' . _MD_XOOPSTUBE_OTHERBYUID . '</b>' . $video['submitter'] . '<br>'); |
||
148 | } else { |
||
149 | $xoopsTpl->assign('other_videos', '<b>' . _MD_XOOPSTUBE_NOOTHERBYUID . '</b>' . $video['submitter'] . '<br>'); |
||
150 | } |
||
151 | |||
152 | $video['showsubmitterx'] = $GLOBALS['xoopsModuleConfig']['showsubmitter']; |
||
153 | $video['showsbookmarx'] = $GLOBALS['xoopsModuleConfig']['showsbookmarks']; |
||
154 | $video['othervideox'] = $GLOBALS['xoopsModuleConfig']['othervideos']; |
||
155 | $xoopsTpl->assign('video', $video); |
||
156 | |||
157 | $xoopsTpl->assign('back', |
||
158 | '<a href="javascript:history.go(-1)"><img src="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/assets/images/icon/back.png" /></a>'); // Displays Back button |
||
159 | $xoopsTpl->assign('module_dir', $xoopsModule->getVar('dirname')); |
||
160 | |||
161 | include XOOPS_ROOT_PATH . '/include/comment_view.php'; |
||
162 | include XOOPS_ROOT_PATH . '/footer.php'; |
||
163 |
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