View file my.php
<?php include_once ('sys/index.php'); head('Моя ферма!'); if(isset($user)){ if(isset($_GET['add_ok']))msg('Грядка приобретена!'); if(isset($_GET['udobr_ok']))msg('Растение удобрено!'); if(isset($_GET['add_no']))msg('Ваш уровень должен быть больше 5!'); if(isset($_GET['gr_add']) && $user['fermer_money']>=5000) { if($level<=50){ mysql_query("UPDATE `user` SET `fermer_money` = `fermer_money`- '5000' WHERE `id` = $user[id] LIMIT 1"); mysql_query("INSERT INTO `fermer_gr` (`semen`, `id_user`) VALUES ( '0', '".$user[id]."') "); header('Location: my.php?add_ok'); }else{header('Location: my.php?add_no');} } if(isset($_GET['add'])){ echo '<div class="ferma_menu">'; echo "Стоимость одной грядки составляет 5000 монет "; echo "<form method='post' action='?gr_add'>\n"; echo "<input type='submit' name='save' value='Приобрести!' />\n"; echo "</form>\n"; echo '</div>'; } else{ $k=mysql_result(mysql_query("SELECT COUNT(*) FROM `fermer_gr` WHERE `id_user` = '$user[id]'"),0); $k_page = ceil($k / $SET['p_str']); $page = page(); $start=$SET['p_str']*$page-$SET['p_str']; $res = mysql_query("select * from `fermer_gr` WHERE `id_user` = '$user[id]' LIMIT $start, $SET[p_str];"); echo'<div class="ferma_menu"><img src="/img/neighbors.gif"/></div>'; while ($post = mysql_fetch_array($res)){ $semen=mysql_fetch_array(mysql_query("select * from `fermer_name` WHERE `id` = '$post[semen]' LIMIT 1")); $p = mysql_fetch_array(mysql_query("select * from `fermer_gr` WHERE `id` = '$post[id]' LIMIT 1")); if($p['semen']!=0 && $time>$p['time'] && $p['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` = '$post[id]' LIMIT 1"); } if($post['semen']==0){$name_gr='Пустая грядка';}else{$name_gr=$semen['name'];} $vremja=$post['time']-$time; $timediff=$vremja; $oneMinute=60; $oneHour=3600; $oneDay=86400; $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.'д. '; else $day=''; if($hourfield>0)$hour=$hourfield.'ч. '; else $hour=''; if($minutefield>0)$min=$minutefield.'м. '; else $min=''; if($time<$post['time'])$time_1="До сбора осталось: ".$day.$hour.$min.$secondfield."с."; else$time_1="Урожай поспел!"; if($post['semen']!=0 && $time>$post['time'] && $post['kol']==0) { $pt=rand($semen['rand1'],$semen['rand2']); mysql_query("UPDATE `fermer_gr` SET `kol` = $pt WHERE `id` = $int LIMIT 1"); } echo '<div class="ferma_menu"> <img src="img/product/'.$post['semen'].'.jpg" alt="*" class="portrait" /> <a href="gr.php?id='.$post['id'].'">'.htmlspecialchars($name_gr).'</a><br/> '; if($post['semen']!=0) echo "".$time_1.""; echo '<br/> '; if($post['time']>0 && $post['time']<=$time)echo '<img src="img/icon/harvest.png" alt="*" /> <a href="gr.php?id='.$post['id'].'&get">Собрать урожай</a> '; echo '<br/> </div>'; } if ($k_page>1)str('my.php?',$k_page,$page); // Вывод страниц } echo "<div class='ferma_rekl'>"; if(isset($_GET['add'])) echo"« <a href='my.php'>Моя ферма</a><br/>"; else echo "» <a href='my.php?add'>Купить грядку</a><br/>"; echo "« <a href='index.php'>На главную</a><br/>"; echo "</div>"; }else{ msg('Только для авторизованых пользователей!'); echo "<div class='ferma_rekl'>"; echo "« <a href='index.php'>На главную</a><br/>"; echo "</div>"; } foot(); ?>