<?
include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/adm_check.php';
include_once '../sys/inc/user.php';
?>
<title>Супер гонки</title>';
<?
?>
<link rel="stylesheet" href="style000.css" type="text/css" />
<?
if(!isset($user)){
echo 'Вы неавторизованы';
include_once '../sys/inc/tfoot.php';
exit;
}

if(mysql_result(mysql_query("SELECT COUNT(*) FROM `supergonki` WHERE `id_u`='".$user['id']."'"),0)==0)
mysql_query("INSERT INTO `supergonki`(`id_u`) VALUES('".$user['id']."')");
  $arr=mysql_fetch_array(mysql_query("SELECT * FROM `supergonki` WHERE `id_u`='".$user['id']."'"));
   $car=mysql_fetch_array(mysql_query("SELECT * FROM `super_car` WHERE `id`='".$arr['car']."'"));
if($arr['color']!='0'){
if($arr['color']==1)
$color='red_';
elseif($arr['color']==2)
$color='blue_';
elseif($arr['color']==3)
$color='green_'; 
}

?>

<table class="wdt black">
<tr>
<td class="yellow" align="left" style="vertical-align: top; padding-bottom: 0px">
<img src="icon/fuelico.png"><span id="FUELCNT">
<?
echo"".$arr['exp']."";
?>
</span>
</td>
<td class="orange" align="left"  style="vertical-align: top;  padding-bottom: 0px">
<img src="icon/2.png">
<?
echo"".$arr['speed']."";
?> км.ч.
</td>
<td class="white"  style="vertical-align: top;  padding-bottom: 0px">
ур.
<?
echo"".$arr['level']."";
?>
</td>
<td class="white" align="right"  style="vertical-align: top; padding-bottom: 0px">
<img src="icon/1.png">
<?
echo"".$arr['money']."";
?>
</td>
<td class="green" align="right"  style="vertical-align: top; padding-bottom: 0px">
<img src="icon/goldico.png">
<?
echo"".$user['balls']."";
?>
</td>
</tr>
<tr>
<td align="left" class="white" style="vertical-align: top; padding: 0px; height: 3px" colspan="5" height="3px">
<img src="icon/expline.png" width="35%" height="3px" style="height: 3px;">
</td>
</tr>
</table>

<table class="wdt black" style="border-bottom: 1px solid #767676;">
<tr>
<td class="white" align="left" style="padding-top: 0px;">
<a class="white" href="index.php">Гараж</a>
</td>
<td class="white" align="left" style="padding-top: 0px;">
<a class="white" href="race.php">Гонки</a>
</td>
<td class="gray" align="left" style="padding-top: 0px;">
<a class="white" href="bank.php">Дилер</a>
</td>
<td class="gray" align="right" style="padding-top: 0px;">
<a class="green" style="font-weight: bold;" href="rate.php">Топ</a>
</td>
</tr>
</table>
<table class="wdt gray-header">
<tr>
<td align="left">TOP гонщиков:</td>
</tr>
</table>

<?
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `supergonki` WHERE `id_u`='".$user['id']."'"),0)==0)
mysql_query("INSERT INTO `supergonki`(`id_u`) VALUES('".$user['id']."')");
  $array=mysql_fetch_array(mysql_query("SELECT * FROM `supergonki` WHERE `id_u`='".$user['id']."'"));
   $car=mysql_fetch_array(mysql_query("SELECT * FROM `super_car` WHERE `id`='".$array['car']."'"));

if(!isset($_GET['sort']))
$sort=1;
else
$sort=abs(intval($_GET['sort']));

$kaktuz_kol=mysql_result(mysql_query("SELECT COUNT(*) FROM `supergonki`"),0);
$k_page=k_page($kaktuz_kol,10);
$page=page($k_page);
$start=10*$page-10;
if($sort==1 || $sort>8)
$all_kaktuz=mysql_query("SELECT * FROM `supergonki` ORDER BY `level` DESC LIMIT $start,10");
elseif($sort==2)
$all_kaktuz=mysql_query("SELECT * FROM `supergonki` ORDER BY `win` DESC LIMIT $start,10");
elseif($sort==3)
$all_kaktuz=mysql_query("SELECT * FROM `supergonki` ORDER BY `lose` DESC LIMIT $start,10");
elseif($sort==4)
$all_kaktuz=mysql_query("SELECT * FROM `supergonki` ORDER BY `exp` DESC LIMIT $start,10");
elseif($sort==5)
$all_kaktuz=mysql_query("SELECT * FROM `supergonki` ORDER BY `money` DESC LIMIT $start,10");
elseif($sort==6)
$all_kaktuz=mysql_query("SELECT * FROM `supergonki` ORDER BY `resp` DESC LIMIT $start,10");
elseif($sort==7)
$all_kaktuz=mysql_query("SELECT * FROM `supergonki` ORDER BY `samoobl` DESC LIMIT $start,10");
elseif($sort==8)
$all_kaktuz=mysql_query("SELECT * FROM `supergonki` ORDER BY `reak` DESC LIMIT $start,10");

while($arr=mysql_fetch_array($all_kaktuz)){
$cars=mysql_fetch_array(mysql_query("SELECT `name` FROM `super_car` WHERE `id`='".$arr['car']."'"));
?>
<table class="wdt gray-table">
<tr>
<td class="white" align="center" width="70%" style="padding-right: 5px;"> 
<?
$queryy=mysql_query("SELECT * FROM `supergonki` WHERE `id_u`!='".$user['id']."' ORDER BY `id` DESC LIMIT $start,10");
while($po=mysql_fetch_array($queryy)){
$carp=mysql_fetch_array(mysql_query("SELECT * FROM `super_car` WHERE `id`='".$po['car']."'"));
  if($po['color']!='0'){
if($po['color']==1)
$color2='red_';
elseif($po['color']==2)
$color2='blue_';
elseif($po['color']==3)
$color2='green_'; 
}}
echo "<img src='car/".$color2."".$carp['screen']."' class='wdt'/> <br>";

?>

</td>

<td class="white" align="left">
<?
echo"<a class='white' style='font-size: 11pt;' href='/info.php?id=".$arr['id_u']."'>".mysql_result(mysql_query("SELECT `nick` FROM `user` WHERE `id`='".$arr['id_u']."'"),0)."</a><br/>";
?>
<img src="icon/raiting-.png"><b class="yellow">
<?
echo"".$arr['exp']."";
?>
</b><br>
<img src="icon/power-ic.png"><b class="orange">
<?
echo"".$arr['speed']."";
?> км.ч.</b><br>

</td>
</tr>
<hr>

<?

}
?>
</table>
<?
if($k_page>1)str('?sort='.$sort.'&amp;',$k_page,$page);
?>

<td class="white td-cell" align="center" style="height:30px;">
<form action="index.php" method="get">
<input type="submit" class="wdt race-btn" value="В гараж"/>
</form>
</td>
</tr>
</table>
