<?php
session_start();
include_once "../inc/db_connect.php";
include_once "../inc/fnc.php";
header('Content-Type: text/html;charset=utf8');
$err = "";
if(isset($_POST['regok'])){unset($_SESSION['reg_ok']);}
if(!isset($_SESSION['user'])){
	header("Location: index.php?");
	exit();
}else{
	$data_user = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE nick='".$_SESSION['user']."'")) or die(mysql_error());
	if($data_user['status'] == "Гонщик" or $data_user['status'] == "VIP" ){
		header("Location: ../index.php?");
		exit();
	}else{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<title>Мобильные гонки</title>
	<meta name="description" content="Мобильные гонки" />
	<link rel="stylesheet" type="text/css" href="../style/css/mobile.css" />
</head>
<body>
<div class='menu'><center>
<span style="color:#fff;"><?=$data_user['fuel']?> лтр.</span>
<span style="color:orange;"><img src="../img/speed.png" alt="Скорость"> <?=$data_user['speed']?> л.с</span>
<span style="color:#fff;"><?=$data_user['level']?> ур.</span>
<span style="color:#0f0;"><img src="../img/money.png" alt="$"> <?=$data_user['money']?></span></center>
</div>
<div class="progress">
	<img src="img/level.png" alt="Уровень" width="<?=$levelimg;?>%" height="7" />
</div>
<table class="wdt cdcdcd menu2">
    <tr>
        <td align="left"><a class="white" href="../index.php">Гараж</a></td>
        <td align="left" style="padding-left:30px;"><a class="white" href="../race.php">Гонки</a></td>
        <td align="left"><a class="white" href="../taxi.php">Такси</a></td>
		<td align="right"><a href="../city.php">Город</a></td>
    </tr>
</table>
<div class="title">Админка</div>
<?php
if(isset($_POST['submit'])){
	if(!empty($_POST['car']) && !empty($_POST['carname']) && !empty($_POST['speed']) && !empty($_POST['price']) && !empty($_POST['level'])){
		$car = trim(mysql_real_escape_string(strip_tags($_POST['car'])));
		$carname = trim(mysql_real_escape_string(strip_tags($_POST['carname'])));
		$speed = trim(mysql_real_escape_string(strip_tags($_POST['speed'])));
		$level = trim(mysql_real_escape_string(strip_tags($_POST['level'])));
		$price = trim(mysql_real_escape_string(strip_tags($_POST['price'])));
		$sql1 = mysql_query("SELECT car,id FROM `auto` ORDER BY `id`") or die(mysql_error());
		$addavt2 = mysql_fetch_assoc($sql1);
	if($car == $addavt2['car']){
		echo "<div class='err'>Такая машина уже есть<br/><a href='index.php?addavto' style='color:#fff;'>Назад</a></div>";
	}else{
		mysql_query("INSERT INTO `auto`(car,carname,speed,price,level) VALUES('$car','$carname','$speed','$price','$level')") or die(mysql_error());
		echo "<meta http-equiv='refresh' content='0; URL=index.php?addavto' />";
		exit();
	}
	}else{
		echo "<meta http-equiv='refresh' content='0; URL=index.php?addavto' />";
		exit();
	}
}else{
	echo "<meta http-equiv='refresh' content='0; URL=index.php?addavto' />";
	exit();
}
?>
<div class="niz">
<p align="center" style="padding-top:3px;padding-bottom:3px;">Вы вошли как <b><?=$_SESSION["user"]?><b> | <a href="exit.php">Выйти</a><br /> <font color='#000'>Игровое время:</font> <b><?=date("H:i:s")?></b><br/><font color="#000">Игровой ID:</font> <b><?=$data_user['id']?></b></p>
</div>
<p align="center" style="margin-top:3px;">&copy; <?=date("Y")?></p>
</body>
</html>
<?
}
}
?>