<?
error_reporting(E_ALL ^ E_NOTICE);
error_reporting(E_ALL ^ E_NOTICE);
define('PROTECTOR', 1);
$head = 'towers';//фикс. места
@include('files/db.php');
@include('files/auth.php');
@include('files/func.php');
ryd();
@include('files/core.php');
if($_GET['mod']==taran or $_GET['mod']=='go' or $_GET['mod']=='outtower' or $_GET['mod']=='repair'){
$header=TRUE;}else{
$textl='Территории';}
@include('files/head.php');
@include('files/zag.php');
////////////////////////
$random=rand(1000,9999);
////////////////
$timer=time()+300;
switch($_GET[mod]){
default:
echo"<font color='#ffc22b'>Захвати территории, разрушая главные форт-посты! Значком <img src='pic/main/status/mmod.png' alt=''/> показано, сколько очков славы ты получишь за захват</div></font>";
if($mestouser['towers']==0){
$req = mysql_query("SELECT * FROM `towers`");
////////////////////////////
$avto=mysql_num_rows($req);
if($avto>=1){
While($tower = mysql_fetch_array($req)){
if($tower['control']=='not'){
echo"<div class='menu'><img src='pic/main/nocontrol.png' alt='*'/> ";}else{
echo"<div class='menu'><img src='pic/main/$tower[control].png' alt='*'/> ";}
echo"<a href=\"towers.php?mod=go&id=$tower[id]\">$tower[name]</a> (<img src='pic/up.png' alt=''/>$tower[lvl]/$tower[mlvl], $tower[hp]/$tower[hpall]хп) <img src='pic/main/status/mmod.png' alt=''/>$tower[point]<br/></div>
";
}}else{
echo'Нет Территорий!<br/>';}
@include('files/down.php');
exit;}else{
$req = mysql_query("SELECT * FROM `towers` WHERE id='$mestouser[towers]'");
$tower = mysql_fetch_array($req);
if($tower[control]=='not'){
echo"<div class='menu'><img src='pic/main/nocontrol.png' alt='*'/> ";
}else{
echo"<div class='menu'><center><img src='pic/main/$tower[control].png' alt='*'/> ";}
echo"$tower[name] - $tower[hp]/$tower[hpall]хп</center>
Вы: <img src=\"hp.php\" alt=\"*\"/><br/>";
if($tower[control]==black){$strazh="Караул Сопротивления";}else{$strazh="Федеральный караул";}
if($tower[control]!=$udata[storona]){
echo"Охрана: <b>$strazh</b></br><center><a href=\"towers.php?mod=taran\">Штурм форт-поста</a></center>";
}else{
echo"<center><a href=\"towers.php?mod=repair\">Ремонтировать Форт</a><br/></center>";}
echo'<div class=dot>';
$odin=false;
$timeout=time()-150;//оффлайн
$req = mysql_query("SELECT * FROM online WHERE laikas > '{$timeout}' and `usr`!='{$log}'");
////////////////////////////
echo"Поблизости:<br/>";
While($who = mysql_fetch_array($req)){
$reqs = mysql_query("SELECT * FROM `mesto` WHERE `usr` = '{$who['usr']}' LIMIT 1");
$mesto = mysql_fetch_array($reqs);//место
$reqs = mysql_query("SELECT id,city,storona,hp FROM `users` WHERE `usr` = '{$who['usr']}' LIMIT 1");
$cit = mysql_fetch_array($reqs);//город
//if($mesto['city']==3 && $mesto['towers']==$mestouser['towers']){
$xyusosu=mysql_fetch_assoc(mysql_query("SELECT `usr` FROM `users` WHERE`id`='".$cit['id']."'"));
if($mesto['towers']==$mestouser['towers'] and $mesto['place']==$mestouser['place']){
$idlog=$who[usr];
if($cit[storona]==$udata[storona]){echo'<font color="green">'.$xyusosu["usr"].' ';}else{
echo'<font color="red">'.$xyusosu["usr"].'';
}
idlog($idlog); echo"</font> <a href=\"ok.php?k=pk&id=$cit[id]\">[!]</a><br/>
";
$odin=true;}
echo"";
}
if($odin==false){
echo' Вокруг никого нет';}
echo" </font>";
echo"</div>
</div>";
echo"<div class=menu>";
$el = mysql_query("SELECT * FROM `res` WHERE `usr` = '$log' and `tip`='elexir' and `kol`>'0' ORDER by `cena` DESC LIMIT 4");
$avt=mysql_num_rows($el);
if($avt>=1){
While($elm = mysql_fetch_array($el)){
echo"$elm[name] ($elm[kol] шт.) <a href=\"elexirs.php?id=$elm[id]\">[исп]</a></font><br/>";
}}
echo"</div>";
}
log_msg($tlog='tower');
echo'<div class=evento><div class=nevb> <div style="text-align:left"><a href="towers.php?mod=outtower"><div class=zag>Покинуть тер-ю</div></a></div>';
break;
case 'go':
$req = mysql_query("SELECT * FROM `towers` WHERE id='$_GET[id]'");
$avto=mysql_num_rows($req);
$tower = mysql_fetch_array($req);
if($avto==0){
header ("Location: towers.php?");exit;}
if($udata[lvl]>$tower[mlvl] and $log!='Admin'){
mysql_query("INSERT INTO log SET usr='$log',text='У вас высокий уровень',kto='system',place='tower',timer='$timer'");
header ("Location: towers.php?");exit;}
if($udata[lvl]<$tower[lvl] and $log!='Admin'){
mysql_query("INSERT INTO log SET usr='$log',text='У вас низкий уровень',kto='system',place='tower',timer='$timer'");
header ("Location: towers.php?");exit;}
mysql_query("UPDATE `mesto` SET `towers` = '$_GET[id]' WHERE `usr`='$log'");
mysql_query("INSERT INTO log SET usr='$log',text='Вы вошли на территорию $tower[name]',kto='system',place='tower',timer='$timer'");
header ("Location: towers.php?");exit;
break;
case 'taran':
$req = mysql_query("SELECT * FROM `towers` WHERE id='$mestouser[towers]'");
$avto=mysql_num_rows($req);
if($avto==0){
mysql_query("INSERT INTO log SET usr='$log',text='Вы не находитесь на территории',kto='system',place='tower',timer='$timer'");
header ("Location: towers.php?");exit;}
$tower = mysql_fetch_array($req);
if($tower[control]==$udata[storona]){
mysql_query("INSERT INTO log SET usr='$log',text='Территория уже ваша',kto='system',place='tower',timer='$timer'");
header ("Location: towers.php?");exit;}
if($tower[hp]<=0){
mysql_query("INSERT INTO log SET usr='$log',text='Территория уже ваша',kto='system',place='tower',timer='$timer'");
header ("Location: towers.php?");exit;}else{
$uron=rand($udata[sila]-$udata[sila]/8,$udata[sila]+$udata[sila]/8);
$muron=2+rand(0,$udata[hp]/5);
$tower[hp]=$tower[hp]-$uron;
if($tower[hp]<=0){
$tow = mysql_query("SELECT * FROM `towers`");
$am=0;
While($sum = mysql_fetch_array($tow))
{
$am=$am+$sum[point];
}
$proc=$am/100;
$point=round($tower[point]/$proc);
$hpin=round($tower[hpall]/1.5);
mysql_query("UPDATE `towers` SET `control`='$udata[storona]',`hp`='$hpin' WHERE id='$mestouser[towers]'");
$req = mysql_query("SELECT * FROM `domination` WHERE `id` = '1' LIMIT 1");
$dom = mysql_fetch_array($req);
$m=explode(",",$tower[money]);
$m=rand($m['0'],$m['1']);
$udata[money]=$udata[money]+$m;
$udata[slava]=$udata[slava]+$tower[point];
$udata[exp]=$udata[exp]+$tower[exp];
if($udata['storona']=='white'){$my=$dom['white'];$enemy=$dom['black'];}else{
$my=$dom['black'];$enemy=$dom['white'];}
$my=$my+$point;
if($tower[control]=='not'){if($udata['storona']=='white'){
mysql_query("UPDATE `domination` SET `white` = '$my' WHERE `id` = '1'");}else{
mysql_query("UPDATE `domination` SET `black` = '$my' WHERE `id` = '1'");}}else{
$enemy=$enemy-$point;
if($udata['storona']=='white'){
mysql_query("UPDATE `domination` SET `white` = '$my',`black`='$enemy' WHERE `id` = '1'");}else{
mysql_query("UPDATE `domination` SET `black` = '$my',`white`='$enemy' WHERE `id` = '1'");}}
mysql_query("UPDATE `users` SET `slava` = '$udata[slava]',`exp` = '$udata[exp]',`money` = '$udata[money]' WHERE `usr` = '$log'");
$resd = mysql_query("SELECT `prodob` FROM `dost` WHERE `usr`='$log'") or die (mysql_error());
$res = mysql_fetch_array($resd);
$dob=$res[prodob]+1;
mysql_query("UPDATE `dost` SET `prodob` = '$dob' WHERE `usr` = '$log'");
mysql_query("INSERT INTO log SET usr='$log',text='Вы захватили территорию $tower[name]! + $tower[exp] опыта, +$m монет',kto='user',place='tower',timer='$timer'");
header ("Location: towers.php?");exit;}
if($udata[hp]<='0'){mysql_query("UPDATE `mesto` SET `place` = 'gorod',`city` = '0' WHERE usr='$log'");header ("Location: index.php?");exit;}
mysql_query("UPDATE `towers` SET `hp` = '$tower[hp]' WHERE id='$mestouser[towers]'");
mysql_query("UPDATE `users` SET `hp` = '$udata[hp]'-'$muron' WHERE usr='$log'");
mysql_query("INSERT INTO log SET usr='$log',text='Вы нанесли урон $uron',kto='user',place='tower',timer='$timer'");
mysql_query("INSERT INTO log SET usr='$log',text='Вас ударили -$muron',kto='enemy',place='tower',timer='$timer'");
header ("Location: towers.php?");exit;}
break;
case 'repair':
$req = mysql_query("SELECT * FROM `towers` WHERE id='$mestouser[towers]' and control='$udata[storona]'");
$avto=mysql_num_rows($req);
if($avto==0){
mysql_query("INSERT INTO log SET usr='$log',text='Вы не находитесь на территории',kto='system',place='tower',timer='$timer'");
header ("Location: towers.php?");exit;}
$tower = mysql_fetch_array($req);
$req = mysql_query("SELECT * FROM `res` WHERE `lat_name` = 'kamen' AND `kol` >= '1' AND `usr` = '$log'");
$kamen=mysql_num_rows($req);
if($kamen==0){
mysql_query("INSERT INTO log SET usr='$log',text='Нет камня',kto='system',place='tower',timer='$timer'");
header ("Location: towers.php?");exit;}
$kam = mysql_fetch_array($req);
$settow = mysql_query("SELECT * FROM `set` WHERE `usr` = '$log'");
$set=mysql_fetch_array($settow);
///////////////////////////
if($set[stroitel]==0){$hprepair=40;}
if($set[stroitel]==1){$hprepair=45;}
if($set[stroitel]==2){$hprepair=50;}
if($set[stroitel]==3){$hprepair=55;}
if($set[stroitel]==4){$hprepair=60;}
if($set[stroitel]==5){$hprepair=65;}
if($set[stroitel]==6){$hprepair=70;}
if($set[stroitel]==7){$hprepair=75;}
if($set[stroitel]==8){$hprepair=80;}
if($set[stroitel]==9){$hprepair=85;}
if($set[stroitel]==10){$hprepair=90;}
///////////////////////////
if($tower[hp]>=$tower[hpall]){
mysql_query("INSERT INTO log SET usr='$log',text='Форт-пост цел',kto='system',place='tower',timer='$timer'");
header ("Location: towers.php?");exit;
}$tower[hp]=$tower[hp]+$hprepair;
if($tower[hp]>$tower[hpall]){$tower[hp]=$tower[hpall];}
$kam[kol]--;
$dostig = mysql_query("SELECT * FROM `dost` WHERE `usr` = '$log'");
$dost=mysql_fetch_array($dostig);
$smon = rand(1,50);
$sexp = rand(5,20);
mysql_query("UPDATE `res` SET `kol` = '$kam[kol]' WHERE `usr`='$log' and `lat_name` = 'kamen'");
mysql_query("UPDATE `towers` SET `hp` = '$tower[hp]' WHERE id='$mestouser[towers]' and control='$udata[storona]'");
mysql_query("UPDATE `dost` SET `str` = '$dost[str]'+'1' WHERE `usr` = '$log'");
mysql_query("UPDATE `users` SET `money` = `money` + '$smon' WHERE `usr` = '$log'");
mysql_query("UPDATE `users` SET `exp` = `exp` + '$sexp' WHERE `usr` = '$log'");
mysql_query("INSERT INTO log SET usr='$log',text='Вы отремонтировали форт-пост на $hprepair единиц, потратив 1 камень.<br/>Получено: $smon монет и $sexp опыта.',kto='user',place='tower',timer='$timer'");
header ("Location: towers.php?");exit;
break;
case 'outtower':
mysql_query("UPDATE `mesto` SET `towers` = '0' WHERE `usr`='$log'");
header ("Location: towers.php?");exit;
break;}
@include('files/end.php');
?>