Файл: terr_2.php
Строк: 227
<?
define('PROTECTOR', 1);
include('files/db.php');
include($path.'files/auth.php');
if ($user_id==0){
header('location: index.php');exit;
}
$textl='Территории';
include($path.'files/core.php');
$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;
}
$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($mobs);
if($rows7!=0)
{
header('location: terr_b.php');exit;
}
if($udata['lvl']<20 or $udata['clan']==0)
{
header('location: game.php');exit;
}
$arr_usr=mysql_num_rows(mysql_query("SELECT * FROM `terr_usr` WHERE `usr`='".$udata['id']."'"));
if($arr_usr!=0)
{
header('location: terr_b.php');exit;
}
if(isset($_GET['att']))
{
$aaas=mysql_query("SELECT * FROM `sectors` WHERE `att_clan`='".$udata['clan']."'");
$atr=mysql_num_rows($aaas);
if($atr!=0)
{
mysql_query("INSERT INTO `user_log` SET
`usr`='".$udata['id']."',
`text`='Ваша гильдия уже напала на другой сектор!'
");
header('location: ?');exit;
}
$gi=mysql_fetch_array(mysql_query("SELECT * FROM `clan` WHERE `id`='".$udata['clan']."'"));
$as=mysql_query("SELECT * FROM `sectors` WHERE `clan`='".$gi['id']."'");
$se=mysql_num_rows($as);
$nabl=mysql_fetch_array(mysql_query("SELECT * FROM `clan_bild` WHERE `clan`='".$gi['id']."' and `name`='Наблюдательный пункт'"));
$ns=$nabl['lvl']+2;
if($se<$ns)
{
$frid=mysql_query("SELECT * FROM `sectors` WHERE `id`='".$_GET['id']."'");
$fr=mysql_fetch_array($frid);
if(time()-1800>$fr['blok'])
{
if($fr['att_clan']==0)
{
if($fr['clan']==0)
{
$t=time();
$bl=time()+1800;
mysql_query("UPDATE `sectors` SET `clan`='".$gi['id']."', `control`='".$t."', `blok`='".$bl."' WHERE `id`='".$fr['id']."'");
$reit=$gi['exp']+100;
mysql_query("UPDATE `clan` SET `exp`='".$reit."' WHERE `id`='".$gi['id']."'");
}
else
{
$t=time()+600;
mysql_query("UPDATE `sectors` SET `att_clan`='".$gi['id']."', `att_time`='".$t."' WHERE `id`='".$fr['id']."'");
$ds=date('d');
if($ds==27)
{
$udata['sila']=round($udata['sila']-$udata['sila']/100*5);
}
mysql_query("INSERT INTO `terr_usr` SET
`id`='',
`usr`='".$udata['id']."',
`tip`='usr',
`arr`='".$fr['id']."',
`hp`='".$udata['hp']."',
`arm`='".$udata['arm']."',
`kom`='".$gi['id']."',
`sila`='".$udata['sila']."',
`lider`='1'
");
$tr=mysql_query("SELECT * FROM `pit` WHERE `usr`='".$udata['id']."' and `status`='1'");
$num=mysql_num_rows($tr);
if($num!=0)
{
$t=mysql_fetch_array($tr);
mysql_query("INSERT INTO `terr_usr` SET
`id`='',
`usr`='".$udata['id']."',
`tip`='pit',
`arr`='".$fr['id']."',
`pit`='".$t['id']."',
`hp`='".$t['hp']."',
`arm`='".$t['arm']."',
`sila`='".$t['sila']."',
`kom`='".$gi['id']."'
");
}
$b3=mysql_num_rows(mysql_query("SELECT * FROM `clan_bild` WHERE `clan`='".$gi['id']."' and `name`='Шпиль'"));
if($b3!=0)
{
$bl3=mysql_fetch_array(mysql_query("SELECT * FROM `clan_bild` WHERE `clan`='".$gi['id']."' and `name`='Шпиль'"));
mysql_query("INSERT INTO `terr_usr` SET
`id`='',
`usr`='0',
`tip`='shpil',
`arr`='".$fr['id']."',
`hp`='".$bl3['hp']."',
`kom`='".$gi['id']."',
`sila`='".$bl3['sila']."',
`ataka`='".$bl3['time']."'
");
}
$b4=mysql_num_rows(mysql_query("SELECT * FROM `clan_bild` WHERE `clan`='".$gi['id']."' and `name`='Сотрясатель'"));
if($b4!=0)
{
$bl4=mysql_fetch_array(mysql_query("SELECT * FROM `clan_bild` WHERE `clan`='".$gi['id']."' and `name`='Сотрясатель'"));
mysql_query("INSERT INTO `terr_usr` SET
`id`='',
`usr`='0',
`tip`='sotr',
`arr`='".$fr['id']."',
`hp`='".$bl4['hp']."',
`kom`='".$gi['id']."',
`sila`='".$bl4['sila']."',
`ataka`='".$bl4['time']."'
");
}
$gis=mysql_fetch_array(mysql_query("SELECT * FROM `clan` WHERE `id`='".$fr['clan']."'"));
$b31=mysql_num_rows(mysql_query("SELECT * FROM `clan_bild` WHERE `clan`='".$gis['id']."' and `name`='Шпиль'"));
if($b31!=0)
{
$bl31=mysql_fetch_array(mysql_query("SELECT * FROM `clan_bild` WHERE `clan`='".$gis['id']."' and `name`='Шпиль'"));
mysql_query("INSERT INTO `terr_usr` SET
`id`='',
`usr`='0',
`tip`='shpil',
`arr`='".$fr['id']."',
`hp`='".$bl31['hp']."',
`kom`='".$gis['id']."',
`sila`='".$bl31['sila']."',
`ataka`='".$bl31['time']."'
");
}
$b41=mysql_num_rows(mysql_query("SELECT * FROM `clan_bild` WHERE `clan`='".$gis['id']."' and `name`='Сотрясатель'"));
if($b41!=0)
{
$bl41=mysql_fetch_array(mysql_query("SELECT * FROM `clan_bild` WHERE `clan`='".$gis['id']."' and `name`='Сотрясатель'"));
mysql_query("INSERT INTO `terr_usr` SET
`id`='',
`usr`='0',
`tip`='sotr',
`arr`='".$fr['id']."',
`hp`='".$bl41['hp']."',
`kom`='".$gis['id']."',
`sila`='".$bl41['sila']."',
`ataka`='".$bl41['time']."'
");
}
$b51=mysql_num_rows(mysql_query("SELECT * FROM `clan_bild` WHERE `clan`='".$gis['id']."' and `name`='Барьер'"));
if($b51!=0)
{
$bl5=mysql_fetch_array(mysql_query("SELECT * FROM `clan_bild` WHERE `clan`='".$gis['id']."' and `name`='Барьер'"));
$ds=date('d');
if($ds==13)
{
$b15['hp']=round($b15['hp']+$b15['hp']/100*10);
}
mysql_query("INSERT INTO `terr_usr` SET
`id`='',
`usr`='0',
`tip`='bar',
`arr`='".$fr['id']."',
`hp`='".$bl5['hp']."',
`kom`='".$gis['id']."'
");
}
}
}
}}
header('location: terr_b.php');exit;
}
if(isset($_GET['vst_att']))
{
$gi=mysql_fetch_array(mysql_query("SELECT * FROM `clan` WHERE `id`='".$udata['clan']."'"));
$frid=mysql_query("SELECT * FROM `sectors` WHERE `id`='".$_GET['id']."'");
$fr=mysql_fetch_array($frid);
if($fr['att_clan']==$udata['clan'] and $fr['clan']!=$udata['clan'])
{
$ds=date('d');
if($ds==27)
{
$udata['sila']=round($udata['sila']-$udata['sila']/100*5);
}
mysql_query("INSERT INTO `terr_usr` SET
`id`='',
`usr`='".$udata['id']."',
`tip`='usr',
`arr`='".$fr['id']."',
`hp`='".$udata['hp']."',
`arm`='".$udata['arm']."',
`kom`='".$gi['id']."',
`sila`='".$udata['sila']."',
`lider`='0'
");
$tr=mysql_query("SELECT * FROM `pit` WHERE `usr`='".$udata['id']."' and `status`='1'");
$num=mysql_num_rows($tr);
if($num!=0)
{
$t=mysql_fetch_array($tr);
mysql_query("INSERT INTO `terr_usr` SET
`id`='',
`usr`='".$udata['id']."',
`tip`='pit',
`arr`='".$fr['id']."',
`pit`='".$t['id']."',
`hp`='".$t['hp']."',
`arm`='".$t['arm']."',
`sila`='".$t['sila']."',
`kom`='".$gi['id']."'
");
}
}
header('location: terr_b.php');exit;
}
if(isset($_GET['vst_def']))
{
$gi=mysql_fetch_array(mysql_query("SELECT * FROM `clan` WHERE `id`='".$udata['clan']."'"));
$frid=mysql_query("SELECT * FROM `sectors` WHERE `id`='".$_GET['id']."'");
$fr=mysql_fetch_array($frid);
if($fr['att_clan']!=$udata['clan'] and $fr['clan']==$udata['clan'])
{
$ds=date('d');
if($ds==27)
{
$udata['sila']=round($udata['sila']-$udata['sila']/100*5);
}
mysql_query("INSERT INTO `terr_usr` SET
`id`='',
`usr`='".$udata['id']."',
`tip`='usr',
`arr`='".$fr['id']."',
`hp`='".$udata['hp']."',
`arm`='".$udata['arm']."',
`kom`='".$gi['id']."',
`sila`='".$udata['sila']."',
`lider`='0'
");
$tr=mysql_query("SELECT * FROM `pit` WHERE `usr`='".$udata['id']."' and `status`='1'");
$num=mysql_num_rows($tr);
if($num!=0)
{
$t=mysql_fetch_array($tr);
mysql_query("INSERT INTO `terr_usr` SET
`id`='',
`usr`='".$udata['id']."',
`tip`='pit',
`arr`='".$fr['id']."',
`pit`='".$t['id']."',
`hp`='".$t['hp']."',
`arm`='".$t['arm']."',
`sila`='".$t['sila']."',
`kom`='".$gi['id']."'
");
}
}
header('location: terr_b.php');exit;
}
include($path.'files/head.php');
include($path.'files/zag.php');
echo '<div class="v3 bts brs bls b p v12">Навигация</div><div class="v4 bts brs bls bbs p">
<img src=img/main/i26.png class="menu"> <a href=game.php>главная</a> / <a href=?>территории</a>
</div>';
echo '<div class="v8"><div class="v3 bts brs bls b p v12">Территории</div><div class="v2 bts brs bls bbs p t1">';
echo '<div align=center><img src=img/inter/16.jpg></div>
<div class="v4 p"><font color=#ff9900>----</font></div>';
switch($_GET['ter'])
{
default:
echo '<b><font color=#ff9900>Навигация</font></b><br>';
$frid=mysql_query("SELECT * FROM `sectors` ORDER BY `id`");
while($fr=mysql_fetch_array($frid))
{
echo '<img src=img/main/e55.png> <a href=?ter=info&id='.$fr['id'].'>'.$fr['name'].'</a><br>';
}
break;
case 'info':
$frid=mysql_query("SELECT * FROM `sectors` WHERE `id`='".$_GET['id']."'");
$fr=mysql_fetch_array($frid);
echo '<img src=img/main/e55.png> <b><font color=#ff9900>'.$fr['name'].'</font></b><br>';
echo '<img src=img/main/p21.png> <font color=#bbbbbb>Контролируют:</font> ';
if($fr['clan']==0)
{
echo 'сектор свободен<br>';
}
else
{
$gi=mysql_fetch_array(mysql_query("SELECT * FROM `clan` WHERE `id`='".$fr['clan']."'"));
echo '<img src=img/main/el'.$gi['element'].'.png>
<img src=img/main/r'.$gi['rasa'].'.png> '.$gi['name'].'<br>';
echo '<img src=img/main/p21.png> <font color=#bbbbbb>Время контроля:</font> <font color=#1faee9>';
$fr['control']=time()-$fr['control'];
if($fr['control']<60){
echo $fr['control']." с.</font>";
}elseif($fr['control']>60 and $fr['control']<3600){
$fr['control']=round($fr['control']/60);
echo $fr['control']." м.</font>";
}else{
$fr['control']=round($fr['control']/3600);
echo $fr['control']." ч.</font>";
}
echo '<br>';
}
echo '<img src=img/main/p21.png> <font color=#bbbbbb>Особенность:</font> <font color=#00ff00>'.$fr['opis'].'</font><br>';
echo '<img src=img/main/p21.png> <font color=#bbbbbb>Статус сектора:</font> ';
if($fr['att_clan']==0)
{
echo 'заявок на нападение нет<br>';
if($udata['clan']!=$fr['clan'])
{
if(time()-1800>$fr['blok'])
{
echo '<img src=img/main/b8.png> <a href=?att&id='.$fr['id'].'>захватить сектор</a>';
}
}
}
else
{
if($fr['att_time']<time())
{
echo '<font color=#ff0000>В бою</font>';
}
else
{
$gis=mysql_fetch_array(mysql_query("SELECT * FROM `clan` WHERE `id`='".$fr['att_clan']."'"));
echo '<font color=#ff0000>атакован гильдией </font><img src=img/main/el'.$gis['element'].'.png>
<img src=img/main/r'.$gis['rasa'].'.png> '.$gis['name'].'<br>';
if($gis['id']==$udata['clan'])
{
echo '<img src=img/main/b8.png> <a href=?vst_att&id='.$fr['id'].'>встать на захват</a>';
}
elseif($fr['clan']==$udata['clan'])
{
echo '<img src=img/main/b8.png> <a href=?vst_def&id='.$fr['id'].'>встать на защиту</a>';
}
}
}
echo '</div></div>';
echo '<div class="v8"><div class="v3 bts brs bls b p v12">История сектора</div><div class="v2 bts brs bls bbs p t1">';
$fridz=mysql_query("SELECT * FROM `sectors_log` WHERE `sector`='".$fr['id']."' ORDER BY `id` DESC LIMIT 5");
while($frz=mysql_fetch_array($fridz))
{
echo $frz['text'].'<br>';
}
break;
}
echo '</div></div>';
include('files/down.php');
?>