<?php
require_once ('../system/func.php');
$title = "Старый лавочник";
require_once ('../system/header.php');
if(isset($user['id']))
{
if(isset($_GET['kamen']))
{
if($user['crystals'] < $user[level]*150)
{
$_SESSION[msg] = "Не хватает  ".($user[level]*150-$user[crystals])." кристаллов";
header('Location: /merchant');
exit();
}
mysql_query("update `users` set `kamen` = '".($user['kamen']+1)."', `crystals` = '".($user['crystals']-$user[level]*150)."' where (`id` = '".$user['id']."')");
$_SESSION[msg] = "Камень успешно куплен";
header('Location: /merchant');
exit();
}
if(isset($_GET['trava']))
{
if($user['crystals'] < $user[level]*125)
{
$_SESSION[msg] = "Не хватает  ".($user[level]*125-$user[crystals])." кристаллов";
header('Location: /merchant');
exit();
}
mysql_query("update `users` set `trava` = '".($user['trava']+1)."', `crystals` = '".($user['crystals']-$user[level]*125)."' where (`id` = '".$user['id']."')");
$_SESSION[msg] = "Трава успешно куплена";
header('Location: /merchant');
exit();
}
echo "
<div class='mess_blue'>Старый лавочник</div>
<div class='taverna_logo'></div>
<div class='blt blue'><img src='/images/icons/kamen.png' width='12px' alt='*' /> Камень 
<img src='/style/style/strength.png' width='12px' alt='*' /> <span class='minor'>+ 35%</span>
<img src='/style/style/time.png' width='12px' alt='*' /> на <span class='green'>30 сек.</span>  - (".$user['kamen']." шт.)</div>
<a href='?kamen' class='btn' title='Купить'>
<img src='/style/style/strength.png' width='12px' alt='*' /> <span class='money'>Купить за</span> 
<img src='/style/style/crystal.png' width='12px' alt='*' />  <span class='minor'>".($user[level]*150)."</span></a>
<div class='blt blue'><img src='/images/icons/trava.png' width='12px' alt='*' /> Трава
<img src='/style/style/armor.png' width='12px' alt='*' /> <span class='minor'>+ 35%</span>
<img src='/style/style/time.png' width='12px' alt='*' /> на <span class='green'>30 сек.</span>  - (".$user['trava']." шт.)</div>
<a href='?trava' class='btn' title='Купить'>
<img src='/style/style/strength.png' width='12px' alt='*' /> <span class='money'>Купить за</span> 
<img src='/style/style/crystal.png' width='12px' alt='*' />  <span class='minor'>".($user[level]*125)."</span></a>";
}
else
{
header('Location: /start');
}
require_once ('../system/footer.php');
?>