Файл: public_html/modules/locations/location.php
Строк: 55
<?php
$root = $_SERVER['DOCUMENT_ROOT'];
include_once ($root.'/core/base.php');
falseauth();
$header = "Окрестности";
include_once ($root.'/core/head.php');
issetLocationBattles();
$loc_id = fl($_GET['id']);
$location = $db->query("SELECT * FROM `locations` WHERE `id` = '".$loc_id."'");
if($location->num_rows == 0) redirect('/locations', 'Окрестность не найдена!');
$loc = $location->fetch_object();
if($loc->level > $u['level']) redirect('/locations', 'Уровень игрока мал!');
?>
<script type="text/javascript" src="../../lib/time.js"></script>
<?
if(isset($_GET['attack']))
{
$mob_id = fl($_GET['mob_id']);
$mob = $db->query("SELECT * FROM `locations_mobs` WHERE `id` = '".$mob_id."'");
if($mob->num_rows == 0) redirect('/locations/'.$loc_id, 'Моб не найден!');
$mob = $mob->fetch_object();
if($mob->cooldown_time > time()) redirect('/locations/'.$loc_id, 'Моб ещё не возродился!');
$issetBattles = $db->query("SELECT * FROM `locations_battles` WHERE `mob` = '".$mob_id."' AND `user` = '"
.$u['id']."'");
if($issetBattles->num_rows > 0) redirect('/locations/'.$loc_id.'/battle', 'Вы уже в бою!');
$db->query("INSERT INTO `locations_battles` (`user`, `location`, `mob`, `my_health`, `mob_health`, `times`) VALUES ('".$u['id']."', '".$loc_id."', '".$mob_id."', '".get_max_health($u['id'])."', '".$mob->health."', '".time()."')");
/*
*
Create log cache
*
*/
$keyList = array('Битва началась, атакуй!');
$memcache->set('log_'.$u['id'].'', $keyList, false, 366400);
redirect('/locations/'.$loc_id.'/battle');
}
$count = $db -> query("SELECT * FROM `locations_mobs` WHERE `location_id` = '".$loc_id."'") -> num_rows;
$k_page = k_page($count,10);
$page = page($k_page);
$start = 10*$page-10;
$sql = $db -> query("SELECT * FROM `locations_mobs` WHERE `location_id` = '".$loc_id."' ORDER BY `mob_level` ASC LIMIT $start, 10");
//<a href="/locations/'.$loc_id.'/mob-info-'.$q->id.'">[Info]</a>
echo'<div class = "index-battleground">';
while($q = $sql->fetch_object())
{
if($q->cooldown_time <= time())
{
echo '<div class = "ram-monster"><a class="monster-'.$q->id.'" href="/locations/'.$loc_id.'/attack-'.$q->id.'">'.$q->name.' ['.$q->mob_level.' ур.]
</a></div>';
}
else
{
?>
<div class = "ram-monster-off"><div class = "monster-<?=$q->id;?>"><?=$q->name;?> [<?=$q->mob_level;?> ур.]
<a href="/locations/<?=$loc_id;?>/mob-info-<?=$q->id;?>">[I]</a> [<span id="time_<?=($q->cooldown_time-time());?>000"><?=tl($q->cooldown_time-time());?></span>]</div></div>
<?
}
}
echo"</div>";
if($count >= 10) echo str('/locations/'.$loc_id.'/?', $k_page, $page);
if($count == 0) echo '<div class="b">Нет мобов!</div>';
include_once ($root.'/core/foot.php');