<?
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 domik3='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="hranilishe.php?make=oxp&der='.$key.'">{охрана}</a>';
$ox=mysql_fetch_array(qw("SELECT * FROM oxp_3 WHERE strana ='$re1[strana]'"));
$ox=$ox[peh]+$ox[kon]+$ox[str]+$ox[puh]+$ox[tan]+$ox[sam];
echo"[($ox)]<br/>";
$sp=mysql_fetch_array(qw("SELECT res FROM domik WHERE strana ='$re1[strana]'"));
$x=$sp[res]-($re2[metal]+$re2[kamen]+$re2[derevo]+$re2[neft]+$re2[zerno]);
echo"Свободное место : (<b>$x</b>)<br/>";
echo"Железо ($re2[metal])<br/>";
echo"Камень ($re2[kamen])<br/>";
echo"Дерево ($re2[derevo])<br/>";
echo"Нефть ($re2[neft])<br/>";
echo"Зерно ($re2[zerno])<br/>";
echo'------<br/><a href="../game.php?make=8&s=2&der='.$key.'">Построить Рынок</a><br/>';
break;
case oxp:
$ox=mysql_fetch_array(qw("SELECT * FROM oxp_3 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='hranilishe.php?make=oxp&k=1&der=$key'>Добавить</a><br/><a href='hranilishe.php?make=oxp&k=3&der=$key'>Забрать</a><br/>";
}
if($_GET[k]==1){
echo"<FORM ACTION='hranilishe.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: hranilishe.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_3 SET peh=peh+'$a1',str=str+'$a2',puh=puh+'$a3',tan=tan+'$a4' WHERE strana='$re1[strana]'");
header("Location: hranilishe.php?make=oxp&der=$key");
}else{header("Location: hranilishe.php?make=oxp&der=$key");}
}else{echo"В охране может находиться не более $ox[max] юнитов!<br/>";}
}
}
if($_GET[k]==3){
echo"<FORM ACTION='hranilishe.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: hranilishe.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_3 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: hranilishe.php?make=oxp&der=$key");
}else{header("Location: hranilishe.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");}
?>