Файл: world-faces.ru/world-faces.ru/fermer/storage.php
Строк: 60
<?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);
$id=intval($id);
$sell_ok = (isset($_GET['sell_ok'])) ? $_GET['sell_ok'] : NULL;
if(isset($sell_ok))msg('Продано!');
aut();
echo '<center><img src="/fermer/img/warehouse.gif" /> </center>';
include 'inc/str.php';
if(isset($id)){
$post=mysql_fetch_array(mysql_query("select * from `fermer_sclad` WHERE `id`= '$id' LIMIT 1"));
$semen=mysql_fetch_array(mysql_query("select * from `fermer_name` WHERE `id` = '$post[semen]' LIMIT 1"));
$dohod=$post['kol']*$semen['dohod'];
if(isset($_GET['sell'])){
mysql_query("UPDATE `user` SET `fermer_money` = `fermer_money`+ $dohod WHERE `id` = $user[id] LIMIT 1");
mysql_query("DELETE FROM `fermer_sclad` WHERE `id` = '$id' ");
header('Location: storage.php?sell_ok');
}
echo "<img src='img/$post[semen].gif' alt=''><br/>» <b>".$semen['name']."</b><br/>";
echo "» Количество урожая: <b>".$post['kol']."</b> <br/>";
echo "» Цена за единицу: <b>".$semen['dohod']."</b> <br/>";
echo "» Общий доход: <b>".$dohod."</b> <br/>";
echo "<form method='post' action='?id=".$int."&sell'>n";
echo "<input type='submit' name='save' value='Продать!' />n";
echo "</form>n";
echo "<div class='foot'>";
echo "« <a href='storage.php'>Склад</a><br/>";
echo "</div>";
}else{
$k_post=mysql_result(mysql_query("SELECT COUNT(*) FROM `fermer_sclad` 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'];
if($k_post==0){echo "<div class='block'>На складе товаров нет</div>";}
$res = mysql_query("select * from `fermer_sclad` 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"));
echo "<img src='img/$post[semen].gif' height='20' width='20'><b>»</b> <a href='?id=$post[id]'>".$semen['name']."</a> [".$post['kol']."] ";
echo "(<a href='?id=$post[id]&sell'><span class='off'>Продать!</span></a>)<br />";
}
if ($k_page>1)str('?',$k_page,$page); // Вывод страниц
}
echo "<div class='foot'>";
echo "« <a href='index.php'>Назад</a><br/>";
echo "</div>";
include_once '../sys/inc/tfoot.php';
?>