<?php
$us = mysql_fetch_array(mysql_query("SELECT *, (SELECT `id` FROM `online` WHERE `date` >= ".(time()-60)." AND `id` = `users`.`id`) AS `online` FROM `users` WHERE `login` = '".mysql_real_escape_string($_POST['target'])."' LIMIT 1"));		
$effect = mysql_fetch_array(mysql_query("SELECT `id` FROM `effects` WHERE `owner` = '{$us['id']}' AND `time` > '".time()."' AND `type` = '13' ORDER BY `id` DESC LIMIT 1")); 
$vip = mysql_fetch_array(mysql_query('SELECT `id`, `uid`, `travmoff` FROM `abils_user` WHERE `uid` = "'.$user['id'].'" LIMIT 1'));

if($vip['travmoff'] <= 0) {
  echo 'Магия была исчерпана ...';
} elseif($user['battle'] > 0) {
  echo "Не в бою...";
} elseif(!isset($effect['id'])) {
  echo "Нет тех травм, которые Вы можете излечить";
} else {
  if($user['invis'] == 1) { $user['login'] = 'невидимка'; }
  if($us['invis']== 1) { $us['login'] = 'невидимка'; }
  addch("<img src=i/sh/cure3.gif><b>{$user['login']}</b> излечил $us[login] от травм.");
  mysql_query('UPDATE `effects` SET `time` = "'.time().'" WHERE `id` = "'.$effect['id'].'" LIMIT 1');
  echo "<font color=red><b>Персонаж \"{$_POST['target']}\" Был излечен от травм</b></font>";
  $vip['travmoff'] -= 1;
  mysql_query('UPDATE `abils_user` SET `travmoff` = "'.$vip['travmoff'].'" WHERE `id` = "'.$vip['id'].'" LIMIT 1');
}