Вход Регистрация
Файл: bloodlands.pw/city/1/pitomnik.php
Строк: 140
<?php
define
('cms'1);
$title 'Питомник Милены';
$patch '../../';
require_once 
$patch.'core.php';

if (
$user && $us['city'] == 1) {
echo 
'<div class="pt" align="">';
switch (
$_GET['a']){
default:
echo 
'<div class="menu">Питомник Милены</div><br/><a href="'.$patch.'img/locations/mila.jpg">
<img src="'
.$patch.'img/locations/mila.jpg" alt="" height="110"></a><br/><br/>
У меня есть разные питомцы, каждый по своему хорош.<br/>Но брать на охоту ты сможешь только одного.<br/><br/>
<a class="linestart" href="?a=buy">Купить питомца</a>
<a class="line" style="border-top:0;border-radius:0;" href="?a=food">Корм для питомцев</a>
<a class="lineend" href="?a=my">Мои питомцы</a><div style="margin-bottom:4px;"></div><br/>
<a class="linestart" href="'
.$patch.'bag.php">Инвентарь</a>';
break;

case 
'food':
echo
'<br/>';
$all mysql_result(mysql_query("select count(*) from `pit_food`"),0);

if(
$all 0){
$total intval(($all-1)/$us['kol'])+1;
$page abs(intval($_GET['page']));
if(empty(
$page) OR $page <= 0$page 1;
if(
$page $total$page $total;
$past intval($all/$us['kol']);
$start round($page*$us['kol']-$us['kol']);

$query mysql_query("select * from `pit_food` order by `id` ASC LIMIT ".$start.",".$us['kol']."");
while(
$res mysql_fetch_assoc($query)){
echo 
'<a class="linestart" href="'.$patch.'things.php?a=food&amp;id='.$res['id'].'">'.$res['name'].'</a>
<a class="lineend" href="?a=buy_food&amp;id='
.$res['id'].'">Купить за '.$res['cost'].' септим</a><div style="margin-bottom:4px;"></div><br/>';
}

navigation($all,$us['kol'],$page,'?a=food&',$total);

} else echo 
'У меня еще нет корма на продажу!<br/>';
echo
'<br/><center><a class="linestart" href="?">К Милене</a></center>';
break;

case 
'buy_food':
if (
$id or $id != 0){
if(empty(
$_POST['ok'])){
echo
'<div class="menu">Питомник Милены</div><br/><a href="'.$patch.'img/locations/mila.jpg">
<img src="'
.$patch.'img/locations/mila.jpg" alt="" height="110"></a><br/><br/>
<form method="POST" action="?a=buy_food&amp;id='
.$id.'"><b>Сколько данного корма<br/>вы хотите приобрести?</b><br/><br />
<input type="text" name="kol" value="1" class="text"><input name="ok" type="submit" value="Купить" class="button"></form>'
;
} else {
$kol abs(intval($_POST['kol']));
$i mysql_fetch_array(mysql_query("SELECT * FROM `pit_food` WHERE `id` = '".$id."'"));
if(empty(
$i)) header('Location: '.$patch.'city/'.$us['city'].'/pitomnik.php');

$error '';
$cost round($i['money']*$kol);
if(
$kol <= 0$error .= 'Неверное количество!<br/>';
if(
$us['money'] < $cost$error .= 'Вам нехватает септим!<br/>';

if(empty(
$error)){
if(
mysql_result(mysql_query("SELECT count(*) FROM `bag` WHERE `tip` = '".$i['tip']."' AND `type` = '".$i['type']."' AND `num` = '".$i['num']."' AND `user` = '".$user."'"),0) == 0)
mysql_query("INSERT INTO `bag` SET `kol` = '".$kol."', `cost` = '".$i['cost']."', `num` = '".$i['num']."', `type` = '".$i['type']."', `title` = '".$i['name']."', `rost` = '".$i['rost']."', `energy` = '".$i['energy']."', `hp` = '".$i['hp']."', `tip` = '".$i['tip']."', `user` = '".$user."'");
else 
mysql_query("UPDATE `bag` SET `kol` = (`kol` + ".$kol.") WHERE `user` = '".$user."' AND `num` = '".$i['num']."' AND `type` = '".$i['type']."' AND `tip` = '".$i['tip']."'");
mysql_query("UPDATE `users` SET `money` = (`money` - ".$cost.") WHERE `id` = '".$user."'");

echo
'<div class="menu">Питомник Милены</div><br/><a href="'.$patch.'img/locations/mila.jpg">
<img src="'
.$patch.'img/locations/mila.jpg" alt="" height="110"></a><br/><br/>
Корм <b>'
.$i['name'].'</b>*'.$kol.' успешно куплен!<br/>
<a class="line" href="?a=food">К кормам</a><div style="margin-bottom:4px;"></div>'
;
} else echo 
'<div class="error">'.$error.'</div>';}}
echo
'<br/><center><a class="linestart" href="?">К Милене</a></center>';
break;

case 
'buy':
echo
'<br/>';
$all mysql_result(mysql_query("select count(*) from `pitomec`"),0);

if(
$all 0){
$total intval(($all-1)/$us['kol'])+1;
$page abs(intval($_GET['page']));
if(empty(
$page) OR $page <= 0){
$page 1;
}
if(
$page $total){
$page $total;
}
$past intval($all/$us['kol']);
$start $page*$us['kol']-$us['kol'];

$query mysql_query("select * from `pitomec` order by `id` ASC LIMIT ".$start.",".$us['kol']."");
while(
$res mysql_fetch_assoc($query)){
echo 
'<a class="linestart" href="'.$patch.'npc.php?a=pit&amp;id='.$res['id'].'">'.$res['name'].'['.$res['lvl'].']</a>
<a class="lineend" href="?a=buy_pit&amp;id='
.$res['id'].'">Купить за '.$res['cost'].' септим</a><div style="margin-bottom:4px;"></div><br/>';
}

navigation($all,$us['kol'],$page,'?a=buy&',$total);

} else echo 
'У меня еще нет питомцев!<br/>';
echo
'<br/><center><a class="linestart" href="?">К Милене</a></center>';
break;

case 
'buy_pit':
if (
$id or $id != 0){
if(empty(
$_POST['ok'])){
echo
'<div class="menu">Питомник Милены</div><br/><a href="'.$patch.'img/locations/mila.jpg">
<img src="'
.$patch.'img/locations/mila.jpg" alt="" height="110"></a><br/><br/>
<form method="POST" action="?a=buy_pit&amp;id='
.$id.'"><b>Дайте имя питомцу [30]:</b><br/>
<input type="text" name="title" class="text">
<input name="ok" class="button" type="submit" value="Купить"></form>'
;
} else {
$title filter($_POST['title']);
$i mysql_fetch_array(mysql_query("SELECT * FROM `pitomec` WHERE `id` = '".$id."'"));
if(empty(
$i)) header('Location: '.$patch.'pitomnik.php');
$error '';

if(
$us['money'] < $i['cost']) $error .= 'У вас недостаточно септим!<br/>';
if(
$us['level'] < $i['lvl']) $error .= 'Вы еще не достигли нужного уровня!<br/>';
if(
mb_strlen($title) < || mb_strlen($title) > 30$error .= 'Неверное количество символов в имени!<br/>';
if(
mysql_result(mysql_query("SELECT count(*) FROM `pit` WHERE `user` = '".$user."'"),0) == 1$error .= 'У вас уже есть питомец!<br/>';

if (empty(
$error)){
$ok mysql_query("INSERT INTO `pit` SET `num` = '".$i['id']."', `lvl` = '".$i['lvl']."', `max_lvl` = '".$i['max_lvl']."', `cost` = '".$i['cost']."', `hp` = '".$i['hp']."', `hp_all` = '".$i['hp']."', `energy` = '".$i['energy']."', `damage` = '".$i['damage']."', `armor` = '".$i['armor']."', `energy_all` = '".$i['energy']."', `uvorot` = '".$i['uvorot']."', `tochnost` = '".$i['tochnost']."', `user` = '".$user."', `title` = '".$title."'");

if(
$ok){
mysql_query("UPDATE `users` SET `money` = (`money` - ".$i['cost'].") WHERE `id` = '".$user."' ");

echo 
'<div class="menu">Питомник Милены</div><br/><a href="'.$patch.'img/locations/mila.jpg">
<img src="'
.$patch.'img/locations/mila.jpg" alt="" height="110"></a><br/><br/>
Теперь у Вас есть питомец с именем: <b>'
.$title.'</b>!<br/><br/>
<a class="line" href="?a=my">К моим питомцам</a><div style="margin-bottom:4px;"></div>'
;
}} else echo 
'<div class="error">'.$error.'</div>';}}
echo
'<br/><center><a class="linestart" href="?">К Милене</a></center>';
break;

case 
'my':
echo
'<br/>';
$all mysql_result(mysql_query("select count(*) from `pit` WHERE `user` = '".$user."'"),0);

if(
$all 0){
$total intval(($all-1)/$us['kol'])+1;
$page abs(intval($_GET['page']));
if(empty(
$page) OR $page <= 0$page 1;
if(
$page $total$page $total;
$past intval($all/$us['kol']);
$start round($page*$us['kol']-$us['kol']);

$query mysql_query("select * from `pit` WHERE `user` = '".$user."' order by `id` ASC LIMIT ".$start.",".$us['kol']."");
while(
$res mysql_fetch_assoc($query)){
echo 
'<a class="linestart" href="'.$patch.'npc.php?a=pit_info&amp;id='.$res['id'].'">'.$res['title'].'['.$res['lvl'].'] - '.$res['energy'].' энергии</a>';
if(
$res['status'] == 1) echo'<a class="lineend" href="?a=ost&amp;id='.$res['id'].'">Оставить на отдых</a><div style="margin-bottom:4px;"></div><br/>';
else echo
'<a class="lineend" href="?a=come&amp;id='.$res['id'].'">Взять на охоту</a><div style="margin-bottom:4px;"></div><br/>';
}

navigation($all,$us['kol'],$page,'?a=buy&',$total);

} else echo 
'У Вас еще нет питомцев!<br/>';
echo
'<br/><center><a class="linestart" href="?">К Милене</a></center>';
break;

case 
'ost':
$kol mysql_result(mysql_query("select count(*) from `pit` WHERE `id` = '".$id."' AND `user` = '".$user."' AND `status` = '1'"),0);

if(
$kol == 1){
mysql_query("UPDATE `pit` SET `status` = '0' WHERE `id` = '".$id."' AND `user` = '".$user."' AND `status` = '1'");
header('Location: ?a=my');
} else echo
'<div class="error">Этот питомец еще не с Вами!</div>';
break;

case 
'come':
$kol mysql_result(mysql_query("select count(*) from `pit` WHERE `id` = '".$id."' AND `user` = '".$user."' AND `status` = '0'"),0);

if(
$kol == 1){
mysql_query("UPDATE `pit` SET `status` = '1' WHERE `id` = '".$id."' AND `user` = '".$user."' AND `status` = '0'");
header('Location: ?a=my');
} else echo
'<div class="error">Этот питомец уже с Вами!</div>';
break;

}} else 
header('Location: '.$patch.'index.php');
include 
$patch.'include/foot.php';
?>
Онлайн: 0
Реклама