<?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="title">Админка</div>
<?php
if(isset($_POST['submit'])){
if(!empty($_POST['car']) && !empty($_POST['carname']) && !empty($_POST['speed']) && !empty($_POST['price']) && !empty($_POST['price2']) && !empty($_POST['ogran']) && !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'])));
		$ogran = trim(mysql_real_escape_string(strip_tags($_POST['ogran'])));
$price = trim(mysql_real_escape_string(strip_tags($_POST['price'])));
 $price2 = trim(mysql_real_escape_string(strip_tags($_POST['price2'])));
		$sql1 = mysql_query("SELECT car,id FROM `vis` 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?addvis' style='color:#fff;'>Назад</a></div>";
	}else{
mysql_query("INSERT INTO `vis`(car,carname,speed,price,price2,ogran,level) VALUES('$car','$carname','$speed','$price','$price2','$ogran','$level')") or die(mysql_error());
		echo "<meta http-equiv='refresh' content='0; URL=index.php?addvis' />";
		exit();
	}
	}else{
		echo "<meta http-equiv='refresh' content='0; URL=index.php?addvis' />";
		exit();
	}
}else{
	echo "<meta http-equiv='refresh' content='0; URL=index.php?addvis' />";
	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>
<?
}
}
?>