<?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());
?>
<?
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
echo '<html>';
echo '<head>';
	echo '<title>LowRaceClub</title>';
	echo '<meta http-equiv="Content-Type" content="text/html" charset="windows-1251" />';
	echo '<meta name="description" content="Мобильные онлайн гонки">';
if(empty($data_user['theme']) or $data_user['theme'] == 'default')
{
$style="/style/default/mobile.css";
}
if($data_user['theme'] == "twotheme")
{
$style="style/twotheme/mobile.css";
}
echo '<link rel="stylesheet" href="'.$style.'" type="text/css" />';
?>
<div class="title">
	<div class="block"><img src="img/benz.png" alt="Бензин"/> <?=$data_user['fuel']?></div>
	<div class="block"><img src="img/speed.png" alt="Скорость" /> <?=$data_user['speed']?> л.с</div>
	<div class="block"><img src="img/money2.png" alt="Золото" /> <?=$data_user['money2']?></div>
	<div class="block"><img src="img/money.png" alt="Баксы" /> <?=$data_user['money']?></div><br><br>
	<div class="progress">
	<div class="progress2" style="width:<?=$levelimg?>%">
	</div></div>
	</div>
<?
echo '<div class="inform"><center>';
        echo '<div class="block"><a href="index.php"><b>Гараж</b></a></div>';
        echo '<div class="block"><a href="/race.php"><b>Гонки</b></a></div>';
        echo '<div class="block"><a href="/bar.php"><b>Бар</b></a></div>';
		echo '<div class="block"><a href="/city.php"><b>Город</b></a></div>';
echo '</center></div>';
?>
<div class="title">Настройки</div>
<?php
if(isset($_POST['sub'])){
	$pass = mysql_real_escape_string(strip_tags($_POST['pass']));
	$email = trim(mysql_real_escape_string($_POST['email']));
	if(!preg_match("/^(?:[a-z0-9]+(?:[-_.]?[a-z0-9]+)?@[a-z0-9_.-]+(?:\.?[a-z0-9]+)?\.[a-z]{2,5})$/i",$email)){
		echo "<meta http-equiv='refresh' content='0; URL=umenu.php'>";
		exit();
	}
	$res = mysql_query("UPDATE `users` SET password='".$pass."',email='".$email."' WHERE nick='".$_SESSION['user']."'") or die(mysql_error());
	if($res == true){
		echo "<meta http-equiv='refresh' content='0; URL=umenu.php'>";
	}else{
		echo "<div class='menu'>Ошибка!</div>";
	}
}
$data = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE nick='".$_SESSION['user']."'")) or die(mysql_error());
echo "
<div class='menu'>
<center>
<form action='' method='post'>
Ник: <br/><input type='text' disabled='disabled' name='nick' value='".$data['nick']."' /><br/>
Пароль: <br/><input type='text' name='pass' value='".$data['password']."' /><br/>
E-mail: <br/><input type='text' name='email' value='".$data['email']."' /><br/>
<input type='submit' name='sub' class='btn' value='Изменить' />
</form>
</center>
</div>
";
?>
</div>
</body>
</html>
<?
}
include 'foot.php';
?>