Файл: b_terr.php
Строк: 292
<?
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;
}
$mobs1=mysql_query("SELECT * FROM `arena_usr` WHERE `usr`='".$udata['id']."'");
$rows1=mysql_num_rows($mobs1);
if($rows1!=0)
{
header('location: arena.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;
}
$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;
}
$bat=mysql_query("SELECT * FROM `terr_usr` WHERE `usr`='".$udata['id']."'");
$num=mysql_num_rows($bat);
if($num==0)
{
header('location: game.php');exit;
}
else
{
$bt=mysql_fetch_array($bat);
$t=time();
$bata=mysql_query("SELECT * FROM `sectors` WHERE `id`='".$bt['arr']."' and `att_time`<='".$t."'");
$numa=mysql_num_rows($bata);
if($numa==0)
{
header('location: terr_b.php');exit;
}
$gi=mysql_fetch_array(mysql_query("SELECT * FROM `clan` WHERE `id`='".$udata['clan']."'"));
$gus=mysql_fetch_array(mysql_query("SELECT * FROM `clan_users` WHERE `usr`='".$udata['id']."'"));
$as=mysql_query("SELECT * FROM `sectors` WHERE `id`='".$bt['arr']."'");
$se=mysql_fetch_array($as);
if($gi['id']==$se['clan'])
{
$gis=mysql_fetch_array(mysql_query("SELECT * FROM `clan` WHERE `id`='".$se['att_clan']."'"));
}
else
{
$gis=mysql_fetch_array(mysql_query("SELECT * FROM `clan` WHERE `id`='".$se['clan']."'"));
}
$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']."'");
mysql_query("UPDATE `terr_usr` SET `hp`='".$udata['hp']."', `arm`='".$udata['arm']."', `sila`='".$udata['sila']."' WHERE `id`='".$bt['id']."'");
mysql_query("INSERT INTO `log_ter` SET
`id`='',
`usr`='".$udata['id']."',
`text`='Ваш уровень повысился до ".$lvl."!'
");
header('location: ?');exit;
}}
$btsn=mysql_num_rows(mysql_query("SELECT * FROM `terr_usr` WHERE `id`='".$bt['enemy']."' and `arr`='".$bt['arr']."' and `kom`!='".$bt['kom']."'"));
$bts=mysql_fetch_array(mysql_query("SELECT * FROM `terr_usr` WHERE `id`='".$bt['enemy']."' and `arr`='".$bt['arr']."' and `kom`!='".$bt['kom']."'"));
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['status']==0)
{
$en1=mysql_num_rows(mysql_query("SELECT * FROM `terr_usr` WHERE `kom`!='".$bt['kom']."' and `status`='0' and `arr`='".$bt['arr']."'"));
if($en1==0)
{
mysql_query("UPDATE `terr_usr` SET `status`='1' WHERE `usr`='".$udata['id']."'");
header('location: ?');exit;
}
if($bt['enemy']!=0)
{
if($btsn==0 or $bts['status']==2)
{
mysql_query("UPDATE `terr_usr` SET `enemy`='0' WHERE `usr`='".$udata['id']."'");
header('location: ?');exit;
}
}
}
if($bts['tip']!='pit')
{
if($us['ava']==0)
{
$img='<img src=img/pers/'.$us['klass'].''.$us['pol'].'.png>';
}
else
{
$img='<img src=img/pers/ava/'.$us['ava'].'.png>';
}
$en_name=' <img src=img/main/c'.$us['klass'].'.png> <img src=img/main/r'.$us['rasa'].'.png><font color=#ff9900>'.$us['usr'].'</font>';
}
else
{
$us['usr']=$us['name'];
$en_name=' <font color=#ff9900>'.$us['usr'].'</font>';
$img= '<img src=img/pit/'.$us['tip'].'/'.$us['img'].'.jpg width=90px><br>';
}
include('b_terr2.php');
if(isset($_GET['leav']))
{
if($bt['status']>0)
{
if($bt['status']==2)
{
$err=time()+1800;
mysql_query("UPDATE `users` SET `err`='".$err."' WHERE `id`='".$udata['id']."'");
}
mysql_query("DELETE FROM `terr_usr` WHERE `usr`='".$udata['id']."'");
mysql_query("UPDATE `mag` SET
`time`='0' WHERE `usr`='".$udata['id']."'");
mysql_query("DELETE FROM `log_terr` WHERE `usr`='".$udata['id']."'");
header('location: game.php');
}
else
{
header('location: ?');exit;
}
}
if(isset($_GET['enemy']))
{
$id=mysql_real_escape_string($_GET['enemy']);
$enemy=mysql_num_rows(mysql_query("SELECT * FROM `terr_usr` WHERE `status`='0' and `arr`='".$bt['arr']."' and `kom`!='".$bt['kom']."' and `id`='".$id."'"));
if($enemy!=0)
{
mysql_query("UPDATE `terr_usr` SET `enemy`='".$id."' WHERE `id`='".$bt['id']."'");
}
header('location: ?');exit;
}
include($path.'files/head.php');
echo '
<div class="head 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'].'</font></div>';
echo '<div class="line bbs m bts brs bls b p v12">Битва</div><div class="box bts brs bls bbs p t2">';
if($bt['status']==0)
{
if($bt['enemy']==0)
{
echo '<table>
<tr>
<td><img src=img/mob/0.jpg></td>
<td> -<i>Нет противника.</i></td>
</tr>
</table>';
}
else
{
$us=mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id`='".$bts['usr']."'"));
$hpp=$us['hp']/100;
$hpp=$bts['hp']/$hpp;
echo '
<table width=100%>
<tr>
<td width=93px>';
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>';
}
echo'</td>
<td width=80%>
-<i>'.$us['usr'].'</i><br>
<div class="bts bbs brs bls">
<div style="background: #990000; height: 20px; width:'.$hpp.'%">
</div></td>
<td width=20% align=right>'.round($hpp).'%</td>
</tr>
</table>';
}
echo '</div><div class="bat p bts bbs brs bls">';
if($bt['time_us']<time())
{
echo'<a href=b_terr_kick.php><div style="position: relative;
font-weight: bold;
margin-top: 2px;
margin-bottom: 4px;
color: #ffff00;
text-decoration: none;
text-shadow: 0 -1px 1px #cc5500;
user-select: none;
padding: 5px;
outline: none;
border-radius: 1px;
background: rgb(128,60,60);
background-size: 100% 100%, auto;
background-position: 50% 50%;
box-shadow: inset rgb(188,60,60) 0 -1px 1px, inset 0 1px 1px rgb(188,60,60), rgb(188,60,60) 0 0 0 1px, #000 0 10px 15px -10px; text-align: center">Атака</div></a>';
}
else
{
$time=$bt['time_us']-time();
$h=floor($time/3600);
$m=floor(($time-($h*3600))/60);
$s=$time-($h*3600)-($m*60);
$tim_boss=$h.':'.$m.':'.$s;
echo'<a href=b_terr_kick.php><div style="position: relative;
font-weight: bold;
color: #ffff00;
margin-top: 2px;
margin-bottom: 4px;
text-decoration: none;
text-shadow: 0 -1px 1px #cc5500;
user-select: none;
padding: 5px;
outline: none;
border-radius: 1px;
background: rgb(128,60,60);
background-size: 100% 100%, auto;
background-position: 50% 50%;
box-shadow: inset rgb(188,60,60) 0 -1px 1px, inset 0 1px 1px rgb(188,60,60), rgb(188,60,60) 0 0 0 1px, #000 0 10px 15px -10px; text-align: center; opacity: 0.7">До полного удара: '.$tim_boss.'</div></a>';
}
echo '<table width=100%>';
echo '<tr>';
$tn=time();
$mobs=mysql_query("SELECT * FROM `mag` WHERE `usr`='".$udata['id']."' and `status`='on' ORDER BY `id`");
while($mag=mysql_fetch_array($mobs))
{
echo '<td align=center>';
if($mag['mag']==1)
{
$sn=1;
$name='заклинание удара';
}
if($mag['mag']==2)
{
$sn=14;
$name='заклинание случайности';
}
if($mag['mag']==3)
{
$sn=3;
$name='заклинание усиления';
}
if($mag['mag']==4)
{
$sn=9;
$name='заклинание пробивания';
}
if($mag['mag']==5)
{
$sn=13;
$name='заклинание стана';
}
if($mag['mag']==6)
{
$sn=2;
$name='заклинание обороны';
}
if($mag['mag']==7)
{
$sn=5;
$name='заклинание молний';
}
if($mag['mag']==8)
{
$sn=4;
$name='заклинание исцеления';
}
if($mag['mag']==9)
{
$sn=11;
$name='заклинание вампира';
}
if($mag['mag']==10)
{
$sn=10;
$name='заклинание возврата';
}
if($mag['mag']==11)
{
$sn=12;
$name='заклинание ослабления';
}
if($mag['mag']==12)
{
$sn=7;
$name='заклинание барьера';
}
if($mag['mag']==13)
{
$sn=8;
$name='заклинание сингулярности';
}
if($mag['mag']==14)
{
$sn=6;
$name='заклинание хаоса';
}
if($mag['time']<=$tn)
{
echo '<a href=b_terr_mag.php?mag='.$mag['mag'].'>
<div class="mag p" style=" margin-top: 3px;
margin-bottom: 4px;"><img src=img/mag/sfera_'.$sn.'.jpg></div></a>';
}
else
{
$mag['time']=$mag['time']-time();
$mag['time']=$mag['time']." с.";
echo '<a href=b_terr_mag.php?mag='.$mag['mag'].'>
<div class="mag p m" style="opacity: 0.8; margin-top: 3px;
margin-bottom: 4px;"><img src=img/mag/sfera_'.$sn.'.jpg>'.$mag['time'].'</div></a>';
}
echo '</td>';
}
echo '</tr>';
echo '</table>';
echo '<table width=100%>';
echo '<tr>';
$eq=mysql_query("SELECT * FROM `elic` WHERE `usr`='".$udata['id']."' and `tip`='hp' and `status`='on'");
while($el=mysql_fetch_array($eq))
{
echo '<td align=center>';
if($el['time']<=$tn)
{
echo '<a href=b_terr_elic.php?elic='.$el['id'].'>
<div class="p elic" style=" margin-top: 3px;
margin-bottom: 4px;">
<img src=img/elic/'.htmlspecialchars($el['tip']).''.$el['ef'].'.png></div></a> ';
}
else
{
$el['time']=$el['time']-time();
if($el['time']<60){
$el['time']=$el['time']." с.</font>";
}
echo '<div style="opacity: 0.8; margin-top: 3px;
margin-bottom: 4px;" class="p elic"><img src=img/elic/'.htmlspecialchars($el['tip']).''.$el['ef'].'.png> '.$el['time'].'</div>';
}
echo '</td>';
}
echo '</tr>';
echo '</table>';
echo '</div>';
$enemy=mysql_num_rows(mysql_query("SELECT * FROM `terr_usr` WHERE `status`='0' and `arr`='".$bt['arr']."' and `kom`!='".$bt['kom']."'"));
if($enemy!=0)
{
echo '<div class=v8><div class="line bbs m bts brs bls b p v12">Противники</div><div class="bat bts brs bls bbs p t2">';
$eny=mysql_query("SELECT * FROM `terr_usr` WHERE `status`='0' and `arr`='".$bt['arr']."' and `kom`!='".$bt['kom']."'");
while($en=mysql_fetch_array($eny))
{
if($en['tip']=='usr')
{
$uss=mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id`='".$en['usr']."'"));
echo ' <img src=img/main/c'.$uss['klass'].'.png> <img src=img/main/r'.$uss['rasa'].'.png> <a href=?enemy='.$en['id'].'><font color=#ffff00>'.$uss['usr'].'</font></a> [<img src=img/main/p6.png><font color=#ff0000>'.$en['hp'].'</font>] <img src=img/main/p10.png>'.$uss['lvl'].', ';
}
elseif($en['tip']=='pit')
{
$uss=mysql_fetch_array(mysql_query("SELECT * FROM `pit` WHERE `id`='".$en['pit']."' and `usr`='".$en['usr']."'"));
echo ' <a href=?enemy='.$en['id'].'><font color=#ff9900>'.$uss['name'].'</font></a> [<img src=img/main/p6.png><font color=#ff0000>'.$en['hp'].'</font>] <img src=img/main/p10.png>'.$uss['lvl'].', ';
}
}
echo '</div></div>';
}
}
elseif($bt['status']==1)
{
if($gi['id']!=$se['clan'])
{
$timt=time();
if($gis['reit']==0){$gis['reit']=1;}
$c=floor($gis['reit']/100*10);
if($c<1){$c=1;}
elseif($c>1000){$c=1000;}
$reit=$gi['reit']+$c;
mysql_query("UPDATE `clan` SET `reit`='".$reit."' WHERE `id`='".$gi['id']."'");
$d=floor($gis['reit']/100*10);
if($d<1){$d=1;}
elseif($d>1000){$d=1000;}
$rei=$gis['reit']-$d;
if($rei<0)
{
$rei=0;
}
mysql_query("UPDATE `clan` SET `reit`='".$rei."' WHERE `id`='".$gis['id']."'");
$t1=''.$gi['name'].' <font color=#00cc00>+'.$c.'</font>';
$t2=''.$gis['name'].' <font color=#ff0000>-'.$d.'</font>';
mysql_query("INSERT INTO `sectors_log` SET
`id`='',
`sector`='".$se['id']."',
`text`='".$t1." <img src=img/main/b2.png> ".$t2."'
");
}
else
{
if($gis['reit']==0){$gis['reit']=1;}
$c=floor($gis['reit']/100*5);
if($c<1){$c=1;}
elseif($c>1000){$c=1000;}
$reit=$gi['reit']+$c;
mysql_query("UPDATE `clan` SET `reit`='".$reit."' WHERE `id`='".$gi['id']."'");
$d=floor($gis['reit']/100*5);
if($d<1){$d=1;}
elseif($d>1000){$d=1000;}
$rei=$gis['reit']-$d;
if($rei<0)
{
$rei=0;
}
mysql_query("UPDATE `clan` SET `reit`='".$rei."' WHERE `id`='".$gis['id']."'");
$t1=''.$gi['name'].' <font color=#00cc00>+'.$c.'</font>';
$t2=''.$gis['name'].' <font color=#ff0000>-'.$d.'</font>';
mysql_query("INSERT INTO `sectors_log` SET
`id`='',
`sector`='".$se['id']."',
`text`='".$t1." <img src=img/main/b2.png> ".$t2."'
");
$timt=$se['control'];
}
$bl=time()+1800;
mysql_query("UPDATE `sectors` SET `clan`='".$gi['id']."', `att_clan`='0', `control`='".$timt."', `blok`='".$bl."' WHERE `id`='".$se['id']."'");
mysql_query("DELETE FROM `terr_usr` WHERE `arr`='".$se['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>
';
}
elseif($bt['status']==2)
{
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>
';
}
$mobs=mysql_query("SELECT * FROM `log_terr` WHERE `usr`='".$udata['id']."' ORDER BY `id` DESC LIMIT 10");
$rows=mysql_num_rows($mobs);
if($rows==0)
{
}
else
{
echo '<div class="line bbs m bts brs bls b p v12">Лог боя:</div><div class="bat bts brs bls bbs p t2">';
while($log=mysql_fetch_array($mobs))
{
echo $log['text'].'<br>';
}
}
}
echo '</div>';
include('files/dwn.php');
?>