elvira |
16th December 2018 21:56 |
Hit & Run mod
Here I have a HitRun but dont think if this work so need a help
announce.php have this
PHP Code:
if ( isset( $self ) && $event == "stopped" ) {
mysql_query( "DELETE FROM peers WHERE $selfwhere" ) or err( "D Err" );
if ( mysql_affected_rows() ) {
$updateset[] = ( $self["seeder"] == "yes" ? "seeders = seeders - 1" :
"leechers = leechers - 1" );
$res = mysql_query( "SELECT start_date, uploaded, downloaded FROM snatched WHERE torrentid = $torrent[id] AND userid = $userid" ) or
err( "hitrun Err" ); //or err(mysql_error());
$snatched = mysql_fetch_assoc( $res );
$hitrun = ( ( $snatched["start_date"] > get_date_time( gmtime() - 86400 ) && ( $snatched["downloaded"] / 1.00 ) > $snatched["uploaded"] ) ? "IF(hitrun = '0000-00-00 00:00:00', '" .
get_date_time() . "', hitrun)" : "hitrun" );
mysql_query( "UPDATE snatched SET ip = " . sqlesc( $ip ) . ", port = $port, connectable = '$connectable', uploaded = uploaded + $upthis, downloaded = downloaded + $downthis, to_go = $left, upspeed = $upspeed, downspeed = $downspeed, $announcetime, last_action = '" .
get_date_time() . "', seeder = '$seeder', agent = " . sqlesc( $agent ) . ", hitrun = $hitrun WHERE torrentid = $torrentid AND userid = $userid" ) or err( "SL Err 1" );
}
} elseif ( isset( $self ) ) {
$prev_action = sqlesc( $self['last_action'] );
if ( $event == "completed" ) {
$updateset[] = "times_completed = times_completed + 1";
$finished = ", finishedat = UNIX_TIMESTAMP()";
$finished1 = ", complete_date = '" . get_date_time() . "'";
}
mysql_query( "UPDATE peers SET ip = " . sqlesc( $ip ) . ", port = $port, connectable = '$connectable', uploaded = $uploaded, downloaded = $downloaded, to_go = $left, last_action = NOW(), prev_action = $prev_action, seeder = '$seeder', agent = " .
sqlesc( $agent ) . " $finished WHERE $selfwhere" ) or err( "PL Err 1" );
if ( mysql_affected_rows() ) {
if ( $seeder <> $self["seeder"] )
$updateset[] = ( $seeder == "yes" ?
"seeders = seeders + 1, leechers = leechers - 1" :
"seeders = seeders - 1, leechers = leechers + 1" );
$anntime = "timesann = timesann + 1";
mysql_query( "UPDATE snatched SET ip = " . sqlesc( $ip ) . ", port = $port, connectable = '$connectable', uploaded = uploaded + $upthis, downloaded = downloaded + $downthis, to_go = $left, upspeed = $upspeed, downspeed = $downspeed, $announcetime, last_action = '" .
get_date_time() . "', seeder = '$seeder', agent = " . sqlesc( $agent ) . " $finished1, $anntime WHERE torrentid = $torrentid AND userid = $userid" ) or
err( "SL Err 2" );
}
} else {
if ( $az["parked"] == "yes" )
err( "Your account is parked! (Read the FAQ)" );
elseif ( $az["downloadpos"] == "no" )
err( "Your downloading priviledges have been disabled! (Read the rules)" );
mysql_query( "INSERT INTO peers (torrent, userid, peer_id, ip, port, connectable, uploaded, downloaded, to_go, started, last_action, seeder, agent, downloadoffset, uploadoffset, passkey) VALUES ($torrentid, $userid, " .
sqlesc( $peer_id ) . ", " . sqlesc( $ip ) . ", $port,'$connectable', $uploaded, $downloaded, $left, NOW(), NOW(), '$seeder', " .
sqlesc( $agent ) . ", $downloaded, $uploaded, " . sqlesc( unesc( $passkey ) ) . ")" ) or
err( "PL Err 2" );
if ( mysql_affected_rows() ) {
$updateset[] = ( $seeder == "yes" ? "seeders = seeders + 1" :
"leechers = leechers + 1" );
$anntime = "timesann = timesann + 1";
$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, connectable = '$connectable', to_go = $left, last_action = '" .
get_date_time() . "', seeder = '$seeder', agent = " . sqlesc( $agent ) . ", $anntime, hitrun = $hitrun, hitrunwarn = $hitrunwarn WHERE torrentid = $torrentid AND userid = $userid" ) or
err( "SL Err 3" );
if ( !mysql_affected_rows() && $seeder == "no" )
mysql_query( "INSERT INTO snatched (torrentid, userid, peer_id, ip, port, connectable, uploaded, downloaded, to_go, start_date, last_action, seeder, agent) VALUES ($torrentid, $userid, " .
sqlesc( $peer_id ) . ", " . sqlesc( $ip ) . ", $port, '$connectable', $uploaded, $downloaded, $left, '" .
get_date_time() . "', '" . get_date_time() . "', '$seeder', " . sqlesc( $agent ) . ")" ) or err( "SL Err 4" );
}
}
}
userdetalis.php
PHP Code:
function snatchtable($res) {
$table = "<table class=main border=1 cellspacing=0 cellpadding=5>
<tr>
<td class=colhead>Kategorija</td>
<td class=colhead>Torrent</td>
<td class=colhead>S.id</td>
<td class=colhead>Up.</td>
<td class=colhead>Rate</td>
<td class=colhead>Downl.</td>
<td class=colhead>Rate</td>
<td class=colhead>Ratio</td>
<td class=colhead>Akcija</td>
<td class=colhead>Zavrseno</td>
</tr>";
while ($arr = mysql_fetch_assoc($res)) {
$upspeed = ($arr["upspeed"] > 0 ? mksize($arr["upspeed"]) : ($arr["seedtime"] > 0 ? mksize($arr["uploaded"] / ($arr["seedtime"] + $arr["leechtime"])) : mksize(0)));
$downspeed = ($arr["downspeed"] > 0 ? mksize($arr["downspeed"]) : ($arr["leechtime"] > 0 ? mksize($arr["downloaded"] / $arr["leechtime"]) : mksize(0)));
$ratio = ($arr["downloaded"] > 0 ? number_format($arr["uploaded"] / $arr["downloaded"], 3) : ($arr["uploaded"] > 0 ? "Inf." : "---"));
$id=$arr[id];
$table .= "<tr>
<td style='padding: 0px'><img src='pic/".htmlspecialchars($arr["catimg"])."' alt='".htmlspecialchars($arr["catname"])."' width=42 height=42></td>
<td><a href=details.php?id=$arr[torrentid]><b>".(strlen($arr["name"]) > 50 ? substr($arr["name"], 0, 50 - 3)."..." : $arr["name"])."</b></a></td>
<td>".($arr["id"])."</td>
<td>".mksize($arr["uploaded"])."</td>
<td>$upspeed/s</td>
<td>".mksize($arr["downloaded"])."</td>
<td>$downspeed/s</td>
<td>$ratio</td>
<td>".mkprettytime($arr["seedtime"] + $arr["leechtime"])."</td>
<td>".($arr["complete_date"] <> "0000-00-00 00:00:00" ? "<font color=green><b>Da</b></font>" : "<font color=red><b>Ne</b></font>")."</td>
</tr>\n";
}
$table .= "</table>\n";
return $table;
}
and this userdetails too
PHP Code:
//=== start snatched
if (get_user_class() >= UC_MODERATOR){
if ($_GET["snatched_table"]){
echo "<tr><td class=clearalt6 align=right valign=top><b>Snatched+</b>[ <a class=altlink href=\"userdetails.php?id=$id\" class=\"sublink\">Sakrij</a> ]</td><td class=clearalt6>";
$res = mysql_query(
"SELECT UNIX_TIMESTAMP(sn.start_date) AS s, UNIX_TIMESTAMP(sn.complete_date) AS c, UNIX_TIMESTAMP(sn.last_action) AS l_a, UNIX_TIMESTAMP(sn.seedtime) AS s_t, sn.seedtime, UNIX_TIMESTAMP(sn.leechtime) AS l_t, sn.leechtime, sn.downspeed, sn.upspeed, sn.uploaded, sn.downloaded, sn.torrentid, sn.start_date, sn.complete_date, sn.seeder, sn.last_action, sn.connectable, sn.agent, sn.seedtime, sn.port, sn.ip, cat.name, cat.image, t.size, t.seeders, t.leechers, t.owner, t.name AS torrent_name ".
"FROM snatched AS sn ".
"LEFT JOIN torrents AS t ON t.id = sn.torrentid ".
"LEFT JOIN categories AS cat ON cat.id = t.category ".
"WHERE sn.userid=$id ORDER BY sn.start_date DESC"
) or die(mysql_error());
echo "<table border=1 cellspacing=0 cellpadding=3 align=center width=750><tr><td class=colhead align=center width=50>Type</td><td class=colhead align=left>Torrent</td>".
"<td class=colhead align=center>S. / L.</td><td class=colhead align=center>Up / Down</td><td class=colhead align=center>Size / Hr / Compl</td>".
"<td class=colhead align=center width=50>Ratio</td><td class=colhead align=center>Client</td></tr>";
while ($arr = mysql_fetch_assoc($res)){
$res2 = mysql_query("SELECT seeder FROM peers WHERE torrent = $arr[torrentid] AND userid=$user[id]");
$arr2 = mysql_fetch_assoc($res2);
//=======change colors
$count2= (++$count2)%2;
$class = 'clearalt'.($count2==0?'6':'7');
//=== speed color red fast green slow ;)
if ($arr["upspeed"] > 0)
$ul_speed = ($arr["upspeed"] > 0 ? mksize($arr["upspeed"]) : ($arr["seedtime"] > 0 ? mksize($arr["uploaded"] / ($arr["seedtime"] + $arr["leechtime"])) : mksize(0)));
else
$ul_speed = mksize(($arr["uploaded"] / ( $arr['l_a'] - $arr['s'] + 1 )));
if ($arr["downspeed"] > 0)
$dl_speed = ($arr["downspeed"] > 0 ? mksize($arr["downspeed"]) : ($arr["leechtime"] > 0 ? mksize($arr["downloaded"] / $arr["leechtime"]) : mksize(0)));
else
$dl_speed = mksize(($arr["downloaded"] / ( $arr['c'] - $arr['s'] + 1 )));
switch (true){
case ($dl_speed > 600):
$dlc = 'red';
break;
case ($dl_speed > 300 ):
$dlc = 'orange';
break;
case ($dl_speed > 200 ):
$dlc = 'yellow';
break;
case ($dl_speed < 100 ):
$dlc = 'chartreuse';
break;
}
if ($arr["downloaded"] > 0){
$ratio = number_format($arr["uploaded"] / $arr["downloaded"], 3);
$ratio = "<font color=" . get_ratio_color($ratio) . "><b>Ratio:</b>$ratio</font>";
}
else
if ($arr["uploaded"] > 0)
$ratio = "Inf.";
else
$ratio = "N/A";
$time = mkprettytime(strtotime("now") - strtotime($arr["complete_date"]) - (($CURUSER["timezone"] + $CURUSER["dst"]) * 60));
$seedtime = mkprettytime(strtotime("now") / 10800);
$days = explode("d ", $seedtime);
if(sizeof($days) > 1) {
$seedtime = $arr["seedtime"] - $days[0];
}
//if ($time < 7 || $seedtime >= 259200)
if ($seedtime >= 86400)
$hr = "<font color=green><b>Ne</b></font>";
else
$hr = "<font color=red><b>Da</b></font>";
/// smallname torrents
$smallname3 =substr(htmlspecialchars($arr["torrent_name"]) , 0, 48);
if ($smallname3 != htmlspecialchars($arr["torrent_name"])) {
$smallname3 .= '...';
}
echo "<tr><td class=$class align=center>".($arr['owner'] == $id ? "<b><font color=orange>Torrent Owner</font></b>" : "".($arr['complete_date'] != '0000-00-00 00:00:00' ? "<b><font color=green>Završeno</font></b>" : "<b><font color=red>Ne Završeno</font>")."")."<img src=pic/$arr[image] alt=$arr[name]></td>".
"<td class=$class><a class=altlink href=details.php?id=$arr[torrentid]><b>$smallname3</b></a> ".($arr['complete_date'] != '0000-00-00 00:00:00' ? "".
"<font color=silver>Početo: ".$arr['start_date']."</font><font color=silver>Završeno: ".$arr['complete_date']."</font>" : "".
"<font color=silver>Početo: ".$arr['start_date']."</font><font color=orange>Akcija: ".$arr['last_action']."</font> ".
"".($arr['complete_date'] == '0000-00-00 00:00:00' ? "".($arr['owner'] == $id ? "" : "[ ".mksize($arr["size"] - $arr["downloaded"])." i još do ]")."" : "")."")."".($arr['complete_date'] != '0000-00-00 00:00:00' ? "".
"".($arr['complete_date'] == '0000-00-00 00:00:00' ? "" : "<font color=silver>Akcija: ".$arr['last_action']."</font>")."".
"<font color=silver>Vrijeme Downloada: ".($arr['leechtime'] != '0' ? mkprettytime($arr['leechtime']) : mkprettytime($arr['c'] - $arr['s'])."")."</font><font color=$dlc>[ Down. at: $dl_speed ]<font>".
"" : "")."<font color=blue>".($arr['seedtime'] != '0' ? "Totalni Seed Vrijeme: ".mkprettytime($arr['seedtime'])." <font color=$dlc> " : "Totalni Seed Vrijeme: N/A")."".
"</font><font color=green> [ Up. Speed: ".$ul_speed." ] </font>".($arr['complete_date'] == '0000-00-00 00:00:00' ? "<font color=$dlc>Download Speed: $dl_speed</font>" : "")."".
"<font color=Green>Totalni Leech Vrijeme: ".mkprettytime($arr['leechtime'])."</font><font color=olive>Announced: ".($arr['timesann'])." puta</font><font color=orange>Leech Za: ".($arr['ip'])."</font></td>"."<td align=center class=$class>Se: ".$arr['seeders']."Le: ".$arr['leechers']."</td><td align=center class=$class><font color=green>Up:".
"<b>".$uploaded =mksize($arr["uploaded"])."</b></font><font color=orange>Down:<b>".$downloaded = mksize($arr["downloaded"])."</b></font></td>".
"<td align=center class=$class>Veličina: ".mksize($arr["size"])."Odvisno od: <font color=orange><b>".mksize($arr['size'] - $arr["downloaded"])."</b></font><b>Hit & Run:</b> $hr<b>Završeno:</b>$time nazad</td>".
"<td align=center class=$class>$ratio".($arr2['seeder'] == 'yes' ? "<font color=green><b>Seeduje</b></font>" : "<font color=red><b>Ne Seeduje</b></font>")."".
"</td><td align=center class=$class>".$arr["agent"]."Port: ".$arr["port"]."".($arr["connectable"] == 'yes' ? "<b>Priključen: <font color=green>Da</font>".
"</b>" : "<b>Priključen: <font color=red><b>Ne</b></font>")."</td></tr>\n";
}
echo "</table></td></tr>\n";
}
else
tr("<font color=orangered>Skinuti Torrenti:</font>","[ <a class=altlink href=\"userdetails.php?id=$id&snatched_table=1\" class=\"sublink\">Prikazi</a> ] - $count_snatched <font color=red><b>staff jedino!!!</font></b>", 1);
}
//=== end snatched
cleanup.php
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////////
|