-
Notifications
You must be signed in to change notification settings - Fork 5
/
topten.php
95 lines (83 loc) · 3.84 KB
/
topten.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
/**
* Module: XoopsTube
*
* You may not change or alter any portion of this comment or credits
* of supporting developers from this source code or any supporting source code
* which is considered copyrighted (c) material of the original comment or credit authors.
*
* PHP version 5
*
* @category Module
* @package Xoopstube
* @author XOOPS Development Team
* @copyright 2001-2016 XOOPS Project (https://xoops.org)
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @link https://xoops.org/
* @since 1.0.6
*/
use Xmf\Request;
use XoopsModules\Xoopstube\{
Tree,
Utility
};
$GLOBALS['xoopsOption']['template_main'] = 'xoopstube_topten.tpl';
require_once __DIR__ . '/header.php';
//require_once XOOPS_ROOT_PATH . '/header.php';
$xoTheme->addStylesheet('modules/' . $moduleDirName . '/assets/css/xtubestyle.css');
$mytree = new Tree($GLOBALS['xoopsDB']->prefix('xoopstube_cat'), 'cid', 'pid');
$action_array = [
'hit' => 0,
'rate' => 1,
];
$list_array = ['hits', 'rating'];
$lang_array = [_MD_XOOPSTUBE_HITS, _MD_XOOPSTUBE_RATING];
$rankings = [];
$sort = in_array(Request::getString('list', '', 'GET'), $action_array) ? Request::getString('list', '', 'GET') : 'rate';
$sort_arr = $action_array[$sort];
$sortDB = $list_array[$sort_arr];
$catarray['imageheader'] = Utility::renderImageHeader();
$xoopsTpl->assign('catarray', $catarray);
$xoopsTpl->assign('mod_url', XOOPS_URL . '/modules/' . $moduleDirName);
$arr = [];
$result = $GLOBALS['xoopsDB']->query('SELECT cid, title, pid FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_cat') . ' WHERE pid=0 ORDER BY ' . $GLOBALS['xoopsModuleConfig']['sortcats']);
$e = 0;
while (list($cid, $ctitle) = $GLOBALS['xoopsDB']->fetchRow($result)) {
if (true === Utility::checkGroups($cid)) {
$query = 'SELECT lid, cid, title, hits, rating, votes FROM ' . $GLOBALS['xoopsDB']->prefix('xoopstube_videos') . ' WHERE published > 0 AND published <= ' . time() . ' AND (expired = 0 OR expired > ' . time() . ') AND offline = 0 AND (cid=' . $cid;
$arr = $mytree->getAllChildId($cid);
$arrayCount = count($arr);
for ($i = 0; $i < $arrayCount; ++$i) {
$query .= ' or cid=' . $arr[$i] . '';
}
$query .= ') order by ' . $sortDB . ' DESC';
$result2 = $GLOBALS['xoopsDB']->query($query, 10, 0);
$filecount = $GLOBALS['xoopsDB']->getRowsNum($result2);
if ($filecount > 0) {
$rankings[$e]['title'] = htmlspecialchars($ctitle, ENT_QUOTES | ENT_HTML5);
$rank = 1;
while (list($did, $dcid, $dtitle, $hits, $rating, $votes) = $GLOBALS['xoopsDB']->fetchRow($result2)) {
$catpath = basename($mytree->getPathFromId($dcid, 'title'));
$dtitle = htmlspecialchars($dtitle, ENT_QUOTES | ENT_HTML5);
$rankings[$e]['file'][] = [
'id' => $did,
'cid' => $dcid,
'rank' => $rank,
'title' => $dtitle,
'category' => $catpath,
'hits' => $hits,
'rating' => number_format($rating, 2),
'votes' => $votes,
];
++$rank;
}
++$e;
}
}
}
$xoopsTpl->assign('back', '<a href="javascript:history.go(-1)"><img src="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/assets/images/icon/back.png"></a>');
$xoopsTpl->assign('lang_sortby', $lang_array[$sort_arr]);
$xoopsTpl->assign('rankings', $rankings);
$xoopsTpl->assign('module_dir', $xoopsModule->getVar('dirname'));
$xoopsTpl->assign('mod_url', XOOPS_URL . '/modules/' . $moduleDirName);
require_once XOOPS_ROOT_PATH . '/footer.php';