Файл: zfarm.mobi/inc/user/warehouse.php
Строк: 170
<?
$title='Амбар';
include_once '../system/config.php';
echo"<div class='rzd2'></div><div class='menuin2'>";
?>
<div class="title">Амбар</h2></div>
<?
echo "<div class='content'>";
echo "<div class='div'>";
if(isset($_GET['sell_all']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_warehouse` WHERE `id_user` = '$ku[id]'"),0)!=0)
{
$q=mysql_query("SELECT * FROM `kolhoz_warehouse` WHERE `id_user` = '$ku[id]'");
$cm=0;
while($post=mysql_fetch_array($q))
{
$plant=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_plant` WHERE `id` = '$post[id_plant]'"));
$m=floor(($plant['money']/$plant['count'])*$post['count']);
$cm=$cm+$m;
}
mysql_query("UPDATE `kolhoz_user` SET `money` = '".($ku['money']+$cm)."' WHERE `id` = '$ku[id]'");
mysql_query("DELETE FROM `kolhoz_warehouse` WHERE `id_user` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_user` SET `umoney` = '$cm' WHERE `id` = '$ku[id]'");
if(isset($mc) && $mc['nalog']>0)
{
$nmoney=floor(($cm/100)*$mc['nalog']);
mysql_query("UPDATE `kolhoz_user` SET `money` = '".($ku['money']+$cm-$nmoney)."' WHERE `id` = '$ku[id]'");
mysql_query("INSERT INTO `kolhoz_collective_cash` SET `id_user` = '$ku[id]', `id_collective` = '$mc[id]', `count` = '$nmoney', `type` = 'money', `time` = '$time'");
mysql_query("UPDATE `kolhoz_collective` SET `money` = '".($mc['money']+$nmoney)."' WHERE `id` = '$mc[id]'");
}
header("Location:/warehouse/");
exit;
}
if(isset($_GET['corm']) && intval($_GET['corm'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_warehouse` WHERE `id_user` = '$ku[id]' AND `id` = '".intval($_GET['corm'])."'"),0)!=0)
{
$pw=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_warehouse` WHERE `id_user` = '$ku[id]' AND `id` = '".intval($_GET['corm'])."'"),0);
mysql_query("UPDATE `kolhoz_warehouse` SET `arena` = '1' WHERE `id` = '$pw[id]'");
}
if(isset($_GET['NOcorm']) && intval($_GET['NOcorm'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_warehouse` WHERE `id_user` = '$ku[id]' AND `id` = '".intval($_GET['NOcorm'])."'"),0)!=0)
{
$pw=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_warehouse` WHERE `id_user` = '$ku[id]' AND `id` = '".intval($_GET['NOcorm'])."'"),0);
mysql_query("UPDATE `kolhoz_warehouse` SET `arena` = '0' WHERE `id` = '$pw[id]'");
}
if(isset($_GET['sell']) && intval($_GET['sell'])!=NULL && mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_warehouse` WHERE `id_user` = '$ku[id]' AND `id` = '".intval($_GET['sell'])."'"),0)!=0)
{
$pw=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_warehouse` WHERE `id_user` = '$ku[id]' AND `id` = '".intval($_GET['sell'])."'"),0);
$plant=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_plant` WHERE `id` = '$pw[id_plant]'"));
$m=floor(($plant['money']/$plant['count'])*$pw['count']);
mysql_query("UPDATE `kolhoz_user` SET `money` = '".($ku['money']+$m)."' WHERE `id` = '$ku[id]'");
mysql_query("DELETE FROM `kolhoz_warehouse` WHERE `id` = '$pw[id]'");
mysql_query("UPDATE `kolhoz_user` SET `umoney` = '$m' WHERE `id` = '$ku[id]'");
if(isset($mc) && $mc['nalog']>0)
{
$nmoney=floor(($m/100)*$mc['nalog']);
mysql_query("UPDATE `kolhoz_user` SET `money` = '".($ku['money']+$m-$nmoney)."' WHERE `id` = '$ku[id]'");
mysql_query("INSERT INTO `kolhoz_collective_cash` SET `id_user` = '$ku[id]', `id_collective` = '$mc[id]', `count` = '$nmoney', `type` = 'money', `time` = '$time'");
mysql_query("UPDATE `kolhoz_collective` SET `money` = '".($mc['money']+$nmoney)."' WHERE `id` = '$mc[id]'");
}
header("Location:/warehouse/");
exit;
}
echo "<div><h3>Овощи</h3>";
echo "<ul class='ptm'>";
$q=mysql_query("SELECT * FROM `kolhoz_warehouse` WHERE `id_user` = '$ku[id]' AND `arena` = '0'");
if(mysql_num_rows($q)==0)echo "<li>В амбаре нету овощей</li>";
$cm=0;
while($post=mysql_fetch_array($q))
{
$plant=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_plant` WHERE `id` = '$post[id_plant]'"));
$m=floor(($plant['money']/$plant['count'])*$post['count']);
echo "<li><div><img src='/img/icons/tomato.png' alt='o'><span class='n'>".hsc($plant['name'])."</span> (<span>$post[count]</span>): <a href='/warehouse/corm/$post[id]'>В кормушку</a>, <a href='/warehouse/sell/$post[id]'>Продать</a> за <img src='/img/icons/money.png' alt='o'><span>$m</span>
</div></li>";
$cm=$cm+$m;
}
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `kolhoz_warehouse` WHERE `id_user` = '$ku[id]' AND `arena` ='0'"),0)!=0)echo "<li><img alt='*' src='/img/icons/money.png'> <a href='/warehouse/SellAll'>Продать всё</a> за <img src='/img/icons/money.png' alt='o'><span>$cm</span></li>";
echo "<div><h3>Кормушка</h3>";
echo "<ul class='ptm'>";
$q=mysql_query("SELECT * FROM `kolhoz_warehouse` WHERE `id_user` = '$ku[id]' AND `arena` = '1'");
if(mysql_num_rows($q)==0)echo "<li>В кормушке нет овощей</li>";
$cm=0;
while($post=mysql_fetch_array($q))
{
$plant=mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_plant` WHERE `id` = '$post[id_plant]'"));
echo "<li><div><img src='/img/icons/tomato.png' alt='o'><span class='n'>".hsc($plant['name'])."</span> (<span>$post[count]</span>): <a href='/warehouse/NOcorm/$post[id]'>Убрать из кормушки</a></span>
</div></li>";
}
echo "<div><h3>Сундуки</h3>";
echo "<ul class='ptm'>";
$q=mysql_query("SELECT * FROM `chest` WHERE `id_user` = '$ku[id]' AND `time` >='$time'");
if(mysql_num_rows($q)==0)echo "<li>Сундуков нет....</li>";
while($post=mysql_fetch_array($q))
{
$name=mysql_fetch_array(mysql_query("SELECT * FROM `chest` WHERE `id` = '$post[id]' AND `time` >= '$time'"));
if($name['type']==6){$nameChest=Проклятый;
$link=magic; }
if($name['type']==5){$nameChest=Золотой;
$link=gold;}
if($name['type']==4){$nameChest=Серебрянный;
$link=silver;}
if($name['type']==3){$nameChest=Бронзовый;
$link=bronze;}
if( $name['type']==2){$nameChest=Обычный;
$link=normal;}
if($name['type']==1){$nameChest=Открытый;
$link=open;}
$key =mysql_fetch_array(mysql_query("SELECT * FROM `key_user` WHERE `id_user` = '$ku[id]'"));
echo "<li><div><img src='/img/icons/chest.png' alt='o'><span class='n'> ".hsc($nameChest)." сундук</span> (<span>исчезнет через ".time_left($name['time']-$time)." </span>):";
if($name['type']==1)echo" <a href='/chest/$link/$post[id]'>Открыть</a>";
if($name['type']!=1 && $key[$link]>0)echo" <a href='/chest/$link/$post[id]'>Открыть</a>";
if($name['type']!=1 && $key[$link]<1)echo" <a href='/shop/key'>Купить ключ</a></span>
</div></li>";
}
echo "</ul></div></div>";
echo "<div class='pt'><img src='/img/icons/tomato.png' alt='*'> <a href='/buyPlant'>Купить овощи</a></div></div>";
echo"</div></div></div><div class='rzd2'></div>";
include_once '../system/foot.php';
?>