<?
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>';
echo '
	  <td class="raml"></td>
        <td class="dbody1">
          <table class="tb00">
            <tbody>
              <tr>
                <td class="logo_l"></td>
                <td class="logo_f">
                  <img src="images/logo_.gif" alt="Мои гонки">
                </td>
                <td class="logo_r"></td>
              </tr>
            </tbody>
          </table>
          <div class="dbody">
		  <fieldset>
  <legend class="h1">Рейтинг</legend>
  <div class="dt100">
   
		  ';

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']."'"));
if($arr['color']!='0'){
if($arr['color']==1)
$color='red_';
elseif($arr['color']==2)
$color='blue_';
elseif($arr['color']==3)
$color='green_'; 
}
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']."')");
  $array=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`='".$array['car']."'"));

if(!isset($_GET['sort']))
$sort=1;
else
$sort=abs(intval($_GET['sort']));
$kaktuz_kol=mysql_result(mysql_query("SELECT COUNT(*) FROM `moigonki`"),0);
$k_page=k_page($kaktuz_kol,10);
$page=page($k_page);
$start=10*$page-10;
if($sort==1 || $sort>8)
$all_kaktuz=mysql_query("SELECT * FROM `moigonki` ORDER BY `level` DESC LIMIT $start,10");
elseif($sort==2)
$all_kaktuz=mysql_query("SELECT * FROM `moigonki` ORDER BY `win` DESC LIMIT $start,10");
elseif($sort==3)
$all_kaktuz=mysql_query("SELECT * FROM `moigonki` ORDER BY `lose` DESC LIMIT $start,10");
elseif($sort==4)
$all_kaktuz=mysql_query("SELECT * FROM `moigonki` ORDER BY `exp` DESC LIMIT $start,10");
elseif($sort==5)
$all_kaktuz=mysql_query("SELECT * FROM `moigonki` ORDER BY `money` DESC LIMIT $start,10");
elseif($sort==6)
$all_kaktuz=mysql_query("SELECT * FROM `moigonki` ORDER BY `resp` DESC LIMIT $start,10");
elseif($sort==7)
$all_kaktuz=mysql_query("SELECT * FROM `moigonki` ORDER BY `samoobl` DESC LIMIT $start,10");
elseif($sort==8)
$all_kaktuz=mysql_query("SELECT * FROM `moigonki` ORDER BY `reak` DESC LIMIT $start,10");
while($arr=mysql_fetch_array($all_kaktuz)){
$cars=mysql_fetch_array(mysql_query("SELECT `name` FROM `moi_gonkis` WHERE `id`='".$arr['car']."'"));
$queryy=mysql_query("SELECT * FROM `moigonki` 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 `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_'; 
}}
?>
<?echo '<a  class="a100" href="/info.php?id='.$arr['id_u'].'">';?>
  <span class="mini2">1.</span>
<?echo"".mysql_result(mysql_query("SELECT `nick` FROM `user` WHERE `id`='".$arr['id_u']."'"),0)."";?>

  <?echo "<img src='images/cars/".$color2."".$carp['screen']."' width='50' height='50' class='im5'/> <br>";?>
  <br>
  <span class="mini2">Уровень:</span>
  <span class="mini"><?echo"".$arr['level']."";?></span>
  <br>
  <span class="mini2">Опыт:</span>
  <span class="mini"><?echo"".$arr['exp']."";?></span>
  <br>
</a>
<?
}
if($k_page>1)str('?sort='.$sort.'&amp;',$k_page,$page);
		  		 echo '     </div>
    
    <div class="clear"></div>
  </div>
</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';
?>