Thread: Hit & Run mod
View Single Post
  #17  
Old 12th January 2019, 12:19
elvira's Avatar
elvira elvira is offline
Senior Member
 
Join Date: Jan 2008
Slovenia
Posts: 172
Default
Here is then you see what is worng...this use from installer 09

snatched SQL

PHP Code:
DROP TABLE IF EXISTS `snatched`;
CREATE TABLE `snatched` (
  `
idint(10unsigned NOT NULL auto_increment,
  `
useridint(10unsigned NOT NULL default '0',
  `
torrentidint(10unsigned NOT NULL default '0',
  `
torrent_namevarchar(255NOT NULL default '',
  `
torrent_categoryint(10unsigned NOT NULL default '0',
  `
ipvarchar(15NOT NULL default '',
  `
portsmallint(5unsigned NOT NULL default '0',
  `
connectableenum('yes','no'NOT NULL default 'no',
  `
completedatdatetime NOT NULL default '0000-00-00 00:00:00',
  `
agentvarchar(60NOT NULL default '',
  `
peer_idvarchar(20NOT NULL default '',
  `
uploadedbigint(20unsigned NOT NULL default '0',
  `
upspeedbigint(20NOT NULL default '0',
  `
downloadedbigint(20unsigned NOT NULL default '0',
  `
downspeedbigint(20NOT NULL default '0',
  `
finishedenum('yes','no'NOT NULL default 'no',
  `
to_gobigint(20unsigned NOT NULL default '0',
  `
seederenum('yes','no'NOT NULL default 'no',
  `
seedtimeint(10unsigned NOT NULL default '0',
  `
leechtimeint(10unsigned NOT NULL default '0',
  `
start_datedatetime NOT NULL default '0000-00-00 00:00:00',
  `
last_actiondatetime NOT NULL default '0000-00-00 00:00:00',
  `
complete_datedatetime NOT NULL default '0000-00-00 00:00:00',
  `
timesannbigint(10unsigned NOT NULL default '0',
  `
sl_warnedenum('yes','no'NOT NULL default 'no',
  `
hitrundatetime NOT NULL default '0000-00-00 00:00:00',
  `
hitrunwarnenum('yes','pending','no'NOT NULL default 'no',
  `
cheatedbigint(10unsigned NOT NULL default '0',
  
PRIMARY KEY  (`id`),
  
KEY `tr_usr` (`torrentid`,`userid`)
ENGINE=MyISAM
announce.php

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_timegmtime() - 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()."', finished = 'yes'";
            
//$finished1 = ", complete_date = '" . get_date_time() . "'";
        
}

        
mysql_query"UPDATE peers SET ip = " sqlesc$ip ) . ", port = $port, connectable = '$connectable', webseeder='$webseeder', 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, webseeder, connectable, uploaded, downloaded, to_go, started, last_action, seeder, agent, downloadoffset, uploadoffset, passkey) VALUES ($torrentid$userid, " .
            
sqlesc$peer_id ) . ", " sqlesc$ip ) . ", $port,'$webseeder', '$connectable', $uploaded$downloaded$left, NOW(), NOW(), '$seeder', " .
            
sqlesc$agent ) . ", $downloaded$uploaded, " sqlescunesc$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_timegmtime() - 5400 ) . "', '0000-00-00 00:00:00', hitrun)";
            
$hitrunwarn "IF(hitrun > '" get_date_timegmtime() - 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, mark_of_cain = 'no' 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" );
        }
    } 
cleanup.php

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();
    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] == "" "s") . ".\n\n We advise you to return to continue seeding " . ($hitrun[$userid] == "this" "these") . " torrent" . ($hitrun[$userid] == "" "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] == "" "s") . " on which you have been found hit and running on " . ($hitrun[$userid] == "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 immunity='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() + (86400)) . "', downloadpos = 'no', dlremoveuntil = '" get_date_time(gmtime() + (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 " Member(s)");
        
write_log2("autohitrun""Auto Hit And Run Cleanup: System warned and disabed download(s) from " $count " 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 " Member(s)");
            
write_log2("autodewarn""Delayed Cleanup: System enabled download(s) from " $count " Member(s)");
        }
        unset (
$users_buffer);
        unset (
$msgs_buffer);
    }
 }
    
// /////end hitrun script//////// 
Reply With Quote