Просмотр файла gta/city1/forsage.php

Размер файла: 18.11Kb
<?php
include "./../ini3.php";
include "./../includes/header2.php";
include "./../includes/inc_online.php";


$id=cyr(htmlspecialchars(stripslashes(trim($id))));
$pass=cyr(htmlspecialchars(stripslashes(trim($pass))));

if(!empty($id)) 
{
$q = mysql_query("select * from users where id='".$id."';");
}
else
{
die ($lang['empty_login']."</body></html>");
}

$data = mysql_fetch_array($q);

$id=$data['id'];
$login=$data['login'];
$money=$data['money'];
$cars=$data['cars'];
$level=$data['level'];
$golod=$data['golod'];
$health=$data['health'];
$secur=$data['secur'];
$zav=$data['zav'];
$lsd=$data['lsd'];
$ban=$data['ban'];
$gold=$data['gold'];
$lox=$data['lox'];

if($pass!=$data['pass'])
{
die ($lang['empty_login']."</body></html>");
}

mysql_query("update users set last='".time()."',city='1' where id='".$id."';");
if($ban==0)
{

mysql_query("delete from forsage where time<('".time()."'-'3600');");

$f_car=mysql_fetch_array(mysql_query("select gonka,car,mods from forsage_cars where userid='".$id."';"));

$gonka=$f_car['gonka'];
$car=$f_car['car'];
$mods=$f_car['mods'];
print "<b>[Зд: $health %][Сыт: $golod %][Зщ: $secur %]</b><br/>";
  
print "<b>".$lang['game_city1']."</b><br/>";

switch ($mode) 
{  
  case "1":

if(mysql_result(mysql_query("SELECT COUNT(id) FROM forsage;"),0)>$limit) die($lang['for_nelzya'].' <b>'.$limit.'</b><br/><anchor>'.$lang['back'].'<prev/></anchor></small></p></card></wml>');


$proverka=mysql_fetch_array(mysql_query("select id from forsage where id='".$gonka."';"));

if($proverka['id']==$gonka && $proverka['id']!='') die($lang['for_uje'].' '.$gonka.'!<br/><anchor>'.$lang['back'].'<prev/></anchor></small></p></card></wml>');


if(empty($tachka))
{

if(!empty($cars))
{
print $lang['for_select'];
$cars_count = explode(".", $cars);
$count_cars=count($cars_count);
print $lang['uv_cars']." <b>($count_cars)</b>:<br/>";
print "<form action=\"forsage.php?id=$id&amp;pass=$pass&amp;mode=1\" method=\"post\">
<postfield name=\"tachka\" value=\"$(tachka)\"/>";
print "<select name=\"tachka\">";
for($i=0;$i<$count_cars;$i++)
{
print "<option value=\"".$cars_count[$i]."\">".$cars_count[$i]."</option>"; 
}
print "</select><br/><small>";
echo "<input class=\"ibutton\" type=\"submit\" value=\"".$lang['ok']."\"/>";
    echo "</form>";
}
else
{
print $lang['bands_user_without_cars']."<br/>";
}

}
else
{

$cars_win_array=array($lang['car3'],$lang['car6'],$lang['car8'],$lang['car9'],$lang['car11'],$lang['car12']);
srand((double)microtime() *1000000);
$rand_key = array_rand($cars_win_array,2);

$win_car=$cars_win_array[$rand_key[0]];

mysql_query("insert into forsage values(0,'".$id."','1','".$win_car."','".time()."');");

$f_gonki=mysql_fetch_array(mysql_query("select id from forsage where users='".$id."';"));

$gid=$f_gonki['id'];

if($tachka==$lang['car1']) $mod_power=2;
elseif($tachka==$lang['car2']) $mod_power=7;
elseif($tachka==$lang['car3']) $mod_power=6;
elseif($tachka==$lang['car4']) $mod_power=8;
elseif($tachka==$lang['car5']) $mod_power=9;
elseif($tachka==$lang['car6']) $mod_power=19;
elseif($tachka==$lang['car7']) $mod_power=12;
elseif($tachka==$lang['car8']) $mod_power=18;
elseif($tachka==$lang['car9']) $mod_power=11;
elseif($tachka==$lang['car10']) $mod_power=23;
elseif($tachka==$lang['car11']) $mod_power=15;
elseif($tachka==$lang['car12']) $mod_power=7;
elseif($tachka==$lang['car13']) $mod_power=18;
elseif($tachka==$lang['car14']) $mod_power=22;
elseif($tachka==$lang['car15']) $mod_power=19;
elseif($tachka==$lang['car16']) $mod_power=8;
elseif($tachka==$lang['car17']) $mod_power=21;
elseif($tachka==$lang['car18']) $mod_power=25;
elseif($tachka==$lang['car19']) $mod_power=35;
elseif($tachka==$lang['car20']) $mod_power=44;
elseif($tachka==$lang['car21']) $mod_power=48;
elseif($tachka==$lang['car22']) $mod_power=73;


if(empty($gonka) || $gonka==0)
mysql_query("insert into forsage_cars values(0,'".$id."','".$gid."','".$tachka."','".$mod_power."');");
else
mysql_query("update forsage_cars set gonka='".$gid."',car='".$tachka."',mods='".$mod_power."' where userid='".$id."'");


print $lang['for_success'];
}


    print "&gt;<a href=\"forsage.php?id=$id&amp;pass=$pass\">".$lang['city1_forsage']."</a><br/>";
    break;
  case "2":

if($car==$lang['car1']) die($lang['for_velik'].'<br/><anchor>'.$lang['back'].'<prev/></anchor></small></p></card></wml>');

print '<u>['.$lang['for_masters'].']</u><br/>';


if(empty($upd))
{
print $lang['for_upg_mes'];
print $lang['city1_at_you'].' '.$money.'$$. '.$lang['for_plz_sel'].'<br/>';
print "<form action=\"forsage.php?id=$id&amp;pass=$pass&amp;mode=2\" method=\"post\">";
print '<select name="upd">';
print '<option value="1">'.$lang['for_upg1'].' (30 $$)</option>';
print '<option value="2">'.$lang['for_upg2'].' (50 $$)</option>';
print '<option value="3">'.$lang['for_upg3'].' (70 $$)</option>';
print '<option value="4">'.$lang['for_upg4'].' (100 $$)</option>';
print '<option value="5">'.$lang['for_upg5'].' (150 $$)</option>';
print '<option value="6">'.$lang['for_upg6'].' (170 $$)</option>';
print '<option value="7">'.$lang['for_upg7'].' (200 $$)</option>';
print '<option value="8">'.$lang['for_upg8'].' (250 $$)</option>';
print '</select><br/>';
print '<postfield name="upd" value="$(upd)"/><br/>';
print "<input class=\"ibutton\" type=\"submit\" value=\"".$lang['ok']."\"/>
   </form>";
}
else
{
if(!intval($upd) || ($upd<1 || $upd>8)) die($lang['error'].'<br/><anchor>'.$lang['back'].'<prev/></anchor></small></p></card></wml>');

if($upd==1)$update=rand(0,1);
elseif($upd==2)$update=rand(0,3);
elseif($upd==3)$update=rand(1,3);
elseif($upd==4)$update=rand(1,6);
elseif($upd==5)$update=rand(1,8);
elseif($upd==6)$update=rand(4,9);
elseif($upd==7)$update=rand(4,10);
elseif($upd==8)$update=rand(6,12);

if($upd==1)$cena=30;
elseif($upd==2)$cena=50;
elseif($upd==3)$cena=70;
elseif($upd==4)$cena=100;
elseif($upd==5)$cena=150;
elseif($upd==6)$cena=170;
elseif($upd==7)$cena=200;
elseif($upd==8)$cena=250;

if($money<$cena) die($lang['voo_no_money'].'<anchor>'.$lang['back'].'<prev/></anchor></small></p></card></wml>');

$mods=$mods+$update;
mysql_query("update forsage_cars set mods='".$mods."' where userid='".$id."'");
$money=$money-$cena;
mysql_query("update users set money='".$money."' where id='".$id."'");

print $lang['for_your_car_pr'].' '.$update.' '.$lang['for_ed'].'! '.$lang['for_uroven'].' <b>'.$car.'</b> '.$mods.' '.$lang['for_ed'].'! '.$lang['city1_at_you'].' '.$money.'$$!<br/>';
print "&gt;<a href=\"forsage.php?id=$id&amp;pass=$pass&amp;mode=2\">".$lang['for_update']."</a><br/>";
}

    print "&gt;<a href=\"forsage.php?id=$id&amp;pass=$pass\">".$lang['city1_forsage']."</a><br/>";
    break;

  case "3":
include './../functions/func_pagination.php';

$start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;
$base_url="forsage.php?id=$id&amp;pass=$pass&amp;mode=3&amp;start=";
$num_items=mysql_num_rows(mysql_query("select id from forsage;"));

print '<u>['.$lang['for_gonwiki'].']</u><br/>';

$i=0;
$now_q = mysql_query("select id,win,users from forsage order by id desc limit $start,$per_page;"); 
if(mysql_num_rows($now_q)<1) print $lang['for_no_zaezd'];
while($now_arr=mysql_fetch_array($now_q))
{
++$i;
$nom=$i+$start;
$uch=count(explode('.',$now_arr['users']));
print '<u>'.$nom.'</u>. '.$lang['for_gonka'].' <b>'.$now_arr['id'].'</b>, '.$lang['for_u4-kov'].' <b>'.$uch.'</b><br/>'.$lang['for_priz'].' '.$now_arr['win'].'<br/>';
print '[<a href="forsage.php?id='.$id.'&amp;pass='.$pass.'&amp;mode=6&amp;dbid='.$now_arr['id'].'">'.$lang['for_info'].'</a>]<br/>';
if($uch<3 && !in_array($id,explode('.',$now_arr['users']))) print '[<a href="forsage.php?id='.$id.'&amp;pass='.$pass.'&amp;mode=4&amp;dbid='.$now_arr['id'].'">'.$lang['for_enjoy'].'</a>]<br/>';
elseif(in_array($id,explode('.',$now_arr['users']))) print '<b>'.$lang['for_you_in_this_g'].'</b><br/>';
}

$pagination = generate_pagination($base_url, $num_items, $per_page, $start);

if(!empty($pagination))print '---<br/>'.$pagination;
    print "<br/>&gt;<a href=\"forsage.php?id=$id&amp;pass=$pass\">".$lang['city1_forsage']."</a><br/>";
    break;

  case "4":

if(empty($tachka))
{
$dbid=cyr(htmlspecialchars(stripslashes(trim($_GET[dbid]))));

$now_q = mysql_fetch_array(mysql_query("select users from forsage where id='".$dbid."';"));
if(count(explode('.',$now_q['users']))>=3) die($lang['error'].'<br/><anchor>'.$lang['back'].'<prev/></anchor></small></p></card></wml>');

$userx=explode('.',$now_q['users']);
if(in_array($id,$userx)) die($lang['for_uje'].'<br/><anchor>'.$lang['back'].'<prev/></anchor></small></p></card></wml>');


if(!empty($cars))
{
print $lang['for_select'];
$cars_count = explode(".", $cars);
$count_cars=count($cars_count);
print $lang['uv_cars']." <b>($count_cars)</b>:<br/>";
print "<form action=\"forsage.php?id=$id&amp;pass=$pass&amp;mode=4\" method=\"post\">
<postfield name=\"tachka\" value=\"$(tachka)\"/>
<input type=\"hidden\" name=\"dbid\" value=\"$dbid\"/>";
print "<select name=\"tachka\">";
for($i=0;$i<$count_cars;$i++)
{
print "<option value=\"".$cars_count[$i]."\">".$cars_count[$i]."</option>"; 
}
print "</select><br/><small>";
echo "<input class=\"ibutton\" type=\"submit\" value=\"".$lang['ok']."\"/>";
    echo "</form>";
}
else
{
print $lang['bands_user_without_cars']."<br/>";
}

}
else
{
$dbid=cyr(htmlspecialchars(stripslashes(trim($_POST[dbid]))));

$now_q = mysql_fetch_array(mysql_query("select users from forsage where id='".$dbid."';"));
if(count(explode('.',$now_q['users']))>=3) die($lang['error'].'<br/><anchor>'.$lang['back'].'<prev/></anchor></small></p></card></wml>');

$userx=explode('.',$now_q['users']);
if(in_array($id,$userx)) die($lang['for_uje'].'<br/><anchor>'.$lang['back'].'<prev/></anchor></small></p></card></wml>');


$n_us=$now_q['users'];
$new_user="$n_us.$id";
mysql_query("update forsage set users='".$new_user."',time='".time()."' where id='".$dbid."';");

if($tachka==$lang['car1']) $mod_power=2;
elseif($tachka==$lang['car2']) $mod_power=7;
elseif($tachka==$lang['car3']) $mod_power=6;
elseif($tachka==$lang['car4']) $mod_power=8;
elseif($tachka==$lang['car5']) $mod_power=9;
elseif($tachka==$lang['car6']) $mod_power=19;
elseif($tachka==$lang['car7']) $mod_power=12;
elseif($tachka==$lang['car8']) $mod_power=18;
elseif($tachka==$lang['car9']) $mod_power=11;
elseif($tachka==$lang['car10']) $mod_power=23;
elseif($tachka==$lang['car11']) $mod_power=15;
elseif($tachka==$lang['car12']) $mod_power=7;
elseif($tachka==$lang['car13']) $mod_power=18;
elseif($tachka==$lang['car14']) $mod_power=22;
elseif($tachka==$lang['car15']) $mod_power=19;
elseif($tachka==$lang['car16']) $mod_power=8;
elseif($tachka==$lang['car17']) $mod_power=21;
elseif($tachka==$lang['car18']) $mod_power=25;
elseif($tachka==$lang['car19']) $mod_power=35;
elseif($tachka==$lang['car20']) $mod_power=44;
elseif($tachka==$lang['car21']) $mod_power=48;
elseif($tachka==$lang['car22']) $mod_power=73;
if(empty($gonka) || $gonka==0)
mysql_query("insert into forsage_cars values(0,'".$id."','".$dbid."','".$tachka."','".$mod_power."');");
else
mysql_query("update forsage_cars set gonka='".$dbid."',mods='".$mod_power."',car='".$tachka."' where userid='".$id."'");

print $lang['for_now_at_you'].' <b>'.$dbid.'</b>!<br/>';

}

    print "&gt;<a href=\"forsage.php?id=$id&amp;pass=$pass\">".$lang['city1_forsage']."</a><br/>";
    break;

  case "5":

$f_gonki=mysql_fetch_array(mysql_query("select * from forsage where id='".$gonka."';"));

$gid=$f_gonki['id'];
$users=$f_gonki['users'];
$stage=$f_gonki['stage'];
$win=$f_gonki['win'];
$timeg=$f_gonki['time'];

print '['.$lang['for_zaezd'].' <b>'.$gid.'</b>. '.$lang['for_a-tup'].' <b>'.$stage.'</b>]<br/>';

if(count(explode('.',$users))<3) print $lang['for_poka'].' '.count(explode('.',$users)).' '.$lang['for_naberi'].'<br/>';
else
{


$zaezd_arr=mysql_fetch_array(mysql_query("select users from forsage where id='".$gonka."';"));

$gon_users=$zaezd_arr['users'];
$gon_users=explode('.',$gon_users);

for($i=0;$i<count($gon_users);$i++)
{
$nom=$i+1;
$uchastnik=mysql_fetch_array(mysql_query("select login from users where id='".$gon_users[$i]."';"));

$zaezd_q=mysql_fetch_array(mysql_query("select * from forsage_cars where userid='".$gon_users[$i]."' order by mods desc;"));

print '<u>'.$nom.'</u>.'.$uchastnik['login'].' '.$lang['for_na'].' '.$zaezd_q['car'].'. '.$lang['for_sila'].' <b>'.$zaezd_q['mods'].'</b> '.$lang['for_ed'].'<br/>';

$mods_us[]=$zaezd_q['mods'];

}




$mods_us2=array_count_values($mods_us);

if(($mods_us2[0]>1 || $mods_us2[1]>1 || $mods_us2[2]>1 || $mods_us2[3]>1 || $mods_us2[4]>1 || $mods_us2[5]>1) && $timeg>(time()-$vremya_gonki))
print $lang['for_g_prod'];
else
{
rsort($mods_us);
$win_user_id=mysql_fetch_array(mysql_query("select userid from forsage_cars where mods='".$mods_us[0]."' and gonka='".$gid."';"));
$win_user_login=mysql_fetch_array(mysql_query("select login,money,level,cars from users where id='".$win_user_id['userid']."';"));
++$stage;
mysql_query("update forsage set stage='".$stage."',time='".time()."' where id='".$gonka."';");
print '<b>'.$lang['for_win'].' '.$win_user_login['login'].'!</b><br/>';
if($stage<4)print'<b>'.$lang['for_next_stage'].' <u>'.$stage.'</u>!</b><br/>';

$userx_go=explode('.',$users);
for($i=0;$i<count($userx_go);$i++)
{
/*$rand_mods=rand(1,10);*/
mysql_query("update forsage_cars set mods='' where userid='".$userx_go[$i]."';");
}

}

if($stage>3)
{


$userx_g=explode('.',$users);
for($i=0;$i<count($userx_g);$i++)
{
$us_pass=mysql_fetch_array(mysql_query("select pass from users where id='".$userx_g[$i]."';"));
$messaga=$lang['for_you_loser']." <u>".$gonka."</u>! ".$lang['for_you_loser2']."<br/>[<a href=\"./../mes.php?pass=".$us_pass['pass']."&amp;id=".$userx_g[$i]."&amp;dbid=0&amp;mode=del\">".$lang['mes_del']."</a>]";
if($userx_g[$i]!=$win_user_id['userid'])mysql_query("insert into messagi values(0,'0','".$userx_g[$i]."','".$messaga."');");
mysql_query("delete from forsage_cars where userid='".$userx_g[$i]."';");
}

mysql_query("delete from forsage where id='".$gonka."';");

$win_rand=rand(1000,100000);
$win_level=rand(0,30);
mysql_query("update users set money='".$win_user_login[money]."'+'".$win_rand."',cars='".$win_user_login[cars].".".$win."',level='".$win_user_login[level]."'+'".$win_level."' where id='".$win_user_id['userid']."';");
print $lang['for_g_full'].' '.$win_user_login['login'].'!<br/> '.$lang['for_viigran'].' '.$win.'! '.$lang['for_takje'].' '.$win_rand.'$$ '.$lang['for_and'].' '.$win_level.' '.$lang['for_ed_avt'].'<br/>';
$us_pass2=mysql_fetch_array(mysql_query("select pass from users where id='".$win_user_id['userid']."';"));
$messaga=$lang['for_you_win']." <u>".$gonka."</u>! ".$lang['for_viigran']." ".$win."! <br/>[<a href=\"./../mes.php?pass=".$us_pass2['pass']."&amp;id=".$win_user_id['userid']."&amp;dbid=0&amp;mode=del\">".$lang['mes_del']."</a>]";
mysql_query("insert into messagi values(0,'0','".$win_user_id['userid']."','".$messaga."');");
}
}

    print "&gt;<a href=\"forsage.php?id=$id&amp;pass=$pass\">".$lang['city1_forsage']."</a><br/>";
    break;

  case "6":

$dbid=cyr(htmlspecialchars(stripslashes(trim($_GET[dbid]))));

if(!intval($dbid) || empty($dbid)) die($lang['error'].'<br/><anchor>'.$lang['back'].'<prev/></anchor></small></p></card></wml>');


$zaezd_arr=mysql_fetch_array(mysql_query("select users from forsage where id='".$dbid."';"));

$gon_users=$zaezd_arr['users'];
$gon_users=explode('.',$gon_users);

print '['.$lang['for_zaezd'].' <b>'.$dbid.'</b>]<br/>';

for($i=0;$i<count($gon_users);$i++)
{
$nom=$i+1;
$uchastnik=mysql_fetch_array(mysql_query("select login from users where id='".$gon_users[$i]."';"));

$zaezd_q=mysql_fetch_array(mysql_query("select * from forsage_cars where userid='".$gon_users[$i]."' order by mods desc;"));

print '<u>'.$nom.'</u>.'.$uchastnik['login'].' '.$lang['for_na'].' '.$zaezd_q['car'].'. '.$lang['for_sila'].' <b>'.$zaezd_q['mods'].'</b> '.$lang['for_ed'].'<br/>';



}




print '&gt;<anchor>'.$lang['back'].'<prev/></anchor><br/>';
    print "&gt;&gt;<a href=\"forsage.php?id=$id&amp;pass=$pass\">".$lang['city1_forsage']."</a><br/>";
    break;
case "7":
print '<u>[Правила гонок]</u><br/>';
print 'Начальный апгрейд тачки определяется по формуле <b>(Скорость-(20% веса))+Управляемость+Прочность-Вес</b><br/>';
print 'Вы можете прокачивать свою машину на любм круге гонок<br/>';
print 'Победителем является гонщик,выигравший в последнем круге или во всех кругах<br/>';
print 'Победитель получает от 1000 до 100000$$,от 0 до 30 единиц авторитета<br/>';
print "-<a href=\"forsage.php?id=$id&amp;pass=$pass\">".$lang['back']."</a><br/>";
break;


  default:
print "<u>[".$lang['city1_forsage']."]</u><br/>";

if(!empty($cars))
{
print $lang['for_mes'];
if(mysql_num_rows(mysql_query("select id from forsage where id='".$gonka."';"))<1)
print "-<a href=\"forsage.php?id=$id&amp;pass=$pass&amp;mode=1\">".$lang['for_create']."</a><br/>";
else
{
print "-<a href=\"forsage.php?id=$id&amp;pass=$pass&amp;mode=5\">".$lang['for_see']."</a><br/>";
print "-<a href=\"forsage.php?id=$id&amp;pass=$pass&amp;mode=2\">".$lang['for_update']."</a><br/>";
}
print "-<a href=\"forsage.php?id=$id&amp;pass=$pass&amp;mode=3\">".$lang['for_now_sor']."</a><br/>";
}
else
{
print $lang['for_without_cars'];
}
print "-<a href=\"forsage.php?id=$id&amp;pass=$pass&amp;mode=7\">Правила гонок</a><br/>";
//print 'Трасса временно закрыта,извини! Приходи в следующий раз!<br/>';
  break;
}

print "---<br/>&gt;<a href=\"index.php?id=$id&amp;pass=$pass\">".$lang['in_city']."</a>";
print "<br/>&gt;&gt;<a href=\"./../game.php?id=$id&amp;pass=$pass\">".$lang['menu']."</a>";
print "<br/>---";

mysql_close();
include "./../includes/footer2.php";
}

elseif($ban==1)
{
die ($lang['empty_login']."</body></html>");

}
?>