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

index.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
$start = xtubeCleanRequestVars($_REQUEST, 'start', 0);
25
$start = intval($start);
26
27
$xoopsOption['template_main'] = 'xoopstube_index.tpl';
28
include XOOPS_ROOT_PATH . '/header.php';
29
30
global $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...
31
32
$mytree = new XoopstubeTree($xoopsDB->prefix('xoopstube_cat'), 'cid', 'pid');
33
34
// Begin Main page Heading etc
35
$sql      = 'SELECT * FROM ' . $xoopsDB->prefix('xoopstube_indexpage');
36
$head_arr = $xoopsDB->fetchArray($xoopsDB->query($sql));
37
38
$catarray['imageheader']      = xtubeRenderImageHeader($head_arr['indeximage'], $head_arr['indexheading']);
39
$catarray['indexheaderalign'] = $xtubemyts->htmlSpecialCharsStrip($head_arr['indexheaderalign']);
40
$catarray['indexfooteralign'] = $xtubemyts->htmlSpecialCharsStrip($head_arr['indexfooteralign']);
41
42
$html   = ($head_arr['nohtml']) ? 0 : 1;
43
$smiley = ($head_arr['nosmiley']) ? 0 : 1;
44
$xcodes = ($head_arr['noxcodes']) ? 0 : 1;
45
$images = ($head_arr['noimages']) ? 0 : 1;
46
$breaks = ($head_arr['nobreak']) ? 1 : 0;
47
48
$catarray['indexheading'] = $xtubemyts->displayTarea(
49
    $head_arr['indexheading'],
50
    $html,
51
    $smiley,
52
    $xcodes,
53
    $images,
54
    $breaks
55
);
56
$catarray['indexheader']  = $xtubemyts->displayTarea(
57
    $head_arr['indexheader'],
58
    $html,
59
    $smiley,
60
    $xcodes,
61
    $images,
62
    $breaks
63
);
64
$catarray['indexfooter']  = $xtubemyts->displayTarea(
65
    $head_arr['indexfooter'],
66
    $html,
67
    $smiley,
68
    $xcodes,
69
    $images,
70
    $breaks
71
);
72
$catarray['letters']      = xtubeGetLetters();
73
$xoopsTpl->assign('catarray', $catarray);
74
// End main page Headers
75
76
$count   = 1;
77
$chcount = 0;
78
$countin = 0;
79
80
// Begin Main page linkload info
81
$listings = xtubeGetTotalItems();
82
// get total amount of categories
83
$total_cat = xtubeGetTotalCategoryCount();
84
85
$catsort = $xoopsModuleConfig['sortcats'];
86
$sql     = 'SELECT * FROM ' . $xoopsDB->prefix('xoopstube_cat') . ' WHERE pid=0 ORDER BY ' . $catsort;
87
$result  = $xoopsDB->query($sql);
88
while ($myrow = $xoopsDB->fetchArray($result)) {
89
    ++$countin;
90
    $subtotalvideoload = 0;
91
    $totalvideoload    = xtubeGetTotalItems($myrow['cid'], 1);
92
    $indicator         = xtubeIsNewImage($totalvideoload['published']);
93
    if (xtubeCheckGroups($myrow['cid'])) {
94
        $title = $xtubemyts->htmlSpecialCharsStrip($myrow['title']);
95
96
        $arr = array();
97
        $arr = $mytree->getFirstChild($myrow['cid'], 'title');
98
99
        $space         = 1;
100
        $chcount       = 1;
101
        $subcategories = '';
102
        foreach ($arr as $ele) {
103
            if (true == xtubeCheckGroups($ele['cid'])) {
104
                if ($xoopsModuleConfig['subcats'] == 1) {
105
                    $chtitle = $xtubemyts->htmlSpecialCharsStrip($ele['title']);
106
                    if ($chcount > 5) {
107
                        $subcategories .= '...';
108
                        break;
109
                    }
110
                    if ($space > 0) {
111
                        $subcategories .= '<br />';
112
                    }
113
                    $subcategories
114
                        .= '<a href="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewcat.php?cid=' . $ele['cid'] . '">' . $chtitle . '</a>';
115
                    ++$space;
116
                    ++$chcount;
117
                }
118
            }
119
        }
120
121
        // This code is copyright WF-Projects
122
        // Using this code without our permission or removing this code voids the license agreement
123
        $_image = ($myrow['imgurl']) ? urldecode($myrow['imgurl']) : '';
124 View Code Duplication
        if ($_image != "" && $xoopsModuleConfig['usethumbs']) {
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...
125
            $_thumb_image = new XtubeThumbsNails($_image, $xoopsModuleConfig['catimage'], 'thumbs');
126
            if ($_thumb_image) {
127
                $_thumb_image->setUseThumbs(1);
128
                $_thumb_image->setImageType('gd2');
129
                $_image = $_thumb_image->createThumbnail(
130
                    $xoopsModuleConfig['shotwidth'],
131
                    $xoopsModuleConfig['shotheight'],
132
                    $xoopsModuleConfig['imagequality'],
133
                    $xoopsModuleConfig['updatethumbs'],
134
                    $xoopsModuleConfig['keepaspect']
135
                );
136
            }
137
        }
138 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.

Loading history...
139
            $imgurl  = $indicator['image'];
140
            $_width  = 33;
141
            $_height = 24;
142
        } else {
143
            $imgurl  = "{$xoopsModuleConfig['catimage']}/$_image";
144
            $_width  = $xoopsModuleConfig['shotwidth'];
145
            $_height = $xoopsModuleConfig['shotheight'];
146
        }
147
        // End
148
149
        $xoopsTpl->append(
150
            'categories',
151
            array(
152
                'image'         => XOOPS_URL . "/$imgurl",
153
                'id'            => $myrow['cid'],
154
                'title'         => $title,
155
                'subcategories' => $subcategories,
156
                'totalvideos'   => $totalvideoload['count'],
157
                'width'         => $_width,
158
                'height'        => $_height,
159
                'count'         => $count,
160
                'alttext'       => $myrow['description']
161
            )
162
        );
163
        ++$count;
164
    }
