<?
define('PROTECTOR', 1);

$head = 'aura';//фикс. места

$textl='Инвентарь';
include('files/db.php');
include('files/auth.php');
include('files/func.php');
going();
include('files/core.php');
include('files/head.php');
include('files/zag.php');

$req = mysql_query("SELECT * FROM `item_aura` WHERE `usr` = '$log' and `id`='$_GET[id]'");

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

$req1 = mysql_query("SELECT * FROM `item_aura` WHERE `usr` = '$log' and `status`='1'");
$avto1=mysql_num_rows($req1);
if($avto1>=1){
echo'Нельзя активировать больше одной ауры!';
include('files/down.php');
exit;
}

if($mag[nlvl] > $udata[lvl]){
echo'<img src="pic/no.png" alt="*"/> Аура неподходит по вашему уровню!</br><a href="inventar.php?mod=aura">Назад</a>';
include('files/down.php');
exit;
}

$actime=time()+$mag[actime];

mysql_query("INSERT INTO
        `aurs` SET
        `usr` = '$log',
        `actimer` = '$actime'");

$nlovk=$mag[lovk]+$udata[lovk];
$nsila=$mag[sila]+$udata[sila];
$nprotect=$mag[protect]+$udata[prot];
$nhp=$mag[hp]+$udata[hpall];
$nmp=$mag[mp]+$udata[mpall];
$nkrit=$mag[krit]+$udata[krit];
$nukrit=$mag[ukrit]+$udata[ukrit];


mysql_query("UPDATE `users` SET
         `sila` = '$nsila',
         `lovk` = '$nlovk',
         `prot` = '$nprotect',
         `hpall` = '$nhp',
         `mpall` = '$nmp',
         `krit` = '$nkrit',
         `ukrit` = '$nukrit'
          WHERE `usr` = '$log'") or die (mysql_error());


mysql_query("UPDATE item_aura SET status = '1' WHERE `usr` = '$log' and `id`='$_GET[id]'");
$chas = round($mag[actime]/3600);
echo"Вы активировали ауру <b>$mag[name]</b> на $chas часов!<br/>";

echo"<a href=\"inventar.php?\">Назад</a>";
include('files/down.php');
?>