<?php
require_once 'wcore/core.php';
if (!isset($_GET['id'])){$p_id = $ank['id'];} else {$p_id = intval($_GET['id']);}
iank();

$profile = mysqli_query($mysqli,"SELECT * FROM `users` WHERE `id` = ".$p_id);
if (mysqli_num_rows($profile) != 0) {$user = mysqli_fetch_assoc($profile);} else {$_SESSION['error'] = $ed . 'Пользователь не найден' . $_ed;go('/profile.php');exit();}

$t = $user['login'];
require_once 'wcore/head.php';

if($user['stars'] == 0){ $stars1 = 1; $stars2 = 1; $stars3 = 1; $stars4 = 1; }
if($user['stars'] == 1){ $stars1 = 1.10; $stars2 = 1; $stars3 = 1; $stars4 = 1; }
if($user['stars'] == 2){ $stars1 = 1.10; $stars2 = 1.05; $stars3 = 1; $stars4 = 1; }
if($user['stars'] == 3){ $stars1 = 1.10; $stars2 = 1.05; $stars3 = 1.30; $stars4 = 1; }
if($user['stars'] == 4){ $stars1 = 1.10; $stars2 = 1.05; $stars3 = 1.30; $stars4 = 1.08; }
if($user['stars'] == 5){ $stars1 = 1.40; $stars2 = 1.05; $stars3 = 1.30; $stars4 = 1.08; }
if($user['stars'] == 6){ $stars1 = 1.10; $stars2 = 1.15; $stars3 = 1.30; $stars4 = 1.08; }
if($user['stars'] == 7){ $stars1 = 1.10; $stars2 = 1.05; $stars3 = 1.60; $stars4 = 1.08; }
if($user['stars'] == 8){ $stars1 = 1.10; $stars2 = 1.05; $stars3 = 1.30; $stars4 = 1.16; } 
if($user['reincarnation_level'] >= 1) { $user['param_1'] = $user['param_1']*$user['reincarnation_bonus_p1']; $user['param_2'] = $user['param_2']*$user['reincarnation_bonus_p2']; $user['param_3'] = $user['param_3']*$user['reincarnation_bonus_p3']; $user['param_4'] = $user['param_4']*$user['reincarnation_bonus_p4']; }
$reincarnation = 'P' . $user['reincarnation_level'] . '.';
	
$power = round((($user['param_1']*$stars1)/2)+($user['param_2']*$stars2)+(($user['param_3']*$stars3)/4)+($user['param_4']*$stars4));
$train = ($user['train_1']+$user['train_2']+$user['train_3']+$user['train_4']);

echo '<center><div class="titles" style="opacity: .99;">'. $user['login'] .' Lv. '. $reincarnation . $user['level'] .'</div></center>';

echo '<style>.game { background: url("/img/game_bg/fuligonggao.png"); background-size: 100% 100%; }</style>';

	echo $_SESSION['error'];
	$_SESSION['error'] = NULL;