165
}
166
switch ($total_cat) {
167
    case '1':
168
        $lang_thereare = _MD_XOOPSTUBE_THEREIS;
169
        break;
170
    default:
171
        $lang_thereare = _MD_XOOPSTUBE_THEREARE;
172
        break;
173
}
174
175
$time = time();
176
177
$sql        = $xoopsDB->query('SELECT lastvideosyn, lastvideostotal FROM ' . $xoopsDB->prefix('xoopstube_indexpage'));
178
$lastvideos = $xoopsDB->fetchArray($sql);
179
180
if ($lastvideos['lastvideosyn'] == 1 && $lastvideos['lastvideostotal'] > 0) {
181
182
    $result = $xoopsDB->query(
183
        'SELECT COUNT(*) FROM ' . $xoopsDB->prefix('xoopstube_videos') . ' WHERE published > 0
184
                                AND published <= ' . $time . '
185
                                AND (expired = 0 OR expired > ' . $time . ')
186
                                AND offline = 0
187
                                ORDER BY published DESC',
188
        0,
189
        0
190
    );
191
    list($count) = $xoopsDB->fetchRow($result);
192
193
    $count = (($count > $lastvideos['lastvideostotal'])
194
        && ($lastvideos['lastvideostotal'] != 0)) ? $lastvideos['lastvideostotal'] : $count;
195
    $limit = (($start + $xoopsModuleConfig['perpage']) > $count) ? ($count - $start) : $xoopsModuleConfig['perpage'];
196
197
    $result = $xoopsDB->query(
198
        'SELECT * FROM ' . $xoopsDB->prefix('xoopstube_videos') . ' WHERE published > 0
199
                                AND published <= ' . time() . '
200
                                AND (expired = 0 OR expired > ' . time() . ')
201
                                AND offline = 0
202
                                ORDER BY published DESC',
203
        $limit,
204
        $start
205
    );
206
207
    while ($video_arr = $xoopsDB->fetchArray($result)) {
208
        if (xtubeCheckGroups($video_arr['cid']) == true) {
209
            $res_type = 0;
210
            $moderate = 0;
211
            $cid      = $video_arr['cid'];
212
            require XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/videoloadinfo.php';
213
            $xoopsTpl->append('video', $video);
214
        }
215
    }
216
217
    $pagenav = new XoopsPageNav($count, $xoopsModuleConfig['perpage'], $start, 'start');
218
    $xoopsTpl->assign('pagenav', $pagenav->renderNav());
219
    $xoopsTpl->assign('showlatest', $lastvideos['lastvideosyn']);
220
}
221
222
$xoopsTpl->assign('cat_columns', $xoopsModuleConfig['catcolumns']);
223
$xoopsTpl->assign('lang_thereare', sprintf($lang_thereare, $total_cat, $listings['count']));
224
$xoopsTpl->assign('module_dir', $xoopsModule->getVar('dirname'));
225
226
include XOOPS_ROOT_PATH . '/footer.php';
227