<?php
define('PROTECTOR', 1);
include('files/path.php');
include($path.'files/db.php');
include($path.'files/auth.php');
include($path.'files/func.php');
going();
$textl='Ауры';
include($path.'files/core.php');
include($path.'files/head.php');
include($path.'files/zag.php');

if(isset($_GET['log'])){
if(($_GET['log']=='aktiv')){
echo"Вы активировали Ауру!<br/>";
include($path.'files/down.php');exit;
}
}

$req = mysql_query("SELECT * FROM `item_aura` WHERE `usr` = '$log' AND `id` = '".mysql_real_escape_string($_GET['id'])."'");
$avto=mysql_num_rows($req);
if($avto==0){
echo'<img src="pic/no.png" alt="*">Ошибка, такой ауры нет!';
include($path.'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($path.'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'");
$hp=$mag['hp']+$udata['hp'];
$mp=$mag['mp']+$udata['mp'];
$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 `hp` = '$hp', `mp` = '$mp',
`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`='".mysql_real_escape_string($_GET['id'])."'");


header('Location: aura.php?log=aktiv');exit;
include($path.'files/down.php');
?>