<?

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/user.php';
include_once 'config.php';
only_reg();
$set['title']='Автосалон';
include_once '../sys/inc/thead.php';
title();


if (isset($_POST['save'])){

if (isset($_POST['avto']) && $_POST['avto']==0)
{
if ($user['cilynders_baks']>=$cena0){

$user['avto']=0;
mysql_query("UPDATE `user` SET `avto` = '0' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `cilynders_baks` = '".($user['cilynders_baks']-$cena0)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `cilynders_fuel` = '".($user['cilynders_fuel']=55)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `cilynders_power` = '".($user['cilynders_fuel']=100)."' WHERE `id` = '$user[id]' LIMIT 1");

}
}
 
 if ($user['cilynders_baks']>=$cena1){
if (isset($_POST['avto']) && $_POST['avto']==1)
{
$user['avto']=1;
mysql_query("UPDATE `user` SET `avto` = '1' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `cilynders_baks` = '".($user['cilynders_baks']-$cena1)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `cilynders_fuel` = '".($user['cilynders_fuel']=60)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `cilynders_power` = '".($user['cilynders_fuel']=100)."' WHERE `id` = '$user[id]' LIMIT 1");
}
}



if ($user['cilynders_baks']>=$cena2){
if (isset($_POST['avto']) && $_POST['avto']==2)
{
$user['avto']=2;
mysql_query("UPDATE `user` SET `avto` = '2' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `cilynders_baks` = '".($user['cilynders_baks']-$cena2)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `cilynders_fuel` = '".($user['cilynders_fuel']=45)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `cilynders_power` = '".($user['cilynders_fuel']=100)."' WHERE `id` = '$user[id]' LIMIT 1");
}
}

if ($user['cilynders_baks']>=$cena3){
if (isset($_POST['avto']) && $_POST['avto']==3)
{
$user['avto']=3;
mysql_query("UPDATE `user` SET `avto` = '3' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `cilynders_baks` = '".($user['cilynders_baks']-$cena3)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `cilynders_fuel` = '".($user['cilynders_fuel']=50)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `cilynders_power` = '".($user['cilynders_fuel']=100)."' WHERE `id` = '$user[id]' LIMIT 1");
}
}

if ($user['cilynders_baks']>=$cena4){
if (isset($_POST['avto']) && $_POST['avto']==4)
{
$user['avto']=4;
mysql_query("UPDATE `user` SET `avto` = '4' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `cilynders_baks` = '".($user['cilynders_baks']-$cena4)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `cilynders_fuel` = '".($user['cilynders_fuel']=55)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `cilynders_power` = '".($user['cilynders_fuel']=100)."' WHERE `id` = '$user[id]' LIMIT 1");
}
}

if ($user['cilynders_baks']>=$cena5){
if (isset($_POST['avto']) && $_POST['avto']==5)
{
$user['avto']=5;
mysql_query("UPDATE `user` SET `avto` = '5' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `cilynders_baks` = '".($user['cilynders_baks']-$cena5)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `cilynders_fuel` = '".($user['cilynders_fuel']=60)."' WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `cilynders_power` = '".($user['cilynders_fuel']=100)."' WHERE `id` = '$user[id]' LIMIT 1");
}
}

if (!isset($err))msg('Автомобиль успешно куплен');
}
err();
aut();
echo "<div style=\" background-color: #0b0f2e; color: #ffffff;\">";
if (isset($user))
{
if ($user['avto']==0){
$cena_avto = 500;
}
if ($user['avto']==1){
$cena_avto = 1000;
}
if ($user['avto']==2){
$cena_avto = 2500;
}
if ($user['avto']==3){
$cena_avto = 5000;
}
if ($user['avto']==4){
$cena_avto = 7000;
}
if ($user['avto']==5){
$cena_avto = 12000;
} 
echo "$verh";
echo "<div style=\"background-color:#2f2e58;\"><center><img src=\"img/my.gif\" alt=\"\" /></center></div>";
if(isset($_GET['prodat']) && $_GET['prodat']=='da'){
echo "<center><img width=\"163\" height=\"73\" src=\"avto/100.PNG\" alt=\"\" /></center>";
if ($user['avto']!=100){echo "<center>Вы продали успешно свой авто!</center>";
$avto_zaezd = ($user['cilynders_zaezd_one'] = 0);
mysql_query("UPDATE `user` SET `cilynders_zaezd_one` = '" . $avto_zaezd . "' WHERE `id` = '$user[id]' LIMIT 1");
$avto_go = ($user['avto'] = 100);
mysql_query("UPDATE `user` SET `avto` = '" . $avto_go . "' WHERE `id` = '$user[id]' LIMIT 1");
$avto_prod = ($user['cilynders_baks'] + $cena_avto);
mysql_query("UPDATE `user` SET `cilynders_baks` = '" . $avto_prod . "' WHERE `id` = '$user[id]' LIMIT 1");
}else{echo "<center>У вас нет тачки.</center>";}




echo "<div style=\"display:block; padding:4px; background:url(img/hr.png) repeat-x scroll 0 0 #504F6E;\"></div>";

echo "<div class=\"hr\"></div>";
echo "<a href=\"salon.php\"><div style=\"background-image: url('img/menu.png');color:#ffffff;font-size:16px; padding-left: 4px; padding:0px;\"><img width=\"24\" height=\"24\" src=\"img/salon.gif\"  alt=\"\" /> Автосалон</div></a>";

echo "<div class=\"hr\"></div>";
echo "<a href=\"index.php\"><div style=\"background-image: url('img/menu.png');color:#ffffff;font-size:16px; padding-left: 4px; padding:1px;\"><img width=\"24\" height=\"24\" src=\"img/cityss.gif\"  alt=\"\" /> Город</div></a>";


echo "<div class=\"hr\"></div>";
echo "<a href=\"profil.php\"><div style=\"background-image: url('img/menu.png');color:#ffffff;font-size:16px; padding-left: 4px; padding:1px;\"><img width=\"24\" height=\"24\" src=\"img/profiles.gif\"  alt=\"\" /> Профиль</div></a>";


echo "<div class=\"hr\"></div>";
echo "<a href=\"garage.php\"><div style=\"background-image: url('img/menu.png');color:#ffffff;font-size:16px; padding-left: 4px; padding:1px;\"><img width=\"24\" height=\"24\" src=\"img/garages.gif\"  alt=\"\" /> В гараж</div></a>";

echo "</div>";
include_once '../sys/inc/tfoot.php';
}


if ($user['avto']==100){echo "<center><img width=\"163\" height=\"73\" src=\"avto/100.PNG\" alt=\"\" /></center>";}
if ($user['avto']==0){echo "<center><img width=\"163\" height=\"73\" src=\"avto/0.png\" alt=\"\" /></center>";}
if ($user['avto']==1){echo "<center><img width=\"163\" height=\"73\" src=\"avto/1.png\" alt=\"\" /></center>";}
if ($user['avto']==2){echo "<center><img width=\"163\" height=\"73\" src=\"avto/2.png\" alt=\"\" /></center>";}
if ($user['avto']==3){echo "<center><img width=\"163\" height=\"73\" src=\"avto/3.png\" alt=\"\" /></center>";}
if ($user['avto']==4){echo "<center><img width=\"163\" height=\"73\" src=\"avto/4.png\" alt=\"\" /></center>";}
if ($user['avto']==5){echo "<center><img width=\"163\" height=\"73\" src=\"avto/5.png\" alt=\"\" /></center>";}
if ($user['avto']!=100){echo "</br><center>Продать за <font color=\"#f1e022\">$cena_avto $</font>?</center></br><center><a href=\"?prodat=da\"><span style=\"background-image: url('img/menu.png');color:#ffffff;font-size:16px; padding-left: wight: 90px; 4px; padding:3px; border-color: #B8CAD8;border-style: solid;border-width: 1px 1px 1px 1px;border-radius: 4px 4px 4px 4px;-moz-border-radius: 1px 1px 1px 1px;\">Продать</span></a></center><br/>";}














echo "<div style=\"background-color:#2f2e58;\"><center><img src=\"img/salons.gif\" alt=\"\" /></center></div>";
echo "<form method='post' action='?$passgen'>\n";

if ($user['avto']!=0){
echo "<img width=\"143\" height=\"60\" src=\"avto/0.png\" alt=\"\" /></br>";
if ($user['cilynders_baks']>=$cena0){
echo "<input name='avto' type='radio' ".($user['avto']==0?' checked="checked"':null)." value='0' />Fiat Punto <font color=\"#f1e022\">$cena0 $</font><div class=\"hr\"></div>";
}else{echo "Fiat Punto <font color=\"#f1e022\">$cena0 $</font><br />$net_sredstv<div class=\"hr\"></div>";}
}



if ($user['avto']!=1){
echo "<img width=\"143\" height=\"60\" src=\"avto/1.png\" alt=\"\" /></br>";
if ($user['cilynders_baks']>=$cena1){
echo "<input name='avto' type='radio' ".($user['avto']==1?' checked="checked"':null)." value='1' />Renault Clio V6 <font color=\"#f1e022\">$cena1 $</font><div class=\"hr\"></div>";
}else{echo "Renault Clio V6 <font color=\"#f1e022\">$cena1 $</font><br />$net_sredstv<div class=\"hr\"></div>";}
}


if ($user['avto']!=2){
echo "<img width=\"143\" height=\"60\" src=\"avto/2.png\" alt=\"\" /></br>";
if ($user['cilynders_baks']>=$cena2){
echo "<input name='avto' type='radio' ".($user['avto']==2?' checked="checked"':null)." value='2' />Toyota Yaris <font color=\"#f1e022\">$cena2 $</font><div class=\"hr\"></div>";
}else{echo "Toyota Yaris <font color=\"#f1e022\">$cena2 $</font><br />$net_sredstv<div class=\"hr\"></div>";}
}

if ($user['avto']!=3){
echo "<img width=\"143\" height=\"60\" src=\"avto/3.png\" alt=\"\" /></br>";
if ($user['cilynders_baks']>=$cena3){
echo "<input name='avto' type='radio' ".($user['avto']==3?' checked="checked"':null)." value='3' />Peugeot 206 <font color=\"#f1e022\">$cena3 $</font><div class=\"hr\"></div>";
}else{echo "Peugeot 206 <font color=\"#f1e022\">$cena3 $</font><br />$net_sredstv<div class=\"hr\"></div>";}
}

if ($user['avto']!=4){
echo "<img width=\"143\" height=\"60\" src=\"avto/4.png\" alt=\"\" /></br>";
if ($user['cilynders_baks']>=$cena4){
echo "<input name='avto' type='radio' ".($user['avto']==4?' checked="checked"':null)." value='4' />VW Golf GTI <font color=\"#f1e022\">$cena4 $</font><div class=\"hr\"></div>";
}else{echo "VW Golf GTI <font color=\"#f1e022\">$cena4 $</font><br />$net_sredstv<div class=\"hr\"></div>";}
}

if ($user['avto']!=5){
echo "<img width=\"143\" height=\"60\" src=\"avto/5.png\" alt=\"\" /></br>";
if ($user['cilynders_baks']>=$cena5){
echo "<input name='avto' type='radio' ".($user['avto']==5?' checked="checked"':null)." value='5' />Citroen C4 <font color=\"#f1e022\">$cena5 $</font><div class=\"hr\"></div>";
}else{echo "Citroen C4 <font color=\"#f1e022\">$cena5 $</font><br />$net_sredstv<div class=\"hr\"></div>";}
}



echo "</select><br />\n";
echo "<input type='submit' name='save' value='Купить' />\n";
echo "</form>\n";

echo "<div style=\"display:block; padding:4px; background:url(img/hr.png) repeat-x scroll 0 0 #504F6E;\"></div>";
echo "<a href=\"index.php\"><div style=\"background-image: url('img/menu.png');color:#ffffff;font-size:16px; padding-left: 4px; padding:1px;\"><img width=\"24\" height=\"24\" src=\"img/cityss.gif\"  alt=\"\" /> Город</div></a>";


echo "<div class=\"hr\"></div>";
echo "<a href=\"profil.php\"><div style=\"background-image: url('img/menu.png');color:#ffffff;font-size:16px; padding-left: 4px; padding:1px;\"><img width=\"24\" height=\"24\" src=\"img/profiles.gif\"  alt=\"\" /> Профиль</div></a>";


echo "<div class=\"hr\"></div>";
echo "<a href=\"garage.php\"><div style=\"background-image: url('img/menu.png');color:#ffffff;font-size:16px; padding-left: 4px; padding:1px;\"><img width=\"24\" height=\"24\" src=\"img/garages.gif\"  alt=\"\" /> В гараж</div></a>";
}else{
echo "<div style=\"float:left; padding-right: 4px;\"><img src=\"img/girl.gif\" alt=\"\" /></div>
 - Приветствую тебя Гость,
добро пожаловать в захватывающию онлайн игру <b>Speed Of Race</b>.</br>В игре тебя ждет захватывающая гонка, в которой ты можешь заработать денег, 
и стать лидером среди участников гонки!</br>
 - Гость, я вижу 
 что ты еще не зарегистрироан, пройди <a href=\"/reg.php\">регистрацию</a> на этом сайте, и тогда тебе будет доступна игра <b>Speed Of Race</b>!.";

}
echo "</div>";
include_once '../sys/inc/tfoot.php';
?>>