his mod is an add-on for the snatchlist mod, so you need to have that installed first.
If you do not have a snatchlist mod installed yet I suggest this one: [New and Improved] Snatchlist
A bit info about what it does:
This will set a user to pending hit and run if he leaves the torrent within 3 hours after the torrent was uploaded and his upload amount is less then half of his download amount and he downloaded at least 1 GB. It will then (through cleanup, to reduce queries on announce) send a message to a user that he has to return to the torrent within 1 hour. Actually he has 1.5 hour to return to the torrent. This is because cleanup can run maybe 20 minutes after he hit and ran the torrent, so if he would receive the message then he would actually have only 40 minutes to return to the torrent instead of 1 hour. If the user does not return to the torrent within the time limit his status will be changed to confirmed hit and run.
If you chose to use the auto warn script the cleanup will update the user’s hit and run total. If the user’s hit and run amount is larger then X the user will be warned. All hit&runs will then be reset and the cycle will start over.
If you chose not to use the auto warn script you can use hitruns.php to view all the hit and runs, and from there select which users to warn and which users to reset (remove from the hit and run list). Just find a nice place to add a link to hitruns.php. Note that you have to go there by hitruns.php?userid=*id* or hitruns.php?torrentid=*id*. So there are 2 possible search options, to view all hit and runs from a single torrent, or to view all hit and runs from a single user.
SQL:
ALTER TABLE `snatched` ADD `hitrun` datetime NOT NULL DEFAULT '0000-00-00 00:00:00'; ALTER TABLE `snatched` ADD `hitrunwarn` ENUM('yes','pending','no') NOT NULL DEFAULT 'no';
if you chose to use the auto warn script add this as well
SQL:
ALTER TABLE `users` ADD `hitruns` tinyint(3) UNSIGNED NOT NULL DEFAULT '0';
announce.php
Find:
$res = mysql_query("SELECT id, banned, seeders + leechers AS numpeers, UNIX_TIMESTAMP(added) AS ts FROM torrents WHERE " . hash_where("info_hash", $info_hash));
Change to: (so add added into it)
$res = mysql_query("SELECT id, added, banned, seeders + leechers AS numpeers, UNIX_TIMESTAMP(added) AS ts FROM torrents WHERE " . hash_where("info_hash", $info_hash));
Note:
If you have the [New and Improved] Snatchlist you do not have to add/replace any queries, you simply have to add the 2 $hitrun = parts before the queries that end on err(“SL Err 1″) and err(“SL Err 3″) and in the queries add hitrun = $hitrun.
Then only before the query that ends on err(“SL Err 3″) you should add the $hutrunwarn = part and in the query add hitrunwarn = $hitrunwarn.
Find:
mysql_query("DELETE FROM peers WHERE $selfwhere"); if (mysql_affected_rows()) {
Add under:
$hitrun = (($torrent["added"] > get_date_time(gmtime() - 10800) && ($downloaded / 2) > $uploaded && $downloaded > (1024 * 1024 * 1024)) ? "IF(hitrun = '0000-00-00 00:00:00', '".get_date_time()."', hitrun)" : "hitrun"); mysql_query("UPDATE snatched SET uploaded = uploaded + $upthis, downloaded = downloaded + $downthis, ip = ".sqlesc($ip).", port = $port, agent= ".sqlesc($agent).", last_action = '".get_date_time()."', hitrun = $hitrun WHERE torrentid = $torrentid AND userid = $userid") or err("Error X1");
And replace:
$res1_s = mysql_query("SELECT torrentid, userid FROM snatched WHERE torrentid = $torrentid AND userid = $userid") or err('Tracker error (120)'); $row1_s = mysql_fetch_assoc($res1_s); if (!$row1_s) mysql_query("INSERT INTO snatched (torrentid, userid, port, start_date, agent,ip,peer_id) VALUES ($torrentid, $userid, $port, '".get_date_time()."', " . sqlesc($agent) . "," . sqlesc($ip) . "," . sqlesc($peer_id) . ")");
with:
if (mysql_affected_rows()) { $hitrun = "IF(hitrun > '".get_date_time(gmtime() - 5400)."', '0000-00-00 00:00:00', hitrun)"; $hitrunwarn = "IF(hitrun > '".get_date_time(gmtime() - 5400)."', 'no', hitrunwarn)"; mysql_query("UPDATE snatched SET ip = ".sqlesc($ip).", port = $port, agent = ".sqlesc($agent).", last_action = '".get_date_time()."', hitrun = $hitrun, hitrunwarn = $hitrunwarn WHERE torrentid = $torrentid AND userid = $userid") or err("Error X2"); if (!mysql_affected_rows()) mysql_query("INSERT INTO snatched (torrentid, userid, port, start_date, agent,ip,peer_id) VALUES ($torrentid, $userid, $port, '".get_date_time()."', " . sqlesc($agent) . "," . sqlesc($ip) . "," . sqlesc($peer_id) . ")") or err("Error X3"); }
and move it after this query:
$ret = mysql_query("INSERT INTO peers (connectable, torrent, peer_id, ip, port, uploaded, downloaded, to_go, started, last_action, seeder, userid, agent, uploadoffset, downloadoffset, passkey) VALUES ('$connectable', $torrentid, " . sqlesc($peer_id) . ", " . sqlesc($ip) . ", $port, $uploaded, $downloaded, $left, NOW(), NOW(), '$seeder', $userid, " . sqlesc($agent) . ", $uploaded, $downloaded, " . sqlesc($passkey) . ")");
cleanup.php
Message the hit and runners:
// Message users who have hit and run $res = mysql_query("SELECT s.id, userid, torrentid, name FROM snatched AS s INNER JOIN torrents AS t ON s.torrentid = t.id WHERE hitrun <> '0000-00-00 00:00:00' && hitrunwarn = 'no'") or sqlerr(); if (mysql_num_rows($res) > 0) { $ids = $userids = array(); while ($arr = mysql_fetch_assoc($res)) { $ids[] = $arr["id"]; $userids[] = $arr["userid"]; $hitrun[$arr["userid"]]++; $torrents[$arr["userid"]] .= "\n[b][url=details.php?id=$arr[torrentid]]$arr[name][/url][/b]"; } $userids = array_unique($userids); foreach($userids as $userid) { $msg = sqlesc("It appears that you have hit and run on $hitrun[$userid] torrent".($hitrun[$userid] == 1 ? "" : "s").".\n\nWe advise you to return to continue seeding ".($hitrun[$userid] == 1 ? "this" : "these")." torrent".($hitrun[$userid] == 1 ? "" : "s")." within 1 hour or else you risk being warned, or if this happends to you repeatedly you may even risk your account being disabled.\n\nThe torrent".($hitrun[$userid] == 1 ? "" : "s")." on which you have been found hit and running ".($hitrun[$userid] == 1 ? "is" : "are").":\n$torrents[$userid]"); // remove this if you DO NOT want to use the auto warn option // $msg = sqlesc("It appears that you have hit and run on $hitrun[$userid] torrent".($hitrun[$userid] == 1 ? "" : "s").".\n\nWe would like to request you to return to ".($hitrun[$userid] == 1 ? "this" : "these")." torrent".($hitrun[$userid] == 1 ? "" : "s").". If you do not return this will reported and the staff will evaluate if appropriate action needs to be taken.\n\nThe torrent".($hitrun[$userid] == 1 ? "" : "s")." on which you have been found hit and running ".($hitrun[$userid] == 1 ? "is" : "are").":\n$torrents[$userid]"); // remove this if you want to use the auto warn script mysql_query("INSERT INTO messages (added, poster, sender, receiver, subject, msg) VALUES ('".get_date_time()."', 0, 0, $userid, 'Hit and Run', $msg)") or sqlerr(); } mysql_query("UPDATE snatched SET hitrunwarn = 'pending' WHERE id IN (".implode(", ", $ids).")") or sqlerr(); }
If you want to use the auto warn script use the following 2 parts for cleanup.php
Process the hit and runners:
// Process hit and runs of users that have not returned $res = mysql_query("SELECT id, userid FROM snatched WHERE hitrunwarn = 'pending' AND hitrun < '".get_date_time(gmtime() - 5400)."'") or sqlerr(); if (mysql_num_rows($res) > 0) { $ids = $userids = array(); while ($arr = mysql_fetch_assoc($res)) { $ids[] = $arr["id"]; $userids[] = $arr["userid"]; $hitrun[$arr["userid"]]++; } $userids = array_unique($userids); foreach($userids as $userid) mysql_query("UPDATE users SET hitruns = hitruns + $hitrun[$userid] WHERE id = $userid") or sqlerr(); mysql_query("UPDATE snatched SET hitrunwarn = 'yes' WHERE id IN (".implode(", ", $ids).")") or sqlerr(); }
And to warn users who hit and run a lot:
// Warn repeating hit and runners $maxhitrun = 10; $res = mysql_query("SELECT id FROM users WHERE hitruns > $maxhitrun AND warned = 'no'") or sqlerr(); if (mysql_num_rows($res) > 0) { $userids = array(); $modcomment = sqlesc(gmdate("d-m-Y")." - Warned by System for Hit and Run.\n"); $msg = sqlesc("You have repeatidly hit and run on torrents even after we have notified you that you should return to the torrent to continue seeding. Therefor you have received this one week warning. Hopefully you will not hit and run on torrents anymore, and if you do it may result in your account being disabled."); while ($arr = mysql_fetch_assoc($res)) { $userids[] = $arr["id"]; mysql_query("INSERT INTO messages (added, poster, sender, receiver, subject, msg) VALUES ('".get_date_time()."', 0, 0, $arr[id], 'Hit and Run', $msg)") or sqlerr(); } mysql_query("UPDATE users SET warned = 'yes', warneduntil = '".get_date_time(gmtime() + (7 * 86400))."', modcomment = CONCAT($modcomment, modcomment), hitruns = 0 WHERE id IN (".implode(", ", $userids).")") or sqlerr(); }
If you do not want to use the auto warn script use the following part for cleanup.php
Process the hit and runners:
// Process hit and runs of users that have not returned mysql_query("UPDATE snatches SET hitrunwarn = 'yes' WHERE hitrunwarn = 'pending' AND hitrun < '".get_date_time(gmtime() - 5400)."'") or sqlerr();
If you do not want to use the auto warn script use the following part
(If you do use the auto warn script you can still use this, but the warn and reset parts would be pretty useless so you could remove them)
No Comment Received
Leave A Reply