Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   TBDev (http://www.bvlist.com/forumdisplay.php?f=20)
-   -   Hit & Run mod (http://www.bvlist.com/showthread.php?t=11889)

elvira 19th December 2018 21:30

@Elena thanks for post but this is not HitRun

Napon 19th December 2018 22:00

no its not lol

elvira 6th January 2019 01:45

is here someone who have a HitRun mod for source TBDev 08....


:welcome:

DND 6th January 2019 01:52

i could help ya with that.:coffee:

elvira 6th January 2019 02:03

so please where we start

Tedmorris 12th January 2019 11:50

I use a heavily modded TB source with a modified 09 hnr added but it would need tweaking to work on 08..

Looking at your hnr announce code and comparing it with mine theres alot of diffrence. You dont have class times defined in your stopped query. Is your db in date time for hnr? Mine doesnt use date time, it uses unix time.

Where did you get the source from that your using? What source was it coded for?

Do you have a gmtime function? Have you downloaded a torrent, completed it and then stopped it and checked the snatched table in your db to see if a hnr time was added for that user and that torrent?

elvira 12th January 2019 12:19

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//////// 


Tedmorris 12th January 2019 12:24

Do you hve gmtime function and can you do the above debugging I've mentioned. Do you have show errors enabled?
At the top of your announce
error_reporting(E_ALL);

elvira 12th January 2019 12:26

Quote:

Originally Posted by Tedmorris (Post 53081)
Do you hve gmtime function and can you do the above debugging I've mentioned. Do you have show errors enabled?

Yes have it in globalfunctions

PHP Code:

function gmtime()
{
    return 
strtotime(get_date_time());



Tedmorris 12th January 2019 12:31

When you browse your snatched table in the db do you have anything besides zeros in the hitrun row?


All times are GMT +2. The time now is 08:54.

Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.