<?php
//
require_once($_SERVER['DOCUMENT_ROOT']."/instalscript/engine/_inc/sys.php");
//
head("Задания",$uid); # Голова
//
$r = rand(1000000,9999999);
//
echo logs();
//
//
$el = 2*$user['premium'];
//
//
if(isset($_GET['ok'])){
$id = number($_GET['ok']);
//
$quest = fch("SELECT * FROM `quest_user` WHERE `id` = ? LIMIT 1", array($id));
//
$q = fch("SELECT * FROM `quest` WHERE `id` = ? LIMIT 1", array($quest['id_quest']));
//
if($quest['koll'] >= $quest['max_koll']){
//
qry("UPDATE `quest_user` SET `koll` = ?, `last` = ? WHERE `id` = ? LIMIT 1", array(0,time()+86400,$quest['id']));
//
qry("UPDATE `users` SET `gold` = `gold` + ?, `silver` = `silver` + ?, `element` = `element` + ? WHERE `id` = ? LIMIT 1", array($q['gold'],$q['silver']*$el,$el,$uid));
//
msg("<center><small>Задание выполнено!<br>Награда: <img class = 'money' src = '/instalscript/images/user/stat/money-gold.gif'> ".$q['gold'].", <img class = 'money' src = '/instalscript/images/user/stat/money-silver.gif'> ".($q['silver']*$el)." <img src = '/instalscript/images/icons/city/professions.png' width='18' height='18'> ".$el." самоцвета</small></center>");
//
header('Location: ?');
exit();
}else{
header('Location: ?');
exit();
}
}
//
$q = $BaseConnect->query("SELECT * FROM `quest_user` WHERE `id_user` = '".$uid."' ORDER BY `id` DESC, `last` ASC");
//
while($post = $q->fetch(PDO::FETCH_ASSOC)){
//
$quest = fch("SELECT * FROM `quest` WHERE `id` = ? LIMIT 1", array($post['id_quest']));
//
echo "<div class='message'>";
//
if($post['last'] < time()){
//
?><b><? echo $quest['name']; ?></b><br>
<? if($post['koll'] >= $quest['koll']) echo "<font color='lime'>Задание выполнено!</font>"; else echo "Прогресс: ".$post['koll']." из ".$quest['koll'].""; ?>
<br>Награда: <img class = "money" src = "/instalscript/images/user/stat/money-gold.gif"> <? echo $quest['gold']; ?> золота, <img class = "money" src = "/instalscript/images/user/stat/money-silver.gif"> <? echo $quest['silver']*$el; ?> серебра и <img src = "/instalscript/images/icons/city/professions.png" width="18" height="18"> <? echo $el; ?> самоцвета
<?
}else{
?>
<span class='grey'><b><? echo $quest['name']; ?></b><br>Откроется через: <? echo "".timer($post['last']).""; ?></span>
<?
}
?>
</div>
<?
if($post['koll'] >= $quest['koll']){
?>
<a href="?ok=<? echo $post['id']; ?>" class="lnk ma cntr">Получить награду</a>
<?
}
?>
<?
}
//
//
//
//
foot($uid);
?>