<? 
session_start();
?>
<? include('header.php'); require('config.php');
$sqryvar="Select sum(visits) from tb_users";
$iqryvar=mysql_query($sqryvar);
$tot1=mysql_result($iqryvar,0,0);
$clickserved=$tot1;

$sqryvar="Select sum(money) from tb_users";
$iqryvar=mysql_query($sqryvar);
$tot1=mysql_result($iqryvar,0,0);
$allmoney=$tot1;

$sqryvar="SELECT COUNT(*) as count from tb_users WHERE referer = ''";
$iqryvar=mysql_query($sqryvar);
$row=mysql_fetch_array($iqryvar);
$zeroref=$row['count'];

$sqryvar="SELECT COUNT(*) as count from tb_users";
$iqryvar=mysql_query($sqryvar);
$row=mysql_fetch_array($iqryvar);
$allu=$row['count'];

$tyff=time()-259200;

$sqryvar="SELECT COUNT(*) as count from tb_users WHERE lastlogdate > '$tyff'";
$iqryvar=mysql_query($sqryvar);
$row=mysql_fetch_array($iqryvar);
$membactiv=$row['count'];

$sqryvar="SELECT COUNT(*) as count from tb_users WHERE account = 'premium'";
$iqryvar=mysql_query($sqryvar);
$row=mysql_fetch_array($iqryvar);
$premembers=$row['count'];
if($premembers>0){$premembers+=1;}else{unset($premembers);}
?>

<h3>Подробная статистика</h3>
Всего денег на счетах: <? echo $allmoney; ?> Рублей <br />
Всего сделано кликов: <? echo $clickserved; ?><br />
Всего пользователей: <? echo $allu; ?><br />
Активность пользователей: <? echo $membactiv/$allu*100;?>%<br />
Пользователей без реферера: <? echo $zeroref; ?><br />
Пользователей с премиум аккаунтом: <? echo $premembers; ?><br />
<br>( ТОП 5 ) активных по колличеству рефералов:<br /><div align="center"><table cellpadding='0' cellspacing='10' style='text-align:center'><tr style="background-color:#FFBB00; color:#FF0000;"><td>логин</td><td>денег на счету</td><td>рефералов</td><td>статус</td><td></td></tr>
<?


		$sql = "SELECT * FROM tb_users order by referals desc limit 5";
		$result = mysql_query($sql);        
while($stat=mysql_fetch_array($result)){$ptime=time()-$stat["joindate"];$ptime=$ptime/86400;settype($ptime, "integer");if($stat["account"]=='premium'){$arr="<font color='#16b2bc'>VIP</font>";}else{$arr="<font color='#FF3300'>Обычный</font>";}
echo "<tr><td>$stat[username]</td><td>$stat[money] Руб </td><td>$stat[referals]</td><td>$arr</td><td></td></tr>";}?>
</table></div><br />&nbsp;<br />( ТОП 5 ) по колличеству денег на счету:<br /><div align="center"><table cellpadding='0' cellspacing='10' style='text-align:center'><tr style="background-color:#FFBB00; color:#FF0000;"><td>логин</td><td>денег на счету</td><td>рефералов</td><td>статус</td><td></td></tr>
<?
$sql = "SELECT * FROM tb_users where username != 'admin' order by money desc limit 5";
$result = mysql_query($sql);        
while($stat=mysql_fetch_array($result)){$ptime=time()-$stat["joindate"];$ptime=$ptime/86400;settype($ptime, "integer");if($stat["account"]=='premium'){$arr="<font color='#16b2bc'>VIP</font>";}else{$arr="<font color='#FF3300'>Обычный</font>";}
echo "<tr><td>$stat[username]</td><td>$stat[money] Руб </td><td>$stat[referals]</td><td>$arr</td><td></td></tr>";}?>
</table></div><br />&nbsp;<br />
</table></div><br />&nbsp;<br />
</table></div>

<?
mysql_close($con);
?>
