Файл: tjersy.worldbyte.net/race.php
Строк: 58
<?php
require_once 'inc/system.php';
require_once 'inc/head.php';
no_auth();
if(isset($_SESSION['race_msg'])){
echo $_SESSION['race_msg'];
$_SESSION['race_msg']=NULL;
}
if(isset($_GET['race'])){
$vs = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '".abs(intval($_GET['race']))."'"));
$smoto = mysql_fetch_array(mysql_query("SELECT * FROM `garage` WHERE `id_user` = '$vs[id]' AND `use` = '1' LIMIT 1"));
$select = mysql_num_rows(mysql_query("SELECT * FROM `race` WHERE `id_user` = '$user[id]' AND `id_racer` = '$vs[id]'"));
if($user['fuel'] < '10'){ error('Для гонки не хватает топлива');}
elseif($select >= '3'){ error('С данным соперником ты провел 3 гонки.<br/> На сегодня заезды с ним окончены');}
else{
if($my_moto['power'] >= $smoto['power']){
mysql_query("UPDATE `user` SET `money` = `money` + '500', `opit`=`opit` + '5', `raiting` = `raiting` + '3', `fuel` = `fuel` - '10' WHERE `id` = '$user[id]'");
mysql_query("INSERT INTO `race` SET `id_racer` = '$vs[id]', `id_user` = '$user[id]', `time` = ".time()."");
$_SESSION['race_msg'] = '<div class="tip-text">
<div class="tit-t">
<b style="text-shadow:1px 1px 2px #0b4731;">
<center>Поздравляю, вы <font color="yellow"> выиграли </font> гонку! <br/> Награда: + 500 <img src="style/img/money.png"> +3 <img src="style/img/star.png"> +5 <img src="style/img/level.png">
<br/>
<br/>
<img src="/style/moto/Kawasaki_ZL1000.png" width="40%"><br/> <br/>
<b> '.$smoto['moto_name'].' <b class="class-'.$smoto['class'].'">'.$smoto['class'].'</b></b> <br/>
<img src="/style/img/power.png"> Мощность: '.$smoto['power'].' <br />
Гонщик: <b>'.user($vs['id']).' </b><br/><br/>
<a href="race?race='.$vs['id'].'"> <input type="submit" style="border-radius:10px; border: 1px double #eeff00;" value="Новая гонка"></a>
</b></center></div></div>';
header('Location: /race');
}elseif($smoto['power'] >= $my_moto['power']){
mysql_query("UPDATE `user` SET `money` = `money` + '200', `opit`=`opit` + '1', `raiting` = `raiting` - '1', `fuel` = `fuel` - '10' WHERE `id` = '$user[id]'");
mysql_query("UPDATE `user` SET `money` = `money` + '400', `opit`=`opit` + '5', `raiting` = `raiting` + '3' ' WHERE `id` = '$vs[id]'");
mysql_query("INSERT INTO `race` SET `id_racer` = '$vs[id]', `id_user` = '$user[id]', `time` = ".time()."");
$_SESSION['race_msg'] = '<div class="tip-text">
<div class="tit-t">
<b style="text-shadow:1px 1px 2px #0b4731;">
<center>Гонка <font color="red"> проиграна </font><br/> Награда: + 200 <img src="style/img/money.png"> -1 <img src="style/img/star.png"> +1 <img src="style/img/level.png">
<br/>
Твой противник получил: + 400 <img src="style/img/money.png"> +5 <img src="style/img/star.png"> +3 <img src="style/img/level.png">
<br/>
<br/>
<img src="/style/moto/Kawasaki_ZL1000.png" width="40%"><br/> <br/>
<b> '.$smoto['moto_name'].' <b class="class-'.$smoto['class'].'">'.$smoto['class'].'</b></b> <br/>
<img src="/style/img/power.png"> Мощность: '.$smoto['power'].' <br />
Гонщик: <b>'.user($vs['id']).' </b><br/><br/>
<a href="race?race='.$vs['id'].'"> <input type="submit" style="border-radius:10px; border: 1px double #f27461;" value="Новая гонка"></a>
</b></center></div></div>';
header('Location: /race');
}
}
}
echo '<div class="top-tit"><div class="tit-t">Гонки</div></div>';
$data_vs = mysql_query("SELECT * FROM `user` WHERE `id` != '$user[id]' AND `level` <= '$user[level]' ORDER BY RAND() LIMIT 3") or die(mysql_error());
while($r =mysql_fetch_array($data_vs)){
$smoto = mysql_fetch_array(mysql_query("SELECT * FROM `garage` WHERE `id_user` = '$r[id]' AND `use` = '1' LIMIT 1"));
echo '<div class="ob-vh">
<center>
<img src="/style/moto/Kawasaki_ZL1000.png" width="40%"><br/> <br/>
<b> '.$smoto['moto_name'].' <b class="class-'.$smoto['class'].'">'.$smoto['class'].'</b></b> <br/>
<img src="/style/img/power.png"> Мощность: '.$smoto['power'].' <br />
Гонщик: <b>'.user($r['id']).' </b><br/><br/>
<a href="race?race='.$r['id'].'"> <input type="submit" style="border-radius:10px;" value="Принять гонку"></a>
</center></div>';
}
require_once 'inc/foot.php';
?>