Файл: vkollektive2014/play_gamescool/car/allrace.php
Строк: 131
<?php
include_once '../../connect.php';
include_once '../../head.php';echo "<br/>";
echo "<div class='aut'>";
echo "<img src='ico/race.gif' alt=''/> $u[login] Тут буду показывать твои вызовы на гонку <br/>";
echo "</div>";
echo "<br/>";
if(!isset($u)){
echo 'Вы неавторизованы';
include_once '../../foot.php';
exit;
}
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']."'"));
$all_racer=mysql_result(mysql_query("SELECT COUNT(*) FROM `racing_race` WHERE `id_1`='".$u['id']."' AND `act`='0'"),0);
$my_race=mysql_result(mysql_query("SELECT COUNT(*) FROM `racing_race` WHERE `id_1`='".$u['id']."' AND `act`='0'"),0);
$sop_race=mysql_result(mysql_query("SELECT COUNT(*) FROM `racing_race` WHERE `id_2`='".$u['id']."' AND `act`='0'"),0);
if($arr['color']!='0'){
if($arr['color']==1)
$color='red_';
elseif($arr['color']==2)
$color='blue_';
elseif($arr['color']==3)
$color='green_';
}
if(!isset($_GET['load'])){
echo "<a href='allrace.php?load&myrace'>Мои приглашения</a> ".($my_race>0 ? '+'.$my_race.'' :'')."<br/><a href='allrace.php?load&oprace'>Приглашения соперников</a> ".($sop_race>0 ? '+'.$sop_race.'' :'')."<br/>
";
}
else
{
if(isset($_GET['oprace'])){
echo "
<div class='aut'>
| опыт: ".$arr['exp']."
| ур: ".$arr['level']."
| <img src='ico/money.gif' alt=''/>".$arr['money']."
| реп: ".$arr['resp']."</div>
<div class='iroder3'>
<center><img src='car/".(isset($color) ? "".$color."".$car['screen']."" : "".$car['screen']."")."' alt=''/> <br/>".$car['name']."</center>
<br/>";
if($sop_race==0){
echo "Гонок нет!<br/>";
}
else
{
if(isset($_POST['submit'])){
$user_id_2=mysql_result(mysql_query("SELECT `id_1` FROM `racing_race` WHERE `id`='".intval($_GET['id_race'])."'"),0);
$arr_2=mysql_fetch_array(mysql_query("SELECT `speed`, `uprav` FROM `racing` WHERE `id_u`='".$user_id_2."'"));
$raznica_speed=$arr['speed']-$arr_2['speed'];
if($raznica_speed<0){
$raznica_speed=$arr_2['speed']-$arr['speed'];
$invers=1;
}
if($raznica_speed>16)
$invers=3;
if($raznica_speed==0)
$invers=2;
if($raznica_speed>=1 && $raznica_speed<=15)
$invers=2;
if($raznica_speed>=1 && $raznica_speed<=15 && $invers==2)
$invers=2;
if($invers==1){
$pob=rand(1,6);
if($pob!=3){
mysql_query("UPDATE `racing` SET `win`=`win`+1, `exp`=`exp`+$pob, `money`=`money`+500, `resp`=`resp`+200, `samoobl`=`samoobl`+250, `reak`=`reak`+310 WHERE `id_u`='".$user_id_2."'");
mysql_query("UPDATE `racing` SET `lose`=`lose`+1 WHERE `id_u`='".$u['id']."'");
ok("Гонка успешно проведенна! Выиграл ".mysql_result(mysql_query("SELECT `login` FROM `users` WHERE `id`='".$user_id_2."'"),0)."");
}
else
{
mysql_query("UPDATE `racing` SET `win`=`win`+1, `exp`=`exp`+$pob, `money`=`money`+500, `resp`=`resp`+200, `samoobl`=`samoobl`+250, `reak`=`reak`+310 WHERE `id_u`='".$u['id']."'");
mysql_query("UPDATE `racing` SET `lose`=`lose`+1 WHERE `id_u`='".$user_id_2."'");
ok("Гонка успешно проведенна! Выиграл ".mysql_result(mysql_query("SELECT `login` FROM `users` WHERE `id`='".$u['id']."'"),0)."");
}}
elseif($invers==2){
$pob=rand(1,2);
if($pob!=2){
mysql_query("UPDATE `racing` SET `win`=`win`+1, `exp`=`exp`+$pob, `money`=`money`+500, `resp`=`resp`+200, `samoobl`=`samoobl`+250, `reak`=`reak`+310 WHERE `id_u`='".$user_id_2."'");
mysql_query("UPDATE `racing` SET `lose`=`lose`+1 WHERE `id_u`='".$u['id']."'");
ok("Гонка успешно проведенна! Выиграл ".mysql_result(mysql_query("SELECT `login` FROM `users` WHERE `id`='".$user_id_2."'"),0)."");
}
else
{
mysql_query("UPDATE `racing` SET `win`=`win`+1, `exp`=`exp`+$pob, `money`=`money`+500, `resp`=`resp`+200, `samoobl`=`samoobl`+250, `reak`=`reak`+310 WHERE `id_u`='".$u['id']."'");
mysql_query("UPDATE `racing` SET `lose`=`lose`+1 WHERE `id_u`='".$user_id_2."'");
ok("Гонка успешно проведенна! Выиграл ".mysql_result(mysql_query("SELECT `login` FROM `users` WHERE `id`='".$u['id']."'"),0)."");
}
}
elseif($invers==3){
$pob=rand(1,6);
if($pob==3){
mysql_query("UPDATE `racing` SET `win`=`win`+1, `exp`=`exp`+$pob, `money`=`money`+500, `resp`=`resp`+200, `samoobl`=`samoobl`+250, `reak`=`reak`+310 WHERE `id_u`='".$user_id_2."'");
mysql_query("UPDATE `racing` SET `lose`=`lose`+1 WHERE `id_u`='".$u['id']."'");
ok("Гонка успешно проведенна! Выиграл ".mysql_result(mysql_query("SELECT `login` FROM `users` WHERE `id`='".$user_id_2."'"),0)."");
}
else
{
mysql_query("UPDATE `racing` SET `win`=`win`+1, `exp`=`exp`+$pob, `money`=`money`+500, `resp`=`resp`+200, `samoobl`=`samoobl`+250, `reak`=`reak`+310 WHERE `id_u`='".$u['id']."'");
mysql_query("UPDATE `racing` SET `lose`=`lose`+1 WHERE `id_u`='".$user_id_2."'");
ok("Гонка успешно проведенна! Выиграл ".mysql_result(mysql_query("SELECT `login` FROM `users` WHERE `id`='".$u['id']."'"),0)."");
}}
mysql_query("DELETE FROM `racing_race` WHERE `id`='".intval($_GET['id_race'])."'");
echo "Ђ
<a href='allrace.php?load&oprace'>Назад</a><br/>";
}
else
{
$k_page=k_page($sop_race,10);
$page=page($k_page);
$start=10*$page-10;
$queryy=mysql_query("SELECT * FROM `racing_race` WHERE `id_2`='".$u['id']."' AND `act`='0' ORDER BY `id` DESC LIMIT $start,10");
while($po=mysql_fetch_array($queryy)){
$pos=mysql_fetch_array(mysql_query("SELECT * FROM `racing` WHERE `id_u`='".$po['id_1']."'"));
$carp=mysql_fetch_array(mysql_query("SELECT * FROM `racing_car` WHERE `id`='".$pos['car']."'"));
if($pos['color']!='0'){
if($pos['color']==1)
$color2='red_';
elseif($pos['color']==2)
$color2='blue_';
elseif($pos['color']==3)
$color2='green_';
}
echo "<div class='iroder3'>";
echo "<img src='car/".(isset($color2) ? "".$color2."".$carp['screen']."" : "".$carp['screen']."")."' alt=''/>";
echo "<div class='rowup'>
Ник : <a href='/info.php?id=".$po['id_1']."'>
".mysql_result(mysql_query("SELECT `login` FROM `users` WHERE `id`='".$po['id_1']."'"),0)."</a><br/>
Поб/Пор : ".$pos['win']."/".$pos['lose']."<br/>
Тачка : ".$carp['name']."<br/>
<form method='post' action='allrace.php?load&oprace&act&id_race=".$po['id']."'>
<input type='submit' name='submit' value='Принять Вызов!'/></form></div>";
}
if($k_page>'1')str('?load&oprace&',$k_page,$page);
}}
}
elseif(!isset($_GET['oprace']) && isset($_GET['myrace'])){
echo "<div class='iroder3'>";
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='".($color!='0' ? "".$color."".$car['screen']."" : "".$car['screen']."")."' alt=''/> <br/>".$car['name']."</center>
<br/>";
if($my_race==0){
echo "Гонок нет!<br/>";
}
else
{
if(isset($_POST['submit'])){
mysql_query("DELETE FROM `racing_race` WHERE `id`='".intval($_GET['id_race'])."' LIMIT 1");
ok('Гонка успешно удалена!');
echo "Ђ
<a href='allrace.php?load&myrace'>Назад</a><br/>";
}
else
{
$k_page=k_page($my_race,10);
$page=page($k_page);
$start=10*$page-10;
$queryy=mysql_query("SELECT * FROM `racing_race` WHERE `id_1`='".$u['id']."' AND `act`='0' ORDER BY `id` DESC LIMIT $start,10");
while($po=mysql_fetch_array($queryy)){
$pos=mysql_fetch_array(mysql_query("SELECT * FROM `racing` WHERE `id_u`='".$po['id_2']."'"));
if($pos['color']!='0'){
if($pos['color']==1)
$color2='red_';
elseif($pos['color']==2)
$color2='blue_';
elseif($pos['color']==3)
$color2='green_';
}
$carp=mysql_fetch_array(mysql_query("SELECT * FROM `racing_car` WHERE `id`='".$pos['car']."'"));
echo "<div class='iroder3'>";
echo "<img src='car/".$color2."".$carp['screen']."' alt=''/>";
echo "<div class='rowup'>
Ник : <a href='/info.php?id=".$po['id_2']."'>
".mysql_result(mysql_query("SELECT `login` FROM `users` WHERE `id`='".$po['id_2']."'"),0)."</a><br/>
Поб/Пор : ".$pos['win']."/".$pos['lose']."<br/>
Тачка : ".$carp['name']."<br/>
<form method='post' action='allrace.php?load&myrace&act&id_race=".$po['id']."'>
<input type='submit' name='submit' value='Здатца!'/></form></div>";
}
if($k_page>'1')str('?load&myrace&',$k_page,$page);
}}
}
}
echo "<div class='rowup'>
<div class='aut'><a style='display:block;' href='index.php'><img src='ico/back.png' alt=''/> Назад</a></div>";
include_once '../../foot.php';
?>