-
Notifications
You must be signed in to change notification settings - Fork 10
/
hnr.php
149 lines (131 loc) · 7.92 KB
/
hnr.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
/**
* ------- 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.'html_functions.php');
require_once(INCL_DIR.'pager_functions.php');
dbconn();
loggedinorreturn();
$lang = array_merge(load_language('global'), load_language('hitandruns'));
$HTMLOUT = "";
$id = (int)$_GET["id"];
if (($CURUSER["class"] < UC_STAFF) && ($id != $CURUSER["id"])) {
stderr("Error", "It appears that you do not have access to this page.");
}
if (!is_valid_id($id)) {
stderr("Error", "It appears that you have entered an invalid id.");
}
($res = sql_query("SELECT * FROM users WHERE id = ".sqlesc($id))) || sqlerr(__FILE__, __LINE__);
$arr = $res->fetch_assoc();
if (!$arr) {
stderr("Error", "It appears that there is no user with that id.");
}
($res = sql_query("SELECT COUNT(*) FROM snatched WHERE userid =".sqlesc($id)." AND hit_and_run != '0'")) || sqlerr(__FILE__, __LINE__);
$row = $res->fetch_row();
$count = $row[0];
$perpage = 25;
$pager = pager($perpage, $count, "?id=$id&");
if (!$count) {
stderr("No Hit And Runs",
"<font class='statusbartext'>It appears that <a class='altlink_default' href='userdetails.php?id=".(int)$arr['id']."'>".htmlsafechars($arr['username'])."</a> currently has no hit and runs.</font>");
}
($r = sql_query("SELECT torrents.name,torrents.added AS torrent_added, snatched.start_date AS s, snatched.complete_date AS c, snatched.downspeed, snatched.seedtime, snatched.seeder, snatched.torrentid as tid, snatched.id, categories.id as category, categories.image, categories.name as catname, users.class, users.id, snatched.uploaded, snatched.downloaded, snatched.hit_and_run, snatched.mark_of_cain, snatched.complete_date, snatched.last_action, torrents.seeders, torrents.leechers, torrents.owner, snatched.start_date AS st, snatched.start_date FROM snatched JOIN users ON users.id = snatched.userid JOIN torrents ON torrents.id = snatched.torrentid JOIN categories ON categories.id = torrents.category WHERE snatched.finished='yes' AND userid=".sqlesc($id)." AND snatched.hit_and_run != '0' AND torrents.owner != ".sqlesc($id)." ORDER BY snatched.id DESC {$pager['limit']}")) || sqlerr(__FILE__,
__LINE__);
if ($r->num_rows > 0) {
$HTMLOUT .= "<div class='disclaimer'>
<div style='background:#0C0C0C;height:25px;'>
<table class='clear' width='100%' border='0'>
<tr>
<td width='100%' class='clear2'>
<font class='statusbartext' size='2'>Hit and Runs for user: <a class='altlink' href='{$TRINITY20['baseurl']}/userdetails.php?id=".(int)$arr['id']."'>".htmlsafechars($arr['username'])."</a></font></td>
</tr>
</table>
</div>
<div style='text-align:left;width:99%;border:1px solid #B4B4B4;background:#4F4F4F;'>\n";
if ($count > $perpage) {
$HTMLOUT .= $pager['pagertop'];
}
$HTMLOUT .= "<table width='100%' border='0'>
<tr>
<td class='colhead'>{$lang['hnr_type']}</td>
<td class='colhead'>{$lang['hnr_name']}</td>
<td class='colhead' align='center'>{$lang['hnr_ul']}</td>
<td class='colhead' align='center'>{$lang['hnr_dl']}</td>
<td class='colhead' align='center'>{$lang['hnr_ratio']}</td>
<td class='colhead' align='center'>{$lang['hnr_seeded']}</td>
<td class='colhead' align='center'>{$lang['hnr_wcompleted']}</td>
</tr>\n";
while ($a = $r->fetch_assoc()) {
$S_date = (XBT_TRACKER === true ? $a['started'] : $a['start_date']);
$torrent_needed_seed_time = $a['seedtime'];
//=== get times per class
switch (true) {
case ($a['class'] < UC_POWER_USER):
$days_3 = 3 * 86400; //== 3 days
$days_14 = 2 * 86400; //== 2 days
$days_over_14 = 86400; //== 1 day
break;
case ($a['class'] < UC_STAFF):
$days_3 = 2 * 86400; //== 2 days
$days_14 = 129600; //== 36 hours
$days_over_14 = 64800; //== 18 hours
break;
case ($a['class'] >= UC_STAFF):
$days_3 = 86400; //== 24 hours
$days_14 = 43200; //== 12 hours
$days_over_14 = 21600; //== 6 hours
break;
}
switch (true) {
case (($S_date - $a['torrent_added']) < 7 * 86400):
$minus_ratio = ($days_3 - $torrent_needed_seed_time);
// or using ratio
//$minus_ratio = ($days_3 - $torrent_needed_seed_time) - ($hit_and_run_arr['uload'] / $hit_and_run_arr['dload'] * 3 * 86400);
break;
case (($S_date - $a['torrent_added']) < 21 * 86400):
$minus_ratio = ($days_14 - $torrent_needed_seed_time);
// or using ratio
//$minus_ratio = ($days_14 - $torrent_needed_seed_time) - ($hit_and_run_arr['uload'] / $hit_and_run_arr['dload'] * 2 * 86400);
break;
case (($S_date - $a['torrent_added']) >= 21 * 86400):
$minus_ratio = ($days_over_14 - $torrent_needed_seed_time);
// or using ratio
//$minus_ratio = ($days_over_14 - $torrent_needed_seed_time) - ($hit_and_run_arr['uload'] / $hit_and_run_arr['dload'] * 86400);
break;
}
$minus_ratio = (false !== stripos($minus_ratio, "-") ? 0 : $minus_ratio);
$color = ($minus_ratio > 0 ? get_ratio_color($minus_ratio) : 'limegreen');
//=== mark of cain / hit and run
$checkbox_for_delete = ($CURUSER['class'] >= UC_STAFF ? " [<a class='altlink' href='".$TRINITY20['baseurl']."/hnr.php?id=".$id."&delete_hit_and_run=".(int)$a['id']."'>Remove</a>]" : '');
$mark_of_cain = ($a['mark_of_cain'] == 'yes' ? "<img src='{$TRINITY20['pic_base_url']}moc.gif' width='40px' alt='Mark Of Cain' title='the mark of Cain!'>" : '');
$hit_n_run = ($a['hit_and_run'] > 0 ? "<img src='{$TRINITY20['pic_base_url']}hnr.gif' width='40px' alt='hit and run' title='hit and run!'>" : '');
$HTMLOUT .= "<tr>
<td style='padding: 0px'><img src='{$TRINITY20['pic_base_url']}caticons/{$CURUSER['categorie_icon']}/".htmlsafechars($a['image'])."' alt='".htmlsafechars($a['name'])."' title='".htmlsafechars($a['name'])."'></td>
<td><a class='altlink' href='{$TRINITY20['baseurl']}/details.php?id=".$a['tid']."&hit=1'><b>".CutName($a['name'], 25)."</b></a></td>
<td align='center'>".mksize($a['uploaded'])."</td>
<td align='center'>".mksize($a['downloaded'])."</td>
<td align='center'>".($a['downloaded'] > 0 ? "<font color='".get_ratio_color(number_format($a['uploaded'] / $a['downloaded'],
3))."'>".number_format($a['uploaded'] / $a['downloaded'], 3)."</font>" : ($a['uploaded'] > 0 ? 'Inf.' : '---'))."<br></td>
<td align='center'> ".(($CURUSER['class'] >= UC_MODERATOR || $arr['id'] == $CURUSER['id']) ? "".mkprettytime($a['seedtime']).(($minus_ratio != '0:00' && $a['uploaded'] < $a['downloaded']) ? "<br><b>Remaining:</b><br>".mkprettytime($minus_ratio)." " : '').($a['seeder'] == 'yes' ? "<br><font color='green'>[<b>seeding</b>]</font>" : $hit_n_run." ".$mark_of_cain) : '')."</td>
<td align='center'>".get_date($a['complete_date'], 'DATE')."<br><b>Last Action:</b><br>".get_date($a['last_action'],
'DATE')."</td></tr>\n";
}
$HTMLOUT .= "</table>\n";
if ($count > $perpage) {
$HTMLOUT .= $pager['pagerbottom'];
}
$HTMLOUT .= "</div></div>\n";
}
echo stdhead('Hit And Runs').$HTMLOUT.stdfoot();
die;
?>