Completed
Branch master (954431)
by Michael
06:30 queued 03:05
created

singlevideo.php (3 issues)

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-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
$lid = xtubeCleanRequestVars($_REQUEST, 'lid', 0);
25
$cid = xtubeCleanRequestVars($_REQUEST, 'cid', 0);
26
$lid = intval($lid);
27
$cid = intval($cid);
28
29
$sql2 = 'SELECT count(*) FROM ' . $xoopsDB->prefix('xoopstube_videos') . ' a LEFT JOIN ' . $xoopsDB->prefix(
30
        'xoopstube_altcat'
31
    ) . ' b' . ' ON b.lid = a.lid' . ' 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='
32
    . intval($cid) . ' OR b.cid=' . intval($cid) . '))';
33
list($count) = $xoopsDB->fetchRow($xoopsDB->query($sql2));
34
35
if (false == xtubeCheckGroups($cid) || $count == 0) {
36
    redirect_header('index.php', 1, _MD_XOOPSTUBE_MUSTREGFIRST);
37
    exit();
38
}
39
40
$sql       = 'SELECT * FROM ' . $xoopsDB->prefix('xoopstube_videos') . ' WHERE lid=' . intval($lid) . '
41
        AND (published > 0 AND published <= ' . time() . ')
42
        AND (expired = 0 OR expired > ' . time() . ')
43
        AND offline = 0
44
        AND cid > 0';
45
$result    = $xoopsDB->query($sql);
46
$video_arr = $xoopsDB->fetchArray($result);
47
48
if (!is_array($video_arr)) {
49
    redirect_header('index.php', 1, _MD_XOOPSTUBE_NOVIDEOLOAD);
50
    exit();
51
}
52
53
$xoopsOption['template_main'] = 'xoopstube_singlevideo.tpl';
54
55
include XOOPS_ROOT_PATH . '/header.php';
56
57
// tags support
58
if (xtubeIsModuleTagInstalled()) {
59
    include_once XOOPS_ROOT_PATH . '/modules/tag/include/tagbar.php';
60
    $xoopsTpl->assign('tagbar', tagBar($video_arr['lid'], 0));
61
}
62
63
$video['imageheader']  = xtubeRenderImageHeader();
64
$video['id']           = $video_arr['lid'];
65
$video['cid']          = $video_arr['cid'];
66
$video['vidid']        = $video_arr['vidid'];
67
$video['description2'] = $xtubemyts->displayTarea($video_arr['description'], 1, 1, 1, 1, 1);
68
69
$mytree     = new XoopstubeTree($xoopsDB->prefix('xoopstube_cat'), 'cid', 'pid');
70
$pathstring = '<a href="index.php">' . _MD_XOOPSTUBE_MAIN . '</a>&nbsp;:&nbsp;';
71
$pathstring .= $mytree->getNicePathFromId($cid, 'title', 'viewcat.php?op=');
72
$video['path'] = $pathstring;
73
// Get video from source
74
$video['showvideo'] = xtubeShowVideo(
75
    $video_arr['vidid'],
76
    $video_arr['vidsource'],
77
    $video_arr['screenshot'],
78
    $video_arr['picurl']
79
);
80
81
// Get Social Bookmarks
82
$video['sbmarks'] = getSocialBookmarks($video_arr['lid']);
83
84
// Start of meta tags
85
global $xoopsTpl, $xoTheme, $xoopsModuleConfig;
0 ignored issues
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 global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
86
87
$maxWords = 100;
88
$words    = array();
89
$words    = explode(' ', xtubeConvertHtml2Text($video_arr['description']));
90
$newWords = array();
91
$i        = 0;
92
while ($i < $maxWords - 1 && $i < count($words)) {
93
    if (isset($words[$i])) {
94
        $newWords[] = trim($words[$i]);
95
    }
96
    ++$i;
97
}
98
$video_meta_description = implode(' ', $newWords);
99
100
if (is_object($xoTheme)) {
101
    if ($video_arr['keywords']) {
102
        $xoTheme->addMeta('meta', 'keywords', $video_arr['keywords']);
103
    }
104
    $xoTheme->addMeta('meta', 'title', $video_arr['title']);
105
    if ($xoopsModuleConfig['usemetadescr'] == 1) {
106
        $xoTheme->addMeta('meta', 'description', $video_meta_description);
107
    }
108
} else {
109
    if ($video_arr['keywords']) {
110
        $xoopsTpl->assign('xoops_meta_keywords', $video_arr['keywords']);
111
    }
112
    if ($xoopsModuleConfig['usemetadescr'] == 1) {
113
        $xoopsTpl->assign('xoops_meta_description', $video_meta_description);
114
    }
115
}
116
$xoopsTpl->assign('xoops_pagetitle', $video_arr['title']);
117
// End of meta tags
118
119
$moderate = 0;
120
include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getvar('dirname') . '/include/videoloadinfo.php';
121
122
$xoopsTpl->assign('show_screenshot', false);
123 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.

