Файл: public_html/modules/campaign.php
Строк: 52
<?php
$root = $_SERVER['DOCUMENT_ROOT'];
include_once ($root.'/core/base.php');
falseauth();
$header = "Кампания";
include_once ($root.'/core/head.php');
$quest = $db->query("SELECT * FROM `campaign_quests` WHERE `chapter` = '".$u['campaign_chapter']."'");
$completedQuests = 0;
echo"<div class = 'index-campaign'>";
$allQuests = $quest->num_rows;
while($q = $quest->fetch_object())
{
$userQuest = $db->query("SELECT * FROM `campaign_user` WHERE `chapter` = '".$u['campaign_chapter']."' AND `quest` = '".$q->quest."' AND `user` = '".$u['id']."'");
if($userQuest->num_rows == 0)
{
$db->query("INSERT INTO `campaign_user` (user, chapter, quest, count) VALUES ('".$u['id']."', '".$u['campaign_chapter']."','".$q->quest."', '0')");
redirect('/campaign');
}
$usQuest = $userQuest->fetch_object();
echo '<div class = "notice_container"><div class = "gborder notice_alert alert-success">
Задание: '.$q->name.'<br>
Прогресс: '.($usQuest->count > $q->target ? $q->target : $usQuest->count).'/'.$q->target.'</div></div>';
if($usQuest->count >= $q->target) $completedQuests += 1;
}
if(isset($_GET['complete']))
{
if($completedQuests < $allQuests) redirect('/campaign', 'Не все задания завершены');
$db->query("DELETE FROM `campaign_user` WHERE `chapter` = '".$u['campaign_chapter']."' AND `user` = '".$u['id']."'");
$db->query("UPDATE `users` SET `campaign_chapter` = `campaign_chapter` + '1' WHERE `id` = '".$u['id']."'");
$rand = rand(100,500)*$u['campaign_chapter'];
updateUserStats($u['id'], $rand, ($rand*2), ($u['campaign_chapter']*4));
redirect('/campaign', 'Глава кампании завершена! Награда: '.$rand.' опыта, '.($rand*2).' серебра и '.($u['campaign_chapter']*4).' гемов!');
}
echo"</div>";
if($u['campaign_chapter'] < 9)
{
echo '<div class="b"><center>Завершено заданий: '.$completedQuests.' из '.$allQuests.'.</center></div>';
}
else
{
echo '<div class="b"><center>Кампания завершена! Ожидайте новых глав!</center></div>';
}
if($completedQuests == $allQuests && $u['campaign_chapter'] < 9)
{
echo '<div class="b"><center><a href="/campaign/complete"><input type="submit" value="Завершить кампанию"</a></center></div>';
}
include_once ($root.'/core/foot.php');