<?php
define('PROTECTOR', 1);

include('files/path.php');
include($path.'files/db.php');
include($path.'files/auth.php');
include($path.'files/func.php');
ryd();
$textl='Магазин Аур';
include($path.'files/core.php');
include($path.'files/head.php');
include($path.'files/zag.php');

switch($_GET['mod']){

default:

if(empty($_GET['old']) OR $_GET['old']==1){
$old=0;
$ss1=' 0 ';
}else{
$ss1='<a href="shopaura.php?old=1"><span class="btn"><span class="end"><input class="label" type="submit" value=" 0 "></span></span></a>';
}

if($_GET['old']==2){
$old=15;
$ss2=' 15 ';
}else{
$ss2='<a href="shopaura.php?old=2"><span class="btn"><span class="end"><input class="label" type="submit" value="15"></span></span></a>';
}

if($_GET['old']==3){
$old=30;
$ss3=' 30 ';
}else{
$ss3='<a href="shopaura.php?old=3"><span class="btn"><span class="end"><input class="label" type="submit" value="30"></span></span></a>';
}

if($_GET['old']==4){
$old=45;
$ss4=' 45 ';
}else{
$ss4='<a href="shopaura.php?old=4"><span class="btn"><span class="end"><input class="label" type="submit" value="45"></span></span></a>';
}

if($_GET['old']==5){
$old=60;
$ss5=' 60 ';
}else{
$ss5='<a href="shopaura.php?old=5"><span class="btn"><span class="end"><input class="label" type="submit" value="60"></span></span></a>';
}

if(isset($_GET['log'])){
$aura = mysql_fetch_array(mysql_query("SELECT * FROM `shop_aura` WHERE `nlvl` = '$old'"));
if(($_GET['log']=='kupil')){
echo"$aura[name] куплена!";
}
}

echo'<div class="main"><div class="block_zero center">';

echo'<span style="color: #3c3;">'.$ss1.' '.$ss2.' '.$ss3.' '.$ss4.' '.$ss5.'</span></div><div class="mini-line"></div><div class="block_zero">';

$req = mysql_query("SELECT * FROM `shop_aura` WHERE `nlvl` = '$old'");
$avto=mysql_num_rows($req);
if($avto>=1){
While($mag = mysql_fetch_array($req)){
if($udata['lvl']>=$mag['nlvl']){
$font='#9c9';
}else{
$font='#c66';
}
echo'<font color="'.$font.'">'.$mag['name'].' (<img src="image/icon/level.png" alt="*"> '.$mag['nlvl'].' ур.)</font><br>';
echo'<img class="float-left" src="image/aurs/'.$mag['ava'].'.png"  width="50" height="50" style="margin-left:10px;margin-right:20px;" alt="*">';

if(!empty($mag['hp'])){
echo'<img src="image/icon/health.png" alt="*"> <font color="71cc71">+'.$mag['hp'].' Жизнь</font></br>';
}
if(!empty($mag['mp'])){
echo'<img src="image/icon/mana.png" alt="*"> <font color="71cc71">+'.$mag['mp'].' Энергия</font></br>';
}
if(!empty($mag['sila'])){
echo'<img src="image/icon/str.png" alt="*"> <font color="71cc71">+'.$mag['sila'].' Сила</font></br>';
}
if(!empty($mag['lovk'])){
echo'<img src="image/icon/agi.png" alt="*"> <font color="71cc71">+'.$mag['lovk'].' Ловкость</font></br>';
}
if(!empty($mag['protect'])){
echo'<img src="image/icon/def.png" alt="*"> <font color="71cc71">+'.$mag['protect'].' Защита</font></br>';
}
if(!empty($mag['ukrit'])){
echo'<img src="image/icon/tournament.png" alt="*"> <font color="71cc71">+'.$mag['ukrit'].' Крит-урон</font><br>';
}

$ark=round($mag['actime']/3600,1);

echo'Длительность: '.$ark.' час.<br>';

echo'<a class="btn" href="shopaura.php?mod=sell&amp;id='.$mag['id'].'"><span class="end"><span class="label">Купить за <img src="image/icon/almaz.png" alt="*"> '.$mag['acena'].'</span></span></a>';
}
}else{
echo'Нет аур на продаже!';
}
echo'';
break;

case 'sell':
$req = mysql_query("SELECT * FROM `shop_aura` WHERE `id`='$_GET[id]'");

$avto=mysql_num_rows($req);
if($avto==0){
echo'<img src="pic/no.png" alt="*"/> Ошибка, такой ауры нет!';break;}
$mag = mysql_fetch_array($req);

$req=mysql_query("SELECT * FROM `domination` WHERE `id` = '1'");
$dom = mysql_fetch_assoc($req);
if($dom['white']>$dom['black']){
$liders='white';
}elseif($dom['black']>$dom['white']){
$liders='black';
}else{
$liders='not';}
if($udata['storona']==$liders){
$mag['cena']=round($mag['cena']-(($mag['cena']/100)*15));}
$nmoney=$udata['money']-$mag['cena'];
$nalm=$udata['almaz']-$mag['acena'];
if($nmoney<0){
echo'<img src="pic/no.png" alt="*"/> Нехватает монет!</br><a href="shopaura.php?">Назад</a>';break;
}
if($nalm<0){
echo'<img src="pic/no.png" alt="*"/> Нехватает Алмазов!</br><a href="shopaura.php?">Назад</a>';break;
}
$req1 = mysql_query("SELECT * FROM `item_aura` WHERE `usr` = '$log' and `name` = '$mag[name]'");
$res = mysql_fetch_array($req1);
$avto1=mysql_num_rows($req1);
if($avto1==0){
mysql_query("INSERT INTO
        `item_aura` SET
        `usr` = '$log',
        `name` = '$mag[name]',
        `ava` = '$mag[ava]',
        `lovk` = '$mag[lovk]',
        `cena` = '$mag[cena]',
        `sila` = '$mag[sila]',
        `acena` = '$mag[acena]',
        `protect` = '$mag[protect]',
        `hp` = '$mag[hp]',
        `mp` = '$mag[mp]',
        `krit` = '$mag[krit]',
        `ukrit` = '$mag[ukrit]',
        `nlvl` = '$mag[nlvl]',
        `actime` = '$mag[actime]' ") or die (mysql_error());

}else{
echo'<img src="pic/no.png" alt="*"/> У вас уже есть эта аура</br><a href="shopaura.php?">Назад</a>';break;
}
mysql_query("UPDATE users SET money = '$nmoney', almaz = '$nalm' WHERE usr = '$log'") or die (mysql_error());

header('Location: shopaura.php?log=kupil');exit;
break;
}
include($path.'files/down.php');
?>