<?
#########################################
# Скрипт онлайн игры "Стритрейсинг"_____#
# Автор: -=FеST=-(СиК)__________________#
# ICQ : 345-22-23 ______________________#
# Все права принадлежат автору(-=FeST=-)#
#########################################
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';
$set['title']='Стритрейсинг';
include_once '../sys/inc/thead.php';
title();
err();
aut();

if(!isset($user)){
echo 'Вы неавторизованы';
include_once '../sys/inc/tfoot.php';
exit;
}
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `racing` WHERE `id_u`='".$user['id']."'"),0)==0)
mysql_query("INSERT INTO `racing`(`id_u`) VALUES('".$user['id']."')");

  $arr=mysql_fetch_array(mysql_query("SELECT * FROM `racing` WHERE `id_u`='".$user['id']."'"));
   $car=mysql_fetch_array(mysql_query("SELECT * FROM `racing_car` WHERE `id`='".$arr['car']."'"));
   $all_racer=mysql_result(mysql_query("SELECT COUNT(*) FROM `racing` WHERE `id_u`!='".$user['id']."'"),0);
   if($arr['color']!='0'){
if($arr['color']==1)
$color='red_';
elseif($arr['color']==2)
$color='blue_';
elseif($arr['color']==3)
$color='green_'; 
}
echo "
<div class='aut'>
<img src='ico/exp.gif' alt=''/>".$arr['exp']."
<img src='ico/level.gif' alt=''/>".$arr['level']."
<img src='ico/money.gif' alt=''/>".$arr['money']."
<img src='ico/resp.gif' alt=''/>".$arr['resp']."</div>
<center><img src='car/".(isset($color) ? "".$color."".$car['screen']."" : "".$car['screen']."")."' alt=''/> <br/>".$car['name']."</center>
<br/>";
if(isset($_POST['submit'])){
$id=abs(intval($_GET['id_user']));

if(mysql_result(mysql_query("SELECT COUNT(*) FROM `racing_race` WHERE `id_2`='".$user['id']."' AND `id_1`='".$id."' AND `act`='0'"),0)==0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `racing_race` WHERE `id_1`='".$user['id']."' AND `id_2`='".$id."' AND `act`='0'"),0)==0){
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `racing` WHERE `id_u`='".$id."'"),0)!=0){
mysql_query("INSERT `racing_race`(`id_1`, `id_2`) VALUES('".$user['id']."', '".$id."')");
msg('Ваше предложение будет рассмотрено соперником');
}}
else
{
msg('У вас не все гонки завершены с данным пользователем');
}}
  
if($all_racer==0){
echo "Гонщиков нет!<br/>";
}
else
{
$k_page=k_page($all_racer,10);
$page=page($k_page);
$start=10*$page-10;
$queryy=mysql_query("SELECT * FROM `racing` WHERE `id_u`!='".$user['id']."' ORDER BY `id` DESC LIMIT $start,10");
while($po=mysql_fetch_array($queryy)){
  $carp=mysql_fetch_array(mysql_query("SELECT * FROM `racing_car` WHERE `id`='".$po['car']."'"));
   if($po['color']!='0'){
if($po['color']==1)
$color2='red_';
elseif($po['color']==2)
$color2='blue_';
elseif($po['color']==3)
$color2='green_'; 
}
echo "<div class='rowup'>
- Ник : <a href='/info.php?id=".$po['id_u']."'>
".mysql_result(mysql_query("SELECT `nick` FROM `user` WHERE `id`='".$po['id_u']."'"),0)."</a><br/>
- Поб/Пор : ".$po['win']."/".$po['lose']."<br/>
- Тачка : ".$carp['name']."<br/>
<img src='car/".$color2."".$carp['screen']."' alt=''/> 
<form method='post' action='race.php?id_user=".$po['id_u']."'>
<input type='submit' name='submit' value='Вызвать на гонки'/></form></div>";
}
if($k_page>'1')str('?',$k_page,$page);
}



echo "<div class='rowup'>
<img src='ico/ico.gif' alt=''/><a href='allrace.php'> Мои гонки</a> (".mysql_result(mysql_query("SELECT COUNT(*) FROM `racing_race` WHERE (`id_2`='".$user['id']."') OR (`id_1`='".$user['id']."')"),0).")</div>
<div class='aut'><a style='display:block;' href='index.php'><img src='ico/back.png' alt=''/> Назад</a></div>";






include_once '../sys/inc/tfoot.php';
?>