Файл: clan_quest.php
Строк: 60
<?
require_once ('system/func.php');
auth(); // Закроем от не авторизованных
$title = 'Клановые задания';
require_once ('system/header.php');
if(isset($_GET['nagrada'])){
$id = num($_GET['nagrada']);
$clanuserquest = mysql_fetch_assoc(mysql_query("SELECT * FROM `clanuser_quest` WHERE `id` = '$id'"));
$q = mysql_fetch_assoc(mysql_query("SELECT * FROM `clan_quest` WHERE `id` = '$clan_quest[id_quest]'"));
if($clan_quest['koll'] >= $clan_quest['max_koll']){
mysql_query("update `clanuser_quest` set `koll` = '0', `last` = '".(time()+60*60*15)."' where (`id` = '".$clan_quest['id']."')");
mysql_query("update `clans` set `gold` = '".($clan['gold']+$q['gold'])."', `crystals` = '".($clan['crystals']+$q['crystals'])."' where (`id` = '".$myID."')");
$_SESSION['msg'] = 'Задание завершено!<br>Награда: '.ico('icons','gold.png').' '.$q['gold'].' золота и '.ico('icons','crystal.png').' '.$q['crystals'].' кристаллов';
header('Location: ?');
exit();
}else{
header('Location: ?');
exit();
}
}
$q = mysql_query("SELECT * FROM `clan_quest` WHERE `id_user` = '$myID' ORDER BY `koll` DESC, `last` ASC");
while($post = mysql_fetch_assoc($q)){
$clan_quest = mysql_fetch_assoc(mysql_query("SELECT * FROM `clan_quest` WHERE `id` = '$post[id_quest]'"));
echo "<div class='block'>";
if($post['last'] < time()){
echo "<span class='money'><b>$clan_quest[name]</b></span><br>";
echo ($post['koll'] >= $clan_quest['koll'] ? "<font color='green'>Задание выполнено!</font>" : "Прогресс: $post[koll] из $clan_quest[koll]");
$round = round($post['koll']/$clan_quest['koll']*100,1);
if($round > 100)$round = 100;
echo "<div class='stat_bar2'><div class='progress' style='width:".$round."%;'></div></div>";
echo "$clan_quest[text]<br>Награда: ".ico('icons','gold.png')." $clan_quest[gold] золота и ".ico('icons','crystal.png')." $clan_quest[crystals] кристаллов";
if($post['koll'] >= $clan_quest['koll']){
echo "<div class='center'><a href='?nagrada=$post[id]' class='btn2'>Получить награду</a></div>";
}
}else{
echo "<span class='grey'><b>$clan_quest[name]</b><br>$clan_quest[text]<br>Осталось ждать: ".tl($post['last']-time())."</span>";
}
echo "</div>";
}
require_once ('system/footer.php');
?>