Completed
Branch master (ddc2b8)
by Michael
02:46
created

singlevideo.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

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
$xoTheme->addStylesheet('modules/'.$moduleDirName.'/assets/css/xtubestyle.css');
52
53
// tags support
54
if (XoopstubeUtilities::xtubeIsModuleTagInstalled()) {
55
    include_once XOOPS_ROOT_PATH . '/modules/tag/include/tagbar.php';
56
    $xoopsTpl->assign('tagbar', tagBar($video_arr['lid'], 0));
57
}
58
59
$video['imageheader']  = XoopstubeUtilities::xtubeRenderImageHeader();
60
$video['id']           = $video_arr['lid'];
61
$video['cid']          = $video_arr['cid'];
62
$video['vidid']        = $video_arr['vidid'];
63
$video['description2'] =& $xtubemyts->displayTarea($video_arr['description'], 1, 1, 1, 1, 1);
64
65
$mytree     = new XoopstubeTree($GLOBALS['xoopsDB']->prefix('xoopstube_cat'), 'cid', 'pid');
66
$pathstring = '<a href="index.php">' . _MD_XOOPSTUBE_MAIN . '</a>&nbsp;:&nbsp;';
67
$pathstring .= $mytree->getNicePathFromId($cid, 'title', 'viewcat.php?op=');
68
$video['path'] = $pathstring;
69
// Get video from source
70
$video['showvideo'] = xtubeShowVideo($video_arr['vidid'], $video_arr['vidsource'], $video_arr['screenshot'], $video_arr['picurl']);
71
72
// Get Social Bookmarks
73
$video['sbmarks'] = getSocialBookmarks($video_arr['lid']);
74
75
// Start of meta tags
76
global $xoopsTpl, $xoTheme;
77
78
$maxWords = 100;
79
$words    = array();
80
$words    = explode(' ', XoopstubeUtilities::xtubeConvertHtml2Text($video_arr['description']));
81
$newWords = array();
82
$i        = 0;
83
while ($i < $maxWords - 1 && $i < count($words)) {
84
    if (isset($words[$i])) {
85
        $newWords[] = trim($words[$i]);
86
    }
87
    ++$i;
88
}
89
$video_meta_description = implode(' ', $newWords);
90
91
if (is_object($GLOBALS['xoTheme'])) {
92
    if ($video_arr['keywords']) {
93
        $GLOBALS['xoTheme']->addMeta('meta', 'keywords', $video_arr['keywords']);
94
    }
95
    $GLOBALS['xoTheme']->addMeta('meta', 'title', $video_arr['title']);
96
    if ($GLOBALS['xoopsModuleConfig']['usemetadescr'] == 1) {
97
        $GLOBALS['xoTheme']->addMeta('meta', 'description', $video_meta_description);
98
    }
99
} else {
100
    if ($video_arr['keywords']) {
101
        $xoopsTpl->assign('xoops_meta_keywords', $video_arr['keywords']);
102
    }
103
    if ($GLOBALS['xoopsModuleConfig']['usemetadescr'] == 1) {
104
        $GLOBALS['xoTheme']->assign('xoops_meta_description', $video_meta_description);
105
    }
106
}
107
$xoopsTpl->assign('xoops_pagetitle', $video_arr['title']);
108
// End of meta tags
109
110
$moderate = 0;
111
include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/videoloadinfo.php';
112
113
$xoopsTpl->assign('show_screenshot', false);
114 View Code Duplication
if (isset($GLOBALS['xoopsModuleConfig']['screenshot']) && $GLOBALS['xoopsModuleConfig']['screenshot'] == 1) {
115
    $xoopsTpl->assign('shotwidth', $GLOBALS['xoopsModuleConfig']['shotwidth']);
116
    $xoopsTpl->assign('shotheight', $GLOBALS['xoopsModuleConfig']['shotheight']);
117
    $xoopsTpl->assign('show_screenshot', true);
118
}
119
120
if (false === $video['isadmin']) {
121
    $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 getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
122
}
123
124
// Show other author videos
125
$sql    = 'SELECT lid, cid, title, published FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . '
126
        WHERE submitter=' . $video_arr['submitter'] . '
127
        AND lid <> ' . $video_arr['lid'] . '
128
        AND published > 0 AND published <= ' . time() . ' AND (expired = 0 OR expired > ' . time() . ')
129
        AND offline = 0 ORDER by published DESC';
130
$result = $GLOBALS['xoopsDB']->query($sql, 10, 0);
131
132
while (false !== ($arr = $GLOBALS['xoopsDB']->fetchArray($result))) {
133
    if (true === XoopstubeUtilities::xtubeCheckGroups($arr['cid'])) {
134
        $videouid['title']     = $xtubemyts->htmlSpecialCharsStrip($arr['title']);
135
        $videouid['lid']       = $arr['lid'];
136
        $videouid['cid']       = $arr['cid'];
137
        $videouid['published'] = XoopstubeUtilities::xtubeGetTimestamp(formatTimestamp($arr['published'], $GLOBALS['xoopsModuleConfig']['dateformat']));
138
        $xoopsTpl->append('video_uid', $videouid);
139
    }
140
}
141
142
// Copyright notice
143
if (isset($GLOBALS['xoopsModuleConfig']['copyright']) && $GLOBALS['xoopsModuleConfig']['copyright'] == 1) {
144
    $xoopsTpl->assign('lang_copyright', '' . $video['publisher'] . ' &#0169; ' . _MD_XOOPSTUBE_COPYRIGHT . ' ' . formatTimestamp(time(), 'Y') . ' - ' . XOOPS_URL);
145
}
146
147
// Show other videos by submitter
148
if (isset($GLOBALS['xoopsModuleConfig']['othervideos']) && $GLOBALS['xoopsModuleConfig']['othervideos'] == 1) {
149
    $xoopsTpl->assign('other_videos', '<b>' . _MD_XOOPSTUBE_OTHERBYUID . '</b>' . $video['submitter'] . '<br>');
150
} else {
151
    $xoopsTpl->assign('other_videos', '<b>' . _MD_XOOPSTUBE_NOOTHERBYUID . '</b>' . $video['submitter'] . '<br>');
152
}
153
154
$video['showsubmitterx'] = $GLOBALS['xoopsModuleConfig']['showsubmitter'];
155
$video['showsbookmarx']  = $GLOBALS['xoopsModuleConfig']['showsbookmarks'];
156
$video['othervideox']    = $GLOBALS['xoopsModuleConfig']['othervideos'];
157
$xoopsTpl->assign('video', $video);
158
159
$xoopsTpl->assign('back',
160
                  '<a href="javascript:history.go(-1)"><img src="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/assets/images/icon/back.png" /></a>'); // Displays Back button
161
$xoopsTpl->assign('module_dir', $xoopsModule->getVar('dirname'));
162
163
include XOOPS_ROOT_PATH . '/include/comment_view.php';
164
include XOOPS_ROOT_PATH . '/footer.php';
165