<?php
define('PROTECTOR', 1);
include('files/path.php');
include($path.'files/db.php');
include($path.'files/auth.php');
include($path.'files/func.php');
$textl='Огненные земли';
include($path.'files/core.php');
include($path.'files/head.php');
include($path.'files/zag.php');
if($new_lvl=='yes'){header('Location: boss.php');exit;}

if($udata['lvl']<5){
echo'<div class="main"><div class="block_zero center">Огненные земли доступны с 5-го уровня!</div></div>';
include($path.'files/down.php');
exit;
}

$timer=time()-86400;
mysql_query("DELETE FROM `temp` WHERE `user` = '$log' AND `user` = '$log' AND `hp` = '0' AND `ltime` < '$timer'") OR die(mysql_error());
switch($_GET['mod']){
default:
echo'<div class="main"><div class="block_zero center"><span style="color: #9bc;">Убивай монстров, получай особую награду!</span></div><div class="mini-line"></div><div class="block_zero center"><b><span style="color: #9c9;">Особая награда</span></b></div><div class="dot-line"></div><div class="block_zero">';
$mag=mysql_fetch_array(mysql_query("SELECT * FROM `shops_drop` WHERE `usr` = '$log' LIMIT 1"));
if($udata['lvl']>=$mag['nlvl']){
$font="#9c9";
$pic="ok.png";
}
if($udata['lvl']<$mag['nlvl']){
$font="#c66";
$pic="error.png";
}
$wep = mysql_query("SELECT * FROM `weapon` WHERE `image` = 'yes' AND `usr` = '$log' AND `tip` = '$mag[tip]'") OR die(mysql_error());
$wep = mysql_fetch_array($wep);
$stat = $wep['hp']+$wep['mp']+$wep['krit']+$wep['ukrit']+$wep['sila']+$wep['lovk']+$wep['prot'];
$statmag = $mag['hp']+$mag['mp']+$mag['krit']+$mag['ukrit']+$mag['sila']+$mag['lovk']+$mag['prot'];
if($stat==$statmag){
$tex='<span style="color: #999;"> + 0</span>';
}
if($statmag-$stat>0){
$sta=$statmag-$stat;
$tex='<span style="color: #9c9;"> +'.$sta.'</span>';
}
if($statmag-$stat<0){
$sta=$statmag-$stat;
$tex='<span style="color: #c66;"> '.$sta.'</span>';
}
if(!empty($mag['img'])){
$patch="art/$mag[img]";
}else{
$patch="weapon/$mag[kompl]/$mag[tip].png";
}
switch($mag['tip']){
case 'weapon':
$tip='Оружие';
break;
case 'body':
$tip='Доспехи';
break;
case 'golova':
$tip='Шлем';
break;
case 'nogi':
$tip='Сапоги';
break;
case 'shit':
$tip='Щит';
break;
}
$myr=mysql_fetch_array(mysql_query("SELECT * FROM `drop_oz` WHERE `usr`='$log' LIMIT 1"));

if(empty($mag['usr']) OR empty($myr['usr'])){
echo'<img class="float-left" src="image/boss/no.png" width="50" height="50" style="margin-left:60px; margin-right:10px;" alt="*"><span style="color: #fc6;">Ничего не выбрано</span><br><small>У Вас ещё не выбрана награда, выбирите её</small><div class="separ"></div><center><img src="image/icon/exp.png" alt="*"> Опыт: 0 из 0';
}
elseif(empty($tip)){
$img = substr($myr['lat_name'],0,3);
if($myr['lat_name']=='jelezo'){
$vid='ресурс';
}
if($myr['lat_name']=='serebro'){
$vid='ресурс';
}
if($myr['lat_name']=='nefrit'){
$vid='ресурс';
}
if($myr['lat_name']=='obsidian'){
$vid='ресурс';
}
if($myr['lat_name']=='kamen'){
$vid='ресурс';
}
if($myr['lat_name']=='remont'){
$vid='артефакт';
}
if($myr['lat_name']=='zakal'){
$vid='артефакт';
}
echo'<img class="float-left" src="image/resurs/'.$img.'.png" width="50" height="50" style="margin-left:60px; margin-right:10px;" alt="*"><span style="color: #fc6;"> '.$myr['name'].'</span><br><small>Тип: '.$vid.'<br>Кол-во: '.$myr['give'].' шт.<br></small><div class="separ"></div><center><img src="image/icon/exp.png" alt="*"> Опыт: '.$myr['exp'].' из '.$myr['expmax'].'';
}else{
echo'<img class="float-left" src="image/'.$patch.'" width="50" height="50" style="margin-left:60px; margin-right:10px;" alt="*"><span style="color: #fc6;"> '.$tip.' '.$mag['name'].' '.$tex.'</span></br><small>Необходимо мастерства: '.$mag['nlvl'].'<br>Бонус: 0/10</small><div class="separ"></div>';
echo'<center>Опыт: '.$mag['exp'].' из '.$mag['expmax'].'';
}
if(empty($mag['usr']) OR empty($myr['usr'])){
echo'<div class="block_zero center"><a href="boss.php?mod=drop"><span class="btn"><span class="end"><input class="label" type="submit" value="Выбрать"></span></span></center></a></div><div class="mini-line"></div>';
}else{
echo'<div class="block_zero center"><a href="boss.php?mod=vibor"><span class="btn"><span class="end"><input class="label" type="submit" value="Подробнее"></span></span></center></a></div><div class="mini-line"></div>';
}
$avto = mysql_query("SELECT * FROM `boss` ORDER BY `lvl` ASC") OR die(mysql_error());
$req = mysql_query("SELECT * FROM `boss` ORDER BY `lvl` ASC") OR die(mysql_error());
$avto=mysql_num_rows($avto);
if($avto>=1){
While($boss = mysql_fetch_array($req)){
$font="#9c9";
$level="$boss[lvl] уровень";
$text = "Достигнут <img src='image/icon/level.png' alt='hp'/> ";
if($boss['lvl']>$udata['lvl']){
$font="#c66";
$text = "Требуется <img src='image/icon/level.png' alt='hp'/> ";
}else{
$timer=time()-86400;
$hp = mysql_query("SELECT `hp` FROM `temp` WHERE `id` = '$boss[id]' AND `user`='$log' LIMIT 1");
$temp = mysql_query("SELECT * FROM `temp` WHERE `id` = '$boss[id]' AND `user`='$log' AND `status`='die' AND `ltime`>'$timer' LIMIT 1");
$avtot=mysql_num_rows($temp);
$bossen = mysql_fetch_array($temp);
$bhp = mysql_fetch_array($hp);
if($bhp['hp']>>0){
$boss['hp']=$bhp['hp'];
}
$time = time();
$ab=$bossen['ltime']+86400-$time;
if($avtot>>0){
$font="#999";
$text = 'Воскреснет через '.Sec2Time($ab).'';
$level = "";
}
}
echo'<div class="main"><div class="block_zero"><a href="boss.php?mod=info&id='.$boss['id'].'"><img class="float-left" src="image/boss/'.$boss['lvl'].'.png" style="margin-left:1px; margin-right:10px;" alt="*"></a><img src="image/icon/2hit.png" alt="*"><span style="color: #fc6;"> '.$boss['name'].'</span><br><small><span style="color: #9cc;">Награда:</span> <img src="image/icon/exp.png" alt="*"> '.$boss['exp'].' опыта<br><span style="color: '.$font.';"> '.$text.' '.$level.'</span></small></div></div>';
if($boss['lvl']<=$udata['lvl'] AND $bossen['status']!=='die'){
echo'<div class="block_zero"><a href="boss.php?mod=info&id='.$boss['id'].'"><span class="btn"><span class="end"><input class="label" type="submit" value="Выбрать"></span></span></a></div>';
}
echo'<div class="mini-line"></div>';
}
echo'<ul class="hint"><li>Для получения "Особой награды" накопи достаточное количество опыта, убивая монстров</li></ul></div></div>';
}else{
echo'<div class="block_zero center">Нет боссов!</div>';
}
echo'</div></div>';
break;

case 'drop':
if($mast>=0 AND $mast<=5){
$lvl=rand(1,70);//обычные
}
elseif($mast>=6 AND $mast<=23){
$lvl=rand(11,70);//редкие
}
elseif($mast>=1*24 AND $mast<=47){
$lvl=rand(21,70);//эпические
}
elseif($mast>=48 AND $mast<=199){
$lvl=rand(31,70);//легендарные
}
elseif($mast>=200 AND $mast<=249){
$lvl=rand(41,70);//божественные
}
elseif($mast>=250 AND $mast<=300){
$lvl=rand(51,70);//титанические
}
$s=mysql_fetch_array(mysql_query("SELECT * FROM `shops` WHERE `id`='$lvl' ORDER BY RAND() LIMIT 1"));
$s['expmax']=$s['kompl']*1000;
$my=mysql_fetch_array(mysql_query("SELECT * FROM `shops_drop` WHERE `usr`='$log' LIMIT 1"));
if(empty($my['usr'])){
mysql_query("INSERT INTO `shops_drop` (usr,exp,expmax,tip,kompl,name,cena,hp,mp,krit,ukrit,sila,lovk,prot,klas,nlvl,img) VALUES ('".$log."','0','".$s['expmax']."','".$s['tip']."','".$s['kompl']."','".$s['name']."','".$s['cena']."','".$s['hp']."','".$s['mp']."','".$s['krit']."','".$s['ukrit']."','".$s['sila']."','".$s['lovk']."','".$s['prot']."','".$s['klas']."','".$s['nlvl']."','".$s['img']."')");
}else{
mysql_query("UPDATE `shops_drop` SET `exp` = '0', `expmax` = '$s[expmax]', `tip` = '$s[tip]', `kompl` = '$s[kompl]', `name` = '$s[name]', `cena` = '$s[cena]', `hp` = '$s[hp]', `mp` = '$s[mp]', `krit` = '$s[krit]', `ukrit` = '$s[ukrit]', `sila` = '$s[sila]', `lovk` = '$s[lovk]', `prot` = '$s[prot]', `klas` = '$s[klas]', `nlvl` = '$s[nlvl]', `img` = '$s[img]' WHERE `usr`='$log'");
}
$ss=mysql_fetch_array(mysql_query("SELECT * FROM `drop` WHERE `what`='res' ORDER BY RAND() LIMIT 1"));
$myr=mysql_fetch_array(mysql_query("SELECT * FROM `drop_oz` WHERE `usr`='$log' LIMIT 1"));
$ss['expmax']=$ss['cena']*100;
if($my['komplekt']==0){
if(empty($myr['usr'])){
mysql_query("INSERT INTO `drop_oz` (usr,exp,expmax,name,lat_name,tip,what,give,cena) VALUES ('".$log."','0','".$ss['expmax']."','".$ss['name']."','".$ss['lat_name']."','".$ss['tip']."','".$ss['what']."','".$ss['give']."','".$ss['cena']."')");
}else{
mysql_query("UPDATE `drop_oz` SET `exp` = '0', `expmax` = '$ss[expmax]', `name` = '$ss[name]', `lat_name` = '$ss[lat_name]', `tip` = '$ss[tip]', `what` = '$ss[what]', `give` = '$ss[give]', `cena` = '$ss[cena]' WHERE `usr`='$log'");
}
}
header('Location: boss.php?mod=vibor');exit;
break;

case 'vibor':
echo'<div class="main">';
$mag=mysql_fetch_array(mysql_query("SELECT * FROM `shops_drop` WHERE `usr`='$log' LIMIT 1"));
if($udata['lvl']>$mag['nlvl']){
$font="#9c9";
$pic="ok.png";
}
if($udata['lvl']<$mag['nlvl']){
$font="#c66";
$pic="error.png";
}
$wep = mysql_query("SELECT * FROM `weapon` WHERE `image` = 'yes' AND `usr` = '$log' AND `tip` = '$mag[tip]'") OR die (mysql_error());
$wep = mysql_fetch_array($wep);
$stat = $wep['hp']+$wep['mp']+$wep['krit']+$wep['ukrit']+$wep['sila']+$wep['lovk']+$wep['prot'];
$statmag = $mag['hp']+$mag['mp']+$mag['krit']+$mag['ukrit']+$mag['sila']+$mag['lovk']+$mag['prot'];
if($stat==$statmag){
$tex='<span style="color: #999;"> + 0</span>';
}
if($statmag-$stat>0){
$sta=$statmag-$stat;
$tex='<span style="color: #9c9;"> +'.$sta.'</span>';
}
if($statmag-$stat<0){
$sta=$statmag-$stat;
$tex='<span style="color: #c66;"> '.$sta.'</span>';
}
if(!empty($mag['img'])){
$patch="art/$mag[img]";
}else{
$patch="weapon/$mag[kompl]/$mag[tip].png";
}
switch($mag['tip']){
case 'weapon':
$tip='Оружие';
break;
case 'body':
$tip='Доспехи';
break;
case 'golova':
$tip='Шлем';
break;
case 'nogi':
$tip='Сапоги';
break;
case 'shit':
$tip='Щит';
break;
}
echo'<div class="block_zero">';
$myr=mysql_fetch_array(mysql_query("SELECT * FROM `drop_oz` WHERE `usr`='$log' LIMIT 1"));
if(empty($tip)){
$img = substr($myr['lat_name'],0,3);
if($myr['lat_name']=='jelezo'){
$vid='ресурс';
}
if($myr['lat_name']=='serebro'){
$vid='ресурс';
}
if($myr['lat_name']=='nefrit'){
$vid='ресурс';
}
if($myr['lat_name']=='obsidian'){
$vid='ресурс';
}
if($myr['lat_name']=='kamen'){
$vid='ресурс';
}
if($myr['lat_name']=='remont'){
$vid='артефакт';
}
if($myr['lat_name']=='zakal'){
$vid='артефакт';
}
echo'<img class="float-left" src="image/resurs/'.$img.'.png" width="50" height="50" style="margin-left:1px; margin-right:10px;" alt="*"><span style="color: #fc6;"> '.$myr['name'].'</span><br><small>Тип: '.$vid.'<br>Кол-во: '.$myr['give'].' шт.</small><br></div><div class="mini-line"></div><div class="block_zero"><img src="image/icon/exp.png" alt="*"> Опыт: '.$myr['exp'].' из '.$myr['expmax'].'';
}else{
echo'<img class="float-left" src="image/'.$patch.'" width="50" height="50" style="margin-left:1px; margin-right:10px;" alt="*"><span style="color: #fc6;"> '.$tip.' '.$mag['name'].'</span> '.$tex.'</br><small>Необходимо мастерства: '.$mag['nlvl'].'<br>Бонус: 0/10</small>';
echo'</div><div class="mini-line"></div><div class="block_zero"><img src="image/icon/exp.png" alt="*"> Опыт: '.$mag['exp'].' из '.$mag['expmax'].'';
}
echo'<br><small><span style="color: #9c9;">Чтобы получить вещь, зарабатывайте опыт сражаясь с монстрами</span></small></div><div class="mini-line"></div><div class="block_zero center">';
if($mag['kompl']==0){
$nagr=($myr['cena']*$myr['give'])/2;
}else{
$nagr=$mag['cena']/2;
}
if($myr['exp']>=$myr['expmax'] OR $mag['exp']>=$mag['expmax'] AND $mag['exp']>0){
echo'<a href="boss.php?mod=pokupka"><span class="btn"><span class="end"><input class="label" type="submit" value="Выкупить награду"></span></span></a><br><img src="image/icon/almaz.png" alt="*"> <small><span style="color: #999;">'.$nagr.' золота</span></small></a><br><br>';
}
echo'<a href="boss.php?mod=smena"><span class="btn"><span class="end"><input class="label" type="submit" value="Выбрать другую награду"></span></span></a><br><img src="image/icon/almaz.png" alt="*"> <small><span style="color: #999;"> 1 золота</span></small></a></div>';
echo'<div class="mini-line"></div><a href="boss.php?"><div class="block_zero"><img src="image/icon/hellworld.png" alt="*"> Огненные земли</div></a><div class="mini-line"></div><ul class="hint"><li>Чем больше прогресс опыта, тем быстрее можно выкупить награду</li><li>При достижении 100% прогресса награду можно выкупить в 2 раза дешевле её стоимости</li><li>При смене вещи текущий прогресс пропадёт</li></ul></div></div>';
break;

case 'pokupka':
$s=mysql_fetch_array(mysql_query("SELECT * FROM `shops_drop` WHERE `usr`='$log' LIMIT 1"));
$ss=mysql_fetch_array(mysql_query("SELECT * FROM `drop_oz` WHERE `usr`='$log' LIMIT 1"));
$res=mysql_fetch_array(mysql_query("SELECT * FROM `res` WHERE `usr`='$log' LIMIT 1"));
if($s['kompl']==0){
if($ss['exp']==0){
header('Location: boss.php?mod=drop');exit;
}
if($ss['lat_name']==$res['lat_name']){
mysql_query("UPDATE `res` SET `name` = '$ss[name]', `tip` = '$ss[tip]', `what` = '$ss[what]', `kol` = `kol`+$ss[give], `cena` = '$ss[cena]' WHERE `usr`='$log' AND `lat_name` = '$ss[lat_name]'");
}else{
mysql_query("INSERT INTO `res` (usr,name,lat_name,tip,what,kol,cena) VALUES ('".$log."','".$ss['name']."','".$ss['lat_name']."','".$ss['tip']."','".$ss['what']."','".$ss['give']."','".$ss['cena']."')");
}
if($ss['exp']==0){
$nagr=0;
}else{
$nagr=($ss['cena']*$ss['give'])/2;
}
mysql_query("UPDATE `users` SET `almaz`=`almaz`-$nagr WHERE `usr` = '$log'");
}else{
if($s['exp']==0){
header('Location: boss.php?mod=drop');exit;
}
if($s['exp']==0){
$nagr=0;
}else{
$nagr=$s['cena']/2;
}
mysql_query("INSERT INTO
        `weapon` SET
        `usr` = '$log',
        `tip` = '$s[tip]',
        `kompl` = '$s[kompl]',
        `proch` = '10',
        `name` = '$s[name]',
        `cena` = '$s[cena]',
        `hp` = '$s[hp]',
        `mp` = '$s[mp]',
        `krit` = '$s[krit]',
        `ukrit` = '$s[ukrit]',
        `sila` = '$s[sila]',
        `lovk` = '$s[lovk]',
        `prot` = '$s[prot]',
        `nlvl` = '$s[nlvl]',
        `image` = 'not'") OR die(mysql_error());
        mysql_query("UPDATE `users` SET `almaz`=`almaz`-$nagr WHERE `usr` = '$log'");
        }
        header('Location: boss.php?mod=drop');exit;
break;

case 'smena':
if($udata['almaz']<1){
$_SESSION['err']="Не достаточно золота!";
header('Location: boss.php?mod=vibor');
exit();
}
mysql_query("UPDATE `users` SET `almaz`=`almaz`-1 WHERE `usr` = '$log'");
header('Location: boss.php?mod=drop');exit;
break;

case 'info':

$id=$_GET['id'];

$req = mysql_query("SELECT * FROM `boss` WHERE `id` = '".mysql_real_escape_string($id)."' LIMIT 1");

if(mysql_num_rows($req)==0){
echo"Такого босса не существует.".mysql_num_rows($req);
include($path.'files/down.php');exit;
}
$hp = mysql_query("SELECT * FROM `temp` WHERE `id` = '".mysql_real_escape_string($id)."' AND `user`='$log' LIMIT 1");
$bhp = mysql_fetch_array($hp);
$mob = mysql_fetch_array($req);
if($bhp['hp']>>0){
$mob['hp']=$bhp['hp'];
}
echo'<div class="main"><div class="block_zero"><img class="float-left" src="image/boss/'.$mob['lvl'].'-big.png" style="margin-left:1px; margin-right:10px;" alt="*">';
echo"<img src='image/icon/2hit.png' alt='*'> <span style='color: #fc6;'>$mob[name]</span><br>";
echo"<img src=\"image/icon/health.png\" alt=\"*\"/> Жизни: $mob[hp]<br>";
echo"<img src=\"image/icon/str.png\" alt=\"*\"/> Сила: $mob[uron]<br>";
echo"<img src=\"image/icon/def.png\" alt=\"*\"/> Защита: $mob[prot]<br>";
echo"<img src=\"image/icon/agi.png\" alt=\"*\"/> Ловкость: $mob[lovk]<br>";
echo"<img src=\"image/icon/sumstat.png\" alt=\"*\"/> Крит-удар: $mob[krit]%<br>";
echo"<img src=\"image/icon/tournament.png\" alt=\"*\"/> Крит-урон: $mob[ukrit]%<br>";
echo"<span style='color: #9cc;'>Награда:</span> <img src=\"image/icon/exp.png\" alt=\"*\"/> $mob[exp] опыта";

if($mob['lvl']>$udata['lvl']){
echo"<br><br><span style='color: #c66;'>Требуется <img src=\"image/icon/level.png\" alt=\"*\"/> $mob[lvl] уровень!</span>";
}else{
$timer=time()-86400;
$temp = mysql_query("SELECT * FROM `temp` WHERE `id` = '$mob[id]' AND `user`='$log' AND `status`='die' AND `ltime`>'$timer' LIMIT 1");
$avtot=mysql_num_rows($temp);
if($avtot>>0){
$bossen = mysql_fetch_array($temp);
$time = time();
echo'<br><span style="color: #999;">Воскреснет через:<br>';
$ab=$bossen['ltime']+86400-$time;
echo''.Sec2Time($ab).'</span>';
}
elseif($in_battle=='1'){
echo'<br><span style="color: #c66;">Вы уже в бою с другим монстром</span>';
}else{
echo'<br><br><form action="ok.php?id='.$id.'" method="POST">';
echo'<span class="btn"><span class="end"><input class="label" type="submit" value="Атаковать"></span></span></form>';
}
}
echo'</div><div class="mini-line"></div><a href="boss.php?"><div class="block_zero"><img src="image/icon/hellworld.png" alt="*"> Огненные земли</div></a><div class="mini-line"></div><ul class="hint"><li>Побеждает тот, кто нанес больше всего урона</li></ul></div></div></div>';
break;
}
include($path.'files/down.php');
?>