<?php
require_once('conf/dbc.php');
require_once('conf/session_start.php');
require_once('conf/ban.php');
if ((!isset($_SESSION['id'])) or (!isset($_SESSION['nick'])))  {
?>
<script type="text/javascript">
  document.location.href = "reg.php?err_login=1";
</script>
<?php
};
$page_title = 'Владиан';
require_once('conf/head.php');
$user_id = abs(intval($_SESSION['id']));

 require_once('conf/top.php');
$H=getenv("HTTP_REFERER");
$user_id = abs(intval($_SESSION['id']));
$user=$dbc->query("SELECT * FROM`users` WHERE`id`='$user_id'")->fetch_assoc();
$s_glas_ploti=3700*$user['glas_ploti'];
$s_noga_snorka=5000*$user['noga_snorka'];
$s_k_kabana=2900*$user['k_kabana'];
$s_sch_krovik=7000*$user['sch_krovik'];
$s_hvost_psa=3370*$user['hvost_psa'];
$s_hvost_sobaki=2870*$user['hvost_sobaki'];
$summa=$s_k_kabana+$s_noga_snorka+$s_glas_ploti+$s_hvost_sobaki+$s_sch_krovik+$s_hvost_psa;
//////////////////////////////////////
switch($_GET[act]){
default:
?><br/><p class="name">Владиан</p>
 <div class='npc_title'>
<img src='img/ico/saharov.png'  style='float:left;margin-right:5px;'/>
		<b>Имя:</b> <b style='color:#faaa05'>Владиан</b></br>
		<b>Ранг:</b> Опытный<br/>
		<b>Расса:</b> Учёный<br/>
</div>
<div class='npc_border'></div>
   <div class='npc_title'><span class="bonus">- Привествую воин, имеются часть тела монстров-куплю, они мне нужны для исследований!
</div>
<div class='npc_border'></div><?php

if($user['glas_ploti']>0){echo'<p class="net">Посох: <span class="bonus">'.$user[glas_ploti].' шт.</span> <span class="white">(<img src="img/ico/materials.png"/>37*'.$user[glas_ploti].'  = <img src="img/ico/materials.png"/>'.$s_glas_ploti.')</span></p>
 <form enctype="multipart/form-data" method="post" action="?act=prod">
	 <input type="text" value="'.$user[glas_ploti].'" style="width:50%; height:18px;" class="input" name="sum" />
<input type="submit" style="width:70px;" class="input" value="продать" name="addchat"/>
     </form><p style="border-top: 1px solid #444e4f;"></p>';}

if($user['noga_snorka']>0){echo'<p class="net">Нога снорка: <span class="bonus">'.$user[noga_snorka].'  шт.</span> <span class="white">(<img src="img/ico/materials.png"/>50*'.$user[noga_snorka].'  = <img src="img/ico/materials.png"/>'.$s_noga_snorka.')</span></p>
 <form enctype="multipart/form-data" method="post" action="?act=prod2">
	 <input type="text" value="'.$user[noga_snorka].'" style="width:50%; height:18px;" class="input" name="sum2" />
<input type="submit" style="width:70px;" class="input" value="продать" name="addchat"/>
     </form><p style="border-top: 1px solid #444e4f;"></p>';}

if($user['k_kabana']>0){echo'<p class="net">Копыто кабана: <span class="bonus">'.$user[k_kabana].'  шт.</span> <span class="white">(<img src="img/ico/materials.png"/>29*'.$user[k_kabana].'  = <img src="img/ico/materials.png"/>'.$s_k_kabana.')</span></p>
 <form enctype="multipart/form-data" method="post" action="?act=prod3">
	 <input type="text" value="'.$user[k_kabana].'" style="width:50%; height:18px;" class="input" name="sum3" />
<input type="submit" style="width:70px;" class="input" value="продать" name="addchat"/>
     </form><p style="border-top: 1px solid #444e4f;"></p>';}

if($user['hvost_psa']>0){echo'<p class="net">Хвост псевдо-пса: <span class="bonus">'.$user[hvost_psa].'  шт.</span> <span class="white">(<img src="img/ico/materials.png"/>37*'.$user[hvost_psa].'  = <img src="img/ico/materials.png"/>'.$s_hvost_psa.')</span></p>
 <form enctype="multipart/form-data" method="post" action="?act=prod4">
	 <input type="text" value="'.$user[hvost_psa].'" style="width:50%; height:18px;" class="input" name="sum4" />
<input type="submit" style="width:70px;" class="input" value="продать" name="addchat"/>
     </form><br/>
<p style="border-top: 1px solid #444e4f;"></p>';}

if($user['sch_krovik']>0){echo'<p class="net">Щупальца кровососа: <span class="bonus">'.$user[sch_krovik].'  шт.</span> <span class="white">(<img src="img/ico/materials.png"/>70*'.$user[sch_krovik].'  = <img src="img/ico/materials.png"/>'.$s_sch_krovik.')</span></p>
 <form enctype="multipart/form-data" method="post" action="?act=prod5">
	 <input type="text" value="'.$user[sch_krovik].'" style="width:50%; height:18px;" class="input" name="sum5" />
<input type="submit" style="width:70px;" class="input" value="продать" name="addchat"/>
     </form><p style="border-top: 1px solid #444e4f;"></p>';}
if($user['hvost_sobaki']>0){echo'<p class="net">Рука зомби: <span class="bonus">'.$user[hvost_sobaki].'  шт.</span> <span class="white">(<img src="img/ico/materials.png"/>28*'.$user[hvost_sobaki].'  = <img src="img/ico/materials.png"/>'.$s_hvost_sobaki.')</span></p>
 <form enctype="multipart/form-data" method="post" action="?act=prod6">
	 <input type="text" value="'.$user[hvost_sobaki].'" style="width:50%; height:18px;" class="input" name="sum6" />
<input type="submit" style="width:70px;" class="input" value="продать" name="addchat"/>
     </form><br/>
<p style="border-top: 1px solid #444e4f;"></p>';}
echo'<p class="white">В сумме: <img src="img/ico/materials.png"/>'.$summa.'</p>
<p style="border-top: 1px solid #444e4f;"></p>
<p><a class="white" href="baza_chn.php">- До встречи</a></p> ';
break;
case'prod':
$sum=abs(intval($_POST['sum']));
if($sum>$user[glas_ploti]){header('location: saharov.php');exit();}
$cena=$sum*37;
$pdo->exec("UPDATE users SET habar = habar+$cena, glas_ploti=glas_ploti-$sum  WHERE id = '$user_id'");
header('location: saharov.php');
break;
case'prod2':
$sum=abs(intval($_POST['sum2']));
if($sum>$user[noga_snorka]){header('location: saharov.php');exit();}
$cena=$sum*50;
$pdo->exec("UPDATE users SET habar = habar+$cena, noga_snorka=noga_snorka-$sum  WHERE id ='$user_id'");
header('location: saharov.php');
break;
case'prod3':
$sum=abs(intval($_POST['sum3']));
if($sum>$user[k_kabana]){header('location: saharov.php');exit();}
$cena=$sum*29;
$pdo->exec("UPDATE users SET habar = habar+$cena, k_kabana=k_kabana-$sum WHERE id = '$user_id'");
header('location: saharov.php');
break;
case'prod4':
$sum=abs(intval($_POST['sum4']));
if($sum>$user[hvost_psa]){header('location: saharov.php');exit();}
$cena=$sum*33;
$pdo->exec("UPDATE users SET habar = habar+$cena, hvost_psa=hvost_psa-$sum WHERE id = '$user_id'");
header('location: saharov.php');
break;
case'prod5':
$sum=abs(intval($_POST['sum5']));
if($sum>$user[sch_krovik]){header('location: saharov.php');exit();}
$cena=$sum*70;
$pdo->exec("UPDATE users SET habar = habar+$cena,sch_krovik=sch_krovik-$sum WHERE id = '$user_id'");
header('location: saharov.php');
break;
case'prod6':
$sum=abs(intval($_POST['sum6']));
if($sum>$user[hvost_sobaki]){header('location: saharov.php');exit();}
$cena=$sum*28;
$pdo->exec("UPDATE users SET habar = habar+$cena, hvost_sobaki=hvost_sobaki-$sum WHERE id = '$user_id'");
header('location: saharov.php');

break;
}
//////////////////////////////////////

require_once('conf/navig.php');
require_once('conf/foot.php');
?>
</body>
</html>