Updated for V3 credit to Original Author updated and added ability for staff to delete H&Rs
[color=rgb(247, 218, 100)]You must have snatchlist installed[/color] http://www.torrenttrader.xyz/index.php?threads/snatchlist-ttv3.9726/
You can import the table bits you need or i find it easier to remove the snatched table and just import the full new table on a live site i would recommend exporting the data first so you can add it back afterwards
[color=rgb(251, 160, 38)]sql[/color]
[color=rgb(247, 218, 100)]Because we remove the table it shows a few errors but this is nothing to worry about just empty the sqlerr table once the new snatched table is added[/color]
[color=rgb(251, 160, 38)]Add in config.php :[/color]
[color=rgb(247, 218, 100)]This is where everything is set - ban is at 50 be careful here to be reasonable you dont want to ban all members, for testing reduce these for more results[/color]
[color=rgb(251, 160, 38)]in admincp.php find[/color]
add after
add before last ?>
[color=rgb(251, 160, 38)]in cleanup.php find:[/color]
replace with :
search :
add before :
[color=rgb(251, 160, 38)]in account-details search :[/color]
Add after :
find
below
[color=rgb(251, 160, 38)]Add to english.php[/color]
Add image to images/admin
[color=rgb(247, 218, 100)]You must have snatchlist installed[/color] http://www.torrenttrader.xyz/index.php?threads/snatchlist-ttv3.9726/
You can import the table bits you need or i find it easier to remove the snatched table and just import the full new table on a live site i would recommend exporting the data first so you can add it back afterwards
[color=rgb(251, 160, 38)]sql[/color]
DROP TABLE IF EXISTS `snatched`;
CREATE TABLE `snatched` (
`sid` int(11) unsigned NOT NULL AUTO_INCREMENT,
`tid` int(11) unsigned NOT NULL DEFAULT '0',
`uid` int(11) unsigned NOT NULL DEFAULT '0',
`stime` int(11) unsigned NOT NULL DEFAULT '0',
`utime` int(11) unsigned NOT NULL DEFAULT '0',
`ltime` int(11) unsigned NOT NULL DEFAULT '0',
`uload` bigint(20) unsigned NOT NULL DEFAULT '0',
`dload` bigint(20) unsigned NOT NULL DEFAULT '0',
`completed` enum('0','1') COLLATE utf8_bin NOT NULL DEFAULT '0',
`hnr` enum('no','yes') COLLATE utf8_bin NOT NULL DEFAULT 'no',
`done` enum('yes','no') COLLATE utf8_bin NOT NULL DEFAULT 'no',
`hitrun` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`hitrunwarn` enum('yes','pending','no') COLLATE utf8_bin NOT NULL DEFAULT 'no',
PRIMARY KEY (`sid`),
UNIQUE KEY `tid_uid` (`tid`,`uid`),
KEY `completed` (`completed`),
KEY `tid` (`tid`),
KEY `uid` (`uid`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
ALTER TABLE `users` ADD `hitruns` tinyint( 3 ) unsigned NOT NULL default '0';
[color=rgb(247, 218, 100)]Because we remove the table it shows a few errors but this is nothing to worry about just empty the sqlerr table once the new snatched table is added[/color]
[color=rgb(251, 160, 38)]Add in config.php :[/color]
[color=rgb(247, 218, 100)]This is where everything is set - ban is at 50 be careful here to be reasonable you dont want to ban all members, for testing reduce these for more results[/color]
//hit mod
$site_config["hnr_deadline"] = 7*86400; // 7 days to hit the seed target
$site_config["hnr_seedtime"] = 172800; // target is to seed for 48 hours
$site_config["hnr_warn"] = 5; // 5 hit & runs then warned
$site_config["hnr_stop_dl"] = 5; // After 5 H & R stop downloading
$site_config["hnr_ban"] = 50; // After 50 H&R they are banned
// hit end[color=rgb(251, 160, 38)]in admincp.php find[/color]
<td align="center"><a href="admincp.php?action=sqlerr"><img src="images/admin/sql_error.png" border="0" width="118" width="80" alt="" /><br />SQL Error<br /></a></td>
add after
<td align="center"><a href=admincp.php?action=hnr><img src="images/admin/hitnrun.png" border=0 width=32 height=32><br />List of Hit and Run</a><br /></td>add before last ?>
//Start List of Hit and Run
if ($action=="hnr")
{
if ($_POST['do'] == 'delete')
{
if (!@count($_POST['ids'])) show_error_msg(T_("ERROR"), "Nothing Selected.", 1);
$ids = array_map('intval', $_POST['ids']);
$ids = implode(',', $ids);
SQL_Query_exec("UPDATE snatched SET ltime = '86400', hnr = 'no', done = 'yes' WHERE `sid` IN ($ids)");
autolink("admincp.php?action=hnr", "Entries deleted.");
}
stdhead("List of Hit and Run");
navmenu();
$res = SQL_Query_exec("SELECT * FROM `snatched` where hnr='yes' ");
$row = mysqli_fetch_array($res);
$count = $row[0];
$perpage = 50;
list($pagertop, $pagerbottom, $limit) = pager($perpage, $count, "admincp.php?action=hnr&");
begin_frame("List of Hit and Run");
print("<div style='margin-top:10px; margin-bottom:10px' align='center'><font size=2>We have <font color=red><b>$count</b></font> User".($count > 1 ? "s" : "")." with Hit and Run</font></div>");
$sql = "SELECT *,s.tid FROM users u left join snatched s on s.uid=u.id where hnr='yes' ORDER BY s.uid DESC $limit";
$result = SQL_Query_exec($sql);
if( mysqli_num_rows($result) != 0 )
{
print("$pagertop");
print'<form id="snatched" method="post" action="admincp.php?action=hnr">';
print'<input type="hidden" name="do" value="delete" />';
print'<table cellpadding="5" class="table_table" width="100%">';
print'<tr>';
print'<td class="table_head"><b>User</b></td>';
print'<td class="table_head"><b>Torrent</b></td>';
print'<td class="table_head"><b>Uploaded</b></td>';
print'<td class="table_head"><b>Downloaded</b></td>';
print'<td class="table_head"><b>Seed Time</b></td>';
print'<td class="table_head"><b>Started</b></td>';
print'<td class="table_head"><b><b>Last Action</b></td>';
print'<td class="table_head"><input type="checkbox" name="checkall" onclick="checkAll(this.form.id)" /></td>';
print'</tr>';
while($row = mysqli_fetch_assoc($result))
{
if ($site_config['MEMBERSONLY'])
{
$sql1 = "SELECT id, username FROM users WHERE id = $row[uid]";
$result1 = SQL_Query_exec($sql1);
$row1 = mysqli_fetch_assoc($result1);
}
if ($row1['username'])
print'<tr><td class=table_col1><a href="account-details.php?id=' . $row['uid'] . '"><b>'.class_user($row1['username']).'</b></a></td>';
else
print'<tr><td class=table_col1>'.$row[ip].'</td>';
$sql2 = "SELECT name FROM torrents WHERE id = $row[tid]";
$result2 = SQL_Query_exec($sql2);
while ($row2 = mysqli_fetch_assoc($result2))
{
$smallname =substr(htmlspecialchars($row2["name"]) , 0, 35);
if ($smallname != htmlspecialchars($row2["name"])) { $smallname .= '...'; }
$stime = mkprettytime($row[ltime]);
$startdate = utc_to_tz(get_date_time($row['stime']));
$lastaction = utc_to_tz(get_date_time($row['utime']));
print'<td class=table_col2><a href="torrents-details.php?id=' . $row['tid'] . '">' . $smallname . '</td>';
print'<td class=table_col1><font color=limegreen>' . mksize($row['uload']) . '</font></td>';
print'<td class=table_col2><font color=red>' . mksize($row['dload']) . '</font></td>';
print'<td class=table_col1>'.(is_null($stime)?'0':$stime).'</td>';
print'<td align=center class=table_col2>'.date('d.M.Y H:i', sql_timestamp_to_unix_timestamp($startdate)).'</td>';
print'<td align=center class=table_col1>'.date('d.M.Y H:i', sql_timestamp_to_unix_timestamp($lastaction)).'</td>';
print'<td class=table_col1><input type=checkbox name=ids[] value=' . mksize($row['sid']) . '/></td>';
}
}
print'</table><br />';
echo "<input type='submit' value='Delete' /></center>";
print("$pagerbottom");
}
else
{
print'<b><center>No recordings of Hit and Run</center></b><br />';
}
end_frame();
stdfoot();
}
#======================================================================#
# End List of Hit and Run
#======================================================================#
[color=rgb(251, 160, 38)]in cleanup.php find:[/color]
//REMOVE WARNING
$res = SQL_Query_exec("SELECT users.id, users.username FROM users INNER JOIN warnings ON users.id=warnings.userid WHERE type='Poor Ratio' AND active = 'yes' AND warned = 'yes' AND enabled='yes' AND uploaded / downloaded >= $minratio AND downloaded >= $downloaded");replace with :
// REMOVE WARNINGS // hit mod
$res = SQL_Query_exec("SELECT users.id, users.username, warnings.expiry FROM users INNER JOIN warnings ON users.id=warnings.userid WHERE type != 'Poor Ratio' AND type != 'HnR' AND warned = 'yes' AND enabled='yes' AND warnings.active = 'yes' AND warnings.expiry < '".get_date_time()."'"); // endsearch :
//OPTIMIZE TABLESadd before :
//HIT & RUN mod
$timenow = gmtime();
SQL_Query_exec("UPDATE snatched SET hnr = 'yes' WHERE completed = '1' AND hnr = 'no' AND uload < dload AND $timenow - $site_config[hnr_deadline] > stime AND $site_config[hnr_seedtime] > ltime AND done='no'");
SQL_Query_exec("UPDATE `snatched` SET `hnr` = 'no' WHERE `hnr` = 'yes' AND uload >= dload");
SQL_Query_exec("UPDATE `snatched` SET `hnr` = 'no' WHERE `hnr` = 'yes' AND ltime >= $site_config[hnr_seedtime]");
$a = SQL_Query_exec("SELECT DISTINCT uid FROM snatched WHERE hnr = 'yes' AND done='no'");
if ( mysqli_num_rows($a) > 0 ) :
while ($b = mysqli_fetch_row($a)) :
$c = SQL_Query_exec("SELECT COUNT( hnr ) FROM snatched WHERE uid = $b[0] AND hnr = 'yes'");
$d = mysqli_fetch_row($c);
$count = $d[0];
$user = $b[0];
$length = $site_config["hnr_disabled"];
$expiretime = gmdate("Y-m-d H:i:s", $timenow + $length);
$e = SQL_Query_exec("SELECT type, active FROM warnings WHERE userid = '$user'");
$f = mysqli_fetch_row($e);
$type = $f[0];
$active = $f[1];
//warn
if ( $count >= $site_config["hnr_warn"] && $type != "HnR" ) :
$reason = "".T_("CLEANUP_WARNING_FOR_ACCUMULATING")." ".$site_config['hnr_warn']." H&R.";
$subject = "".T_("CLEANUP_WARNING_FOR_H&R")."";
$msg = "".T_("CLEANUP_YOU_HAVE_BEEN_WARNEWD_ACCUMULATED")." ".$site_config['hnr_warn']." ".T_("CLEANUP_H&R_INVITE_CHECK_RULE")."\n".T_("CLEANUP_MSG_WARNING_7_DAYS_BANNED")."";
$rev = SQL_Query_exec("SELECT enabled FROM users WHERE id = $user");
$rov = mysqli_fetch_assoc($rev);
if ($rov["enabled"] == "yes") :
SQL_Query_exec("UPDATE users SET warned = 'yes' WHERE id = $user");
SQL_Query_exec("INSERT INTO warnings (userid, reason, added, expiry, warnedby, type) VALUES ($user,".sqlesc($reason).",'".get_date_time()."','".$expiretime."','0','HnR')");
SQL_Query_exec("INSERT INTO messages (sender, receiver, added, subject, msg, poster) VALUES (0, $user, '".get_date_time()."', ".sqlesc($subject).", ".sqlesc($msg).", 1)");
endif;
endif;
//Unwarned
if ( $count < $site_config["hnr_warn"] && $type == "HnR") :
$subject = "".T_("CLEANUP_REMOVAL_OF_H&R_WARNING")."";
$msg = "".T_("CLEANUP_YOU_NOW_HAVE_LESS_THAN")." ".$site_config['hnr_warn']." H&R.\n".T_("CLEANUP_YOUR_WARNING_FOR_H&R_HAS_REMOVED")."";
SQL_Query_exec("UPDATE users SET warned = 'no' WHERE id = $user");
SQL_Query_exec("DELETE FROM warnings WHERE userid = $user AND type = 'HnR'");
SQL_Query_exec("INSERT INTO messages (sender, receiver, added, subject, msg, poster) VALUES (0, $user, '".get_date_time()."', ".sqlesc($subject).", ".sqlesc($msg).", 1)");
endif;
//Ban
if ( $count >= $site_config["hnr_ban"] ) :
$g = SQL_Query_exec("SELECT username, email, modcomment FROM users WHERE id = $user");
$h = mysqli_fetch_row($g);
$modcomment = $h[2];
$modcomment = gmdate("d/m/Y") . " - ".T_("CLEANUP_BANNED_FOR")." " .$count. " H&R.\n " .$modcomment;
SQL_Query_exec("UPDATE users SET enabled = 'no', warned = 'no', modcomment = '$modcomment' WHERE id = $user");
SQL_Query_exec("DELETE FROM warnings WHERE userid = $user AND type = 'HnR'");
write_log(T_("CLEANUP_THE_MEMBER")." <a href='account-details.php?id=".$user."'>".$h[0]."</a> ".T_("CLEANUP_HAS_BEEN_BANNED_REASON")." ".$count." H&R.");
$subject = "".T_("CLEANUP_YOUR_ACCOUNT")." $site_config[SITENAME] ".T_("CLEANUP_HAS_BEEN_DISABLED")."";
$body = "".T_("CLEANUP_YOU_WERE_BANNED_FOLLOWING")."\n
------------------------------
\n/".T_("CLEANUP_YOU_HAVE_ACCUMULATED")." $count H&R.\n
------------------------------
\n".T_("CLEANUP_YOU_CAN_CONTACT_BY_LINK")." :
".$site_config['SITEURL']."/contact.php
\n\n\n".$site_config['SITENAME']." ".T_("ADMIN");
sendmail($h[1], "$subject", "$body", "".T_("OF").": $site_config[SITEEMAIL]", "-f$site_config[SITEEMAIL]");
endif;
endwhile;
endif;
//Ban warned
$timenow = gmtime();
$k = SQL_Query_exec("SELECT userid FROM warnings WHERE type = 'HnR' AND active = 'yes' AND UNIX_TIMESTAMP(expiry) < $timenow");
if ( mysqli_num_rows($k) > 0 ) :
while ($l = mysqli_fetch_row($k)) :
$m = SQL_Query_exec("SELECT username, email, modcomment FROM users WHERE id = $l[0] AND enabled = 'yes' AND warned = 'yes'");
$n = mysqli_fetch_row($m);
$modcomment = $n[2];
$modcomment = gmdate("d/m/Y") . " - ".T_("CLEANUP_BANNED_FOR_EXPIRED_H&R_WARNING_TIMEOUT")."\n " .$modcomment;
SQL_Query_exec("UPDATE users SET enabled = 'no', warned = 'no', modcomment = '$modcomment' WHERE id = $l[0]");
SQL_Query_exec("DELETE FROM warnings WHERE userid = $l[0] AND type = 'HnR'");
write_log(T_("CLEANUP_THE_MEMBER")." <a href='account-details.php?id=".$l[0]."'>".$n[0]."</a> ".T_("CLEANUP_HAS_BEEN_BANNED_TIMEOUT")."");
$subject = "".T_("CLEANUP_YOUR_ACCOUNT")." $site_config[SITENAME] ".T_("CLEANUP_HAS_BEEN_DISABLED")."";
$body = "".T_("CLEANUP_YOU_WERE_BANNED_FOLLOWING")."\n
------------------------------
\n".T_("CLEANUP_TIMEOUT_WARNING_H&R_EXPIRED")."\n
------------------------------
\n".T_("CLEANUP_YOU_CAN_CONTACT_BY_LINK")." :
".$site_config['SITEURL']."/contact.php
\n\n\n".$site_config['SITENAME']." ".T_("ADMIN");
sendmail($n[1], "$subject", "$body", "".T_("OF").": $site_config[SITEEMAIL]", "-f$site_config[SITEEMAIL]");
endwhile;
endif;
// END HIT & RUN[color=rgb(251, 160, 38)]in account-details search :[/color]
$numtorrents = get_row_count("torrents", "WHERE owner = $id");Add after :
//h&r mod
$qry = SQL_Query_exec("SELECT COUNT(`hnr`) FROM `snatched` WHERE `uid` = '$id' AND `hnr` = 'yes'");
$res = mysqli_fetch_row($qry);
$hnr = $res[0];
//End h&rfind
<?php echo T_("RATIO"); ?>: <?php echo $ratio; ?><br />below
<?php echo T_("H&R"); ?>: <?php echo $hnr; ?><br />[color=rgb(251, 160, 38)]Add to english.php[/color]
$LANG["CLEANUP_WARNING_FOR_ACCUMULATING"] ="You're warned because you have accumulated";
$LANG["CLEANUP_WARNING_FOR_H&R"] ="Warning for H&R";
$LANG["CLEANUP_YOU_HAVE_BEEN_WARNEWD_ACCUMULATED"] ="You're warned because you have accumulated";
$LANG["CLEANUP_REMOVAL_OF_H&R_WARNING"] ="Your warning for H&R has been removed";
$LANG["CLEANUP_YOU_NOW_HAVE_LESS_THAN"] =" You have now less than";
$LANG["CLEANUP_YOUR_WARNING_FOR_H&R_HAS_REMOVED"] ="Your warning for H&R has been removed.";
$LANG["CLEANUP_BANNED_FOR"] ="Banned because that the warning time for H&R has expired.";
$LANG["CLEANUP_HAS_BEEN_BANNED_REASON"] ="Banned because that the warning time for H&R has expired.";
$LANG["CLEANUP_YOUR_ACCOUNT"] ="Your account at";
$LANG["CLEANUP_HAS_BEEN_DISABLED"] ="has been disabled";
$LANG["CLEANUP_YOU_WERE_BANNED_FOLLOWING"] ="You have been banned for the following reason";
$LANG["CLEANUP_YOU_CAN_CONTACT_BY_LINK"] ="You can contact us by following this link:";
$LANG["CLEANUP_BANNED_FOR_EXPIRED_H&R_WARNING_TIMEOUT"] ="Banned because that the warning time for H&R has expired";
$LANG["THERE_ARE_NO_RECORDINGS"] ="There are no recordings of Hit and Run!";
$LANG["H&R"] ="HnR";Add image to images/admin

