Файл: zamki.php
Строк: 233
<?
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;
}
$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;
}
$mobs9=mysql_query("SELECT * FROM `labir_usr` WHERE `usr`='".$udata['id']."'");
$rows9=mysql_num_rows($mobs9);
if($rows9!=0)
{
header('location: b_oh.php');exit;
}
if($udata['clan']==0)
{
header('location: game.php');exit;
}
$gi=mysql_fetch_array(mysql_query("SELECT * FROM `clan` WHERE `id`='".$udata['clan']."'"));
$magaz=mysql_fetch_array(mysql_query("SELECT * FROM `clan_bild` WHERE `clan`='".$gi['id']."' and `img`='7'"));
$arr_usr=mysql_num_rows(mysql_query("SELECT * FROM `clan_zamki_usr` WHERE `usr`='".$udata['id']."'"));
if($arr_usr!=0)
{
header('location: terr_b.php');exit;
}
if(isset($_GET['att']))
{
$id=mysql_real_escape_string($_GET['att']);
$zamki=mysql_query("SELECT * FROM `clan_zamki` WHERE `id`='".$id."'");
$num=mysql_num_rows($zamki);
if($num==0)
{
}
else
{
$zm=mysql_fetch_array($zamki);
$nz=mysql_num_rows(mysql_query("SELECT * FROM `clan_zamki` WHERE `clan`='".$gi['id']."'"));
if($magaz['lvl']<3){$k=1;}
elseif($magaz['lvl']>=3 and $magaz['lvl']<5){$k=2;}
elseif($magaz['lvl']==5){$k=3;}
if($k==$nz)
{
mysql_query("INSERT INTO `user_log` SET
`usr`='".$udata['id']."',
`text`='Ваша гильдия не может контролировать больше замков.'
");
}
else
{
$nzk=mysql_num_rows(mysql_query("SELECT * FROM `clan_zamki` WHERE `att_clan`='".$gi['id']."'"));
if($nzk!=0)
{
mysql_query("INSERT INTO `user_log` SET
`usr`='".$udata['id']."',
`text`='Ваша гильдия уже проводит осаду на другой замок.'
");
}
else
{
if($zm['clan']==$gi['id'])
{
mysql_query("INSERT INTO `user_log` SET
`usr`='".$udata['id']."',
`text`='Этот заок уже ваш.'
");
}
else
{
if($zm['att_clan']!=0)
{
mysql_query("INSERT INTO `user_log` SET
`usr`='".$udata['id']."',
`text`='Этот замок уже атакован.'
");
}
else
{
$time=time()+600;
$tim=$time+3600;
mysql_query("UPDATE `clan_zamki` SET
`att_clan`='".$gi['id']."',
`att_time`='".$time."',
`att_close`='".$tim."' WHERE `id`='".$zm['id']."'
");
mysql_query("INSERT INTO `clan_zamki_usr` SET
`id`='',
`usr`='".$udata['id']."',
`tip`='usr',
`arr`='".$zm['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 `clan_zamki_usr` SET
`id`='',
`usr`='".$udata['id']."',
`tip`='pit',
`arr`='".$zm['id']."',
`pit`='".$t['id']."',
`hp`='".$t['hp']."',
`arm`='".$t['arm']."',
`sila`='".$t['sila']."',
`kom`='".$gi['id']."'
");
}
mysql_query("INSERT INTO `clan_zamki_usr` SET
`tip`='vr',
`hp`='".$zm['vr']."',
`arr`='".$zm['id']."',
`kom`='".$zm['clan']."'
");
mysql_query("INSERT INTO `clan_zamki_usr` SET
`tip`='fl',
`hp`='".$zm['fl']."',
`arr`='".$zm['id']."',
`kom`='".$zm['clan']."'
");
mysql_query("INSERT INTO `user_log` SET
`usr`='".$udata['id']."',
`text`='Вы начали осаду на ".$zm['name'].".'
");
}
}
}
}
}
header('location: ?');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 t3">
<img src=img/main/i26.png class="menu"> <a href=game.php>главная</a>
</div>';
echo '<div class="v8"><div class="v3 bts brs bls b p v12">Битва Замков</div><div class="v2 bts brs bls bbs p t3">';
echo '<center><img src=img/clan/bild/7.png></center>';
echo '<center><i><font color=#ffff00>Замки, ранее были владениями темного Лорда.
Скорее всего где то в недрах еще остались древние сокровища.</font></i></center>';
if(isset($_GET['zm']))
{
$id=mysql_real_escape_string($_GET['zm']);
$zamki=mysql_query("SELECT * FROM `clan_zamki` WHERE `id`='".$id."'");
$num=mysql_num_rows($zamki);
if($num==0)
{
echo '<center><font color=#ff0000>Вы заблудились!</font></center>';
}
else
{
$zm=mysql_fetch_array($zamki);
if($zm['clan']==0 and $zm['att_clan']==0)
{
$t='<font color=#00cc00>свободен</font>';
}
elseif($zm['clan']==0 and $zm['att_clan']!=0)
{
$cl=mysql_fetch_array(mysql_query("SELECT * FROM `clan` WHERE `id`='".$zm['att_clan']."'"));
$t='<font color=#ff0000>Под осодой</font>: <a href=clans.php?id='.$cl['id'].'>'.$cl['name'].'</a>';
}
elseif($zm['clan']!=0 and $zm['att_clan']==0)
{
$cl=mysql_fetch_array(mysql_query("SELECT * FROM `clan` WHERE `id`='".$zm['clan']."'"));
$t='<font color=#ffff00>Под контролем</font>: <a href=clans.php?id='.$cl['id'].'>'.$cl['name'].'</a>';
}
elseif($zm['clan']!=0 and $zm['att_clan']!=0)
{
$cl=mysql_fetch_array(mysql_query("SELECT * FROM `clan` WHERE `id`='".$zm['clan']."'"));
$cl2=mysql_fetch_array(mysql_query("SELECT * FROM `clan` WHERE `id`='".$zm['att_clan']."'"));
$t='<font color=#ff0000>Готовится бой</font>: <a href=clans.php?id='.$cl['id'].'>'.$cl['name'].'</a> VS <a href=clans.php?id='.$cl2['id'].'>'.$cl2['name'].'</a>';
}
elseif($zm['clan']!=0 and $zm['att_mob']!=0)
{
$cl=mysql_fetch_array(mysql_query("SELECT * FROM `clan` WHERE `id`='".$zm['clan']."'"));
$cl2=mysql_fetch_array(mysql_query("SELECT * FROM `clan` WHERE `id`='".$zm['att_clan']."'"));
$t='<font color=#ff0000>Готовится бой</font>: <a href=clans.php?id='.$cl['id'].'>'.$cl['name'].'</a> VS Монстры';
}
echo '</div><div class="v2 brs bls bbs p t3">';
echo '<img src=img/main/e30.png> '.$zm['name'].'<br>';
echo '<img src=img/main/e30.png> '.$t.'<br>';
if($zm['drop']==1){$b='<img src=img/main/cr1.png>3 дерева';}
elseif($zm['drop']==2){$b='<img src=img/main/cr2.png>3 железа';}
elseif($zm['drop']==3){$b='<img src=img/main/cr3.png>5 энергии';}
echo '<img src=img/main/e30.png> <small><font color=#0099ff>Гильдия контролирующая этот замок, получает '.$b.' каждые 2 часа.</font></small><br>';
if($zm['att_clan']!=0 and $zm['att_clan']!=$gi['id'])
{
echo '<img src=img/main/e28.png> <font color=#ff0000>Замок атакован. Вы не можете присоедениться к этой битве.</font><br>';
}
elseif($zm['att_clan']!=0 and $zm['att_clan']==$gi['id'])
{
echo '<img src=img/main/e28.png> <a href=?vst='.$zm['id'].'>Присоедениться в осаде</a><br>';
}
elseif($zm['att_clan']!=0 and $zm['clan']==$gi['id'])
{
echo '<img src=img/main/e28.png> <a href=?vst='.$zm['id'].'>Встать на защиту</a><br>';
}
elseif($zm['att_clan']==0 and $zm['clan']!=$gi['id'])
{
echo '<img src=img/main/e28.png> <a href=?att='.$zm['id'].'>Осадить замок</a><br>';
}
elseif($zm['att_clan']==0 and $zm['clan']==0)
{
echo '<img src=img/main/e28.png> <a href=?att='.$zm['id'].'>Осадить замок</a><br>';
}
}
}
else
{
$zamki=mysql_query("SELECT * FROM `clan_zamki` ORDER BY `id`");
while($zm=mysql_fetch_array($zamki))
{
if($zm['clan']==0 and $zm['att_clan']==0)
{
$t='<font color=#00cc00>свободен</font>';
}
elseif($zm['clan']==0 and $zm['att_clan']!=0)
{
$cl=mysql_fetch_array(mysql_query("SELECT * FROM `clan` WHERE `id`='".$zm['att_clan']."'"));
$t='<font color=#ff0000>Под осодой</font>: <a href=clans.php?id='.$cl['id'].'>'.$cl['name'].'</a>';
}
elseif($zm['clan']!=0 and $zm['att_clan']==0)
{
$cl=mysql_fetch_array(mysql_query("SELECT * FROM `clan` WHERE `id`='".$zm['clan']."'"));
$t='<font color=#ffff00>Под контролем</font>: <a href=clans.php?id='.$cl['id'].'>'.$cl['name'].'</a>';
}
elseif($zm['clan']!=0 and $zm['att_clan']!=0)
{
$cl=mysql_fetch_array(mysql_query("SELECT * FROM `clan` WHERE `id`='".$zm['clan']."'"));
$cl2=mysql_fetch_array(mysql_query("SELECT * FROM `clan` WHERE `id`='".$zm['att_clan']."'"));
$t='<font color=#ff0000>Готовится бой</font>: <a href=clans.php?id='.$cl['id'].'>'.$cl['name'].'</a> VS <a href=clans.php?id='.$cl2['id'].'>'.$cl2['name'].'</a>';
}
elseif($zm['clan']!=0 and $zm['att_mob']!=0)
{
$cl=mysql_fetch_array(mysql_query("SELECT * FROM `clan` WHERE `id`='".$zm['clan']."'"));
$cl2=mysql_fetch_array(mysql_query("SELECT * FROM `clan` WHERE `id`='".$zm['att_clan']."'"));
$t='<font color=#ff0000>Готовится бой</font>: <a href=clans.php?id='.$cl['id'].'>'.$cl['name'].'</a> VS Монстры';
}
echo '<div class="v5 v8 p"><img src=img/main/e30.png> '.$zm['name'].'<br><img src=img/main/e30.png> '.$t.'<br>
<a href=?zm='.$zm['id'].'><img src=img/main/e28.png> Войти</a></div>';
}
}
echo '</div></div>';
include('files/down.php');
?>