Файл: world-faces.ru/world-faces.ru/fermer/fermers_gr.php
Строк: 86
<?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;
$int=intval($id);
echo '<center><img src="/fermer/img/neighbors.gif" /> </center>';
$ank=mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id`= $int LIMIT 1"));
if($id==$user['id'])header('Location: my.php');
include 'inc/str.php';
$vor = (isset($_GET['vor'])) ? $_GET['vor'] : NULL;
$vor=htmlspecialchars($vor);
$gr=htmlspecialchars($gr);
if(isset($vor)){
$gr = mysql_fetch_array(mysql_query("select * from `fermer_gr` WHERE `id` = $vor "));
$semen = mysql_fetch_array(mysql_query("select * from `fermer_name` WHERE `id` = '$gr[semen]' "));
$qi = mysql_fetch_assoc(mysql_query("SELECT * FROM `fermer_vor` WHERE `id_user` = '$user[id]' AND `gr` = $vor LIMIT 1"));
if($qi['time']<$time){
$rand1=floor($semen['rand1']/5);
$rand2=floor($semen['rand2']/5);
$rand=rand($rand1,$rand2);
$dog=mysql_fetch_array(mysql_query("select * from `fermer_dog` WHERE `id_user` = '$ank[id]' "));
if($dog['time']<$time){
$t=$time+86400;
mysql_query("INSERT INTO `fermer_vor` (`id_user` , `gr`, `time`) VALUES ('".$user['id']."', '".$vor."', '".$t."') ");
mysql_query("UPDATE `user` SET `fermer_oput` = `fermer_karma`- '1' WHERE `id` = $user[id] LIMIT 1");
if($gr['kol']>$rand){
mysql_query("UPDATE `fermer_gr` SET `kol` = `kol`- $rand WHERE `id` = $vor LIMIT 1");
mysql_query("INSERT INTO `fermer_sclad` (`kol` , `semen`, `id_user`) VALUES ('".$rand."', '".$gr['semen']."', '".$user['id']."') ");
}else{
$rand=mysql_result(mysql_query("SELECT `kol` FROM `fermer_gr` WHERE `id` = $vor "),0);
mysql_query("UPDATE `fermer_gr` SET `semen` = '0' WHERE `id` = $vor LIMIT 1");
mysql_query("UPDATE `fermer_gr` SET `time` = NULL WHERE `id` = $vor LIMIT 1");
mysql_query("UPDATE `fermer_gr` SET `kol` = NULL WHERE `id` = $vor LIMIT 1");
mysql_query("INSERT INTO `fermer_sclad` (`kol` , `semen`, `id_user`) VALUES ('".$rand."', '".$gr['semen']."', '".$user['id']."') ");
}
msg('Украдено '.$rand.'!!!');
}else{
mysql_query("UPDATE `user` SET `fermer_money` = `fermer_money` - $rand WHERE `id` = $user[id] LIMIT 1");
mysql_query("UPDATE `user` SET `fermer_money` = `fermer_money` + $rand WHERE `id` = $ank[id] LIMIT 1");
$rand=rand(1,100);
echo '<div class="err">На вас напала собака фермера! При побеге вы потеряли '.$rand.' монет!!!</div>';
}
}else{echo "<div class='err'>С этой грядки больше воровать нелзя!!!</div>";}
}
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `fermer_gr` WHERE `id_user` = '".$int."'"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
$res = mysql_query("select * from `fermer_gr` WHERE `id_user` = '".$int."' LIMIT $start, $set[p_str];");
while ($post = mysql_fetch_array($res)){
$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'];}
echo "<img src='img/$post[semen].gif' height='20' width='20'><b>»</b> ".$name_gr."";
if($post['semen']!=0 && $post['time']<$time){
echo " (".$post['kol'].") ";
$qi = mysql_fetch_array(mysql_query("SELECT * FROM `fermer_vor` WHERE `id_user` = '$user[id]' AND `gr` = '$post[id]' LIMIT 1"));
if($qi['time']<$time)
echo "<a href='?id=".$int."&vor=".$post['id']."'>[Воровать!]</a>";
}else{if($post['semen']!=0)echo " (Созревает)";}
echo "<br/>";
}
if ($k_page>1)str('?',$k_page,$page);
echo "<div class='foot'>";
echo "« <a href='my.php'>Моя ферма</a><br/>";
echo "« <a href='fermers.php'>Назад</a><br/>";
echo "</div>";
include_once '../sys/inc/tfoot.php';
?>