forked from aerograf/xtorrent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
149 lines (133 loc) · 5.79 KB
/
index.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
include __DIR__ . '/header.php';
global $xoopsModuleConfig, $xoopsModule, $xoopsUser;
if (0 != $xoopsModuleConfig['htaccess'])
{
if (strpos($_SERVER['REQUEST_URI'], 'odules/')>0 || strpos($_SERVER['REQUEST_URI'], 'ndex.php')>0)
{
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . XOOPS_URL . '/torrents/');
exit;
}
}
include_once XOOPS_ROOT_PATH . '/class/xoopstree.php';
$mytree = new XoopsTree($xoopsDB -> prefix('xtorrent_cat'), "cid", "pid");
$GLOBALS['xoopsOption']['template_main'] = 'xtorrent_index.tpl';
include XOOPS_ROOT_PATH . '/header.php';
/**
* Begin Main page Heading etc
*/
$sql = 'SELECT * FROM ' . $xoopsDB->prefix('xtorrent_indexpage') . ' ';
$head_arr = $xoopsDB->fetchArray($xoopsDB->query($sql));
$catarray['imageheader'] = xtorrent_imageheader();
$catarray['indexheading'] = $myts->displayTarea($head_arr['indexheading']);
$catarray['indexheaderalign'] = $head_arr['indexheaderalign'];
$catarray['indexfooteralign'] = $head_arr['indexfooteralign'];
$html = $head_arr['nohtml'] ? 0 : 1;
$smiley = $head_arr['nosmiley'] ? 0 : 1;
$xcodes = $head_arr['noxcodes'] ? 0 : 1;
$images = $head_arr['noimages'] ? 0 : 1;
$breaks = $head_arr['nobreak'] ? 1 : 0;
$catarray['indexheader'] = $myts->displayTarea($head_arr['indexheader'], $html, $smiley, $xcodes, $images, $breaks);
$catarray['indexfooter'] = $myts->displayTarea($head_arr['indexfooter'], $html, $smiley, $xcodes, $images, $breaks);
$catarray['letters'] = xtorrent_letters();
$catarray['toolbar'] = xtorrent_toolbar();
$xoopsTpl->assign('catarray', $catarray);
/**
* End main page Headers
*/
$count = 1;
$chcount = 0;
$countin = 0;
$groups = (is_object($xoopsUser)) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
$module_id = $xoopsModule->getVar('mid');
$gpermHandler = xoops_getHandler('groupperm');
/**
* Begin Main page download info
*/
$listings = xtorrent_getTotalItems();
/*
* get total amount of categories
*/
$total_cat = xtorrent_totalcategory();
$result = $xoopsDB->query('SELECT * FROM ' . $xoopsDB->prefix('xtorrent_cat') . ' WHERE pid = 0 ORDER BY weight');
while ($myrow = $xoopsDB->fetchArray($result))
{
$countin++;
$subtotaldownload = 0;
$totaldownload = xtorrent_getTotalItems($myrow['cid'], 1);
//$subtotaldownload = xtorrent_getTotalItems($myrow['cid'], 1);
$indicator = xtorrent_isnewimage($totaldownload['published']);
if ($gpermHandler -> checkRight('xtorrentownCatPerm', $myrow['cid'] , $groups, $module_id))
{
$title = $myts->htmlSpecialChars($myrow['title']);
$summary = $myts->displayTarea($myrow['summary']);
/**
* get child category objects
*/
$arr = [];
$mytree = new XoopsTree($xoopsDB->prefix('xtorrent_cat'), 'cid', 'pid');
$arr = $mytree->getFirstChild($myrow['cid'], 'title');
$space = 0;
$chcount = 0;
$subcategories = '';
foreach($arr as $ele)
{
if ($gpermHandler->checkRight('xtorrentownCatPerm', $ele['cid'] , $groups, $xoopsModule->getVar('mid')))
{
if (1 == $xoopsModuleConfig['subcats'])
{
$chtitle = $myts->htmlSpecialChars($ele['title']);
if ($chcount > 5)
{
$subcategories .= '...';
break;
}
if ($space > 0) $subcategories .= '<br>';
$subcategories .= "<a href='" . XOOPS_URL . "/modules/xtorrent/viewcat.php?cid=" . $ele['cid'] . "'>" . $chtitle . '</a>';
$space++;
$chcount++;
}
}
}
if (is_file(XOOPS_ROOT_PATH . '/' . $xoopsModuleConfig['catimage'] . '/' . $myts->htmlSpecialChars($myrow['imgurl'])) && !empty($myrow['imgurl']))
{
if ($xoopsModuleConfig['usethumbs'] && function_exists('gd_info'))
{
$imgurl = down_createthumb($myts->htmlSpecialChars($myrow['imgurl']), $xoopsModuleConfig['catimage'], "thumbs", $xoopsModuleConfig['shotwidth'], $xoopsModuleConfig['shotheight'], $xoopsModuleConfig['imagequality'], $xoopsModuleConfig['updatethumbs'], $xoopsModuleConfig['keepaspect']);
}
else
{
$imgurl = XOOPS_URL . '/' . $xoopsModuleConfig['catimage'] . '/' . $myts->htmlSpecialChars($myrow['imgurl']);
}
}
else
{
$imgurl = $indicator['image'];
}
$xoopsTpl->append('categories', [
'image' => $imgurl,
'id' => $myrow['cid'],
'title' => $title,
'summary' => $summary,
'subcategories' => $subcategories,
'totaldownloads' => $totaldownload['count'],
'count' => $count,
'alttext' => $indicator['alttext']
]);
$count++;
}
}
switch ($total_cat)
{
case '1':
$lang_ThereAre = _MD_XTORRENT_THEREIS;
break;
default:
$lang_ThereAre = _MD_XTORRENT_THEREARE;
break;
}
$xoopsTpl -> assign('htaccess', $xoopsModuleConfig['htaccess']);
$xoopsTpl -> assign('lang_thereare', sprintf($lang_ThereAre, $total_cat, $listings['count']));
$xoopsTpl -> assign('navitem', 1);
include __DIR__ . '/footer.php';