<?
$clan = mysql_fetch_array(mysql_query("SELECT * FROM `clans` WHERE `id` = '".$user['id_clan']."' LIMIT 1"));
$clan_bonus = mysql_fetch_array(mysql_query("SELECT * FROM `clan_bonus` WHERE `id_clan` = '".$clan['id']."' AND `last` < '".time()."' LIMIT 1"));
if($clan_bonus){
mysql_query("UPDATE `clans` SET `stat` = '".($clan['stat']-$clan_bonus['stat'])."' WHERE `id` = '".$clan['id']."' LIMIT 1");
mysql_query("UPDATE `users` SET `str` = `str`-'$clan_bonus[stat]', `def` = `def`-'$clan_bonus[stat]', `max_health` = `max_health`-'$clan_bonus[stat]' WHERE `id_clan` = '".$clan['id']."' LIMIT 1");
mysql_query("DELETE FROM `clan_bonus` WHERE `id` = '".$clan_bonus['id']."'");
}
$clan = 0;
$clan_bonus = 0;
?>