Файл: vkollektive2014/play_gamescool/car/bot_race.php
Строк: 63
<?
include_once '../../connect.php';
include_once '../../head.php';
echo "<div class='iroder2'>";
if(!isset($u)){
echo 'Вы неавторизованы';
include_once '../../foot.php';
exit;
}
function sictime($timediff){
$oneMinute=60;
$oneHour=60*60;
$oneDay=60*60*24;
$dayfield=floor($timediff/$oneDay);
$hourfield=floor(($timediff-$dayfield*$oneDay)/$oneHour);
$minutefield=floor(($timediff-$dayfield*$oneDay-$hourfield*$oneHour)/$oneMinute);
$secondfield=floor(($timediff-$dayfield*$oneDay-$hourfield*$oneHour-$minutefield*$oneMinute));
$time_1="$hourfield ч. $minutefield м. $secondfield c";
return $time_1;
}
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `racing` WHERE `id_u`='".$u['id']."'"),0)==0)
mysql_query("INSERT INTO `racing`(`id_u`) VALUES('".$u['id']."')");
$arr=mysql_fetch_array(mysql_query("SELECT * FROM `racing` WHERE `id_u`='".$u['id']."'"));
$car=mysql_fetch_array(mysql_query("SELECT * FROM `racing_car` 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_';
}
echo "
<div class='aut'>
| опыт: ".$arr['exp']."
| ур: ".$arr['level']."
| <img src='ico/money.gif' alt=''/>".$arr['money']."
| реп: ".$arr['resp']."</div>
<div class='iroder4'>
<div class='div'>Мое авто: <b>".$car['name']."</b></div>
";
if($arr['race_kol']>5){
$newtime=time()-60*50;
mysql_query("UPDATE `racing` SET `race_kol`='0', `race_last`='".$newtime."' WHERE `id_u`='".$u['id']."'");
error("У вас закончился бензин в течении ".sictime($arr['race_last']-time())." часов он будет востановлен ");
}
if(isset($_GET['a'])){
if($arr['race_last']<time()){
if(isset($_GET['b'])){
$rand=rand(1,2);
if($rand==1){
mysql_query("UPDATE `racing` SET `race_kol`=`race_kol`+1, `win`=`win`+1, `exp`=`exp`+3, `money`=`money`+500, `resp`=`resp`+200, `samoobl`=`samoobl`+250, `reak`=`reak`+310 WHERE `id_u`='".$u['id']."'");
ok('Поздравляем! Вы выиграли гонку!');
}
else
{
mysql_query("UPDATE `racing` SET `race_kol`=`race_kol`+1, `lose`=`lose`+1 WHERE `id_u`='".$u['id']."'");
error('Вы проиграли :( Соперник вас обагнал');
}
}}
else
{
echo "<br/>";
echo "<img src='ico/avto_tun.png' alt=''/> ";
ok("Ваш бензобак будет востановлен через ".sictime($arr['race_last']-time())."");
$t=1;
}
$cars=mysql_fetch_array(mysql_query("SELECT * FROM `racing_car` WHERE `class`='".$car['class']."' ORDER BY RAND() DESC LIMIT 1"));
if($t!=1){
echo "<div class='div'>";
echo "
<center><img src='car/".$car['screen']."' alt=''/> <br/>".$car['name']."</center>
</div><div class='div'>
-> <a href='bot_race.php?a&b'>Вызвать на гонку</a>";}
}
echo "<br/>
- <a href='bot_race.php?a'>Искать гонщиков</a><br/>";
echo "</div><div class='aut'><a style='display:block;' href='index.php'><img src='ico/back.png' alt=''/> Назад</a></div>";
include_once '../../foot.php';
?>