Loading history...
124
    $xoopsTpl->assign('shotwidth', $xoopsModuleConfig['shotwidth']);
125
    $xoopsTpl->assign('shotheight', $xoopsModuleConfig['shotheight']);
126
    $xoopsTpl->assign('show_screenshot', true);
127
}
128
129
if ($video['isadmin'] == false) {
130
    $count = xtubeUpdateCounter($lid);
0 ignored issues
show
Are you sure the assignment to $count is correct as xtubeUpdateCounter($lid) (which targets 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...
131
}
132
133
// Show other author videos
134
$sql    = 'SELECT lid, cid, title, published FROM ' . $xoopsDB->prefix('xoopstube_videos') . '
135
        WHERE submitter=' . $video_arr['submitter'] . '
136
        AND lid <> ' . $video_arr['lid'] . '
137
        AND published > 0 AND published <= ' . time() . ' AND (expired = 0 OR expired > ' . time() . ')
138
        AND offline = 0 ORDER by published DESC';
139
$result = $xoopsDB->query($sql, 10, 0);
140
141
while ($arr = $xoopsDB->fetchArray($result)) {
142
    if (xtubeCheckGroups($arr['cid']) == true) {
143
        $videouid['title']     = $xtubemyts->htmlSpecialCharsStrip($arr['title']);
144
        $videouid['lid']       = $arr['lid'];
145
        $videouid['cid']       = $arr['cid'];
146
        $videouid['published'] = xtubeGetTimestamp(
147
            formatTimestamp($arr['published'], $xoopsModuleConfig['dateformat'])
148
        );
149
        $xoopsTpl->append('video_uid', $videouid);
150
    }
151
}
152
153
// Copyright notice
154
if (isset($xoopsModuleConfig['copyright']) && $xoopsModuleConfig['copyright'] == 1) {
155
    $xoopsTpl->assign(
156
        'lang_copyright',
157
        '' . $video['publisher'] . ' &#0169; ' . _MD_XOOPSTUBE_COPYRIGHT . ' ' . formatTimestamp(time(), 'Y') . ' - ' . XOOPS_URL
158
    );
159
}
160
161
// Show other videos by submitter
162
if (isset($xoopsModuleConfig['othervideos']) && $xoopsModuleConfig['othervideos'] == 1) {
163
    $xoopsTpl->assign('other_videos', '<b>' . _MD_XOOPSTUBE_OTHERBYUID . '</b>' . $video['submitter'] . '<br />');
164
} else {
165
    $xoopsTpl->assign('other_videos', '<b>' . _MD_XOOPSTUBE_NOOTHERBYUID . '</b>' . $video['submitter'] . '<br />');
166
}
167
168
$video['showsubmitterx'] = $xoopsModuleConfig['showsubmitter'];
169
$video['showsbookmarx']  = $xoopsModuleConfig['showsbookmarks'];
170
$video['othervideox']    = $xoopsModuleConfig['othervideos'];
171
$xoopsTpl->assign('video', $video);
172
173
$xoopsTpl->assign(
174
    'back',
175
    '<a href="javascript:history.go(-1)"><img src="' . XOOPS_URL . '/modules/' . $xoopsModule->getvar('dirname') . '/assets/images/icon/back.png" /></a>'
176
); // Displays Back button
177
$xoopsTpl->assign('module_dir', $xoopsModule->getVar('dirname'));
178
179
include XOOPS_ROOT_PATH . '/include/comment_view.php';
180
include XOOPS_ROOT_PATH . '/footer.php';
181