111 lines
		
	
	
		
			5.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
		
		
			
		
	
	
			111 lines
		
	
	
		
			5.6 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
|  | <?php | |||
|  | if( ! defined( 'DATALIFEENGINE' ) ) { | |||
|  | 	die( "Hacking attempt!" ); | |||
|  | } | |||
|  | $tpl->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 ); | |||
|  | 
 | |||
|  | //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | |||
|  |    $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']));*/ | |||
|  | //!<21><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | |||
|  | 
 | |||
|  | //<2F><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | |||
|  | 	$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 = "<thead><td>{$lang['top_name']}</td><td align=\"center\">{$lang['top_status']}</td><td align=\"center\">{$lang['top_reg']}</td><td align=\"center\">{$lang['top_last']}</td><td align=\"center\">{$lang['top_nnum']}</td><td align=\"center\">{$lang['top_cnum']}</td></thead>"; | |||
|  | 	while ( $row = $db->get_row() ) { | |||
|  | 
 | |||
|  | 		$registration = langdate( $config['timestamp_active'], $row['reg_date'] ); | |||
|  | 		$last = langdate( $config['timestamp_active'], $row['lastdate'] ); | |||
|  |         $user_name = "<a href=\"" . $config['http_home_url'] . "user/" . urlencode( $row['name'] ) . "/\">" . $row['name']. "</a>"; | |||
|  |         $user_pm = "<a href=\"$PHP_SELF?do=pm&doaction=newpm&user=" . $row['user_id'] . "\">{$lang['top_pm']}</a>"; | |||
|  | 
 | |||
|  |         if ($user_group[$row['user_group']]['colour']){ | |||
|  |       			$group_span = $user_group[$row['user_group']]['colour']; | |||
|  |       			$group_name =  "<span style=\"color:{$group_span}\">".$user_group[$row['user_group']]['group_name']."</span>"; | |||
|  |       		}else{ | |||
|  |       			$group_name = $user_group[$row['user_group']]['group_name']; | |||
|  |       		} | |||
|  | 
 | |||
|  |     $top_table .= "<tr><td>{$user_name}</td><td align=\"center\">{$group_name}</td><td align=\"center\">{$registration}</td><td align=\"center\">{$last}</td><td align=\"center\">{$row['news_num']}</td><td align=\"center\">{$row['comm_num']}</td></tr>"; | |||
|  | 	} | |||
|  | 	$db->free(); | |||
|  | 	$tpl->set( '{topusers}', $top_table ); | |||
|  | //!<21><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | |||
|  | 
 | |||
|  | //<2F><><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | |||
|  | $i=0; | |||
|  | $sql_upload = $db->query("SELECT name,uploaded FROM ".USERPREFIX."_users ORDER BY uploaded DESC LIMIT 10;"); | |||
|  | $upload = "<thead><td><3E></td><td align=\"center\"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></td><td align=\"center\"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD></td></thead>"; | |||
|  |    while ($u = $db->get_row($sql_upload)) { | |||
|  |       $i++; | |||
|  |       $dw = mksize($u['uploaded']); | |||
|  |       $user = "<a href=\"/user/".urlencode($u['name'])."/\">".$u['name']."</a>"; | |||
|  |       $upload .= "<tr><td>{$i}</td><td>{$user}</td><td>{$dw}</td></tr>"; | |||
|  |    } | |||
|  |    $u=$user=""; | |||
|  |    $tpl->set( '{topuploaded}', $upload ); | |||
|  | //!<21><><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
 | |||
|  | 
 | |||
|  | 	$tpl->compile( 'content' ); | |||
|  | 	$tpl->clear(); | |||
|  |     $cache->save( "stats", $tpl->result['content'], $config['skin'] ); | |||
|  | } | |||
|  | ?>
 |