########################################## 
## MOD Title:  Speed Control Page
## MOD Author:  fakka < fakkast@gmail.com > (N/A) N/A 
## MOD Translate to TorrentPier R775: Pandora
## MOD Description: 
##      Adds peer to cheaters table if peer_speed is over allowed
## MOD Version:  1.0.5
## 
## Installation Level:  Easy 
## Installation Time:   1-2 Minutes 
## Included files: 
##
##	viewcheater.php
##	templates/default/viewcheater.tpl
########################################## 

# 
#-----[ SQL ]--------------------------------------------- 
# 

CREATE TABLE `bb_bt_cheater` (
  `user_id` bigint(20) NOT NULL,
  `time` bigint(20) unsigned NOT NULL default '0',
  `torrent_id` bigint(20) NOT NULL,
  `speed_up` bigint(20) NOT NULL,
  `ch_up_tor` bigint(20) unsigned NOT NULL default '0',
  `ch_up_up` bigint(20) unsigned NOT NULL default '0',
  KEY `user_id` (`user_id`),
  KEY `torrent_id` (`torrent_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

#
#-----[ COPY ]--------------------------------------------- 
#
viewcheater.php to viewcheater.php
/templates/default/viewcheater.tpl to /templates/default/viewcheater.tpl

# 
#-----[ OPEN ]--------------------------------------------- 
# 
forum/templates/default/page_header.tpl
# 
#-----[ FIND ]--------------------------------------------- 
# 
<a href="{U_MEMBERLIST}"><b>{L_MEMBERLIST}</b></a>

# 
#-----[ AFTER ADD ]--------------------------------------------- 
# 
			<a href="viewcheater.php"><b></b></a>
# 
#-----[ OPEN ]--------------------------------------------- 
# 
bt/announcer.php

# 
#-----[ FIND ]--------------------------------------------- 
# 
if (!$lp_info || !$peer_info_updated)
{
	$columns = 'peer_hash,    topic_id,  user_id,   ip,       port, client, seeder,  releaser, tor_type,  uploaded,  downloaded, remain, speed_up,  speed_down,  up_add,  down_add,  update_time';
	$values = "'$peer_hash', $topic_id, $user_id, '$ip_sql', $port, '$client', $seeder, $releaser, $tor_type, $uploaded, $downloaded, $left, $speed_up, $speed_down, $up_add, $down_add, $update_time";

	DB()->query("REPLACE INTO ". BB_BT_TRACKER ." ($columns) VALUES ($values)");

	if (DBG_LOG) dbg_log(' ', 'this_peer-insert');
}

# 
#-----[ AFTER ADD ]--------------------------------------------- 
# 
// speed threshold anticheat
if($speed_up > $bb_cfg['speed_threshold'] && $bb_cfg['ban_speed_cheaters'] )
{   
  $current_time = TIMENOW; //time();
	
  $sql = 'INSERT INTO ' . BB_BT_CHEATER
       . " (user_id, time, torrent_id, speed_up)"
       . " VALUES ('$user_id','$current_time', '$topic_id', '$speed_up')";

  @DB()->sql_query($sql);  
}

# 
#-----[ OPEN ]--------------------------------------------- 
# 
init_bb.php

# 
#-----[ FIND ]--------------------------------------------- 
# 
define('BB_BT_USERS',    'bt_users');

# 
#-----[ AFTER ADD ]--------------------------------------- 
# 

define('BB_BT_CHEATER',  'bt_cheater'); // bb_bt_cheater

# 
#-----[ OPEN ]--------------------------------------------- 
# 
config.php

# 
#-----[ FIND ]--------------------------------------------- 
# 
$banned_user_agents = array(
// Download Master
#	'download',
#	'master',
// Others
#	'wget',
);

# 
#-----[ AFTER ADD ]--------------------------------------- 
# 
$bb_cfg['speed_threshold']           = 10*1024*1024; // In bytes per second. 10mbytes by default
$bb_cfg['ban_speed_cheaters']        = true ; // true or false   >:-]

# 
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
#