Просмотр файла inc/gr.php

Размер файла: 3.98Kb
<?php
$semen=mysql_fetch_array(mysql_query("select * from `fermer_name` WHERE  `id` = '$post[semen]'  LIMIT 1")); 
if($post['semen']==0){$name_gr='Пустая грядка';}else{$name_gr=$semen['name'];}
$vremja=$post['time']-$time;
$timediff=$vremja;
$oneMinute=60; 
$oneHour=60*60; 
$oneDay=60*60*24; 
$dayfield=floor($timediff/$oneDay); 
$hourfield=floor(($timediff-$dayfield*$oneDay)/$oneHour); 
$minutefield=floor(($timediff-$dayfield*$oneDay-$hourfield*$oneHour)/$oneMinute); 
$secondfield=floor(($timediff-$dayfield*$oneDay-$hourfield*$oneHour-$minutefield*$oneMinute)); 
if($dayfield>0)$day=$dayfield.'д. ';
if($post['semen']!=0){ 
if($time<$post['time'])$time_1=$day.$hourfield."ч. ".$minutefield."м.";
else$time_1=0;
}
echo '<div class="ferma_menu"><img src="img/product/'.$post['semen'].'.jpg" alt="*" /> '.htmlspecialchars($name_gr).'</div>';
if($post['semen']!=0){
if($time>$post['time']){

if($post['semen']!=0 && $post['kol']!=0)echo '
<div class="ferma_menu">
<img src="img/icon/harvest.png" alt="*" />
<a href="?id='.$int.'&amp;get"> Собрать урожай</a>
</div>
';


elseif($post['semen']!=0 &&  $post['kol']==0)echo '<div class="ferma_menu"><img src="img/icon/refresh.png" alt="*" /> Обновите страницу!</div>';
}
if($post['semen']!=0 && $time>$post['time'] && $post['kol']==0)
{
$pt=rand($semen['rand1'],$semen['rand2']);
if($post['woter']==0)$pt=floor($pt/2);
mysql_query("UPDATE `fermer_gr` SET `kol` = $pt WHERE `id` = $int LIMIT 1");
}
if($time<$post['time']){
$k2=mysql_result(mysql_query("SELECT COUNT(*) FROM `fermer_udobr` WHERE `id_user` = '$user[id]'"),0);
if($k2!=0){
$res2 = mysql_query("select * from `fermer_udobr` WHERE `id_user` = '$user[id]' "); 
echo '<div class="ferma_menu">
<form method="post" action="?id='.$int.'">
Удобрения:<br />
<select name="udobr">';
while ($post2 = mysql_fetch_array($res2)){
$semen2=mysql_fetch_array(mysql_query("select * from `fermer_udobr_name` WHERE  `id` = '$post2[udobr]'  LIMIT 1")); 
echo "<option value='".$post2['id']."'>".htmlspecialchars($semen2['name'])." [".$post2['kol']."]</option>";
}
echo "</select><br />\n";
echo "<input type='submit' name='save' value='Удобрить' />\n";
echo "</form></div>\n";
}else{
echo '<div class="ferma_menu">
<select name="cad" disabled="disabled" >
<option value="0" selected="selected">На складе удобрений нет!</option>
</select></div>';
}
echo "<div class='ferma_menu'> До сбора осталось: <b>".$time_1."</b> <br/>";
if($post['woter']==1){$w='Да';}else{$w='Нет';}
echo "Полито: <b>".$w."</b> <br/>";
if($post['woter']==0){echo "<a href='?id=".$int."&amp;woter'>Полить</a> <br/>";}
echo "</div>";
}else{
echo "<div class='ferma_menu'>
Опыт: <b>+".$semen['oput']."</b> <br/>
Количество урожая: <b>".$post['kol']."</b> <br/>
";

if($post['woter']==0)echo "*Вы потеряли половину урожая, не полив ферму! <br/>";
echo "Цена за единицу: <b>".$semen['dohod']."</b> <br/>";
$dohod=$post['kol']*$semen['dohod'];
echo "Общий доход: <b>".$dohod."</b></div>";
}
}else{
$k=mysql_result(mysql_query("SELECT COUNT(*) FROM `fermer_sclad` WHERE `id_user` = '$user[id]'"),0);
if($k!=0){
$res = mysql_query("select * from `fermer_sclad` WHERE `id_user` = '$user[id]' "); 
echo "<div class='ferma_menu'>";
echo "<form method='post' action='?id=".$int."&amp;$passgen'>\n";
echo "Семена:<br />\n<select name='sadit'>";
while ($post = mysql_fetch_array($res)){
$semen=mysql_fetch_array(mysql_query("select * from `fermer_name` WHERE  `id` = '$post[semen]'  LIMIT 1")); 
$name_gr=$semen['name'];
echo "<option value='".$post['id']."'>".$name_gr." [".$post['kol']."]</option>";
}
echo "</select><br />\n";
echo "<input type='submit' name='save' value='Посадить' />\n";
echo "</form>\n";
echo "</div>";
}else{
echo '<div class="ferma_menu">
<select name="cad" disabled="disabled" ><br />
<option value="0" selected="selected">На складе семян нет!</option>
</select></div>';
}
}
?>