<?
ob_start();
require'../sys/head.php';
require'../sys/conf.php';
require'../sys/sess.php';
require'../otsev.php';
echo"<b>Бункер</b><br/>";
$sp=mysql_fetch_array(qw("SELECT id FROM domik WHERE strana ='$re1[strana]' and domik9='1'"));
if($sp[id]>0){
echo'</div><div class="knews">';
if(!empty($_GET['make'])){$make = $_GET['make'];} else {$make= '';}
switch($make){
default:
echo'<a href="bunker.php?make=oxp&der='.$key.'">{охрана}</a>';
$ox=mysql_fetch_array(qw("SELECT * FROM oxp_9 WHERE strana ='$re1[strana]'"));
$ox=$ox[peh]+$ox[kon]+$ox[str]+$ox[puh]+$ox[tan]+$ox[sam];
echo"[($ox)]<br/>";
echo"<u>В бункере:</u><br/>пехота-($re1[peh3]) <br/>кавалерия-($re1[kon3]) <br/>стрелки-($re1[str3])<br/>
пушки-($re1[puh3]) <br/>танки-($re1[tan3]) <br/>самолёты-($re1[sam3])<br/>";
echo'<a href="bunker.php?der='.$key.'&make=bunk">Спрятать/Забрать</a><br/>';
break;
////////////////////////
////////////////////////
case bunk:
if(empty($_GET[k])){
echo"<u>В бункере:</u><br/>пехота-($re1[peh3]) <br/>кавалерия-($re1[kon3]) <br/>стрелки-($re1[str3])<br/>
пушки-($re1[puh3]) <br/>танки-($re1[tan3]) <br/>самолёты-($re1[sam3])<br/>";
echo"<a href='bunker.php?make=bunk&k=1&der=$key'>Добавить</a><br/><a href='bunker.php?make=bunk&k=3&der=$key'>Забрать</a><br/>";
}
if($_GET[k]==1){
echo"<FORM ACTION='bunker.php?make=bunk&k=2&der=$key' METHOD='POST'>";?>
Пехота:<br/><input type="text" name="peh" maxlength="4" value="<?=$re2[peh];?>" size="5"/><br/>
Кавалерия:<br/><input type="text" name="kon" maxlength="4" value="<?=$re2[kon];?>" size="5"/><br/>
Стрелки:<br/><input type="text" name="str" maxlength="4" value="<?=$re2[str];?>" size="5"/><br/>
Пушки:<br/><input type="text" name="puh" maxlength="4" value="<?=$re2[puh];?>" size="5"/><br/>
Танки:<br/><input type="text" name="tan" maxlength="4" value="<?=$re2[tan];?>" size="5"/><br/>
Самолёты:<br/><input type="text" name="sam" maxlength="4" value="<?=$re2[sam];?>" size="5"/><br/>
<INPUT TYPE='submit'VALUE='Добавить'></FORM><br/><?
}
if($_GET[k]==2){
$a1=zif($_POST[peh]);$a2=zif($_POST[str]);$a3=zif($_POST[puh]);$a4=zif($_POST[tan]);$a5=zif($_POST[kon]);$a6=zif($_POST[sam]);$a7=$a1+$a2+$a3+$a4+$a5+$a6;
if($a7==0){header("Location: bunker.php?make=bunk&der=$key");}else{
if($re2[peh]>=$a1 and $re2[kon]>=$a5 and $re2[str]>=$a2 and $re2[puh]>=$a3 and $re2[tan]>=$a4 and $re2[sam]>=$a6 ){
qw("UPDATE gos2 SET peh=peh-'$a1',kon=kon-'$a5',str=str-'$a2',puh=puh-'$a3',tan=tan-'$a4',sam=sam-'$a6' WHERE strana='$re1[strana]'");
qw("UPDATE gos SET peh3=peh3+'$a1',kon3=kon3+'$a5',str3=str3+'$a2',puh3=puh3+'$a3',tan3=tan3+'$a4',sam3=sam3+'$a6' WHERE strana='$re1[strana]'");
header("Location: bunker.php?make=bunk&der=$key");
}else{header("Location: bunker.php?make=bunk&der=$key");}
}
}
if($_GET[k]==3){
echo"<FORM ACTION='bunker.php?make=bunk&k=4&der=$key' METHOD='POST'>";?>
Пехота:<br/><input type="text" name="peh" maxlength="4" value="<?=$re1[peh3];?>" size="5"/><br/>
Кавалерия:<br/><input type="text" name="kon" maxlength="4" value="<?=$re1[kon3];?>" size="5"/><br/>
Стрелки:<br/><input type="text" name="str" maxlength="4" value="<?=$re1[str3];?>" size="5"/><br/>
Пушки:<br/><input type="text" name="puh" maxlength="4" value="<?=$re1[puh3];?>" size="5"/><br/>
Танки:<br/><input type="text" name="tan" maxlength="4" value="<?=$re1[tan3];?>" size="5"/><br/>
Самолёты:<br/><input type="text" name="sam" maxlength="4" value="<?=$re1[sam3];?>" size="5"/><br/>
<INPUT TYPE='submit'VALUE='Забрать'></FORM><br/><?
}
if($_GET[k]==4){
$a1=zif($_POST[peh]);$a2=zif($_POST[str]);$a3=zif($_POST[puh]);$a4=zif($_POST[tan]);$a5=zif($_POST[kon]);$a6=zif($_POST[sam]);$a7=$a1+$a2+$a3+$a4+$a5+$a6;
if($a7==0){header("Location: bunker.php?make=bunk&der=$key");}else{
if($re1[peh3]>=$a1 and $re1[kon3]>=$a5 and $re1[str3]>=$a2 and $re1[puh3]>=$a3 and $re1[tan3]>=$a4 and $re1[sam3]>=$a6){
qw("UPDATE gos SET peh3=peh3-'$a1',kon3=kon3-'$a5',str3=str3-'$a2',puh3=puh3-'$a3',tan3=tan3-'$a4',sam3=sam3-'$a6' WHERE strana='$re1[strana]'");
qw("UPDATE gos2 SET peh=peh+'$a1',kon=kon+'$a5',str=str+'$a2',puh=puh+'$a3',tan=tan+'$a4',sam=sam+'$a6' WHERE strana='$re1[strana]'");
header("Location: bunker.php?make=bunk&der=$key");
}else{header("Location: bunker.php?make=bunk&der=$key");}
}
}
break;
///////////////////////
///////////////////////
case oxp:
$ox=mysql_fetch_array(qw("SELECT * FROM oxp_9 WHERE strana ='$re1[strana]'"));
if(empty($_GET[k])){
echo"<u>В охране </u>:<br/>Пехота ($ox[peh])<br/>Стрелки ($ox[str])<br/>Пушки ($ox[puh])<br/>Танки ($ox[tan])<br/>";
echo"<a href='bunker.php?make=oxp&k=1&der=$key'>Добавить</a><br/><a href='bunker.php?make=oxp&k=3&der=$key'>Забрать</a><br/>";
}
if($_GET[k]==1){
echo"<FORM ACTION='bunker.php?make=oxp&k=2&der=$key' METHOD='POST'>";?>
Пехота:<br/><input type="text" name="peh" maxlength="4" value="<?=$re2[peh];?>" size="5"/><br/>
Стрелки:<br/><input type="text" name="str" maxlength="4" value="<?=$re2[str];?>" size="5"/><br/>
Пушки:<br/><input type="text" name="puh" maxlength="4" value="<?=$re2[puh];?>" size="5"/><br/>
Танки:<br/><input type="text" name="tan" maxlength="4" value="<?=$re2[tan];?>" size="5"/><br/>
<INPUT TYPE='submit'VALUE='Добавить'></FORM><br/><?
}
if($_GET[k]==2){
$a1=zif($_POST[peh]);$a2=zif($_POST[str]);$a3=zif($_POST[puh]);$a4=zif($_POST[tan]);$a5=$a1+$a2+$a3+$a4;
if($a5==0){header("Location: bunker.php?make=oxp&der=$key");}else{
$lim=$a5+$ox[peh]+$ox[str]+$ox[puh]+$ox[tan];
if($ox[max]>=$lim){
if($re2[peh]>=$a1 and $re2[str]>=$a2 and $re2[puh]>=$a3 and $re2[tan]>=$a4){
qw("UPDATE gos2 SET peh=peh-'$a1',str=str-'$a2',puh=puh-'$a3',tan=tan-'$a4' WHERE strana='$re1[strana]'");
qw("UPDATE oxp_9 SET peh=peh+'$a1',str=str+'$a2',puh=puh+'$a3',tan=tan+'$a4' WHERE strana='$re1[strana]'");
header("Location: bunker.php?make=oxp&der=$key");
}else{header("Location: bunker.php?make=oxp&der=$key");}
}else{echo"В охране может находиться не более $ox[max] юнитов!<br/>";}
}
}
if($_GET[k]==3){
echo"<FORM ACTION='bunker.php?make=oxp&k=4&der=$key' METHOD='POST'>";?>
Пехота:<br/><input type="text" name="peh" maxlength="4" value="<?=$ox[peh];?>" size="5"/><br/>
Стрелки:<br/><input type="text" name="str" maxlength="4" value="<?=$ox[str];?>" size="5"/><br/>
Пушки:<br/><input type="text" name="puh" maxlength="4" value="<?=$ox[puh];?>" size="5"/><br/>
Танки:<br/><input type="text" name="tan" maxlength="4" value="<?=$ox[tan];?>" size="5"/><br/>
<INPUT TYPE='submit'VALUE='Забрать'></FORM><br/><?
}
if($_GET[k]==4){
$a1=zif($_POST[peh]);$a2=zif($_POST[str]);$a3=zif($_POST[puh]);$a4=zif($_POST[tan]);$a5=$a1+$a2+$a3+$a4;
if($a5==0){header("Location: bunker.php?make=oxp&der=$key");}else{
if($ox[peh]>=$a1 and $ox[str]>=$a2 and $ox[puh]>=$a3 and $ox[tan]>=$a4){
qw("UPDATE oxp_9 SET peh=peh-'$a1',str=str-'$a2',puh=puh-'$a3',tan=tan-'$a4' WHERE strana='$re1[strana]'");
qw("UPDATE gos2 SET peh=peh+'$a1',str=str+'$a2',puh=puh+'$a3',tan=tan+'$a4' WHERE strana='$re1[strana]'");
header("Location: bunker.php?make=oxp&der=$key");
}else{header("Location: bunker.php?make=oxp&der=$key");}
}
}
break;
}
echo'</div><div class="knews">';
?>|<a href='javascript:history.go(-1)'>Назад</a><br/><?
echo'<a href="../game.php?der='.$key.'">В страну</a><br/>';
echo'</div><div class="knews"><a href="../out.php?der='.$key.'">Выход</a><br/>';
require'../sys/foot.php';
}else{header("Location:../../game.php?der=$key");}
?>