1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Module: XoopsTube |
4
|
|
|
* |
5
|
|
|
* You may not change or alter any portion of this comment or credits |
6
|
|
|
* of supporting developers from this source code or any supporting source code |
7
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
8
|
|
|
* |
9
|
|
|
* PHP version 5 |
10
|
|
|
* |
11
|
|
|
* @category Module |
12
|
|
|
* @package Xoopstube |
13
|
|
|
* @author XOOPS Development Team |
14
|
|
|
* @copyright 2001-2016 XOOPS Project (http://xoops.org) |
15
|
|
|
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
16
|
|
|
* @link http://xoops.org/ |
17
|
|
|
* @since 1.0.6 |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @param int $cid |
22
|
|
|
* @param string $permType |
23
|
|
|
* @param bool $redirect |
24
|
|
|
* |
25
|
|
|
* @return bool |
26
|
|
|
*/ |
27
|
|
View Code Duplication |
function checkBlockGroups($cid = 0, $permType = 'XTubeCatPerm', $redirect = false) |
|
|
|
|
28
|
|
|
{ |
29
|
|
|
$moduleDirName = basename(dirname(__DIR__)); |
30
|
|
|
$groups = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS; |
31
|
|
|
$gpermHandler = xoops_getHandler('groupperm'); |
32
|
|
|
$moduleHandler = xoops_getHandler('module'); |
33
|
|
|
$module = $moduleHandler->getByDirname($moduleDirName); |
34
|
|
|
if (!$gpermHandler->checkRight($permType, $cid, $groups, $module->getVar('mid'))) { |
35
|
|
|
if (false === $redirect) { |
36
|
|
|
return false; |
37
|
|
|
} else { |
38
|
|
|
redirect_header('index.php', 3, _NOPERM); |
39
|
|
|
} |
40
|
|
|
} |
41
|
|
|
unset($module); |
42
|
|
|
|
43
|
|
|
return true; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @param int $cid |
48
|
|
|
* @param string $permType |
49
|
|
|
* @param bool $redirect |
50
|
|
|
* |
51
|
|
|
* @return bool |
52
|
|
|
*/ |
53
|
|
|
function xtubeCheckBlockGroups($cid = 0, $permType = 'XTubeCatPerm', $redirect = false) |
|
|
|
|
54
|
|
|
{ |
55
|
|
|
$moduleDirName = basename(dirname(__DIR__)); |
56
|
|
|
$groups = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS; |
57
|
|
|
$moduleHandler = xoops_getHandler('module'); |
58
|
|
|
$xtubeModule = $moduleHandler->getByDirname($moduleDirName); |
59
|
|
|
$gpermHandler = xoops_getHandler('groupperm'); |
60
|
|
|
if (!$gpermHandler->checkRight($permType, $cid, $groups, $xtubeModule->getVar('mid'))) { |
61
|
|
|
if (false === $redirect) { |
62
|
|
|
return false; |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
return true; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @param $bvidid |
71
|
|
|
* @param $btitle |
72
|
|
|
* @param $bsource |
73
|
|
|
* @param $bpicurl |
74
|
|
|
* @param array $size |
75
|
|
|
* |
76
|
|
|
* @return string |
77
|
|
|
*/ |
78
|
|
|
function getThumbsTopVideoBlock($bvidid, $btitle, $bsource, $bpicurl, $size = array()) |
79
|
|
|
{ |
80
|
|
|
$thumbb = ''; |
81
|
|
|
$moduleHandler = xoops_getHandler('module'); |
82
|
|
|
$xtubeModule = $moduleHandler->getByDirname('xoopstube'); |
83
|
|
|
$configHandler = xoops_getHandler('config'); |
84
|
|
|
$xtubeModuleConfig = $configHandler->getConfigsByCat(0, $xtubeModule->getVar('mid')); |
85
|
|
|
if (isset($size['shotwidth'])) { |
86
|
|
|
$xtubeModuleConfig['shotwidth'] = $size['shotwidth']; |
87
|
|
|
} |
88
|
|
|
if (isset($size['shotheight'])) { |
89
|
|
|
$xtubeModuleConfig['shotheight'] = $size['shotheight']; |
90
|
|
|
} |
91
|
|
|
// Determine if video source YouTube |
92
|
|
View Code Duplication |
if (0 == $bsource) { |
|
|
|
|
93
|
|
|
$thumbb = '<img src="http://img.youtube.com/vi/' . $bvidid . '/default.jpg" title="' . $btitle . '" alt="' . $btitle . '" width="' . $xtubeModuleConfig['shotwidth'] . '" height="' |
94
|
|
|
. $xtubeModuleConfig['shotheight'] . '" border="0" />'; |
95
|
|
|
} |
96
|
|
|
// Determine if video source MetaCafe |
97
|
|
|
if ($bsource == 1) { |
98
|
|
|
list($metaclip) = explode('[/]', $bvidid); |
99
|
|
|
$videothumb['metathumb'] = $metaclip; |
|
|
|
|
100
|
|
|
$thumbb = |
101
|
|
|
'<img src="http://www.metacafe.com/thumb/' . $videothumb['metathumb'] . '.jpg" title="' . $btitle . '" alt="' . $btitle . '" width="' . $xtubeModuleConfig['shotwidth'] . '" height="' |
102
|
|
|
. $xtubeModuleConfig['shotheight'] . '" border="0" />'; |
103
|
|
|
} |
104
|
|
|
// Determine if video source iFilm/Spike |
105
|
|
|
if ($bsource == 2) { |
106
|
|
|
$thumbb = '<img src="http://img2.ifilmpro.com/resize/image/stills/films/resize/istd/' . $bvidid . '.jpg?width=' . $xtubeModuleConfig['shotwidth'] . ' title="' . $btitle . '" alt="' . $btitle |
107
|
|
|
. '" border="0" />'; |
108
|
|
|
} |
109
|
|
|
// Determine if video source Photobucket |
110
|
|
View Code Duplication |
if ($bsource == 3) { |
|
|
|
|
111
|
|
|
$thumbb = '<img src="http://i153.photobucket.com/albums/' . $bvidid . '.jpg" title="' . $btitle . '" alt="' . $btitle . '" width="' . $xtubeModuleConfig['shotwidth'] . '" height="' |
112
|
|
|
. $xtubeModuleConfig['shotheight'] . '" border="0" />'; |
113
|
|
|
} |
114
|
|
|
// Determine if video source Google Video / MySpace TV / DailyMotion |
115
|
|
View Code Duplication |
if ($bsource == 100) { |
|
|
|
|
116
|
|
|
$thumbb = '<img src="' . $bpicurl . '" title="' . $btitle . '" alt="' . $btitle . '" width="' . $xtubeModuleConfig['shotwidth'] . '" height="' . $xtubeModuleConfig['shotheight'] |
117
|
|
|
. '" border="0" />'; |
118
|
|
|
} |
119
|
|
|
// Determine if video source MySpace TV |
120
|
|
View Code Duplication |
if ($bsource == 101) { |
|
|
|
|
121
|
|
|
$thumbb = '<img src="' . $bpicurl . '" title="' . $btitle . '" alt="' . $btitle . '" width="' . $xtubeModuleConfig['shotwidth'] . '" height="' . $xtubeModuleConfig['shotheight'] |
122
|
|
|
. '" border="0" />'; |
123
|
|
|
} |
124
|
|
|
// Determine if video source DailyMotion |
125
|
|
View Code Duplication |
if ($bsource == 102) { |
|
|
|
|
126
|
|
|
$thumbb = '<img src="' . $bpicurl . '" title="' . $btitle . '" alt="' . $btitle . '" width="' . $xtubeModuleConfig['shotwidth'] . '" height="' . $xtubeModuleConfig['shotheight'] |
127
|
|
|
. '" border="0" />'; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
return $thumbb; |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/* Function: b_xoopstube_spotlight_show |
134
|
|
|
* Input : $options[0] = date for the most recent videos |
135
|
|
|
* hits for the most popular videos |
136
|
|
|
* $block['content'] = The optional above content |
137
|
|
|
* $options[1] = How many videos are displayes |
138
|
|
|
* Output : Returns the most recent or most popular videos |
139
|
|
|
*/ |
140
|
|
|
/** |
141
|
|
|
* @param $options |
142
|
|
|
* |
143
|
|
|
* @return array |
|
|
|
|
144
|
|
|
*/ |
145
|
|
|
function getSpotlightVideos($options) |
|
|
|
|
146
|
|
|
{ |
147
|
|
|
include_once dirname(__DIR__) . '/include/video.php'; |
148
|
|
|
$block = array(); |
149
|
|
|
$moduleHandler = xoops_getHandler('module'); |
150
|
|
|
$xtubeModule = $moduleHandler->getByDirname('xoopstube'); |
151
|
|
|
$configHandler = xoops_getHandler('config'); |
152
|
|
|
$xtubeModuleConfig = $configHandler->getConfigsByCat(0, $xtubeModule->getVar('mid')); |
153
|
|
|
$xtubemyts = MyTextSanitizer:: getInstance(); |
154
|
|
|
|
155
|
|
|
$options[1] = 4; |
156
|
|
|
$result = |
157
|
|
|
$GLOBALS['xoopsDB']->query('SELECT lid, cid, title, vidid, date, hits, vidsource, picurl FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' WHERE published > 0 AND published <= ' |
158
|
|
|
. time() . ' AND (expired = 0 OR expired > ' . time() . ') AND offline = 0 ORDER BY ' . $options[0] . ' DESC', $options[1], 0); |
159
|
|
|
|
160
|
|
|
$i = 0; |
161
|
|
|
while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result))) { |
162
|
|
View Code Duplication |
if (false === checkBlockGroups($myrow['cid']) || $myrow['cid'] == 0) { |
|
|
|
|
163
|
|
|
continue; |
164
|
|
|
} |
165
|
|
|
if (false === xtubeCheckBlockGroups($myrow['cid'])) { |
166
|
|
|
exit; |
|
|
|
|
167
|
|
|
} |
168
|
|
|
$videoload = array(); |
169
|
|
|
$title = $xtubemyts->htmlSpecialChars($xtubemyts->stripSlashesGPC($myrow['title'])); |
170
|
|
View Code Duplication |
if (!XOOPS_USE_MULTIBYTES) { |
|
|
|
|
171
|
|
|
if (strlen($myrow['title']) >= $options[2]) { |
172
|
|
|
$title = substr($myrow['title'], 0, $options[2] - 1) . '...'; |
173
|
|
|
} |
174
|
|
|
} |
175
|
|
|
$videoload['id'] = (int)$myrow['lid']; |
176
|
|
|
$videoload['cid'] = (int)$myrow['cid']; |
177
|
|
|
$videoload['title'] = $title; |
178
|
|
View Code Duplication |
if ($options[0] == 'date') { |
|
|
|
|
179
|
|
|
$videoload['date'] = formatTimestamp($myrow['date'], $xtubeModuleConfig['dateformat']); |
180
|
|
|
} elseif ('hits' === $options[0]) { |
|
|
|
|
181
|
|
|
$videoload['hits'] = $myrow['hits']; |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
$size = array(); |
185
|
|
|
$rate = 425 / 350; |
186
|
|
|
$size['shotwidth'] = '100'; |
187
|
|
|
$size['shotheight'] = (int)($size['shotwidth'] / $rate); |
188
|
|
|
|
189
|
|
|
if (0 == $i && 0 == $myrow['vidsource']) { |
190
|
|
|
$videowidth = 340; |
191
|
|
|
$videoheight = (int)($videowidth / $rate); |
192
|
|
|
$showvideo = '<object width="' . $videowidth . '" height="' . $videoheight . '"><param name="movie" value="http://www.youtube.com/v/' . $myrow['vidid'] |
193
|
|
|
. '"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/' . $myrow['vidid'] |
194
|
|
|
. '" type="application/x-shockwave-flash" wmode="transparent" width="' . $videowidth . '" height="' . $videoheight . '"></embed></object>'; |
195
|
|
|
$videoload['showvideo'] = $showvideo; |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
$videoload['videothumb'] = getThumbsTopVideoBlock($myrow['vidid'], $title, $myrow['vidsource'], $myrow['picurl'], $size); |
199
|
|
|
|
200
|
|
|
$videoload['dirname'] = $xtubeModule->getVar('dirname'); |
201
|
|
|
$block['videos'][] = $videoload; |
202
|
|
|
++$i; |
203
|
|
|
} |
204
|
|
|
unset($_block_check_array); |
205
|
|
|
|
206
|
|
|
return $block; |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
// Function: showTopVideoBlock |
210
|
|
|
// Input : $options[0] = date for the most recent videos |
211
|
|
|
// hits for the most popular videos |
212
|
|
|
// $block['content'] = The optional above content |
213
|
|
|
// $options[1] = How many videos are displayes |
214
|
|
|
// $options[2] = Length of title |
215
|
|
|
// $options[3] = Set date format |
216
|
|
|
// Output : Returns the most recent or most popular videos |
217
|
|
|
/** |
218
|
|
|
* @param $options |
219
|
|
|
* |
220
|
|
|
* @return array |
|
|
|
|
221
|
|
|
*/ |
222
|
|
|
function showTopVideoBlock($options) |
|
|
|
|
223
|
|
|
{ |
224
|
|
|
$moduleDirName = basename(dirname(__DIR__)); |
225
|
|
|
$block = array(); |
226
|
|
|
$moduleHandler = xoops_getHandler('module'); |
227
|
|
|
$xtubeModule = $moduleHandler->getByDirname($moduleDirName); |
228
|
|
|
$configHandler = xoops_getHandler('config'); |
229
|
|
|
$xtubeModuleConfig = $configHandler->getConfigsByCat(0, $xtubeModule->getVar('mid')); |
230
|
|
|
$xtubemyts = MyTextSanitizer:: getInstance(); |
231
|
|
|
|
232
|
|
|
if (isset($options[4]) && ($options[4] > 0)) { |
233
|
|
|
$result = $GLOBALS['xoopsDB']->query('SELECT lid, cid, title, vidid, screenshot, published, hits, vidsource, picurl FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' WHERE published>0 |
234
|
|
|
AND published<=' . time() . ' |
235
|
|
|
AND (expired=0 OR expired>' . time() . ') |
236
|
|
|
AND offline=0 |
237
|
|
|
AND cid=' . $options[4] . ' |
238
|
|
|
ORDER BY ' . $options[0] . ' |
239
|
|
|
DESC', $options[1], 0); |
240
|
|
|
} else { |
241
|
|
|
$result = $GLOBALS['xoopsDB']->query('SELECT lid, cid, title, vidid, screenshot, published, hits, vidsource, picurl FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' WHERE published>0 |
242
|
|
|
AND published<=' . time() . ' |
243
|
|
|
AND (expired=0 OR expired>' . time() . ') |
244
|
|
|
AND offline=0 |
245
|
|
|
ORDER BY ' . $options[0] . ' |
246
|
|
|
DESC', $options[1], 0); |
247
|
|
|
} |
248
|
|
|
|
249
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/' . $xtubeModule->getVar('dirname') . '/include/video.php'; |
250
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/' . $xtubeModule->getVar('dirname') . '/class/utilities.php'; |
251
|
|
|
|
252
|
|
|
while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result))) { |
253
|
|
View Code Duplication |
if (false === checkBlockGroups($myrow['cid']) || 0 == $myrow['cid']) { |
|
|
|
|
254
|
|
|
continue; |
255
|
|
|
} |
256
|
|
|
|
257
|
|
|
if (false === xtubeCheckBlockGroups($myrow['cid'])) { |
258
|
|
|
exit; |
|
|
|
|
259
|
|
|
} |
260
|
|
|
|
261
|
|
|
$videoload = array(); |
262
|
|
|
$title = $xtubemyts->htmlSpecialChars($xtubemyts->stripSlashesGPC($myrow['title'])); |
263
|
|
View Code Duplication |
if (!XOOPS_USE_MULTIBYTES) { |
|
|
|
|
264
|
|
|
if (strlen($myrow['title']) >= $options[2]) { |
265
|
|
|
$title = substr($myrow['title'], 0, $options[2] - 1) . '...'; |
266
|
|
|
} |
267
|
|
|
} |
268
|
|
|
$videoload['id'] = (int)$myrow['lid']; |
269
|
|
|
$videoload['cid'] = (int)$myrow['cid']; |
270
|
|
|
$videoload['title'] = $title; |
271
|
|
View Code Duplication |
if ('published' === $options[0]) { |
|
|
|
|
272
|
|
|
$videoload['date'] = XoopstubeUtilities::xtubeGetTimestamp(formatTimestamp($myrow['published'], $options[3])); |
273
|
|
|
} elseif ('hits' === $options[0]) { |
274
|
|
|
$videoload['hits'] = $myrow['hits']; |
275
|
|
|
} |
276
|
|
|
|
277
|
|
|
$videoload['videothumb'] = |
278
|
|
|
xtubeGetVideoThumb($myrow['vidid'], $title, $myrow['vidsource'], $myrow['picurl'], $xtubeModuleConfig['videoimgdir'] . '/' . $myrow['screenshot'], $xtubeModuleConfig['shotwidth'], |
279
|
|
|
$xtubeModuleConfig['shotheight']); |
280
|
|
|
$videoload['dirname'] = $xtubeModule->getVar('dirname'); |
281
|
|
|
$videoload['width'] = $xtubeModuleConfig['shotwidth'] + 2; |
282
|
|
|
$block['videos'][] = $videoload; |
283
|
|
|
} |
284
|
|
|
unset($_block_check_array); |
285
|
|
|
|
286
|
|
|
return $block; |
287
|
|
|
} |
288
|
|
|
|
289
|
|
|
// Function: getRandomVideo |
290
|
|
|
// Output : Returns random video |
291
|
|
|
/** |
292
|
|
|
* @param $options |
293
|
|
|
* |
294
|
|
|
* @return array |
295
|
|
|
*/ |
296
|
|
|
function getRandomVideo($options) |
|
|
|
|
297
|
|
|
{ |
298
|
|
|
global $xtubemyts; |
|
|
|
|
299
|
|
|
$moduleDirName = basename(dirname(__DIR__)); |
300
|
|
|
$block = array(); |
301
|
|
|
$moduleHandler = xoops_getHandler('module'); |
302
|
|
|
$xtubeModule = $moduleHandler->getByDirname($moduleDirName); |
303
|
|
|
$configHandler = xoops_getHandler('config'); |
304
|
|
|
$xtubeModuleConfig = $configHandler->getConfigsByCat(0, $xtubeModule->getVar('mid')); |
305
|
|
|
$xtubemyts = MyTextSanitizer:: getInstance(); |
306
|
|
|
|
307
|
|
View Code Duplication |
if (isset($options[4]) && ($options[4] > 0)) { |
|
|
|
|
308
|
|
|
$result2 = $GLOBALS['xoopsDB']->query('SELECT lid, cid, title, vidid, screenshot, published, vidsource, picurl FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' WHERE published > 0 |
309
|
|
|
AND published<=' . time() . ' |
310
|
|
|
AND (expired=0 OR expired>' . time() . ') |
311
|
|
|
AND offline=0 |
312
|
|
|
AND cid=' . $options[4] . ' |
313
|
|
|
ORDER BY RAND() LIMIT ' . $options[1]); |
314
|
|
|
} else { |
315
|
|
|
$result2 = $GLOBALS['xoopsDB']->query('SELECT lid, cid, title, vidid, screenshot, published, vidsource, picurl FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' WHERE published > 0 |
316
|
|
|
AND published<=' . time() . ' |
317
|
|
|
AND (expired=0 OR expired>' . time() . ') |
318
|
|
|
AND offline=0 |
319
|
|
|
ORDER BY RAND() LIMIT ' . $options[1]); |
320
|
|
|
} |
321
|
|
|
|
322
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/' . $xtubeModule->getVar('dirname') . '/include/video.php'; |
323
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/' . $xtubeModule->getVar('dirname') . '/class/utilities.php'; |
324
|
|
|
|
325
|
|
|
while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result2))) { |
326
|
|
View Code Duplication |
if (false === checkBlockGroups($myrow['cid']) || 0 == $myrow['cid']) { |
|
|
|
|
327
|
|
|
continue; |
328
|
|
|
} |
329
|
|
|
$videorandom = array(); |
330
|
|
|
$title = $xtubemyts->htmlSpecialChars($xtubemyts->stripSlashesGPC($myrow['title'])); |
331
|
|
View Code Duplication |
if (!XOOPS_USE_MULTIBYTES) { |
|
|
|
|
332
|
|
|
if (strlen($myrow['title']) >= $options[2]) { |
333
|
|
|
$title = substr($myrow['title'], 0, $options[2] - 1) . '...'; |
334
|
|
|
} |
335
|
|
|
} |
336
|
|
|
$videorandom['id'] = (int)$myrow['lid']; |
337
|
|
|
$videorandom['cid'] = (int)$myrow['cid']; |
338
|
|
|
$videorandom['title'] = $title; |
339
|
|
View Code Duplication |
if (isset($options[3])) { |
|
|
|
|
340
|
|
|
$videorandom['date'] = XoopstubeUtilities::xtubeGetTimestamp(formatTimestamp($myrow['published'], $options[3])); |
341
|
|
|
} |
342
|
|
|
$videorandom['videothumb'] = |
343
|
|
|
xtubeGetVideoThumb($myrow['vidid'], $myrow['title'], $myrow['vidsource'], $myrow['picurl'], $xtubeModuleConfig['videoimgdir'] . '/' . $myrow['screenshot'], $xtubeModuleConfig['shotwidth'], |
344
|
|
|
$xtubeModuleConfig['shotheight']); |
345
|
|
|
$videorandom['dirname'] = $xtubeModule->getVar('dirname'); |
346
|
|
|
$videorandomh['width'] = $xtubeModuleConfig['shotwidth'] + 2; |
|
|
|
|
347
|
|
|
$block['random'][] = $videorandom; |
348
|
|
|
} |
349
|
|
|
unset($_block_check_array); |
350
|
|
|
|
351
|
|
|
return $block; |
352
|
|
|
} |
353
|
|
|
|
354
|
|
|
// Function: b_xoopstube_random_h |
355
|
|
|
// Output : Returns random video in horizontal block |
356
|
|
|
/** |
357
|
|
|
* @param $options |
358
|
|
|
* |
359
|
|
|
* @return array |
360
|
|
|
*/ |
361
|
|
|
function getRandomVideoForHorizontalBlock($options) |
|
|
|
|
362
|
|
|
{ |
363
|
|
|
global $xtubemyts; |
|
|
|
|
364
|
|
|
$moduleDirName = basename(dirname(__DIR__)); |
365
|
|
|
$block = array(); |
366
|
|
|
$moduleHandler = xoops_getHandler('module'); |
367
|
|
|
$xtubeModule = $moduleHandler->getByDirname($moduleDirName); |
368
|
|
|
$configHandler = xoops_getHandler('config'); |
369
|
|
|
$xtubeModuleConfig = $configHandler->getConfigsByCat(0, $xtubeModule->getVar('mid')); |
370
|
|
|
$xtubemyts = MyTextSanitizer:: getInstance(); |
371
|
|
|
|
372
|
|
View Code Duplication |
if (isset($options[4]) && ($options[4] > 0)) { |
|
|
|
|
373
|
|
|
$result2 = $GLOBALS['xoopsDB']->query('SELECT lid, cid, title, vidid, screenshot, published, vidsource, picurl FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' WHERE published > 0 |
374
|
|
|
AND published<=' . time() . ' |
375
|
|
|
AND (expired=0 OR expired>' . time() . ') |
376
|
|
|
AND offline=0 |
377
|
|
|
AND cid=' . $options[4] . ' |
378
|
|
|
ORDER BY RAND() LIMIT ' . $options[1]); |
379
|
|
|
} else { |
380
|
|
|
$result2 = $GLOBALS['xoopsDB']->query('SELECT lid, cid, title, vidid, screenshot, published, vidsource, picurl FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' WHERE published > 0 |
381
|
|
|
AND published<=' . time() . ' |
382
|
|
|
AND (expired=0 OR expired>' . time() . ') |
383
|
|
|
AND offline=0 |
384
|
|
|
ORDER BY RAND() LIMIT ' . $options[1]); |
385
|
|
|
} |
386
|
|
|
|
387
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/' . $xtubeModule->getVar('dirname') . '/include/video.php'; |
388
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/' . $xtubeModule->getVar('dirname') . '/class/utilities.php'; |
389
|
|
|
|
390
|
|
|
while (false !== ($myrow = $GLOBALS['xoopsDB']->fetchArray($result2))) { |
391
|
|
View Code Duplication |
if (false === checkBlockGroups($myrow['cid']) || 0 == $myrow['cid']) { |
|
|
|
|
392
|
|
|
continue; |
393
|
|
|
} |
394
|
|
|
$videorandomh = array(); |
395
|
|
|
$title = $xtubemyts->htmlSpecialChars($xtubemyts->stripSlashesGPC($myrow['title'])); |
396
|
|
|
$videorandomh['balloon'] = $myrow['title']; |
397
|
|
View Code Duplication |
if (!XOOPS_USE_MULTIBYTES) { |
|
|
|
|
398
|
|
|
if (strlen($myrow['title']) >= $options[2]) { |
399
|
|
|
$title = substr($myrow['title'], 0, $options[2] - 1) . '...'; |
400
|
|
|
} |
401
|
|
|
} |
402
|
|
|
$videorandomh['id'] = (int)$myrow['lid']; |
403
|
|
|
$videorandomh['cid'] = (int)$myrow['cid']; |
404
|
|
|
$videorandomh['title'] = $title; |
405
|
|
View Code Duplication |
if (isset($options[3])) { |
|
|
|
|
406
|
|
|
$videorandomh['date'] = XoopstubeUtilities::xtubeGetTimestamp(formatTimestamp($myrow['published'], $options[3])); |
407
|
|
|
} |
408
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/' . $xtubeModule->getVar('dirname') . '/include/video.php'; |
409
|
|
|
$videorandomh['videothumb'] = |
410
|
|
|
xtubeGetVideoThumb($myrow['vidid'], $myrow['title'], $myrow['vidsource'], $myrow['picurl'], $xtubeModuleConfig['videoimgdir'] . '/' . $myrow['screenshot'], $xtubeModuleConfig['shotwidth'], |
411
|
|
|
$xtubeModuleConfig['shotheight']); |
412
|
|
|
$videorandomh['dirname'] = $xtubeModule->getVar('dirname'); |
413
|
|
|
$videorandomh['width'] = $xtubeModuleConfig['shotwidth'] + 2; |
414
|
|
|
$block['random'][] = $videorandomh; |
415
|
|
|
} |
416
|
|
|
unset($_block_check_array); |
417
|
|
|
|
418
|
|
|
return $block; |
419
|
|
|
} |
420
|
|
|
|
421
|
|
|
// editTopVideoBlock() |
422
|
|
|
// @param $options |
423
|
|
|
// @return |
424
|
|
|
/** |
425
|
|
|
* @param $options |
426
|
|
|
* |
427
|
|
|
* @return string |
428
|
|
|
*/ |
429
|
|
|
function editTopVideoBlock($options) |
|
|
|
|
430
|
|
|
{ |
431
|
|
|
$form = '' . _MB_XOOPSTUBE_DISP . ' '; |
432
|
|
|
$form .= "<input type='hidden' name='options[]' value='"; |
433
|
|
|
if ('published' === $options[0]) { |
434
|
|
|
$form .= "published'"; |
435
|
|
|
} |
436
|
|
|
if ('random' === $options[0]) { |
437
|
|
|
$form .= "random'"; |
438
|
|
|
} |
439
|
|
|
if ('randomh' === $options[0]) { |
440
|
|
|
$form .= "randomh'"; |
441
|
|
|
} else { |
442
|
|
|
$form .= "hits'"; |
443
|
|
|
} |
444
|
|
|
$form .= ' />'; |
445
|
|
|
$form .= "<input type='text' name='options[]' value='" . $options[1] . "' /> " . _MB_XOOPSTUBE_FILES . ''; |
446
|
|
|
$form .= ' <br>' . _MB_XOOPSTUBE_CHARS . " <input type='text' name='options[]' value='" . $options[2] . "' /> " . _MB_XOOPSTUBE_LENGTH . ''; |
447
|
|
|
$form .= ' <br>' . _MB_XOOPSTUBE_DATEFORMAT . " <input type='text' name='options[]' value='" . $options[3] . "' /> " . _MB_XOOPSTUBE_DATEFORMATMANUAL; |
448
|
|
|
|
449
|
|
|
$cat_arr = array(); |
|
|
|
|
450
|
|
|
include_once XOOPS_ROOT_PATH . '/modules/xoopstube/class/xoopstubetree.php'; |
451
|
|
|
$xt = new XoopstubeTree($GLOBALS['xoopsDB']->prefix('xoopstube_cat'), 'cid', 'pid'); |
452
|
|
|
$cat_arr = $xt->getChildTreeArray(0, 'title'); |
453
|
|
|
|
454
|
|
|
$form .= '<br>' . _MB_XOOPSTUBE_SELECTCAT . "<br><select name=\"options[]\" multiple=\"multiple\" size=\"5\">"; |
455
|
|
|
$form = false === array_search(0, $options) ? $form . "<option value=\"0\">" . _MB_XOOPSTUBE_ALLCAT . '</option>' : $form . "<option value=\"0\" selected=\"selected\">" . _MB_XOOPSTUBE_ALLCAT |
456
|
|
|
. '</option>'; |
457
|
|
|
|
458
|
|
|
foreach ($cat_arr as $catlist) { |
459
|
|
|
if (false === array_search($catlist, $options)) { |
460
|
|
|
$form .= "<option value=\"" . $catlist['cid'] . "\">" . $catlist['title'] . '</option>'; |
461
|
|
|
} else { |
462
|
|
|
$form .= "<option value=\"" . $catlist['cid'] . "\" selected=\"selected\">" . $catlist['title'] . '</option>'; |
463
|
|
|
} |
464
|
|
|
} |
465
|
|
|
$form .= '</select>'; |
466
|
|
|
|
467
|
|
|
return $form; |
468
|
|
|
} |
469
|
|
|
|
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.