<?php
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 '<table class="wdt msg-table">
<tr>
<td align="left" style="vertical-align: top; width: 10%">
<img src="icon/face-mex.png">
</td>
<td align="left" style="vertical-align: top">
Играть могут лишь зарегистрированные пользователи!</td>
</tr>
</table>';
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="white" href="rate.php">Топ</a>
</td>
</tr>


<table class="wdt msg-table">
<tr>
<td align="left" style="vertical-align: top; width: 10%">
<img src="icon/face-mex.png">
</td>
<td align="left" style="vertical-align: top">
Здесь ты можешь купить новую машину!
<?
if(isset($_GET['class'])){


if(isset($_GET['id_car'])){

$arr_m=mysql_fetch_array(mysql_query("SELECT * FROM `super_car` WHERE `id`='".intval($_GET['id_car'])."'"));
if($arr['level']>=$arr_m['level']){
if($arr['money']>=$arr_m['cost']){
mysql_query("UPDATE `supergonki` SET `car`='".$arr_m['id']."', `speed`='".$arr_m['m_speed']."', `uprav`='".$arr_m['m_speed']."', `shina`='1', `za`='1', `cz`='1', `zak`='1', `podv`='1', `vpusk`='1', `money`=`money`-$arr_m[cost] WHERE `id_u`='".$user['id']."'");
msg('Машина успешно куплена');
}
else
{
msg('У вас нехватает денег!');
}
}
else
{
msg('У вас слишком низкий уровень!');
}
}
echo "";
}
?>
</td>
</tr>
</table>

<table class="wdt garage-table">
<tr>
<td align="right"  style="padding-top: 10px;">
<table class="wdt">
<tr>
<td style="vertical-align: top; padding-left: 10px;" align="left" rowspan="4">
</td>
<td align="left" class="white" style="vertical-align: top" width="40%"><b>
<?
echo"".$car['name']."";
?>
</b>
</td>
</tr>
<tr>
<td align="left" class="white" nowrap="nowrap" style="font-size: 14px">Мощность:&nbsp;<img src="icon/power-ic.png"><b class="orange">
<?
echo"".$arr['speed']."";
?> км.ч.</b></td>
</tr>
<tr>
<td align="left" class="white" style="font-size: 14px">Уровень: <img src="icon/raiting-.png"><b class="yellow">
<?
echo"".$arr['level']."";
?>
</b></td>
</tr>
<tr>
<td align="left" class="white" style="font-size: 14px">Опыт: <img src="icon/fuel-ico.png"><b class="yellow" style="color: #000"><span id="FUELTIME">
<?
echo"".$arr['exp']."";
?></span></b></td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center" style="padding-bottom: 0px; padding-left: 10px; padding-right: 10px;" valign="bottom">
<?
echo"<img class='wdt' src='car/".(isset($color) ? "".$color."".$car['screen']."" : "".$car['screen']."")."' alt=''/> <br/>";
?>
</br>
<img class="wdt" style="margin-top: -18px;" src="icon/car_shad.png">
</td>
</tr>
</table>
<table class="wdt green-header">
<tr>
<td align="left">Автосалон:</td>
</tr>
</table>
<table class="wdt green-table">



<?



$cars=mysql_result(mysql_query("SELECT COUNT(*) FROM `super_car` WHERE `class`='d'"),0);

$k_page=k_page($cars,5);
$page=page($k_page);
$start=5*$page-5;
$starts=mysql_query("SELECT * FROM `super_car` WHERE `class`='d' ORDER BY `cost` ASC LIMIT ".$start.",5");
while($crr=mysql_fetch_array($starts)){
?>

<tr>
<td class="white td-cell" align="left" style="width: 140px">
<table>
<tr>
<td align="left">
<b>
<?
echo"".$crr['name']."";
?>
</b>
</td>
</tr>
<tr>
<td align="left">
<?
echo "<img src='car/".$crr['screen']."' width='128px'></img><br>";
?>
<img style="width: 128px; margin-top: -18px;" src="icon/car_shad.png">
</td>
</tr>
</table>
</td>
<td class="td-cell" align="left">
<table class="wdt">
<tr><td>
<b class="white">Уровень:</b> <b class="class-d" style="font-weight: bold;">
<?
echo "".$crr['level']."";
?>
</b><br>
<b class="orange">Мощность: 
<?
echo "".$crr['m_speed']."";
?>
 км.ч.</b>
</td></tr><tr><td>
<div style="float: left; padding-right: 10px;">
<img src="icon/money-ic.png">
<b class='white'>
<?
echo "".$crr['cost']."";
?>
</b></div></td></tr><tr><td>
<?
echo"<form action='auto.php?class&amp;id_car=".$crr['id']."' method='post'>";
?>
<input class="race-btn" type="submit" value="Купить">
</form></td></tr></table>
<?
}

if($k_page>1)str('?class&amp;c&amp;',$k_page,$page);
?>

</td>
</table>

<table class="wdt gray-table">
<tr>
<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>