Файл: world-faces.ru/world-faces.ru/fermer/gr.php
Строк: 72
<?php
include_once '../i.php';
$set['title']='Моя ферма!';
verh();
err();
aut();
if(mysql_result(mysql_query("SELECT count(id) FROM `my_apps` where `id_us` = '".$us['id']."' and `id_app` = '1'"),0)==0){
pdo();
$app = DB::$dbs->queryFetch("SELECT * FROM `apps` where `id` = ? limit 1",array(1));
function ret($type){
$type = str_replace('И','и',$type);
$type = str_replace('а','ы',$type);
$type = str_replace('П','п',$type);
$type = str_replace('ие','ия',$type);
return $type;
}
echo '<div class="title" align="center">Запуск '.ret($app['type']).' | <a href="/play">закрыть</a></div>';
echo '<div class="prof"><img src="'.$app['img'].'" align="middle" alt="'.$app['name'].'"/><b>'.$app['name'].'</b><br/>'.$app['opis'].'</div>';
echo '<div class="app">Запустили уже <b>'.DB::$dbs->querySingle("SELECT count(id) FROM `my_apps` where `id_app` = '1'").'</b> человек! <a href="?add"><input type="submit" value="Запустить '.$app['name'].'!"/></a></div>';
if(isset($_GET['add'])){
DB::$dbs->query("INSERT INTO `my_apps` set `id_us` = ?, `id_app` = ?",array($us['id'],1));
$text = 'запустил'.(($us['pol']==0)?'а':'').' приложение <b>[url='.$app['src'].']"'.$app['name'].'"[/url]</b>!';
DB::$dbs->query("INSERT INTO `lenta_saita` set `user` = ?, `time` = ?,`action` = ?",array($us['nick'],time(),$text));
header('location:'.$app['src'].'');
}
niz(); exit;
}
$id = (isset($_GET['id'])) ? $_GET['id'] : NULL;
$ok = (isset($_GET['ok'])) ? $_GET['ok'] : NULL;
$get = (isset($_GET['get'])) ? $_GET['get'] : NULL;
$sob_ok = (isset($_GET['sob_ok'])) ? $_GET['sob_ok'] : NULL;
$sadit = (isset($_POST['sadit'])) ? $_POST['sadit'] : NULL;
$udobr = (isset($_POST['udobr'])) ? $_POST['udobr'] : NULL;
$woter = (isset($_GET['woter'])) ? $_GET['woter'] : NULL;
$int=intval($id);
$sadit=htmlspecialchars($sadit);
$udobr=htmlspecialchars($udobr);
$post = mysql_fetch_array(mysql_query("select * from `fermer_gr` WHERE `id` = '$int' LIMIT 1"));
if(isset($ok))msg('Новое ростение посажено!');
if(isset($sob_ok))msg('Урожай собран!');
if(isset($sadit) && $post && $user['id']==$post['id_user'] && $post['semen']==0){
$res = mysql_fetch_array(mysql_query("select * from `fermer_semen` WHERE `id` = '$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_semen` SET `kol` = `kol`-'1' WHERE `id` = $sadit LIMIT 1");
}else{
mysql_query("DELETE FROM `fermer_semen` WHERE `id` = '$sadit'");
}
header("Location: inc/header.php?gr=".$int."");
}
if(isset($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]' "));
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 `water` = '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 `water` = '0' WHERE `id` = $int LIMIT 1");
header("Location: inc/header.php?gr2=".$int."");
}
if(isset($udobr) && $post && $user['id']==$post['id_user'] && $post['semen']!=0)
{
$res = mysql_fetch_array(mysql_query("select * from `fermer_udobr` WHERE `id` = '$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` = $udobr LIMIT 1");
}else{
mysql_query("DELETE FROM `fermer_udobr` WHERE `id` = udobr ");
}
header("Location: my.php?udobr_ok");
}
if(isset($woter) && $post['woter']!=1){
mysql_query("UPDATE `fermer_gr` SET `woter` = '1' WHERE `id` = $int LIMIT 1");
msg('Успешно полито!!!');
}
aut();
include 'inc/str.php';
if($post){
if($user['id']==$post['id_user']){
include 'inc/gr.php';
}else{echo "<div class='err'>Это не ваша грядка!</div>";}
}else{echo "<div class='err'>Такой грядки не существует!!!</div>";}
echo "<div class='foot'>";
echo "« <a href='my.php'>Назад</a><br/>";
echo "« <a href='index.php'>На ферму</a><br/>";
echo "</div>";
include_once '../sys/inc/tfoot.php';
?>