Файл: terr.php
Строк: 203
<?
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');
if($udata['err']>time())
{
mysql_query("INSERT INTO `user_log` SET
`usr`='".$udata['id']."',
`text`='Штраф смерти в территориях 30 минут. Приходите позже.'
");
header('location: game.php');exit;
}
$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;
}
if($udata['err']>time())
{
mysql_query("INSERT INTO `user_log` SET
`usr`='".$udata['id']."',
`text`='Штраф смерти в территориях 30 минут. Приходите позже.'
");
header('location: game.php');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;
$tyt=time()+7200;
mysql_query("UPDATE `sectors` SET `clan`='".$gi['id']."', `control`='".$t."', `blok`='".$bl."', `res`='".$tyt."' WHERE `id`='".$fr['id']."'");
$reit=$gi['reit']+10;
mysql_query("UPDATE `clan` SET `reit`='".$reit."' WHERE `id`='".$gi['id']."'");
}
else
{
$t=time()+600;
$tc=time()+4200;
$kod=rand(1000,9999999);
mysql_query("UPDATE `sectors` SET `att_clan`='".$gi['id']."', `att_time`='".$t."', `time_close`='".$tc."', `kod`='".$kod."' WHERE `id`='".$fr['id']."'");
mysql_query("DELETE FROM `log_terr` WHERE `terr`='".$fr['id']."'");
$terr=mysql_query("SELECT * FROM `sectors_loc` WHERE `id`='".$fr['loc']."'");
$ter=mysql_fetch_array($terr);
$gi1=mysql_fetch_array(mysql_query("SELECT * FROM `clan` WHERE `id`='".$fr['clan']."'"));
$gi2=mysql_fetch_array(mysql_query("SELECT * FROM `clan` WHERE `id`='".$gi['id']."'"));
$lgf='<font color=#00ff99>'.$ter['name'].'-'.$fr['name'].'</font><br><a href=clans.php?id='.$gi1['id'].'>'.$gi1['name'].'</a>('.$gi1['lvl'].') vs <a href=clans.php?id='.$gi2['id'].'>'.$gi2['name'].'</a>('.$gi2['lvl'].')';
mysql_query("INSERT INTO `adm_res` SET
`id`='',
`usr`='".$kod."',
`tip`='terr',
`text`='".$lgf."',
`time`='".time()."'
");
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',
`time_close`='".$tc."',
`kod`='".$kod."'
");
$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']."',
`time_close`='".$tc."'
");
}
}
}
}}
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'] and $udata['err']<time())
{
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',
`time_close`='".$fr['time_close']."',
`kod`='".$fr['kod']."'
");
$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']."',
`time_close`='".$fr['time_close']."'
");
}
}
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'] and $udata['err']<time())
{
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',
`time_close`='".$fr['time_close']."',
`kod`='".$fr['kod']."'
");
$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']."',
`time_close`='".$fr['time_close']."'
");
}
}
header('location: terr_b.php');exit;
}
include($path.'files/head.php');
include($path.'files/zag.php');
echo '<table width=100%>
<tr>
<td width=35%>
<a href=game.php><div style="background: #882222; border-radius: 7px 0 0 7px" class="m p bts bbs brs bls" align=center>Главная</div></a>
</td><td>';
echo '<a href=?><div class="line bts brs bls bbs p m" style="border-radius: 0 7px 7px 0">
<font color=#ffffff>Территории
</font>
</div></a></td></tr></table>';
echo '<div class="bat bts brs bls bbs p">';
if(isset($_GET['info']))
{
$id=mysql_real_escape_string($_GET['info']);
$terr=mysql_query("SELECT * FROM `sectors_loc` WHERE `id`='".$id."'");
$num=mysql_num_rows($terr);
if($num==0)
{
echo 'Ошибка!';
}
else
{
$ter=mysql_fetch_array($terr);
echo '
<div class="bbs p"><img src=img/main/i25.png> <b><font color=#00ff99>'.$ter['name'].'</font></b></div>
<div align=center class="p bbs"><img src=img/terr/'.htmlspecialchars($ter['img']).'.png>
<div class="v5 p"><font color=#0099ff><i>'.$ter['opis'].'</i></font></div>
</div><div class=p>';
$seck=mysql_query("SELECT * FROM `sectors` WHERE `loc`='".$ter['id']."'");
while($sec=mysql_fetch_array($seck))
{
echo '<img src=img/main/i26.png> <a href=?info='.$ter['id'].'&sek='.$sec['id'].'>'.$ter['name'].' - '.$sec['name'].'</a><br>';
}
echo '</div>';
if(isset($_GET['sek']))
{
$is=mysql_real_escape_string($_GET['sek']);
$seck=mysql_query("SELECT * FROM `sectors` WHERE `loc`='".$ter['id']."' and `id`='".$is."'");
$n_sek=mysql_num_rows($seck);
if($n_sek!=0)
{
$sk=mysql_fetch_array($seck);
echo '</div><div class="v8"><div class="line m bbs bts brs bls b p v12">'.$ter['name'].' - '.$sk['name'].'</div><div class="bat bts brs bls bbs p t1">';
echo '<img src=img/main/p21.png> <font color=#bbbbbb>Контролируют:</font> ';
if($sk['clan']==0)
{
echo 'сектор свободен<br>';
}
else
{
$gi=mysql_fetch_array(mysql_query("SELECT * FROM `clan` WHERE `id`='".$sk['clan']."'"));
echo ' <a href=clans.php?id='.$gi['id'].'>'.$gi['name'].'</a><br>';
echo '<img src=img/main/p21.png> <font color=#bbbbbb>Время контроля:</font> <font color=#1faee9>';
$sk['control']=time()-$sk['control'];
if($sk['control']<60){
echo $sk['control']." с.</font>";
}elseif($sk['control']>60 and $sk['control']<3600){
$sk['control']=round($sk['control']/60);
echo $sk['control']." м.</font>";
}else{
$sk['control']=round($sk['control']/3600);
echo $sk['control']." ч.</font>";
}
echo '<br>';
}
echo '<img src=img/main/p21.png> <font color=#bbbbbb>Особенность:</font> <font color=#00ff00>'.$sk['opis'].'</font><br>';
echo '<img src=img/main/p21.png> <font color=#bbbbbb>Статус сектора:</font> ';
if($sk['att_clan']==0)
{
echo 'заявок на нападение нет<br>';
if($udata['clan']!=$sk['clan'])
{
if(time()-1800>$sk['blok'])
{
echo '<img src=img/main/b8.png> <a href=?att&id='.$sk['id'].'>захватить сектор</a>';
}
}
}
else
{
$gis=mysql_fetch_array(mysql_query("SELECT * FROM `clan` WHERE `id`='".$sk['att_clan']."'"));
echo '<font color=#ff0000>атакован гильдией </font> '.$gis['name'].'<br>';
if($gis['id']==$udata['clan'])
{
echo '<img src=img/main/b8.png> <a href=?vst_att&id='.$sk['id'].'>встать на захват</a>';
}
elseif($sk['clan']==$udata['clan'])
{
echo '<img src=img/main/b8.png> <a href=?vst_def&id='.$sk['id'].'>встать на защиту</a>';
}
}
echo '</div></div>';
echo '<div class="v8"><div class="line bbs m bts brs bls b p v12">История сектора</div><div class="bat bts brs bls bbs p t1">';
$fridz=mysql_query("SELECT * FROM `sectors_log` WHERE `sector`='".$sk['id']."' ORDER BY `id` DESC LIMIT 5");
while($frz=mysql_fetch_array($fridz))
{
echo $frz['text'].'<br>';
}
}
}
}
}
else
{
$terr=mysql_query("SELECT * FROM `sectors_loc`");
while($ter=mysql_fetch_array($terr))
{
echo '<a href=?info='.$ter['id'].'><div class="v2s p">
<img src=img/main/i25.png> <b><font color=#00ff99>'.$ter['name'].'</font></b>
</div></a>';
}
}
echo '</div></div>';
include('files/down.php');
?>