<?php
define('PROTECTOR', 1);
include('files/path.php');
include($path.'files/db.php');
include($path.'files/auth.php');
include($path.'files/func.php');
if($_GET['act']=='vooruzh'){
$textl='Шмотки';
}else{
$textl='Камера';
}
include($path.'files/core.php');
include($path.'files/head.php');
include($path.'files/zag.php');

$jel = mysql_fetch_array(mysql_query("SELECT `kol` FROM `res` WHERE `usr` = '$log' AND `lat_name`= 'jelezo'"));
$kam = mysql_fetch_array(mysql_query("SELECT `kol` FROM `res` WHERE `usr` = '$log' AND `lat_name`= 'kamen'"));
$nef = mysql_fetch_array(mysql_query("SELECT `kol` FROM `res` WHERE `usr` = '$log' AND `lat_name`= 'nefrit'"));
$obs = mysql_fetch_array(mysql_query("SELECT `kol` FROM `res` WHERE `usr` = '$log' AND `lat_name`= 'obsidian'"));
$ser = mysql_fetch_array(mysql_query("SELECT `kol` FROM `res` WHERE `usr` = '$log' AND `lat_name`= 'serebro'"));

if($udata['klas']=='fighert'){
if($udata['wins']>=0 AND $udata['wins']<500){
$stat2='Новичок';
}
elseif($udata['wins']>=500 AND $udata['wins']<2000){
$stat2='Боец';
}
elseif($udata['wins']>=2000 AND $udata['wins']<5000){
$stat2='Рыцарь';
}
elseif($udata['wins']>=5000 AND $udata['wins']<10000){
$stat2='Гладиатор';
}
elseif($udata['wins']>=10000 AND $udata['wins']<15000){
$stat2='Титан';
}
elseif($udata['wins']>15000 AND $udata['wins']<20000){
$stat2='Богатырь';
}
elseif($udata['wins']>20000){
$stat2='Бог';
}
}

if($udata['klas']=='wizard'){
if($udata['wins']>=0 AND $udata['wins']<500){
$stat2='Новичок';
}
elseif($udata['wins']>=500 AND $udata['wins']<2000){
$stat2='Ученик';
}
elseif($udata['wins']>=2000 AND $udata['wins']<5000){
$stat2='Волшебник';
}
elseif($udata['wins']>=5000 AND $udata['wins']<10000){
$stat2='Магистр магии';
}
elseif($udata['wins']>=10000 AND $udata['wins']<15000){
$stat2='Чародей';
}
elseif($udata['wins']>15000 AND $udata['wins']<20000){
$stat2='Властелин';
}
elseif($udata['wins']>20000){
$stat2='Повелитель';
}
}

