Completed
Pull Request — master (#12)
by Michael
02:42
created

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
$start = XoopsRequest::getInt('start', XoopsRequest::getInt('start', 0, 'POST'), 'GET');
24
25
$xoopsOption['template_main'] = 'xoopstube_index.tpl';
26
include XOOPS_ROOT_PATH . '/header.php';
27
28
$mytree = new XoopstubeTree($GLOBALS['xoopsDB']->prefix('xoopstube_cat'), 'cid', 'pid');
29
30
// Begin Main page Heading etc
31
$sql      = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_indexpage');
32
$head_arr = $GLOBALS['xoopsDB']->fetchArray($GLOBALS['xoopsDB']->query($sql));
33
34
$catarray['imageheader']      = XoopstubeUtilities::xtubeRenderImageHeader($head_arr['indeximage'], $head_arr['indexheading']);
35
$catarray['indexheaderalign'] = $xtubemyts->htmlSpecialCharsStrip($head_arr['indexheaderalign']);
36
$catarray['indexfooteralign'] = $xtubemyts->htmlSpecialCharsStrip($head_arr['indexfooteralign']);
37
38
$html   = $head_arr['nohtml'] ? 0 : 1;
39
$smiley = $head_arr['nosmiley'] ? 0 : 1;
40
$xcodes = $head_arr['noxcodes'] ? 0 : 1;
41
$images = $head_arr['noimages'] ? 0 : 1;
42
$breaks = $head_arr['nobreak'] ? 1 : 0;
43
44
$catarray['indexheading'] =& $xtubemyts->displayTarea($head_arr['indexheading'], $html, $smiley, $xcodes, $images, $breaks);
45
$catarray['indexheader']  =& $xtubemyts->displayTarea($head_arr['indexheader'], $html, $smiley, $xcodes, $images, $breaks);
46
$catarray['indexfooter']  =& $xtubemyts->displayTarea($head_arr['indexfooter'], $html, $smiley, $xcodes, $images, $breaks);
47
//$catarray['letters']      = XoopstubeUtilities::xtubeGetLetters();
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% 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.

Loading history...
48
$catarray['letters'] = XoopstubeUtilities::xoopstubeLettersChoice();
49
$xoopsTpl->assign('catarray', $catarray);
50
// End main page Headers
51
52
$count   = 1;
53
$chcount = 0;
54
$countin = 0;
55
56
// Begin Main page linkload info
57
$listings = XoopstubeUtilities::xtubeGetTotalItems();
58
// get total amount of categories
59
$total_cat = XoopstubeUtilities::xtubeGetTotalCategoryCount();
60
61
$catsort = $GLOBALS['xoopsModuleConfig']['sortcats'];
62
$sql     = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_cat') . ' WHERE pid=0 ORDER BY ' . $catsort;
63
$result  = $GLOBALS['xoopsDB']->query($sql);
64
while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result))) {
65
    ++$countin;
66
    $subtotalvideoload = 0;
67
    $totalvideoload    = XoopstubeUtilities::xtubeGetTotalItems($myrow['cid'], 1);
68
    $indicator         = XoopstubeUtilities::xtubeIsNewImage($totalvideoload['published']);
69
    if (XoopstubeUtilities::xtubeCheckGroups($myrow['cid'])) {
70
        $title = $xtubemyts->htmlSpecialCharsStrip($myrow['title']);
71
72
        $arr = array();
73
        $arr = $mytree->getFirstChild($myrow['cid'], 'title');
74
75
        $space         = 1;
76
        $chcount       = 1;
77
        $subcategories = '';
78 View Code Duplication
        foreach ($arr as $ele) {
79
            if (true === XoopstubeUtilities::xtubeCheckGroups($ele['cid'])) {
80
                if ($GLOBALS['xoopsModuleConfig']['subcats'] == 1) {
81
                    $chtitle = $xtubemyts->htmlSpecialCharsStrip($ele['title']);
82
                    if ($chcount > 5) {
83
                        $subcategories .= '...';
84
                        break;
85
                    }
86
                    if ($space > 0) {
87
                        $subcategories .= '<br>';
88
                    }
89
                    $subcategories .= '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewcat.php?cid=' . $ele['cid'] . '">' . $chtitle . '</a>';
90
                    ++$space;
91
                    ++$chcount;
92
                }
93
            }
94
        }
95
96
        // This code is copyright WF-Projects
97
        // Using this code without our permission or removing this code voids the license agreement
98
        $_image = $myrow['imgurl'] ? urldecode($myrow['imgurl']) : '';
99 View Code Duplication
        if ($_image !== '' && $GLOBALS['xoopsModuleConfig']['usethumbs']) {
100
            $_thumb_image = new XtubeThumbsNails($_image, $GLOBALS['xoopsModuleConfig']['catimage'], 'thumbs');
101
            if ($_thumb_image) {
102
                $_thumb_image->setUseThumbs(1);
103
                $_thumb_image->setImageType('gd2');
104
                $_image = $_thumb_image->createThumbnail($GLOBALS['xoopsModuleConfig']['shotwidth'], $GLOBALS['xoopsModuleConfig']['shotheight'], $GLOBALS['xoopsModuleConfig']['imagequality'],
105
                                                         $GLOBALS['xoopsModuleConfig']['updatethumbs'], $GLOBALS['xoopsModuleConfig']['imageAspect']);
106
            }
107
        }
108 View Code Duplication
        if (empty($_image) || '' === $_image) {
109
            $imgurl  = $indicator['image'];
110
            $_width  = 33;
111
            $_height = 24;
112
        } else {
113
            $imgurl  = "{$GLOBALS['xoopsModuleConfig']['catimage']}/$_image";
114
            $_width  = $GLOBALS['xoopsModuleConfig']['shotwidth'];
115
            $_height = $GLOBALS['xoopsModuleConfig']['shotheight'];
116
        }
117
        // End
118
119
        $xoopsTpl->append('categories', array(
120
            'image'         => XOOPS_URL . "/$imgurl",
121
            'id'            => $myrow['cid'],
122
            'title'         => $title,
123
            'subcategories' => $subcategories,
124
            'totalvideos'   => $totalvideoload['count'],
125
            'width'         => $_width,
126
            'height'        => $_height,
127
            'count'         => $count,
128
            'alttext'       => $myrow['description']
129
        ));
130
        ++$count;
131
    }
132
}
133
switch ($total_cat) {
134
    case '1':
135
        $lang_thereare = _MD_XOOPSTUBE_THEREIS;
136
        break;
137
    default:
138
        $lang_thereare = _MD_XOOPSTUBE_THEREARE;
139
        break;
140
}
141
142
$time = time();
143
144
$sql        = $GLOBALS['xoopsDB']->query('SELECT lastvideosyn, lastvideostotal FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_indexpage'));
145
$lastvideos = $GLOBALS['xoopsDB']->fetchArray($sql);
146
147
if ($lastvideos['lastvideosyn'] == 1 && $lastvideos['lastvideostotal'] > 0) {
148
    $result = $GLOBALS['xoopsDB']->query('SELECT COUNT(*) FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' WHERE published > 0
149
                                AND published <= ' . $time . '
150
                                AND (expired = 0 OR expired > ' . $time . ')
151
                                AND offline = 0
152
                                ORDER BY published DESC', 0, 0);
153
    list($count) = $GLOBALS['xoopsDB']->fetchRow($result);
154
155
    $count = (($count > $lastvideos['lastvideostotal']) && ($lastvideos['lastvideostotal'] !== 0)) ? $lastvideos['lastvideostotal'] : $count;
156
    $limit = (($start + $GLOBALS['xoopsModuleConfig']['perpage']) > $count) ? ($count - $start) : $GLOBALS['xoopsModuleConfig']['perpage'];
157
158
    $result = $GLOBALS['xoopsDB']->query('SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' WHERE published > 0
159
                                AND published <= ' . time() . '
160
                                AND (expired = 0 OR expired > ' . time() . ')
161
                                AND offline = 0
162
                                ORDER BY published DESC', $limit, $start);
163
164
    while (false !== ($video_arr = $GLOBALS['xoopsDB']->fetchArray($result))) {
165
        if (true === XoopstubeUtilities::xtubeCheckGroups($video_arr['cid'])) {
166
            $res_type = 0;
167
            $moderate = 0;
168
            $cid      = $video_arr['cid'];
169
            require XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/videoloadinfo.php';
170
            $xoopsTpl->append('video', $video);
171
        }
172
    }
173
174
    $pagenav = new XoopsPageNav($count, $GLOBALS['xoopsModuleConfig']['perpage'], $start, 'start');
175
    $xoopsTpl->assign('pagenav', $pagenav->renderNav());
176
    $xoopsTpl->assign('showlatest', $lastvideos['lastvideosyn']);
177
}
178
179
$xoopsTpl->assign('cat_columns', $GLOBALS['xoopsModuleConfig']['catcolumns']);
180
$xoopsTpl->assign('lang_thereare', sprintf($lang_thereare, $total_cat, $listings['count']));
181
$xoopsTpl->assign('module_dir', $xoopsModule->getVar('dirname'));
182
183
include XOOPS_ROOT_PATH . '/footer.php';
184