Файл: world-faces.ru/world-faces.ru/fermer/my.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;
}
$add_ok = (isset($_GET['add_ok'])) ? $_GET['add_ok'] : NULL;
$udobr_ok = (isset($_GET['udobr_ok'])) ? $_GET['udobr_ok'] : NULL;
$gr_add = (isset($_GET['gr_add'])) ? $_GET['gr_add'] : NULL;
$add_no = (isset($_GET['add_no'])) ? $_GET['add_no'] : NULL;
if(isset($add_ok))msg('Грядка приобретена!');
if(isset($udobr_ok))msg('Растение удобрено!');
if(isset($add_no))echo '<div class="err">Ваш уровень должен быть больше 5!</div>';
if(isset($gr_add) && $user['fermer_money']>=5000){
if($level>=5){
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');}
}
include 'inc/str.php';
$add = (isset($_GET['add'])) ? $_GET['add'] : NULL;
if(isset($add)){
echo "Стоимость одной грядки составляет 5000$";
echo "<form method='post' action='?gr_add'>n";
echo "<input type='submit' name='save' value='Приобрести!' />n";
echo "</form>n";
}else{
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `fermer_gr` WHERE `id_user` = '$user[id]'"),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` = '$user[id]' 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'];}
$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($time<$post['time'])$time_1="(".$day.$hourfield."ч. ".$minutefield."м.)";
else$time_1=" (<span class='off'>Пора собирать!</span>)";
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 "<img src='img/$post[semen].gif' height='20' width='20'><b>»</b> <a href='gr.php?id=$post[id]'>".$name_gr."</a>";
if($post['semen']!=0)
echo " ".$time_1."";
echo "<br/>n";
}
if ($k_page>1)str('?',$k_page,$page); // Вывод страниц
}
echo "<div class='foot'>";
echo "» <a href='my.php?add'>Купить грядку</a><br/>";
echo "« <a href='index.php'>Назад</a><br/>";
echo "</div>";
include_once '../sys/inc/tfoot.php';
?>