if(empty($_GET['act'])){

if($udata['lvl']<5){
$st='a';
}
elseif($udata['lvl']>=5 AND $udata['lvl']<10){
$st='b';
}
elseif($udata['lvl']>=10 AND $udata['lvl']<15){
$st='c';
}
elseif($udata['lvl']>=15 AND $udata['lvl']<20){
$st='d';
}
elseif($udata['lvl']>=20 AND $udata['lvl']<25){
$st='e';
}
elseif($udata['lvl']>=25 AND $udata['lvl']<35){
$st='f';
}
elseif($udata['lvl']>=35 AND $udata['lvl']<45){
$st='g';
}
elseif($udata['lvl']>=45 AND $udata['lvl']<55){
$st='h';
}
elseif($udata['lvl']>=55){
$st='i';
}

if($udata['storona']=='white'){
$pers=1;
}else{
$pers=0;
}

if ($user_id==0){
$gde='off';
}else{
$gde='';
}
if($udata['prava']==5){
$status='Создатель игры';
$im='adm';
}
if($udata['prava']==4){
$status='Гейм Мастер';
$im='adm';
}
if($udata['prava']==3){
$status='Поддержка';
$im='mod3';
}
if($udata['prava']==2){
$status='Модератор';
$im='mod';
}
if($udata['prava']==1){
$status='Тест Мастер';
$im='gam';
}
if($udata['prava']==0){
$status='Заключенный';
$im='gam';
}
echo'';
echo'<div class="main">- '.$status.' <div class="block_zero"><img src="image/icon/'.$pers.''.$gde.'.png" alt="*"><b> '.$log.' </b>';

echo'<img src="image/icon/level.png" alt="*"> '.$udata['lvl'].'  ур, ';


if($udata['pol']=='m'){
echo'муж.';
}else{
echo'жен.';
}


echo'';


if($udata['klas']=='wizard'){
$kl='w';
}
if($udata['klas']=='fighert'){
$kl='f';
}


echo'<br>';

if(!empty($udata['clan'])){
$clan = mysql_fetch_array(mysql_query("SELECT * FROM `clan` WHERE `lider` = '$udata[clan]' LIMIT 1"));
if($udata['storona']=='white'){
$cl='c1';
}else{
$cl='c0';
}
echo'<img src="image/icon/'.$cl.'.png"> Банда: <a href="clan.php?id='.$clan['id'].'">'.$clan['name'].'</a>';
if($udata['dolz']=='lider'){
echo' - Лидер банды';
}
elseif($udata['dolz']=='general'){
echo' - Помошник лидера';
}
elseif($udata['dolz']=='user' OR $udata['dolz']==''){
echo' - Член банды';
}
}else{
echo'Не состоит в банде.';
}

echo'</div><div class="mini-line"></div><div class="block_zero center">';
//-----
if(isset($_GET['acti'])){
if($udata['skill']>0){
if($_GET['acti']=='sila'){
$nparm=$udata['sila']+1;
mysql_query("UPDATE `users` SET `skill` = `skill`-1, `sila` = '$nparm' WHERE `usr` = '$log'");
header('Location: pers.php');exit;
}
if($_GET['acti']=='prot'){
$nparm=$udata['prot']+1;
mysql_query("UPDATE `users` SET `skill` = `skill`-1, `prot` = '$nparm' WHERE `usr` = '$log'");
header('Location: pers.php');exit;
}
if($_GET['acti']=="lovk"){
$nparm=$udata['lovk']+1;
mysql_query("UPDATE `users` SET `skill` = `skill`-1, `lovk` = '$nparm' WHERE `usr` = '$log'");
header('Location: pers.php');exit; 
}
if($_GET['acti']=="ukrit"){
$nparm=$udata['ukrit']+1;
mysql_query("UPDATE `users` SET `skill` = `skill`-1, `ukrit` = '$nparm' WHERE `usr` = '$log'");
header('Location: pers.php');exit;
}
if($_GET['acti']=="hp"){
$nparm=$udata['hpall']+1;
mysql_query("UPDATE `users` SET `skill` = `skill`-1, `hpall` = '$nparm', `hp` = `hp`+1 WHERE `usr` = '$log'");
header('Location: pers.php');exit;
}
if($_GET['acti']=="mp"){
$nparm=$udata['mpall']+1;
mysql_query("UPDATE `users` SET `skill` = `skill`-1, `mpall` = '$nparm', `mp` = `mp`+1 WHERE `usr` = '$log'");
header('Location: pers.php');exit;
}
}
}
//-----
$set = mysql_fetch_assoc(mysql_query("SELECT * FROM `set` WHERE `usr` = '$log'"));
$time=time();
$ab = $set['viptime'] -$time;
if($set['vip']=='on'){
echo'<div class="block_zero"><a href="vip.php?"><div class="head"><span style="color: #939;">VIP-аккаунт ('.Sec2Time($ab).')</span></div></a></div>';
}
echo'</div><img src="image/avatar/not.png" alt="*"></br>';


echo'<div class="mini-line"></div>';
echo'<div class="menuList"><li><a href="pers.php?act=vooruzh"><img src="image/icon/equip.png" alt="*">Шмотки</a></li>
<li><a href="inventar.php?"><img src="image/icon/bag.png" alt="*">Тумбочка</a></li>

<li><a href="sklad.php?"><img src="image/icon/bag.png" alt="*">Сейф</a></li>

<li><a href="inventar.php?mod=artefact"><img src="image/icon/up.png" alt="*">Инструменты</a></li>

<li><a href="inventar.php?mod=res"><img src="image/icon/up.png" alt="*">Ресурсы</a></li>

</div>
<div class="mini-line"></div><div class="block_zero">';
if($udata['skill']>0){
echo'<img src="image/icon/ok.png" alt="*"> Свободных статов: '.$udata['skill'].'<br>';
}else{
//echo'<img src="image/icon/error.png" alt="*"> Нет очков для распределения';
}echo'<img src="image/icon/health.png" alt="*"> Жизнь: '.$udata['hpall'].'';
if($udata['skill']>0){
echo'(<a href="pers.php?acti=hp">+</a>)';
}
echo'<br>';
echo'<img src="image/icon/mana.png" alt="*"> Энергия: '.$udata['mpall'].'';
if($udata['skill']>0){
echo'(<a href="pers.php?acti=mp">+</a>)';
}
echo'<br>';
echo'<img src="image/icon/str.png" alt="*"> Сила: '.$udata['sila'].'';
if($udata['skill']>0){
echo'(<a href="pers.php?acti=sila">+</a>)';
}
echo'<br>';
echo'<img src="image/icon/agi.png" alt="*"> Ловкость: '.$udata['lovk'].'';
if($udata['skill']>0){
echo'(<a href="pers.php?acti=lovk">+</a>)';
}
echo'<br>';
echo'<img src="image/icon/def.png" alt="*"> Защита: '.$udata['prot'].'';
if($udata['skill']>0){
echo'(<a href="pers.php?acti=prot">+</a>)';
}
echo'<br>';
echo'<img src="image/icon/tournament.png" alt="*"> Крит-урон: '.$udata['ukrit'].'%';
if($udata['skill']>0){
echo'(<a href="pers.php?acti=ukrit">+</a>)';
}
echo'<br>';
echo'<img src="image/icon/sumstat.png" alt="*"> Крит-удар: '.$udata['krit'].'%';
//-----

echo'</div><div class="mini-line"></div><div class="block_zero center">';

if($avtob == 1){
echo'На Вас наложен бан:</br>Причина: '.$ban['text'].'<br>';
}
elseif($set['pred']>0){
echo'<img src="image/icon/error.png" alt="*"> Предупреждений: '.$set['pred'].'<br>';
}else{
//echo'<img src="image/icon/ok.png" alt="*"> Предупреждений: нет<br>';
}


echo'</div><div class="mini-line"></div>';

echo'<div class="menuList">';



$req = mysql_query("SELECT `id`, `name`, `old`, `status` FROM `pit` WHERE `usr` = '$log'");
$avto=mysql_num_rows($req);
if($avto==1){
$pit = mysql_fetch_array($req);
if($pit['old']==1){
$old="Пёс ";
}
if($pit['old']==2){
$old="Змея ";
}
if($pit['old']==3){
$old="Крокодил ";
}
if($pit['status']=="die"){
$die=" (мёртв)";
}else{
$die="";
}
echo'<li><a href="pitomec.php?"><img src="image/icon/pet.png" alt="*">Питомец: '.$old.''.$pit['name'].''.$die.'</a></li>';
}else{
//echo'<li><a href="pitomec.php?"><img src="image/icon/king.png" alt="*">Питомец</a></li>';
}

$mag=mysql_fetch_array(mysql_query("SELECT * FROM `mag` WHERE `usr` = '$log'"));


if($mag['yarost']>0){
$a=1;
}else{
$a=false;
}
if($mag['bronya']>0){
$b=1;
}else{
$b=false;
}
if($mag['vihr']>0){
$c=1;
}else{
$c=false;
}
if($mag['stoika']>0){
$d=1;
}else{
$d=false;
}

$umehi=$a+$b+$c+$d;

echo'

<li><a href="trenirovka.php?"><img src="image/icon/train.png" alt="*">Навыки ('.$umehi.'/4)</a></li>

<li><a href="masterstvo.php?"><img src="image/icon/skill.png" alt="*">Качалка</a></li>
';
/*<li><a href="inventar.php?mod=elexir"><img src="image/icon/bag.png" alt="*">Эликсиры</a></li>

<li><a href="inventar.php?mod=aura"><img src="image/icon/bag.png" alt="*">Ауры</a></li>*/


echo'<li><a href="relic.php?"><img src="image/icon/relic.png" alt="*">Реликвии</a></li>';
if($set['shahter']+$set['kuznec']+$set['razb']==0){
echo'<li><a href="profi.php?"><img src="image/icon/up.png" alt="*">Талант</a></li>';
}else{
echo'<li><a href="profi.php?"><img src="image/icon/up.png" alt="*">Таланты</a></li>';
}
echo'<li><a href="msg.php?"><img src="image/icon/mail.png" alt="*">Малявы</a></li>';
//echo'<li><a href="anketa.php?"><img src="image/icon/user.png" alt="*"> Анкета</a></li>';

$avtos=mysql_num_rows(mysql_query("SELECT * FROM `users` WHERE `ref` = '$udata[id]'"));

echo'<li><a href="index.php?mod=ref"><img src="image/icon/friends.png" alt="*">Рефералы ('.$avtos.')</a></li>';


echo'<li><a href="/set.php"><img src="image/icon/set.png" alt="*">Настройки </a></li>';
echo'<li><a href="pers.php?act=stats"><img src="image/icon/statistika.png" alt="*">Досье</a></li>';

echo'</div></div>';
//-----
}
elseif($_GET['act']=='stats'){
echo'Статистика:<br>Репутация: '.$udata['slava'].'<br>
Крысился: '.$udata['predatel'].'<br>
Побед на разборках: '.$udata['arenawins'].'<br>
Поражений на разботках: '.$udata['arenaloses'].'<br>
Побед в лиге бойцов: '.$udata['wins'].'<br>
Поражений в лиге бойцов: '.$udata['loses'].'';
}
//-----
elseif($_GET['act']=='vooruzh'){
$i=1;
while($i<=5){
switch($i){
case '1':
$tip='';
$gt='golova';
$x='';
break;
case '2':
$tip='';
$gt='body';
$x='';
break;
case '3':
$tip='';
$gt='nogi';
$x='';
break;
case '4':
$tip='';
$gt='weapon';
$x='';
break;
case '5':
$tip='';
$gt='shit';
$x='';
break;
}
$req = mysql_query("SELECT * FROM `weapon` WHERE `usr` = '$log' AND `tip`='$gt' AND `image`='yes'");
$avto=mysql_num_rows($req);
if($avto!==0){              
$mag = mysql_fetch_array($req);
if(!empty($mag['img'])){
$patch="art/$mag[img]";
}else{
$patch="weapon/$mag[kompl]/$gt.png";
}
$wep = mysql_query("SELECT * FROM `weapon` WHERE `image` = 'yes' AND `usr` = '$log' AND `tip` = '$mag[tip]'") OR die (mysql_error());
$wep = mysql_fetch_array($wep);
$stat = $wep['hp']+$wep['mp']+$wep['krit']+$wep['ukrit']+$wep['sila']+$wep['lovk']+$wep['prot'];
if($wep['runa']==1){
$runa='<img src="image/kachestvo/0.png" alt="*">';
}
elseif($wep['runa']==2){
$runa='<img src="image/kachestvo/1.png" alt="*">';
}
elseif($wep['runa']==3){
$runa='<img src="image/kachestvo/2.png" alt="*">';
}
elseif($wep['runa']==4){
$runa='<img src="image/kachestvo/3.png" alt="*">';
}
elseif($wep['runa']==5){
$runa='<img src="image/kachestvo/4.png" alt="*">';
}
elseif($wep['runa']==6){
$runa='<img src="image/kachestvo/5.png" alt="*">';
}else{
$runa=FALSE;
}
echo'</div><div class="dot-line"></div>';
echo'<div class="main"><div class="block_zero">';
echo'<img class="float-left" src="image/'.$patch.'" width="60" height="60" style="margin-left:10px; margin-right:10px;" alt="*"><a href="inventar.php?mod=info&amp;id='.$mag['id'].'"> '.$runa.' '.$tip.' '.$mag['name'].'</a> +'.$mag['zakal'].'<br>+ '.$stat.' к параметрам<br>Бонус: '.$mag['proch'].'/10</small><br><a href="dress.php?mod=snyat&tip='.$gt.'"><span class="btn"><span class="end"><input class="label" type="submit" value="Снять"></span></span></a></a></div></div>';
}
if($avto<=0){
echo'</div><div class="dot-line"></div>';
echo'<div class="main"><div class="block_zero"><img class="float-left" src="image/weapon/'.$gt.'.png" width="60" height="60" style="margin-left:10px; margin-right:10px;" alt="*"><span style="color: #999;">'.$tip.' не одет'.$x.'</span><br><br><br><br></div></div>';
}
$i++;
}
}
include($path.'files/down.php');
?>