'UD_ALL' => humn_size($stats['total_dl_ul']),
'UPL' => humn_size($stats['upload']),
'S_UL' => humn_size($stats['s_ul']),
'DNL' => humn_size($stats['download']),
'S_DL' => humn_size($stats['s_dl']),
'ST' => $stats['active_seeders'],
'LT' => $stats['active_leechers'],
'STU' => $stats['active_seeders_u'],
'LTU' => $stats['active_leechers_u'],
'PERV' => $stats['active_peers_all'],
'TT' => $stats['active_tor'],
'TS' => humn_size($stats['active_tor_size']),
'TN' => $stats['all_tor'],
'TOS' => humn_size($stats['all_tor_size']),
// Tracker stats
if ($bb_cfg['tor_stats'])
{
//up_down total
$sql = "SELECT ROUND(SUM(u_up_total+u_down_total)) AS pumped, ROUND(SUM(u_up_total)) AS upl, ROUND(SUM(u_down_total)) AS donl FROM " . BB_BT_USERS;
$row = DB()->fetch_row($sql);
$data['total_dl_ul'] = $row['pumped'];
$data['upload'] = $row['upl'];
$data['download'] = $row['donl'];
//up_down total end
//active seeders begin
$sql = 'SELECT COUNT(user_id) AS st FROM '. BB_BT_TRACKER .' WHERE seeder = 1';
$row = DB()->fetch_row($sql);
$data['active_seeders'] = number_format($row['st']);
//active seeders end
//active leechers begin
$sql = 'SELECT COUNT(user_id) AS lt FROM '. BB_BT_TRACKER .' WHERE seeder = 0';
$row = DB()->fetch_row($sql);
$data['active_leechers'] = number_format($row['lt']);
//active leechers end
//active leechers begin
$sql = 'SELECT COUNT(user_id) AS perv FROM '. BB_BT_TRACKER .'';
$row = DB()->fetch_row($sql);
$data['active_peers_all'] = number_format($row['perv']);
//active leechers end
//active seeders begin
$sql = 'SELECT COUNT(DISTINCT user_id) AS stu FROM '. BB_BT_TRACKER .' WHERE seeder = 1';
$row = DB()->fetch_row($sql);
$data['active_seeders_u'] = number_format($row['stu']);
//active seeders end
//active leechers begin
$sql = 'SELECT COUNT(DISTINCT user_id) AS ltu FROM '. BB_BT_TRACKER .' WHERE seeder = 0';
$row = DB()->fetch_row($sql);
$data['active_leechers_u'] = number_format($row['ltu']);
//active leechers end
//active torrents begin
$sql = 'SELECT COUNT(DISTINCT tor.topic_id) AS tt , SUM(tor.size) AS ts
FROM '. BB_BT_TRACKER .' tr , '. BB_BT_TORRENTS .' tor
WHERE tr.topic_id = tor.topic_id';
$row = DB()->fetch_row($sql);
$data['active_tor'] = number_format($row['tt']);
$data['active_tor_size'] = $row['ts'];
//active torrents end
//all torrents begin
$sql = ' SELECT COUNT(*) as tn, SUM(size) AS tos
FROM '.BB_BT_TORRENTS;
$row = DB()->fetch_row($sql);
$data['all_tor'] = number_format($row['tn']);
$data['all_tor_size'] = $row['tos'];
//all torrents end
// users speed
$sql = 'SELECT sum(speed_up) AS s_ul, sum(speed_down) AS s_dl
FROM bb_bt_tracker';
$row = DB()->fetch_row($sql);
$data['s_ul'] = $row['s_ul'];
$data['s_dl'] = $row['s_dl'];
// users speed
}
$template->assign_vars(array(
'UD_ALL' => ($bb_cfg['tor_stats']) ? humn_size($stats['total_dl_ul']) : '',
'UPL' => ($bb_cfg['tor_stats']) ? humn_size($stats['upload']) : '',
'S_UL' => ($bb_cfg['tor_stats']) ? humn_size($stats['s_ul']) : '',
'DNL' => ($bb_cfg['tor_stats']) ? humn_size($stats['download']) : '',
'S_DL' => ($bb_cfg['tor_stats']) ? humn_size($stats['s_dl']) : '',
'ST' => ($bb_cfg['tor_stats']) ? $stats['active_seeders'] : '',
'LT' => ($bb_cfg['tor_stats']) ? $stats['active_leechers'] : '',
'STU' => ($bb_cfg['tor_stats']) ? $stats['active_seeders_u'] : '',
'LTU' => ($bb_cfg['tor_stats']) ? $stats['active_leechers_u'] : '',
'PERV' => ($bb_cfg['tor_stats']) ? $stats['active_peers_all'] : '',
'TT' => ($bb_cfg['tor_stats']) ? $stats['active_tor'] : '',
'TS' => ($bb_cfg['tor_stats']) ? humn_size($stats['active_tor_size']) : '',
'TN' => ($bb_cfg['tor_stats']) ? $stats['all_tor'] : '',
'TOS' => ($bb_cfg['tor_stats']) ? humn_size($stats['all_tor_size']) : '',
));