Файл: 402m/myrace.php
Строк: 223
<?
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';
err();
aut();
//header("Content-type: application/vnd.wap.xhtml+xml");
header("Content-type: text/html");
echo "<link rel='stylesheet' href='style.css' type='text/css' />";
echo '<div id="cnt"><div id="hdr"><div class="hdr"><div></div></div>';
echo"<div class='loc'><img alt='.' height='50' src='intro_162.png' width='162' /></div><hr/><dl class='mai2n'>";
if(!isset($user)){
echo "Секретная зона! Доступна после авторизации";
include_once '../sys/inc/tfoot.php';
break;
}
$mod=htmlspecialchars(trim($_GET['mod']));
if($mod=='myrace'){
$q=mysql_result(mysql_query("SELECT COUNT(*) FROM `xrexrace` WHERE `id2`='".$user['id']."'"), 0);
if($q=='0'){
echo "Гонок ещё не было<br/>";
}
else
{
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `xrexrace` WHERE `id2`='".$user['id']."'"), 0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
$all=mysql_query("SELECT * FROM `xrexrace` WHERE `id2`='".$user['id']."' ORDER BY `id` DESC LIMIT $start,$set[p_str]");
while($arr=mysql_fetch_array($all)){
$id=$arr['id'];
$id1=$arr['id1'];
$id2=$arr['id2'];
$s1=$arr['s1'];
$s2=$arr['s2'];
$kon=$arr['kon'];
$act=$arr['act'];
$winner=$arr['winner'];
$id_w=$arr['id_w'];
echo "Соперник : ".mysql_result(mysql_query("SELECT `nick` FROM `xrexmy` WHERE `id`='".$id1."'"), 0)."<br/>";
echo "Скорость вашей машины : $s2 км.ч<br/>";
echo "Скорость машины соперника : $s1 км.ч<br/>";
switch($kon){
case '1':
echo "Ставка : 200 $<br/>";
break;
case '2':
echo "Ставка : 500 $<br/>";
break;
}
$ok=htmlspecialchars(trim($_GET['ok']));
if($ok=='ok'){
$rand=rand(1,10);
if($rand=='1' || $rand=='3' || $rand=='5' || $rand=='7'){
$sw='1';
}
elseif($rand=='2' || $rand=='4' || $rand=='6' || $rand=='8'){
$sw='2';
}
elseif($rand=='9'){
$sw='3';
}
elseif($rand=='10'){
$sw='4';
}
switch($rand){
case '1':
if($kon=='1'){
mysql_query("UPDATE `xrexrace` SET `winner`='$id1', `act`='1' WHERE `id`='$id' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `win`=`win`+1, `dollars`=`dollars`+200 WHERE `id`='$id1' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `lose`=`lose`+1, `dollars`=`dollars`-200 WHERE `id`='$id2' LIMIT 1");
}
elseif($kon=='2'){
mysql_query("UPDATE `xrexrace` SET `winner`='$id1', `act`='1' WHERE `id`='$id' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `win`=`win`+1, `dollars`=`dollars`+500 WHERE `id`='$id1' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `lose`=`lose`+1, `dollars`=`dollars`-500 WHERE `id`='$id2' LIMIT 1");
}
header("Location:myrace.php?$rand");
break;
case '3':
if($kon=='1'){
mysql_query("UPDATE `xrexrace` SET `winner`='$id1', `act`='1' WHERE `id`='$id' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `win`=`win`+1, `dollars`=`dollars`+200 WHERE `id`='$arr[id1]' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `lose`=`lose`+1, `dollars`=`dollars`-200 WHERE `id`='$arr[id2]' LIMIT 1");
}
elseif($kon=='2'){
mysql_query("UPDATE `xrexrace` SET `winner`='$id1', `act`='1' WHERE `id`='$id' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `win`=`win`+1, `dollars`=`dollars`+500 WHERE `id`='$arr[id1]' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `lose`=`lose`+1, `dollars`=`dollars`-500 WHERE `id`='$arr[id2]' LIMIT 1");
}
header("Location:myrace.php?$rand");
break;
case '5':
if($kon=='1'){
mysql_query("UPDATE `xrexrace` SET `winner`='$id1', `act`='1' WHERE `id`='$id' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `win`=`win`+1, `dollars`=`dollars`+200 WHERE `id`='$arr[id1]' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `lose`=`lose`+1, `dollars`=`dollars`-200 WHERE `id`='$arr[id2]' LIMIT 1");
}
elseif($kon=='2'){
mysql_query("UPDATE `xrexrace` SET `winner`='$id1', `act`='1' WHERE `id`='$id' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `win`=`win`+1, `dollars`=`dollars`+500 WHERE `id`='$arr[id1]' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `lose`=`lose`+1, `dollars`=`dollars`-500 WHERE `id`='$arr[id2]' LIMIT 1");
}
header("Location:myrace.php?$rand");
break;
case '7':
if($kon=='1'){
mysql_query("UPDATE `xrexrace` SET `winner`='$id1', `act`='1' WHERE `id`='$id' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `win`=`win`+1, `dollars`=`dollars`+200 WHERE `id`='$arr[id1]' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `lose`=`lose`+1, `dollars`=`dollars`-200 WHERE `id`='$arr[id2]' LIMIT 1");
}
elseif($kon=='2'){
mysql_query("UPDATE `xrexrace` SET `winner`='$id1', `act`='1' WHERE `id`='$id' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `win`=`win`+1, `dollars`=`dollars`+500 WHERE `id`='$arr[id1]' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `lose`=`lose`+1, `dollars`=`dollars`-500 WHERE `id`='$arr[id2]' LIMIT 1");
}
header("Location:myrace.php?$rand");
break;
case '2':
if($kon=='1'){
mysql_query("UPDATE `xrexrace` SET `winner`='$id2', `act`='1' WHERE `id`='$id' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `win`=`win`+1, `dollars`=`dollars`+200 WHERE `id`='$arr[id2]' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `lose`=`lose`+1, `dollars`=`dollars`-200 WHERE `id`='$arr[id1]' LIMIT 1");
}
elseif($kon=='2'){
mysql_query("UPDATE `xrexrace` SET `winner`='$id2', `act`='1' WHERE `id`='$id' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `win`=`win`+1, `dollars`=`dollars`+500 WHERE `id`='$arr[id2]' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `lose`=`lose`+1, `dollars`=`dollars`-500 WHERE `id`='$arr[id1]' LIMIT 1");
}
header("Location:myrace.php?$rand");
break;
case '4':
if($kon=='1'){
mysql_query("UPDATE `xrexrace` SET `winner`='$id2', `act`='1' WHERE `id`='$id' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `win`=`win`+1, `dollars`=`dollars`+200 WHERE `id`='$arr[id2]' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `lose`=`lose`+1, `dollars`=`dollars`-200 WHERE `id`='$arr[id1]' LIMIT 1");
}
elseif($kon=='2'){
mysql_query("UPDATE `xrexrace` SET `winner`='$id2', `act`='1' WHERE `id`='$id' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `win`=`win`+1, `dollars`=`dollars`+500 WHERE `id`='$arr[id2]' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `lose`=`lose`+1, `dollars`=`dollars`-500 WHERE `id`='$arr[id1]' LIMIT 1");
}
header("Location:myrace.php?$rand");
break;
case '6':
if($kon=='1'){
mysql_query("UPDATE `xrexrace` SET `winner`='$id2', `act`='1' WHERE `id`='$id' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `win`=`win`+1, `dollars`=`dollars`+200 WHERE `id`='$arr[id2]' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `lose`=`lose`+1, `dollars`=`dollars`-200 WHERE `id`='$arr[id1]' LIMIT 1");
}
elseif($kon=='2'){
mysql_query("UPDATE `xrexrace` SET `winner`='$id2', `act`='1' WHERE `id`='$id' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `win`=`win`+1, `dollars`=`dollars`+500 WHERE `id`='$arr[id2]' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `lose`=`lose`+1, `dollars`=`dollars`-500 WHERE `id`='$arr[id1]' LIMIT 1");
}
header("Location:myrace.php?$rand");
break;
case '8':
if($kon=='1'){
mysql_query("UPDATE `xrexrace` SET `winner`='$id2', `act`='1' WHERE `id`='$id' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `win`=`win`+1, `dollars`=`dollars`+200 WHERE `id`='$arr[id2]' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `lose`=`lose`+1, `dollars`=`dollars`-200 WHERE `id`='$arr[id1]' LIMIT 1");
}
elseif($kon=='2'){
mysql_query("UPDATE `xrexrace` SET `winner`='$id2', `act`='1' WHERE `id`='$id' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `win`=`win`+1, `dollars`=`dollars`+500 WHERE `id`='$arr[id2]' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `lose`=`lose`+1, `dollars`=`dollars`-500 WHERE `id`='$arr[id1]' LIMIT 1");
}
header("Location:myrace.php?$rand");
break;
case '9':
if($kon=='1'){
mysql_query("UPDATE `xrexrace` SET `winner`='$id1', `act`='1' WHERE `id`='$id' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `win`=`win`+1, `dollars`=`dollars`+200 WHERE `id`='$arr[id1]' LIMIT 1");
mysql_query("UPDATE `xrexcars` SET `arest`=`arest`+1 WHERE `id`='$arr[id_w1]' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `lose`=`lose`+1, `dollars`=`dollars`-200 WHERE `id`='$arr[id2]' LIMIT 1");
}
elseif($kon=='2'){
mysql_query("UPDATE `xrexrace` SET `winner`='$id1', `act`='1' WHERE `id`='$id' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `win`=`win`+1, `dollars`=`dollars`+500 WHERE `id`='$arr[id2]' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `lose`=`lose`+1, `dollars`=`dollars`-500 WHERE `id`='$arr[id1]' LIMIT 1");
mysql_query("UPDATE `xrexcars` SET `arest`=`arest`+1 WHERE `id`='$arr[id_w1]' LIMIT 1");
}
header("Location:myrace.php?$rand");
break;
case '10':
if($kon=='1'){
mysql_query("UPDATE `xrexrace` SET `winner`='$id2', `act`='1' WHERE `id`='$arr[id]' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `win`=`win`+1, `dollars`=`dollars`+200 WHERE `id`='$arr[id2]' LIMIT 1");
mysql_query("UPDATE `xrexcars` SET `arest`=`arest`+1 WHERE `id`='$arr[id_w2]' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `lose`=`lose`+1, `dollars`=`dollars`-200 WHERE `id`='$arr[id1]' LIMIT 1");
}
elseif($kon=='2'){
mysql_query("UPDATE `xrexrace` SET `winner`='$id2', `act`='1' WHERE `id`='$arr[id]' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `win`=`win`+1, `dollars`=`dollars`+500 WHERE `id`='$arr[id1]' LIMIT 1");
mysql_query("UPDATE `xrexmy` SET `lose`=`lose`+1, `dollars`=`dollars`-500 WHERE `id`='$arr[id2]' LIMIT 1");
mysql_query("UPDATE `xrexcars` SET `arest`=`arest`+1 WHERE `id`='$arr[id_w2]' LIMIT 1");
}
header("Location:myrace.php?$rand");
break;
}
}
switch($act){
case '0':
echo "<a href='?mod=myrace&ok=ok&page=$page'><font color='SeaShell'>Согласен</font></a><br/>";
break;
case '1':
echo "Гонка завершена<br/>Победил : ".mysql_result(mysql_query("SELECT `nick` FROM `xrexmy` WHERE `id`='".$winner."'"), 0)."<br/>
Выйгрыш победителя : ";
if($kon=='1'){
echo "200 $<br/>";
}
else
{
echo "".mysql_result(mysql_query("SELECT `name` FROM `xrexcars` WHERE `id`='".$id_w."'"), 0)."<br/>";
}
break;
} echo "<hr/>";}
if($k_page>'1')str('?mod=myrace&',$k_page,$page);
}
include_once '../sys/inc/tfoot.php';
break;
}
$q=mysql_result(mysql_query("SELECT COUNT(*) FROM `xrexrace` WHERE `id1`='".$user['id']."'"), 0);
if($q=='0'){
echo "Гонок ещё не было<br/>";
}
else
{
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `xrexrace` WHERE `id1`='".$user['id']."'"), 0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
$all=mysql_query("SELECT * FROM `xrexrace` WHERE `id1`='".$user['id']."' LIMIT $start,$set[p_str]");
while($arr=mysql_fetch_array($all)){
$id1=$arr['id1'];
$id2=$arr['id2'];
$s1=$arr['s1'];
$s2=$arr['s2'];
$kon=$arr['kon'];
$act=$arr['act'];
$winner=$arr['winner'];
$id_w=$arr['id_w'];
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `xrexcars` WHERE `id_u`='".$user['id']."'"), 0);
echo "Соперник : ".mysql_result(mysql_query("SELECT `nick` FROM `xrexmy` WHERE `id`='".$id2."'"), 0)."<br/>";
echo "Скорость вашей машины : $s1 км.ч<br/>";
echo "Скорость машины соперника : $s2 км.ч<br/>";
switch($kon){
case '1':
echo "Ставка : 200 $<br/>";
break;
case '2':
echo "Ставка : 500 $<br/>";
break;
}
switch($act){
case '0':
echo "Ожидается соперник<br/>";
break;
case '1':
echo "Гонка завершена<br/>Победил : ".mysql_result(mysql_query("SELECT `nick` FROM `xrexmy` WHERE `id`='".$winner."'"), 0)."<br/>
Выйгрыш победителя : ";
if($kon=='1'){
echo "200 $<br/>";
}
else
{
echo "500 $<br/>";
}
break;
} echo "<hr/>";
}
if($k_page>'1')str('?',$k_page,$page);
}
$k_post2=mysql_result(mysql_query("SELECT COUNT(*) FROM `xrexrace` WHERE `id2`='".$user['id']."' AND `act`='0'"), 0);
echo "<dl class='mai2n'>
<dt></dt>
<a href='?mod=myrace'><dt><img src='img/i_h_races.gif'/><font color='SeaShell'>Гонки +$k_post2</dt></a></font>";
echo "<a href='bl.php'><dt><img src='img/i_cars.gif'/><font color='SeaShell'>Гонщики</font></dt></a>";
echo "<a href='index.php'><dt><img src='img/i_back.gif'/><font color='SeaShell'>На главную</font></dt></a></TABLE>";
include_once '../sys/inc/tfoot.php';
?>