result['content'] = $cache->open( "stats", $config['skin'] );
if( ! $tpl->result['content'] ) {
$db->query( "SHOW TABLE STATUS FROM `" . DBNAME . "`" );
$mysql_size = 0;
while ( $r = $db->get_row() ) {if( strpos( $r['Name'], PREFIX . "_" ) !== false ) $mysql_size += $r['Data_length'] + $r['Index_length'];}
$db->free();
$mysql_size = mksize( $mysql_size );
$size_info = $db->super_query("SELECT sum(size) size FROM ".PREFIX."_torrents");
$row = $db->super_query( "SELECT COUNT(*) as count FROM " . PREFIX . "_post" );
$stats_news = $row['count'];
$row = $db->super_query( "SELECT COUNT(*) as count FROM " . PREFIX . "_post WHERE approve ='1'" );
$stats_approve = $row['count'];
$row = $db->super_query( "SELECT COUNT(*) as count FROM " . PREFIX . "_comments" );
$count_comments = $row['count'];
$row = $db->super_query( "SELECT COUNT(*) as count FROM " . USERPREFIX . "_users" );
$stats_users = $row['count'];
$row = $db->super_query( "SELECT COUNT(*) as count FROM " . USERPREFIX . "_users WHERE banned='yes'" );
$stats_banned = $row['count'];
$row = $db->super_query( "SELECT COUNT(*) as count FROM " . PREFIX . "_post WHERE allow_main ='1' AND approve ='1'" );
$stats_main = $row['count'];
$tpl->load_template( 'stats.tpl' );
$tpl->set( '{datenbank}', $mysql_size );
$tpl->set( '{size_info}', mksize($size_info['size']) );
$tpl->set( '{news_num}', $stats_news );
$tpl->set( '{news_allow}', $stats_approve );
$tpl->set( '{comm_num}', $count_comments );
$tpl->set( '{user_num}', $stats_users );
$tpl->set( '{user_banned}', $stats_banned );
$tpl->set( '{news_main}', $stats_main );
$tpl->set( '{news_moder}', $stats_news - $stats_approve );
//Статистика торрента
$result = $db->super_query("SELECT sum(leechers) leechers, sum(seeders) seeders, sum(leechers or seeders) torrents FROM ".PREFIX."_torrents");
$result['peers'] = $result['leechers'] + $result['seeders'];
if($result['peers']) {
$leechers = $result['leechers']." (".round($result['leechers']*100/$result['peers'])."%)";
$seeders = $result['seeders']." (".round($result['seeders']*100/$result['peers'])."%)";
} else {$leechers = $seeders = 0;}
$tr_a = $db->super_query("SELECT count(id) as c FROM ".PREFIX."_torrents");
$rt_dz = $tr_a['c'] - $result['torrents'];
if($tr_a['c']) {
$tr_d = $rt_dz." (".round($rt_dz*100/$tr_a['c'])."%)";
$result['torrents'] = $result['torrents']." (".round($result['torrents']*100/$tr_a['c'])."%)";
} else {$tr_d = $tr_dz;}
$res_info = $db->super_query("SELECT sum(downloaded) downloaded, sum(uploaded) uploaded FROM ".PREFIX."_users");
$res_info['all'] = $res_info['downloaded'] + $res_info['uploaded'];
$tpl->set( '{all_tor}', $tr_a['c'] );
$tpl->set( '{active_tor}', $result['torrents'] );
$tpl->set( '{dead_tor}', $tr_d );
$tpl->set( '{activeconn_tor}', $result['peers'] );
$tpl->set( '{seeders_tor}', $seeders );
$tpl->set( '{leechers_tor}', $leechers );
$tpl->set( '{sumupl_tor}', mksize($res_info['uploaded']) );
$tpl->set( '{sumdown_tor}', mksize($res_info['downloaded']) );
$tpl->set( '{sumall_tor}', mksize($res_info['all']) );
/*$res = $db->super_query("SELECT sum(down_speed) down_speed, sum(up_speed) up_speed FROM xbt_files_users");
$tpl->set( '{speed_up}', mksize($res['up_speed']) );
$tpl->set( '{speed_down}', mksize($result['down_speed']));*/
//!статистика торрента
//Топ юзеров по новостям
$db->query( "SELECT user_id, name, user_group, reg_date, lastdate, news_num, comm_num FROM " . USERPREFIX . "_users WHERE news_num > '0' ORDER BY news_num DESC LIMIT 0,10" );
$top_table = "{$lang['top_name']} {$lang['top_status']} {$lang['top_reg']} {$lang['top_last']} {$lang['top_nnum']} {$lang['top_cnum']} ";
while ( $row = $db->get_row() ) {
$registration = langdate( $config['timestamp_active'], $row['reg_date'] );
$last = langdate( $config['timestamp_active'], $row['lastdate'] );
$user_name = "" . $row['name']. "";
$user_pm = "{$lang['top_pm']}";
if ($user_group[$row['user_group']]['colour']){
$group_span = $user_group[$row['user_group']]['colour'];
$group_name = "".$user_group[$row['user_group']]['group_name']."";
}else{
$group_name = $user_group[$row['user_group']]['group_name'];
}
$top_table .= "