Файл: b_arena.php
Строк: 309
<?
define('PROTECTOR', 1);
$textl='Битва';
include('files/db.php');
include($path.'files/auth.php');
if ($user_id==0){
header('location: index.php');exit;
}
$lv=time();
$last=date('d.m.Y - H:i:s');
mysql_query("UPDATE `users` SET
`lv`='".$lv."',
`last`='".$last."',
`mesto`='".$textl."'
WHERE `id`='".$udata['id']."'");
$mobs=mysql_query("SELECT * FROM `craft` WHERE `usr`='".$udata['id']."'");
$rows=mysql_num_rows($mobs);
if($rows!=0)
{
header('location: work.php');exit;
}
$mobs2=mysql_query("SELECT * FROM `avan_usr` WHERE `usr`='".$udata['id']."'");
$rows2=mysql_num_rows($mobs2);
if($rows2!=0)
{
header('location: avan.php');exit;
}
$mobs3=mysql_query("SELECT * FROM `battle` WHERE `usr`='".$udata['id']."'");
$rows3=mysql_num_rows($mobs3);
if($rows3!=0)
{
header('location: battle.php');exit;
}
$mobs4=mysql_query("SELECT * FROM `ohota` WHERE `usr`='".$udata['id']."'");
$rows4=mysql_num_rows($mobs4);
if($rows4!=0)
{
header('location: b_oh.php');exit;
}
$mobs5=mysql_query("SELECT * FROM `okr_usr` WHERE `usr`='".$udata['id']."'");
$rows5=mysql_num_rows($mobs5);
if($rows5!=0)
{
header('location: b_okr.php');exit;
}
$mobs6=mysql_query("SELECT * FROM `str_usr` WHERE `usr`='".$udata['id']."'");
$rows6=mysql_num_rows($mobs6);
if($rows6!=0)
{
header('location: b_str.php');exit;
}
$mobs7=mysql_query("SELECT * FROM `terr_usr` WHERE `usr`='".$udata['id']."'");
$rows7=mysql_num_rows($mobs7);
if($rows7!=0)
{
header('location: terr_b.php');exit;
}
$t=time();
$bat=mysql_query("SELECT * FROM `arena_usr` WHERE `usr`='".$udata['id']."' and `time`<='".$t."'");
$num=mysql_num_rows($bat);
if($num==0)
{
header('location: arena.php');exit;
}
else
{
$bt=mysql_fetch_array($bat);
$lvl=$udata['lvl']+1;
$exzn=mysql_num_rows(mysql_query("SELECT * FROM `lvl` WHERE `lvl`='".$lvl."'"));
if($exzn!=0)
{
$ex=mysql_fetch_array(mysql_query("SELECT * FROM `lvl` WHERE `lvl`='".$lvl."'"));
if($udata['exp']>=$ex['exp'])
{
$kl=$udata['lvl']+1;
if($udata['klass']==1)
{
$hp=$udata['hp1']+2;
$sila=$udata['sila1']+3;
$arm=$udata['arm1']+1;
}
if($udata['klass']==2)
{
$hp=$udata['hp1']+3;
$sila=$udata['sila1']+1;
$arm=$udata['arm1']+2;
}
if($udata['klass']==3)
{
$hp=$udata['hp1']+1;
$sila=$udata['sila1']+2;
$arm=$udata['arm1']+3;
}
mysql_query("UPDATE `users` SET `lvl`='".$kl."', `hp1`='".$hp."', `sila1`='".$sila."', `arm1`='".$arm."' WHERE `id`='".$udata['id']."'");
if($udata['ref']!=0)
{
$refer=mysql_query("SELECT * FROM `users` WHERE `id`='".$udata['ref']."'");
$ref=mysql_fetch_array($refer);
if($kl==30)
{
$ref_m=$ref['money']+100;
mysql_query("UPDATE `users` SET `money`='".$ref_m."' WHERE `id`='".$ref['id']."'");
$rows211=mysql_num_rows(mysql_query("SELECT * FROM `msg_kont` WHERE `usr1`='".$ref['id']."' and `usr2`='0'"));
if($rows211==0)
{
mysql_query("INSERT INTO `msg_kont` SET
`id`='',
`usr1`='".$ref['id']."',
`usr2`='0',
`read`='1',
`time`='".time()."'
");
}else
{
$rows21=mysql_fetch_array(mysql_query("SELECT * FROM `msg_kont`
WHERE `usr2`='0' and `usr1`='".$ref['id']."'"));
mysql_query("UPDATE `msg_kont` SET `read`='1', `time`='".time()."' WHERE `usr2`='0' and `usr1`='".$ref['id']."'");
}
$rows21=mysql_fetch_array(mysql_query("SELECT * FROM `msg_kont`
WHERE `usr2`='0' and `usr1`='".$ref['id']."'"));
$text='<font color=#cccccc>Ваш реферал '.$udata['usr'].' прокачался до 30 уровня. За это вы получаете <img src=img/main/p5.png>100.</font>
';
mysql_query("INSERT INTO `msg_dialog` SET
`id`='',
`dialog`='".$rows21['id']."',
`vhod`='1',
`time`='".time()."',
`text`='".$text."',
`usr`='".$ref['id']."'
");
}
if($kl==40)
{
$ref_m=$ref['jem']+5;
mysql_query("UPDATE `users` SET `jem`='".$ref_m."' WHERE `id`='".$ref['id']."'");
$rows211=mysql_num_rows(mysql_query("SELECT * FROM `msg_kont` WHERE `usr1`='".$ref['id']."' and `usr2`='0'"));
if($rows211==0)
{
mysql_query("INSERT INTO `msg_kont` SET
`id`='',
`usr1`='".$ref['id']."',
`usr2`='0',
`read`='1',
`time`='".time()."'
");
}else
{
$rows21=mysql_fetch_array(mysql_query("SELECT * FROM `msg_kont`
WHERE `usr2`='0' and `usr1`='".$ref['id']."'"));
mysql_query("UPDATE `msg_kont` SET `read`='1', `time`='".time()."' WHERE `usr2`='0' and `usr1`='".$ref['id']."'");
}
$rows21=mysql_fetch_array(mysql_query("SELECT * FROM `msg_kont`
WHERE `usr2`='0' and `usr1`='".$ref['id']."'"));
$text='<font color=#cccccc>Ваш реферал '.$udata['usr'].' прокачался до 40 уровня. За это вы получаете <img src=img/main/p13.png>5.</font>
';
mysql_query("INSERT INTO `msg_dialog` SET
`id`='',
`dialog`='".$rows21['id']."',
`vhod`='1',
`time`='".time()."',
`text`='".$text."',
`usr`='".$ref['id']."'
");
}
if($kl==45)
{
$ref_m=$ref['jem']+15;
mysql_query("UPDATE `users` SET `jem`='".$ref_m."' WHERE `id`='".$ref['id']."'");
$rows211=mysql_num_rows(mysql_query("SELECT * FROM `msg_kont` WHERE `usr1`='".$ref['id']."' and `usr2`='0'"));
if($rows211==0)
{
mysql_query("INSERT INTO `msg_kont` SET
`id`='',
`usr1`='".$ref['id']."',
`usr2`='0',
`read`='1',
`time`='".time()."'
");
}else
{
$rows21=mysql_fetch_array(mysql_query("SELECT * FROM `msg_kont`
WHERE `usr2`='0' and `usr1`='".$ref['id']."'"));
mysql_query("UPDATE `msg_kont` SET `read`='1', `time`='".time()."' WHERE `usr2`='0' and `usr1`='".$ref['id']."'");
}
$rows21=mysql_fetch_array(mysql_query("SELECT * FROM `msg_kont`
WHERE `usr2`='0' and `usr1`='".$ref['id']."'"));
$text='<font color=#cccccc>Ваш реферал '.$udata['usr'].' прокачался до 45 уровня. За это вы получаете <img src=img/main/p13.png>15.</font>
';
mysql_query("INSERT INTO `msg_dialog` SET
`id`='',
`dialog`='".$rows21['id']."',
`vhod`='1',
`time`='".time()."',
`text`='".$text."',
`usr`='".$ref['id']."'
");
}
if($kl==50)
{
$ref_m=$ref['jem']+30;
mysql_query("UPDATE `users` SET `jem`='".$ref_m."' WHERE `id`='".$ref['id']."'");
$rows211=mysql_num_rows(mysql_query("SELECT * FROM `msg_kont` WHERE `usr1`='".$ref['id']."' and `usr2`='0'"));
if($rows211==0)
{
mysql_query("INSERT INTO `msg_kont` SET
`id`='',
`usr1`='".$ref['id']."',
`usr2`='0',
`read`='1',
`time`='".time()."'
");
}else
{
$rows21=mysql_fetch_array(mysql_query("SELECT * FROM `msg_kont`
WHERE `usr2`='0' and `usr1`='".$ref['id']."'"));
mysql_query("UPDATE `msg_kont` SET `read`='1', `time`='".time()."' WHERE `usr2`='0' and `usr1`='".$ref['id']."'");
}
$rows21=mysql_fetch_array(mysql_query("SELECT * FROM `msg_kont`
WHERE `usr2`='0' and `usr1`='".$ref['id']."'"));
$text='<font color=#cccccc>Ваш реферал '.$udata['usr'].' прокачался до 50 уровня. За это вы получаете <img src=img/main/p13.png>30.</font>
';
mysql_query("INSERT INTO `msg_dialog` SET
`id`='',
`dialog`='".$rows21['id']."',
`vhod`='1',
`time`='".time()."',
`text`='".$text."',
`usr`='".$ref['id']."'
");
}
}
mysql_query("UPDATE `arena_usr` SET `hp`='".$udata['hp']."', `arm`='".$udata['arm']."', `sila`='".$udata['sila']."' WHERE `id`='".$bt['id']."'");
mysql_query("INSERT INTO `log_arena` SET
`id`='',
`usr`='".$udata['id']."',
`text`='Ваш уровень повысился до ".$lvl."!'
");
header('location: ?');exit;
}}
$bts=mysql_fetch_array(mysql_query("SELECT * FROM `arena_usr` WHERE `id`='".$bt['enemy']."'"));
if($bts['tip']!='pit')
{
$us=mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id`='".$bts['usr']."'"));
}
else
{
$us=mysql_fetch_array(mysql_query("SELECT * FROM `pit` WHERE `id`='".$bts['pit']."'"));
$us['usr']=$us['name'];
}
if($bt['enemy']==0 or $bts['status']!=0)
{
$en=mysql_num_rows(mysql_query("SELECT * FROM `arena_usr` WHERE `kom`!='".$bt['kom']."' and `status`='0' and `arr`='".$bt['arr']."'"));
if($en!=0 and $bt['enemy']==0)
{
$ens=mysql_fetch_array(mysql_query("SELECT * FROM `arena_usr` WHERE `kom`!='".$bt['kom']."' and `status`='0' and `arr`='".$bt['arr']."'"));
mysql_query("UPDATE `arena_usr` SET `enemy`='".$ens['id']."' WHERE `usr`='".$udata['id']."'");
header('location: ?');exit;
}
}
include('b_arena2.php');
if(isset($_GET['leav']))
{
if($bt['status']==1 or $bt['status']==2 or $bt['status']==3)
{
mysql_query("DELETE FROM `arena_usr` WHERE `usr`='".$udata['id']."'");
mysql_query("UPDATE `mag` SET
`time`='0' WHERE `usr`='".$udata['id']."'");
mysql_query("DELETE FROM `log_arena` WHERE `usr`='".$udata['id']."'");
mysql_query("DELETE FROM `bot` WHERE `usr`='".$udata['id']."'");
header('location: arena.php');
}
else
{
header('location: ?');
}
}
if(isset($_GET['elic']))
{
if($bt['status']==2 or $bt['status']==1)
{
header('location: ?');exit;
}
$elic=mysql_query("SELECT * FROM `elic` WHERE `id`='".$_GET['ef']."' and `usr`='".$udata['id']."' and `status`='on'");
$cd=mysql_num_rows($elic);
if($cd==0)
{
header('location: ?');
}
else
{
$el=mysql_fetch_array($elic);
if($el['tip']=='hp')
{
if($el['time']>time())
{
header('location: ?');exit;
}
else
{
if($bt['hp']==$udata['hp'] or $bt['hp']==0)
{
header('location: ?');
}
$hp=$bt['hp']+$el['ef'];
if($hp>$udata['hp'])
{
$hp=$udata['hp'];
}
mysql_query("UPDATE `arena_usr` SET `hp`='".$hp."' WHERE `id`='".$bt['id']."'");
}
}
$elk=$el['kol']-1;
if($elk==0)
{
mysql_query("DELETE FROM `elic` WHERE `id`='".$el['id']."'");
}
else
{
$ds=date('d');
if($ds==8)
{
$el['rest']=round($el['rest']-$el['rest']/100*10);
}
$time=time()+$el['rest'];
mysql_query("UPDATE `elic` SET `kol`='".$elk."', `time`='".$time."' WHERE `id`='".$el['id']."'");
}
if($el['ef']!=20000)
{
mysql_query("INSERT INTO `log_arena` SET
`id`='',
`usr`='".$udata['id']."',
`text`='<img src=img/main/p21.png> <font color=#009900>Ты испил зелья и исцелился +".$el['ef']." <img src=img/main/p6.png></font>'
");
}
else
{
mysql_query("INSERT INTO `log_arena` SET
`id`='',
`usr`='".$udata['id']."',
`text`='<img src=img/main/p21.png> <font color=#009900>Ты испил зелья и ваше здоровье востановилось <img src=img/main/p6.png></font>'
");
}
$ds=$udata['dost3a']+1;
mysql_query("UPDATE `users` SET `dost3a`='".$ds."' WHERE `id`='".$udata['id']."'");
}
header('location: ?');
}
if(isset($_GET['rand']))
{
if($bt['status']==2 or $bt['status']==1)
{
header('location: ?');exit;
}
$num=mysql_num_rows(mysql_query("SELECT * FROM `arena_usr` WHERE `kom`!='".$bt['kom']."' and `arr`='".$bt['arr']."' and `status`='0'"));
if($num>0)
{
if($num==1)
{
$ra=1;
$ene=mysql_fetch_array(mysql_query("SELECT * FROM `arena_usr` WHERE `kom`!='".$bt['kom']."' and `arr`='".$bt['arr']."' and `status`='0'"));
}
else
{
$ra=rand(1,$num);
$ene=mysql_fetch_array(mysql_query("SELECT * FROM `arena_usr` WHERE `kom`!='".$bt['kom']."' and `arr`='".$bt['arr']."' and `status`='0' ORDER BY `id` LIMIT ".$ra.",1"));
}
mysql_query("UPDATE `arena_usr` SET `enemy`='".$ene['id']."' WHERE `id`='".$bt['id']."'");
header('location: ?kick');exit;
}
}
include($path.'files/head.php');
echo '
<div class="v2 brs bls v8 bts bbs p v12"><font color=#00ccff>
<img src=img/main/p6.png>'.$bt['hp'].' | '.$hpw.'
<font color=#ff0000>'.$bt['att'].'</font> | <font color=#ff0000>'.$bt['att2'].'</font>
| '.$bts['hp'].' <img src=img/main/p6.png>'.$us['usr'].'';
$q = mysql_query("SELECT COUNT(*) FROM `msg_kont` WHERE `usr1` = '".$udata['id']."' AND `read` = '1';");
$new_mail = mysql_result($q, 0);
if($new_mail > 0)
{
echo"
<a href="mail.php"><img src=img/main/e1.png></a>";
}
if($udata['clan']!=0)
{
$fridaa=mysql_query("SELECT * FROM `sectors` WHERE `clan`='".$udata['clan']."' and `att_clan`!='0'");
$fra=mysql_num_rows($fridaa);
if($fra!=0)
{
echo'<a href=clan.php?gi=ter><img src=img/main/st.png></a>';
}
}
echo'<br>
Состояние:
</font>
</div>';
$giza=mysql_fetch_array(mysql_query("SELECT * FROM `clan` WHERE `id`='".$udata['clan']."'"));
if($giza['gorn_time']>time() and $udata['gorn']==1)
{
echo '<div class="v6 rr rt rl p">'.$giza['gorn'].'<br>
<img src=img/main/e55.png><a href=clan.php?gorn_def>Закрыть</a>
</div>';
}
echo '<div class="v3 bts brs bls b p v12">Битва</div><div class="v2 bts brs bls bbs p t2">';
if($bt['status']==0)
{
if($bts['tip']!='pit')
{
if($us['ava']==0)
{
echo'<img src=img/pers/'.$us['klass'].''.$us['pol'].'.png><br>
';
}
else
{
echo'<img src=img/pers/ava/'.$us['ava'].'.png><br>';
}
}
else
{
$us['usr']=$us['name'];
echo '<img src=img/pit/'.$us['tip'].'/'.$us['img'].'.jpg width=90px><br>';
}
echo'<a href=?kick><div class="v2s p"><img src=img/main/b17.png> <font color=#ffff00>бить '.$us['usr'].'</font> <font color=#ffffff>['.$bts['hp'].']</font></div></a>
';
$tn=time();
$mobs=mysql_query("SELECT * FROM `mag` WHERE `usr`='".$udata['id']."' and `status`='on' ORDER BY `id`");
$rows=mysql_num_rows($mobs);
if($rows==0)
{
}
else
{
while($mag=mysql_fetch_array($mobs))
{
if($mag['mag']==1)
{
$name='заклинание удара';
}
if($mag['mag']==2)
{
$name='заклинание случайности';
}
if($mag['mag']==3)
{
$name='заклинание усиления';
}
if($mag['mag']==4)
{
$name='заклинание пробивания';
}
if($mag['mag']==5)
{
$name='заклинание стана';
}
if($mag['mag']==6)
{
$name='заклинание обороны';
}
if($mag['mag']==7)
{
$name='заклинание молний';
}
if($mag['mag']==8)
{
$name='заклинание исцеления';
}
if($mag['mag']==9)
{
$name='заклинание вампира';
}
if($mag['mag']==10)
{
$name='заклинание возврата';
}
if($mag['mag']==11)
{
$name='заклинание ослабления';
}
if($mag['mag']==12)
{
$name='заклинание барьера';
}
if($mag['mag']==13)
{
$name='заклинание сингулярности';
}
if($mag['mag']==14)
{
$name='заклинание хаоса';
}
if($mag['time']<=$tn)
{
echo '<a href=?mag&nin='.$mag['mag'].'>
<div class="v2s p"><img src=img/main/b10.png> <font color=#ffff00>'.$name.'</font></div></a>';
}
else
{
$mag['time']=$mag['time']-time();
$mag['time']=$mag['time']." с.";
echo '<a href=?mag&nin='.$mag['mag'].'>
<div class="v2s p"><img src=img/main/b10.png> <font color=#555500>'.$name.'</font><font color=#ffffff> ['.$mag['time'].']</font></div></a>';
}
}
}
echo '<a href=?rand><div class="v2s p"><img src=img/main/b8.png> <font color=#ffff00>бить любого</font></div></a>';
$eq=mysql_query("SELECT * FROM `elic` WHERE `usr`='".$udata['id']."' and `tip`='hp' and `status`='on'");
$rowse=mysql_num_rows($eq);
if($rowse==0)
{
}
else
{
while($el=mysql_fetch_array($eq))
{
if($el['time']<=$tn)
{
echo '<img src=img/elic/'.$el['tip'].''.$el['ef'].'.png> <a href=?elic&ef='.$el['id'].'>пить</a> ';
}
else
{
$el['time']=$el['time']-time();
if($el['time']<60){
$el['time']=$el['time']." с.</font>";
}
echo '<img src=img/elic/'.$el['tip'].''.$el['ef'].'.png> '.$el['time'].' ';
}
}
}
echo '<br><br><a href=?leav><img src=img/main/p21.png> Покинуть бой</a>';
echo '</div>';
echo '<div class="v3 bts brs bls b p v12">Твой противник:</div>';
echo '<div class="v2 bts brs bls bbs p t2"><font color=#cccccc>';
$aq=mysql_query("SELECT * FROM `arena_usr` WHERE `arr`='".$bt['arr']."' and `kom`!='".$bt['kom']."'");
while($arrs=mysql_fetch_array($aq))
{
if($arrs['tip']!='pit')
{
$usrz=mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id`='".$arrs['usr']."'"));
$usrz['usr']='<img src=img/main/c'.$usrz['klass'].'.png> <img src=img/main/r'.$usrz['rasa'].'.png>'.$usrz['usr'];
}
else
{
$usrz=mysql_fetch_array(mysql_query("SELECT * FROM `pit` WHERE `id`='".$arrs['pit']."'"));
$usrz['usr']=$usrz['name'];
}
echo $usrz['usr'].' <img src=img/main/p10.png>'.$usrz['lvl'].' [<img src=img/main/p6.png>'.$arrs['hp'].'], ';
}
echo '</div>';
}
elseif($bt['status']==1)
{
mysql_query("DELETE FROM `bot` WHERE `usr`='".$udata['id']."'");
echo '<div align=center><img src=img/inter/win.jpg></div>
<img src=img/main/b18.png> Вы победили! Бой завершен!<br>
<a href=?leav><img src=img/main/p21.png> Покинуть бой</a>
</div>
';
if($udata['lvl']>$udata['rang'])
{
$vips=mysql_query("SELECT * FROM `vip` WHERE `usr`='".$udata['id']."'");
$nvip=mysql_num_rows($vips);
if($nvip!=0)
{
$q=20;
}
else
{
$q=10;
}
$r=$udata['exp_rang']+$q;
}
else
{
$r=$udata['exp_rang']+0;
}
mysql_query("UPDATE `users` SET `exp_rang`='".$r."' WHERE `id`='".$udata['id']."'");
mysql_query("UPDATE `arena_usr` SET `status`='3' WHERE `id`='".$bt['id']."'");
}
elseif($bt['status']==2)
{
mysql_query("DELETE FROM `bot` WHERE `usr`='".$udata['id']."'");
echo '<div align=center><img src=img/inter/lose.jpg></div>
<img src=img/main/b18.png> Вы проиграли! Бой завершен!<br>
<a href=?leav><img src=img/main/p21.png> Покинуть бой</a>
</div>
';
}
elseif($bt['status']==3)
{
mysql_query("DELETE FROM `bot` WHERE `usr`='".$udata['id']."'");
echo '<div align=center><img src=img/inter/win.jpg></div>
<img src=img/main/b18.png> Вы победили! Бой завершен!<br>
<a href=?leav><img src=img/main/p21.png> Покинуть бой</a>
</div>
';
}
$mobs=mysql_query("SELECT * FROM `log_arena` WHERE `usr`='".$udata['id']."' ORDER BY `id` DESC LIMIT 10");
$rows=mysql_num_rows($mobs);
if($rows==0)
{
}
else
{
echo '<div class="v3 bts brs bls b p v12">Лог боя:</div><div class="v2 bts brs bls bbs p t2">';
while($log=mysql_fetch_array($mobs))
{
echo $log['text'].'<br>';
}
}
}
echo '</div>';
include('files/dwn.php');
?>