-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathcatalogue.php
143 lines (131 loc) · 8.11 KB
/
catalogue.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
<?php
/**
* ------- U-232 Codename Trinity ----------*
* ---------------------------------------------*
* -------- @authors U-232 Team --------------*
* ---------------------------------------------*
* ----- @site https://u-232.duckdns.org/ ----*
* ---------------------------------------------*
* ----- @copyright 2020 U-232 Team ----------*
* ---------------------------------------------*
* ------------ @version V6 ------------------*
*/
require_once(__DIR__.DIRECTORY_SEPARATOR.'include'.DIRECTORY_SEPARATOR.'bittorrent.php');
require_once(INCL_DIR.'user_functions.php');
require_once(INCL_DIR.'bbcode_functions.php');
require_once INCL_DIR.'html_functions.php';
require_once INCL_DIR.'pager_functions.php';
dbconn(false);
loggedinorreturn();
$lang = array_merge(load_language('global'), load_language('catalogue'));
$htmlout = '';
function readMore($text, $char, $link)
{
global $TRINITY20, $lang;
return (strlen($text) > $char ? substr(htmlsafechars($text), 0,
$char - 1)."...<br><a href='$link'>{$lang['catol_read_more']}</a>" : htmlsafechars($text));
}
function peer_list($array)
{
global $TRINITY20, $lang, $CURUSER;
$htmlout = '';
$htmlout .= "
{$lang['catol_user']} {$lang['catol_port']}&{$lang['catol_ip']} {$lang['catol_ratio']} {$lang['catol_downloaded']} {$lang['catol_uploaded']} {$lang['catol_started']} {$lang['catol_finished']} </tr>-->";
foreach ($array as $p) {
$time = max(1, (TIME_NOW - $p["started"]) - (TIME_NOW - $p["last_action"]));
$htmlout .= "
<a href='userdetails.php?id=".(int)$p["p_uid"]."' >".htmlsafechars($p["p_user"])."</a>
".($CURUSER['class'] >= UC_STAFF ? htmlsafechars($p["ip"])." : ".(int)$p["port"] : "xx.xx.xx.xx:xxxx")."
".($p["downloaded"] > 0 ? number_format(($p["uploaded"] / $p["downloaded"]), 2) : ($p["uploaded"] > 0 ? "∞" : "---"))."
".($p["downloaded"] > 0 ? mksize($p["downloaded"])." @".(mksize(($p["downloaded"] - $p["downloadoffset"]) / $time))."s" : "0kb")."
".($p["uploaded"] > 0 ? mksize($p["uploaded"])." @".(mksize(($p["uploaded"] - $p["uploadoffset"]) / $time))."s" : "0kb")."
".(get_date($p["started"], 'LONG', 0, 1))." <td align='center'>".(get_date($p["finishedat"], 'LONG', 0, 1))." ";
}
return $htmlout."";
}
$letter = (isset($_GET["letter"]) ? htmlsafechars($_GET["letter"]) : "");
$search = (isset($_GET["search"]) ? htmlsafechars($_GET["search"]) : "");
if (strlen($search) > 4) {
$where = "WHERE t.name LIKE".sqlesc("%".$search."%");
$p = "search=".$search."&";
} elseif (strlen($letter) == 1 && strpos("abcdefghijklmnopqrstuvwxyz", (string)$letter) !== false) {
$where = "WHERE t.name LIKE '".$letter."%'";
$p = "letter=".$letter."&";
} else {
$where = "WHERE t.name LIKE 'a%'";
$p = "letter=a&";
$letter = "a";
}
($sql_qry = sql_query("SELECT count(*) FROM torrents AS t $where")) || sqlerr(__FILE__, __LINE__);
$count = $sql_qry->fetch_row();
$perpage = 12;
$pager = pager($perpage, $count[0], $_SERVER["PHP_SELF"]."?".$p);
//$tid='';
//$rows='';
//$top = '';
//$bottom = '';
$rows = [];
$tids = [];
($t = sql_query("SELECT t.id,t.name,t.leechers,t.seeders,t.poster,t.times_completed as snatched,t.owner,t.size,t.added,t.descr, u.username as user FROM torrents as t LEFT JOIN users AS u on u.id=t.owner $where ORDER BY t.name ASC ".$pager['limit'])) || sqlerr(__FILE__,
__LINE__);
while ($ta = $t->fetch_assoc()) {
$rows[] = $ta;
$tid[] = (int)$ta["id"];
}
if (isset($tids) && count($tids)) {
($p = sql_query("SELECT p.id,p.torrent as tid,p.seeder, p.finishedat, p.downloadoffset, p.uploadoffset, p.ip, p.port, p.uploaded, p.downloaded, p.started AS started, p.last_action AS last_action, u.id as p_uid , u.username as p_user FROM peers AS p LEFT JOIN users as u on u.id=p.userid WHERE p.torrent IN (".implode(",",
$tid).") AND p.seeder = 'yes' AND to_go=0 LIMIT 5")) || sqlerr(__FILE__, __LINE__);
while ($pa = $p->fetch_assoc()) {
$peers[$pa["tid"]][] = $pa;
}
}
$htmlout .= "<div class='row'><div class='col-md-12'>
<fieldset style='border:2px solid #333333;'>
<div class='row'><div class='col-md-8 col-md-push-2'><h4 class='text-center'>{$lang['catol_search']}</h4>
<form action='".$_SERVER["PHP_SELF"]."' method='get' style='margin:10px;'>
<input type='text' size='100' name='search' value='".($search ? $search : "{$lang['catol_search_for_tor']}")."' onblur=\"if (this.value == '') this.value='{$lang['catol_search_for_tor']}';\" onfocus=\"if (this.value == '{$lang['catol_search_for_tor']}') this.value='';\"> <input type='submit' value='search!'>
</form></div></div>";
$htmlout .= "<div class='row'><div class='col-md-8 col-md-push-4'>";
for ($i = 97; $i < 123; ++$i) {
$l = chr($i);
$L = chr($i - 32);
if ($l == $letter) {
$htmlout .= "<font class=\"sublink-active\">$L</font>\n";
} else {
$htmlout .= "<a class=\"sublink\" href=\"".$_SERVER["PHP_SELF"]."?letter=".$l."\">".$L."</a>\n";
}
$htmlout .= "<!--</div></div>-->";
}
$htmlout .= "</fieldset></div></div><br>";
$htmlout .= "<div class='container'>";
if (count($rows) > 0) {
$htmlout .= "<div class='row'><div class='col-md-10'>".$pager['pagerbottom']."</div><br><br><div class='col-md-2 col-md-push-0'><a class='btn btn-default btn-link' title='Back to Browse' href='".$TRINITY20['baseurl']."/browse.php'>Back to Browse</a></div></div>";
$htmlout .= "<h3 class='text-center'>{$lang['catol_std_head']}</h3>";
$htmlout .= "<div class='row'>";
foreach ($rows as $row) {
$htmlout .= "<div class='panel col-sm-3 col-sm-offset-0 panel-default browsep'>
<div style='display:block; height:5px;'></div>
<p class='browsed text-center'><b><font color='rgb(67,158,76)'>{$lang['catol_upper']} :</font></b> <a href='userdetails.php?id=".(int)$row["owner"]."'>".($row["user"] ? htmlsafechars($row["user"]) : "{$lang['catol_unknown']}[".(int)$row["owner"]."]")."</a></p>
<p class='browsepd text-center'>".($row["poster"] ? "<a href=\"".htmlsafechars($row["poster"])."\"><img src=\"".htmlsafechars($row["poster"])."\" border=\"0\" width=\"150\" height=\"225\" alt=\"{$lang['catol_no_poster']}\" title=\"{$lang['catol_no_poster']}\"></a>" : "<img src=\"pic/noposter.png\" border=\"0\" width=\"150\" alt=\"{$lang['catol_no_poster']}\" title=\"{$lang['catol_no_poster']}\">")."</p>
<p class='squashp browsepd text-center'><b><font color='rgb(67,158,76)'>Torrent:</font></b> <a href='details.php?id=".(int)$row["id"]."&hit=1'><b>".substr(htmlsafechars($row["name"]),
0, 60)."</b></a></p>
";
$htmlout .= "<div class=''>
<p><b><font color='rgb(67,158,76)'>{$lang['catol_added']}:</font></b> ".get_date($row["added"], 'LONG', 0, 1)."<br>
<b><font color='rgb(67,158,76)'>{$lang['catol_size']}:</font></b> ".(mksize($row["size"]))."<br >
<b><font color='rgb(67,158,76)'>{$lang['catol_snatched']}:</font></b> ".($row["snatched"] > 0 ? ($row["snatched"] == 1 ? (int)$row["snatched"]." time" : (int)$row["snatched"]." times") : 0)."<br>
<b><font color='rgb(67,158,76)'>Seeds:</font></b> ".(int)$row["seeders"]."<br>
<b><font color='rgb(67,158,76)'>Leechers:</font></b> ".(int)$row["leechers"]."<br>
</p>
<p class='squashp'><b><font color='rgb(67,158,76)'>{$lang['catol_info']}:</font></b> ".readMore($row["descr"], 500,
"details.php?id=".(int)$row["id"]."&hit=1")."</p>
<!--<p><b><font color='rgb(67,158,76)'>{$lang['catol_seeder_info']}:</font></b>".(isset($peers[$row["id"]]) ? peer_list($peers[$row["id"]]) : "{$lang['catol_no_info_show']}")."</p>-->
<p><b><font color='rgb(67,158,76)'>{$lang['catol_orig_created_by']}</font></b></p></div></div>";
}
$htmlout .= "</div></div><br>";
$htmlout .= $pager['pagerbottom']."<br>";
} else {
$htmlout .= "<div class='row'><div class='col-sm-04'><h2>{$lang['catol_nothing_found']}!</h2></div></div>";
}
echo stdhead($lang['catol_std_head']).$htmlout.stdfoot();
?>