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