in cleanup replace this
PHP Code:
function doautohitrun()
{
global $SITENAME, $CURUSER, $DEFAULTBASEURL, $autohitrun_interval, $queries, $query_stat;
set_time_limit(1200);
$result = mysql_query("show processlist") or sqlerr(__FILE__, __LINE__);
while ($row = mysql_fetch_array($result)) {
if (($row["Time"] > 100) || ($row["Command"] == "Sleep")) {
$sql = "kill " . $row["Id"] . "";
mysql_query($sql) or sqlerr(__FILE__, __LINE__);
}
}
ignore_user_abort(1);
// 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=$DEFAULTBASEURL/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\n We 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 happens to you regular you may even risk your account being disabled - If your a Donor you can choose to seed or not as donors wont be warned.\n\nThe torrent" . ($hitrun[$userid] == 1 ? "" : "s") . " on which you have been found hit and running on " . ($hitrun[$userid] == 1 ? "is" : "are") . ":\n$torrents[$userid]");
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();
}
// 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();
}
// modified Warn repeating hit and runners
$maxhitrun = 5;
$res = mysql_query("SELECT id FROM users WHERE hitruns > $maxhitrun AND warned = 'no' AND class < " . UC_VIP . " AND immun='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 continued to hit and run on torrents even after we have notified you. Therefore you have received a five day warning with your downloads disabled. You know when you sign up to a private community we rely on you following seedtime's so hopefully you will learn the system here :), and if you dont 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() + (5 * 86400)) . "', downloadpos = 'no', dlremoveuntil = '" . get_date_time(gmtime() + (5 * 86400)) . "', modcomment = CONCAT($modcomment, modcomment), hitruns = 0 WHERE id IN (" . implode(", ", $userids) . ")") or sqlerr();
$count = mysql_affected_rows();
write_log("Auto Hit And Run Cleanup: System warned and disabed download(s) from " . $count / 2 . " Member(s)");
write_log2("autohitrun", "Auto Hit And Run Cleanup: System warned and disabed download(s) from " . $count / 2 . " Member(s)");
}
// ==New remove expired warning and download disablement's for hit and run system
$res = sql_query("SELECT id FROM users WHERE warned='yes' AND downloadpos='no' AND dlremoveuntil < NOW() AND dlremoveuntil <> '0000-00-00 00:00:00'") or sqlerr(__FILE__, __LINE__);
$msgs_buffer = $users_buffer = array();
if (mysql_num_rows($res) > 0) {
$msg = "Your downloads have been enabled and your warning removed. Please keep in your best behaviour from now on.\n";
while ($arr = mysql_fetch_assoc($res)) {
$modcomment = sqlesc(gmdate("Y-m-d H:i") . " - Downloads automatically enabled By System\n");
$msgs_buffer[] = '(0,' . $arr['id'] . ',NOW(), ' . sqlesc($msg) . ', \'Downloads enabled\')';
$users_buffer[] = '(' . $arr['id'] . ',\'yes\',\'no\',\'0000-00-00 00:00:00\',\'0000-00-00 00:00:00\',' . $modcomment . ')';
}
if (sizeof($msgs_buffer) > 0) {
sql_query("INSERT INTO messages (sender,receiver,added,msg,subject) VALUES " . implode(', ', $msgs_buffer)) or sqlerr(__FILE__, __LINE__);
sql_query("INSERT INTO users (id, downloadpos, warned, dlremoveuntil, warneduntil, modcomment) VALUES " . implode(', ', $users_buffer) . " ON DUPLICATE key UPDATE downloadpos=values(downloadpos),
warned=values(warned),dlremoveuntil=values(dlremoveuntil),warneduntil=values(warneduntil),modcomment=concat(values(modcomment),modcomment)") or sqlerr(__FILE__, __LINE__);
$count = mysql_affected_rows();
write_log("Delayed Cleanup: System enabled download(s) from " . $count / 2 . " Member(s)");
write_log2("autodewarn", "Delayed Cleanup: System enabled download(s) from " . $count / 2 . " Member(s)");
}
unset ($users_buffer);
unset ($msgs_buffer);
}
// /////end hitrun script////////
write_log("----------------------Auto hit and run clean complete using $queries queries---------------------");
write_log2("autohitrun", " -------------------- Auto hit and run clean Complete using $queries queries --------------------");
// /////end hitrun script////////
}
with this
PHP Code:
// 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(__FILE__, __LINE__);
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=$DEFAULTBASEURL/details.php?id=$arr[torrentid]]$arr[name][/url][/b]";
}
$userids = array_unique($userids);
foreach($userids as $userid) {
$msg = sqlesc("Izgleda da imate HnR za $hitrun[$userid] torrent-a" . ($hitrun[$userid] == 1 ? "" : "s") . ".\n\n Savjetujemo, da se vratite na seed " . ($hitrun[$userid] == 1 ? "ovog" : "ovih") . " torrent" . ($hitrun[$userid] == 1 ? "" : "a") . " za 1 sat ili će vaš račun biti opozoren. Ako se to dogodi, da redovito dobijate upozorenja imate čak i rizik vaš račun bude blokiran - Ako ste donator sami presudite za seed ili ne, jer donatori neće biti opozoreni.\n\nTorrent" . ($hitrun[$userid] == 1 ? "" : "i") . " na kojem je pronaden HnR " . ($hitrun[$userid] == 1 ? "je" : "su") . ":\n$torrents[$userid]");
mysql_query("INSERT INTO messages (added, poster, sender, receiver, subject, msg) VALUES ('" . get_date_time() . "', 0, 0, $userid, 'HnR Torrent', $msg)") or sqlerr(__FILE__, __LINE__);
}
mysql_query("UPDATE snatched SET hitrunwarn = 'pending' WHERE id IN (" . implode(", ", $ids) . ")") or sqlerr(__FILE__, __LINE__);
}
// 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(__FILE__, __LINE__);
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(__FILE__, __LINE__);
mysql_query("UPDATE snatched SET hitrunwarn = 'yes' WHERE id IN (" . implode(", ", $ids) . ")") or sqlerr(__FILE__, __LINE__);
}
// modified Warn repeating hit and runners
$maxhitrun = 5;
$res = mysql_query("SELECT id FROM users WHERE hitruns > $maxhitrun AND warned = 'no' AND class < " . UC_VIP . " AND immunity='no'") or sqlerr(__FILE__, __LINE__);
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 continued to hit and run on torrents even after we have notified you. Therefore you have received a five day warning with your downloads disabled. You know when you sign up to a private community we rely on you following seedtime's so hopefully you will learn the system here :), and if you dont 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(__FILE__, __LINE__);
}
mysql_query("UPDATE users SET warned = 'yes', warneduntil = '" . get_date_time(gmtime() + (5 * 86400)) . "', downloadpos = 'no', dlremoveuntil = '" . get_date_time(gmtime() + (5 * 86400)) . "', modcomment = CONCAT($modcomment, modcomment), hitruns = 0 WHERE id IN (" . implode(", ", $userids) . ")") or sqlerr(__FILE__, __LINE__);
$count = mysql_affected_rows();
write_log("Auto Hit And Run Cleanup: System warned and disabed download(s) from " . $count / 2 . " Member(s)");
write_log2("autohitrun", "Auto Hit And Run Cleanup: System warned and disabed download(s) from " . $count / 2 . " Member(s)");
}
// ==New remove expired warning and download disablement's for hit and run system
$res = sql_query("SELECT id FROM users WHERE warned='yes' AND downloadpos='no' AND dlremoveuntil < NOW() AND dlremoveuntil <> '0000-00-00 00:00:00'") or sqlerr(__FILE__, __LINE__);
$msgs_buffer = $users_buffer = array();
if (mysql_num_rows($res) > 0) {
$msg = "Your downloads have been enabled and your warning removed. Please keep in your best behaviour from now on.\n";
while ($arr = mysql_fetch_assoc($res)) {
$modcomment = sqlesc(gmdate("Y-m-d H:i") . " - Downloads automatically enabled By System\n");
$msgs_buffer[] = '(0,' . $arr['id'] . ',NOW(), ' . sqlesc($msg) . ', \'Downloads enabled\')';
$users_buffer[] = '(' . $arr['id'] . ',\'yes\',\'no\',\'0000-00-00 00:00:00\',\'0000-00-00 00:00:00\',' . $modcomment . ')';
}
if (sizeof($msgs_buffer) > 0) {
sql_query("INSERT INTO messages (sender,receiver,added,msg,subject) VALUES " . implode(', ', $msgs_buffer)) or sqlerr(__FILE__, __LINE__);
sql_query("INSERT INTO users (id, downloadpos, warned, dlremoveuntil, warneduntil, modcomment) VALUES " . implode(', ', $users_buffer) . " ON DUPLICATE key UPDATE downloadpos=values(downloadpos),
warned=values(warned),dlremoveuntil=values(dlremoveuntil),warneduntil=values(warneduntil),modcomment=concat(values(modcomment),modcomment)") or sqlerr(__FILE__, __LINE__);
$count = mysql_affected_rows();
write_log("Delayed Cleanup: System enabled download(s) from " . $count / 2 . " Member(s)");
write_log2("autodewarn", "Delayed Cleanup: System enabled download(s) from " . $count / 2 . " Member(s)");
}
unset ($users_buffer);
unset ($msgs_buffer);
}
// /////end hitrun script////////
|