echo '<center class="profile" style="background: url(img/hero/'. $user['power'] .'_'. $user['sex'] .'.png) center center, url(img/bg_hero.png) center center;">';
echo '<br><br>';
echo '<table width="100%"><tbody><tr>';
echo '<td width="20%"><center><img src="img/items/1/'.$user['items_1'].'.png"></center></td>';
echo '<td width="60%"></td>';
echo '<td width="20%"><center><img src="img/items/2/'.$user['items_2'].'.png"></center></td>';
echo '</tr></tbody></table>';
echo '<table width="100%"><tbody><tr>';
echo '<td width="20%"><center><img src="img/items/3/'.$user['items_3'].'.png"></center></td>';
echo '<td width="60%"></td>';
echo '<td width="20%"><center><img src="img/items/4/'.$user['items_4'].'.png"></center></td>';
echo '</tr></tbody></table>';
echo '<table width="100%"><tbody><tr>';
echo '<td width="20%"><center><img src="img/items/5/'.$user['items_5'].'.png"></center></td>';
echo '<td width="60%"></td>';
echo '<td width="20%"><center><img src="img/items/6/'.$user['items_6'].'.png"></center></td>';
echo '</tr></tbody></table>';
echo '<table width="100%"><tbody><tr>';
echo '<td width="20%"><center><img src="img/items/5/'.$user['items_7'].'.png"></center></td>';
echo '<td width="60%"></td>';
echo '<td width="20%"><center><img src="img/items/6/'.$user['items_8'].'.png"></center></td>';
echo '</tr></tbody></table>';
echo '<br>';
echo '<center><img src="img/stars/'. $user['stars'] .'_8.png"></center>';
echo '<img src="img/power.png"><br>';
echo '<span class="tpower" data-text="'. $power .'"><b>'. $power .'</b></span>';
echo '</center>';
echo '<div style="background: url(img/style/bc_params.png) repeat-x;box-shadow: 0 0 8px black;border: 1px solid #050505;">';
echo '<table width="100%" style="color: DEA05D;font-size: 14px"><tbody><tr>';
echo '<td width="25%" style="text-align: right;">Здоровье</td>';
echo '<td width="25%" style="text-align: right;"><span class="params">'.round($user['param_1']*$stars1).'</span></td>';
echo '<td width="25%" style="text-align: right;">Сила</td>';
echo '<td width="25%" style="text-align: right;"><span class="params">'.round($user['param_2']*$stars2).'</span></td>';
echo '</tr></tbody></table>';
echo '<table width="100%" style="color: DEA05D;font-size: 14px"><tbody><tr>';
echo '<td width="25%" style="text-align: right;">Защита</td>';
echo '<td width="25%" style="text-align: right;"><span class="params">'.round($user['param_3']*$stars3).'</span></td>';
echo '<td width="25%" style="text-align: right;">Скорость</td>';
echo '<td width="25%" style="text-align: right;"><span class="params">'.round($user['param_4']*$stars4).'</span></td>';
echo '</tr></tbody></table>';
echo '</div>';

$equipment = ($user['items_1']+$user['items_2']+$user['items_3']+$user['items_4']+$user['items_5']+$user['items_6']+$user['items_7']+$user['items_8']);

if($user['id'] == $ank['id']) echo '<a href="/equip.php" class="buttons"><img src="img/icons/504006.png" width="32px"> Снаряжение ('. $equipment .' / 8)</a>';
#if($user['id'] == $ank['id']) echo '<a href="/astral.php" class="buttons"><img src="img/icons/504025.png" width="32px"> Астрал</a>';
if($user['id'] == $ank['id']) echo '<a href="/train.php" class="buttons"><img src="img/icons/504003.png" width="32px"> Тренировка ('. $train .' / 2000)</a>';
if($user['id'] == $ank['id'] and $ank['level'] >= 30) echo '<a href="/stars.php" class="buttons"><img src="img/icons/504021.png" width="32px"> Пробуждение</a>';
elseif($user['id'] == $ank['id']) echo '<div class="no buttons"><img src="img/icons/504021.png" width="32px"> Пробуждение <font class="darkred">(30 ур.)</font></div>';
if($user['id'] == $ank['id'] and $ank['level'] >= 70) echo '<a href="/wings.php" class="buttons"><img src="img/icons/504010.png" width="32px"> Облик</a>';
elseif($user['id'] == $ank['id']) echo '<div class="no buttons"><img src="img/icons/504010.png" width="32px"> Облик <font class="darkred">(70 ур.)</font></div>';
if($user['id'] == $ank['id'] and $ank['level'] >= 110) echo '<a href="/wings.php" class="buttons"><img src="img/icons/504010.png" width="32px"> Крылья</a>';
elseif($user['id'] == $ank['id']) echo '<div class="no buttons"><img src="img/icons/504010.png" width="32px"> Крылья <font class="darkred">(110 ур.)</font></div>';

if($user['id'] == $ank['id']) echo '<a href="/mail.php" class="buttons"><img src="img/icons/504014.png" width="32px"> Письма</a>';
if($user['id'] == $ank['id']) echo '<a href="/gifts.php" class="buttons"><img src="img/icons/504009.png" width="32px"> Подарки</a>';

require_once 'wcore/foot.php';
?>