<?php
echo "<div class='aut'>Мои постройки</div>";
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `empire_stroi` WHERE `id_u`='".$user['id']."'"),0)=='0'){
  echo "У вас нет зданий! Для постройки зданий вам необходимы строители<br/>";
}
else
{
  $p=abs(intval($_GET['p']));
  if($p=='0'){
  $all_p=mysql_result(mysql_query("SELECT COUNT(*) FROM `empire_stroi` WHERE `id_u`='".$user['id']."'"),0);
  $k_page=k_page($all_p,$set['p_str']);
  $page=page($k_page);
  $start=$set['p_str']*$page-$set['p_str'];
  $my_p=mysql_query("SELECT * FROM `empire_stroi` WHERE `id_u`='".$user['id']."' ORDER BY `id` LIMIT $start,$set[p_str]");
  while($arr=mysql_fetch_array($my_p)){
    echo "<img src='buildings.PNG' alt='.'/><a href='?do=7&amp;p=$arr[id]'>$arr[name]</a><br/>";
  }
  if($k_page>'1')str('?do=7&amp;',$k_page,$page);
}
else
{
 $all_p=mysql_result(mysql_query("SELECT COUNT(*) FROM `empire_stroi` WHERE `id`='".$p."' AND `id_u`='".$user['id']."'"),0);
if($all_p>'0'){
  $my_p=mysql_fetch_array(mysql_query("SELECT * FROM `empire_stroi` WHERE `id`='".$p."'"));
  echo "$my_p[name]<br/>Еда: +$my_p[eda]<br/>
  Дерево: +$my_p[derevo]<br/>
  Золото: +$my_p[zoloto]<br/>
  Железо: +$my_p[gelezo]<br/>
  Воины: +$my_p[voin]<br/>
  Пушки: +$my_p[push]<br/>";
  $cherez=$my_p['time_r']-time();
  if($cherez>='1'){
  echo "Прибыль через : ".sictime($cherez)." сек<br/>  ";
  }
  echo "<a href='?do=20&amp;id=$p'>Продать постройку</a><br/>";
 /* echo "  $my_p[zoloto]/$q[zoloto_l]/
     $my_p[eda]/$q[eda_l]/
      $my_p[derevo]/$q[dr_l]/
       $my_p[gelezo]/$q[gelezo_l]";*/



  if($my_p['time_r']<=time()){
    $ntime=time()+60*60*3;
    $zoloto=$my_p['zoloto']*$q['zoloto_l'];
     $eda=$my_p['eda']*$q['eda_l'];
      $derevo=$my_p['derevo']*$q['dr_l'];
       $gelezo=$my_p['gelezo']*$q['gelezo_l'];
       $voin=$my_p['voin'];
       $push=$my_p['push'];

    mysql_query("UPDATE `empire` SET `eda`=`eda`+$eda, `zoloto`=`zoloto`+$zoloto, `derevo`=`derevo`+$derevo, `gelezo`=`gelezo`+$gelezo, `voin`=`voin`+$voin, `push`=`push`+$push WHERE `id_u`='$user[id]' LIMIT 1");
    mysql_query("UPDATE `empire_stroi` SET `time_r`='$ntime' WHERE `id`='$p' LIMIT 1");

    msg('Налоги успешно собраны');
  }
}}
}
echo "<div class='aut'><a href='?do=0'>Назад</a></div>";
?>