<?
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';

$set['title'] = 'Мои гонки';
include_once '../../sys/inc/thead.php';
title();
err();
aut();
/*
=========================
Автор: BleIK
=========================
Игра: Мои гонки
=========================
*/

?>
<link rel="stylesheet" type="text/css" href="style.css"/>
<link href="images/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<?

if(!$user)
{
echo 'Зарегестрируйтесь ';
exit();
}
echo '
  <table class="tb00">
    <tbody>
      <tr>';
include'bleik.php';
echo '
	  <td class="raml"></td>
        <td class="dbody1">
          <table class="tb00">
            <tbody>
         
            </tbody>
          </table>
          <div class="dbody">
		  <div class="dt100">
  <p>
		  ';?>




<? 
if(isset($_POST['submit'])){
echo '<div style="background:#333;width:100%;height:2px;"><div style="background:rgb(0,140,0);width:0%;height:2px;" class="mini2"></div></div></legend></fieldset>
	<fieldset>
	<legend class="ok">Помощник BleIK</legend>
	<div class="dt100"><img src="images/info100.gif" width="50" height="50" alt="Инфо" class="im5"  />';
$id=abs(intval($_GET['id_user']));

if(mysql_result(mysql_query("SELECT COUNT(*) FROM `racing_moi` WHERE `id_2`='".$user['id']."' AND `id_1`='".$id."' AND `act`='0'"),0)==0 && mysql_result(mysql_query("SELECT COUNT(*) FROM `racing_moi` WHERE `id_1`='".$user['id']."' AND `id_2`='".$id."' AND `act`='0'"),0)==0){
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `moigonki` WHERE `id_u`='".$id."'"),0)!=0){
mysql_query("INSERT `racing_moi`(`id_1`, `id_2`) VALUES('".$user['id']."', '".$id."')");
echo 'Гонщику было отпавлено уведомление о вызове на гонку';
mysql_query("INSERT INTO `mail` (`id_user`, `id_kont`, `msg`, `time`) values('0', $id, '$user[nick] Вызвал вас на гонку  [url=/online_games/racing/zaezd.php?load&oprace] принимать вызов[/url]!', '$time')");
}}
else
{
echo 'Гонщик еще не принял вызов';
}
echo '<br/><div class="clear"></div></div></fieldset>';
}
?>

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

  $arr=mysql_fetch_array(mysql_query("SELECT * FROM `moigonki` WHERE `id_u`='".$user['id']."'"));
   $car=mysql_fetch_array(mysql_query("SELECT * FROM `moi_gonkis` WHERE `id`='".$arr['car']."'"));
   $all_racer=mysql_result(mysql_query("SELECT COUNT(*) FROM `moigonki` 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_'; 
}

if($all_racer==0){
echo '
<div style="background:#333;width:100%;height:2px;"><div style="background:rgb(0,140,0);width:0%;height:2px;" class="mini2"></div></div></legend></fieldset>
	<fieldset>
	<legend class="ok">Помощник BleIK</legend>
	<div class="dt100"><img src="images/info100.gif" width="50" height="50" alt="Инфо" class="im5"  />Гонщики отдыхают<br/><div class="clear"></div></div></fieldset>
';
}
else
{
$k_page=k_page($all_racer,10);
$page=page($k_page);
$start=10*$page-10;
$queryy=mysql_query("SELECT * FROM `moigonki` WHERE `id_u`!='".$user['id']."' ORDER BY `id` DESC LIMIT $start,15");
while($po=mysql_fetch_array($queryy)){
  $carp=mysql_fetch_array(mysql_query("SELECT * FROM `moi_gonkis` 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_'; 
}
?>
<div class="d101">
<?echo "<img src='images/cars/".$color2."".$carp['screen']."' class='wdt'/>";
echo"<b>
".mysql_result(mysql_query("SELECT `nick` FROM `user` WHERE `id`='".$po['id_u']."'"),0)."</b>";?>
  <span class="mini2">на</span>
    <?echo $carp['name'];?>
  <br>
 
  <span class="color9 mini">мощность:</span><?echo $po['speed'];?> км/ч

<?
echo"<form method='post' action='gonki.php?id_user=".$po['id_u']."'>
<input class='a100' type='submit' name='submit' value='Начать гонку'/></form>";
?>

</div>
<?
}
if($k_page>'1')str('?',$k_page,$page);
}
?>

<fieldset>
  <legend class="h1">
    <img src="images/flag.gif" alt=".">
    Случайный заезд 
  </legend>
  <div class="dt100">
  
	
<form method='post' action='vet.php?a'>
<input class="ag100 center" type='submit' name='submit' value='Погнали'/></form>
    

   
    <div class="clear"></div>
  </div>
</fieldset></p>
  </div>
<?
echo '<fieldset>
  <legend class="path">
    <a href="/online_games/racing/index1.php.php">
      <img src="images/green.gif" alt="/" style="margin:0px 4px 0px 0px;">
      Главная
    </a>
     » 
   
  </legend>
</fieldset>
<br class="br1">
          </div>
        </td>
        <td class="ramr"></td>
      </tr>
    </tbody>
  </table>
  <div class="ramd"></div>
  <br>
  <span class="mini2">
    <center>by xLoF.Ru</center>
    <br>
    
  </span>';
include_once '../../sys/inc/tfoot.php';
?>



