<?include('header.php');

if(!(isset($_SESSION["username"]) && isset($_SESSION["password"])))
{
	?>
	<script type="text/javascript">
	location.replace("login.php");
	</script>
	<noscript>
	<meta http-equiv="refresh" content="0; url=login.php">
	</noscript>
	<?
	exit();
}

$user=text($_SESSION["username"]);

$res=mysql_query("select * from tb_users where username='$user'");
$row=mysql_fetch_array($res);

$res=mysql_query("select sum(visits) from tb_refbot where user='$user'");
$refbotvisits=mysql_result($res,0,0);

$res=mysql_query("select count(*) as kolvo, sum(amount) as paid from tb_taskstats where status='1' and user='$user'");
$res=mysql_fetch_array($res);
$tasksok=$res["kolvo"];
$taskpaid=round($res["paid"],2);


?>
<div class="menucenter">
<div class='navil'>
<table width='100%' border='0' cellpadding='0' cellspacing='0'>
<tr>
<td width='49%' style='font-size:11px;'>
Рефералов 1 ур.: <font color='red'><?
$sqryvar="SELECT COUNT(*) as count from tb_users where referer='$user'";
$iqryvar=mysql_query($sqryvar);
$row22=mysql_fetch_assoc($iqryvar);
$myrefs=$row22['count'];
echo $myrefs; ?></font> чел.
&nbsp;&nbsp;<a href="/referals.php">Просмотреть »</a>
</td>
<td width='2%'></td>
<td width='49%' style='font-size:11px;'>
Рефералов 2 ур.: <font color='red'><?
$sqryvar="SELECT COUNT(*) as count from tb_users where referer2='$user'";
$iqryvar=mysql_query($sqryvar);
$row22=mysql_fetch_assoc($iqryvar);
$myrefs=$row22['count'];

echo $myrefs; ?></font> чел.
&nbsp;&nbsp;<a href="/referals2.php">Просмотреть »</a>
</td>
</tr>
</table>
</div>
<?
$user=text($_SESSION["username"]);

$num = 100;
$upag = "referals2.php?";
$page = (isset($_GET['n']))? intval($_GET['n']) : 1 ;
$numpag = mysql_num_rows(mysql_query("SELECT * FROM tb_users WHERE referer2='$user' order by visits desc"));
$np =$numpag;
$obpag = intval(($np - 1) / $num) + 1;
if(empty($page) or $page < 0) $page = 1;
if($page > $obpag) $page = $obpag;
$nach = $page * $num - $num;
$res = mysql_query("SELECT * FROM tb_users WHERE referer2='$user' order by visits desc LIMIT $nach, $num");
include("navi.php");?>
<table class='reyt' width='100%' border='0' cellpadding='0' cellspacing='0'>
<thead><tr>
<th align="center" width='35px'></th>
<th align="center" colspan='4'><b>Информация</b></th>
</tr></thead>
<?

$i=0;
	$vhod=date("H:i", $row["lastvxod"]);
while ($row = mysql_fetch_array($res))
{$i++;
echo "<tr><td align='center' width='35px'>"; ?>
<div align='center' style='border: solid 1px #ddd;padding:1px;'>
<img src="avp/<?=$row["avatar"]; ?>" width='38px' height='38px' title="<?=$row["id"]; ?>"/>
</div>
<?	echo "</td>
<td align='left'>Логин: ";
echo $row["username"];
echo "<br /><font color='green'>Рейтинг: ";
echo round($row["ball"],3);
echo "</font><br />";
$nowdate1=date("Y.m.d");
$nowdate2=date("Y.m.d", strtotime('-1 day'));
$nowdate3=date("Y.m.d", strtotime('-2 day'));
$gg=$row[lastlogdate];
if($nowdate1==$gg) { $nowdate="<span style='color: #009126'><b>Сегодня</b> в $vhod</span>"; }
elseif($nowdate2==$gg) { $nowdate="<span style='color: #006699'><b>Вчера</b> в $vhod</span>"; }
elseif($nowdate3==$gg) { $nowdate="<span style='color: #FF4500'><b>Позавчера</b> в $vhod</span>"; }
else{ $nowdate="Активность: $gg"; }
echo"$nowdate <br />";
echo "</td><td class='value' align='left'>";
echo "Серфинг: ";
echo $row["visits"]; 
echo "<br />Письма: ";
echo $row["views_mails"];
echo "<br />Регистрация: ";
echo $row["joindate"];
echo "</td><td class='value' align='left'>";
echo "Задания: ";
echo $row["task"];
echo "<br />Скачивания: ";
echo $row["dow_user"];
echo "<br />Вопросы: ";
echo $row["questions_user"];
echo "</td></tr>";

}
?>
</table>
<? include('footer.php'); ?>


