View file gr.php
<?php include_once ('sys/index.php'); head('Моя ферма! - Грядка'); if(isset($user)){ $int=intval($_GET['id']); $post = mysql_fetch_array(mysql_query("select * from `fermer_gr` WHERE `id` = '$int' LIMIT 1")); if(isset($_GET['ok']))msg('Новое ростение посажено!'); if(isset($_GET['sob_ok']))msg('Урожай собран!'); if(isset($_POST['sadit']) && $post && $user['id']==$post['id_user'] && $post['semen']==0) { $res = mysql_fetch_array(mysql_query("select * from `fermer_sclad` WHERE `id` = '$_POST[sadit]' ")); $semen = mysql_fetch_array(mysql_query("select * from `fermer_name` WHERE `id` = '$res[semen]' ")); $t=$time+$semen['time']; mysql_query("UPDATE `fermer_gr` SET `semen` = $res[semen] WHERE `id` = $int LIMIT 1"); mysql_query("UPDATE `fermer_gr` SET `time` = '$t' WHERE `id` = $int LIMIT 1"); if($res['kol']>=2){ mysql_query("UPDATE `fermer_sclad` SET `kol` = `kol`-'1' WHERE `id` = $_POST[sadit] LIMIT 1"); }else{ mysql_query("DELETE FROM `fermer_sclad` WHERE `id` = $_POST[sadit] "); } header("Location: inc/header.php?gr=".$int.""); } if(isset($_GET['get']) && $user['id']==$post['id_user'] && $post['semen']!=0 && $post['time']<$time) { $semen = mysql_fetch_array(mysql_query("select * from `fermer_name` WHERE `id` = '$post[semen]' ")); $remils = mysql_result(mysql_query("SELECT COUNT(*) FROM `fermer_sclad` WHERE `id_user` = '$user[id]' AND `semen` = '$post[semen]'"),0); if($remils>0) mysql_query("UPDATE `fermer_sclad` SET `kol` = `kol`+ '".$post['kol']."' WHERE `id_user` = $user[id] AND `semen` = '$post[semen]' LIMIT 1"); else mysql_query("INSERT INTO `fermer_sclad` (`kol` , `semen`, `id_user`) VALUES ('".$post['kol']."', '".$post['semen']."', '".$user['id']."') "); mysql_query("UPDATE `user` SET `fermer_oput` = `fermer_oput`+ '".$semen['oput']."' WHERE `id` = $user[id] LIMIT 1"); mysql_query("UPDATE `fermer_gr` SET `semen` = '0' WHERE `id` = $int LIMIT 1"); mysql_query("UPDATE `fermer_gr` SET `time` = NULL WHERE `id` = $int LIMIT 1"); mysql_query("UPDATE `fermer_gr` SET `woter` = '0' WHERE `id` = $int LIMIT 1"); mysql_query("UPDATE `fermer_gr` SET `kol` = '0' WHERE `id` = $int LIMIT 1"); mysql_query("UPDATE `fermer_gr` SET `woter` = '0' WHERE `id` = $int LIMIT 1"); header("Location: inc/header.php?gr2=".$int.""); } if(isset($_POST['udobr']) && $post && $user['id']==$post['id_user'] && $post['semen']!=0) { $res = mysql_fetch_array(mysql_query("select * from `fermer_udobr` WHERE `id` = '$_POST[udobr]' ")); $semen = mysql_fetch_array(mysql_query("select * from `fermer_udobr_name` WHERE `id` = '$res[udobr]' ")); mysql_query("UPDATE `fermer_gr` SET `time` = `time`- $semen[time] WHERE `id` = $int LIMIT 1"); if($res['kol']>=2){ mysql_query("UPDATE `fermer_udobr` SET `kol` = `kol`-'1' WHERE `id` = $_POST[udobr] LIMIT 1"); }else{ mysql_query("DELETE FROM `fermer_udobr` WHERE `id` = $_POST[udobr] "); } header("Location: my.php?udobr_ok"); } if(isset($_GET['woter']) && $post['woter']!=1){ mysql_query("UPDATE `fermer_gr` SET `woter` = '1' WHERE `id` = $int LIMIT 1"); msg('Успешно полито!!!'); } if($post){ if($user['id']==$post['id_user']){ include 'inc/gr.php'; }else{echo "<div class='ferma_menu'>Это не ваша грядка!</div>";} }else{echo "<div class='ferma_menu'>Такой грядки не существует!!!</div>";} echo "<div class='ferma_rekl'>"; echo "« <a href='my.php'>Моя ферма</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(); ?>