Вход Регистрация
Файл: rayb.me/maze.php
Строк: 328
<?php
require_once './system/func.php';
$title 'Сокровищница'
auth();
antihack();
require_once 
'./system/header.php'

echo 
'<div class="block">Забытая '.$title.'</div>';

?><style>
.p_re{position:relative;}
.p_ab{position:absolute;right:0px;left:5%;margin-top:5%;margin-bottom:0px;}
.block_s{width: 20%; height: 20%;}
.maze {width: 85%;height: 85%; margin: 0 auto;}
</style>

<script type="text/javascript" language="javascript">
function open_maze(block,block2){ var xhr = new XMLHttpRequest(); xhr.open('GET','/maze_func.php?m=open&block='+block+'&block2='+block2, true); xhr.send(); xhr.onreadystatechange = function(){ if(xhr.readyState == 4){ if(xhr.status != 200){ location.reload(); }else{ stats = JSON.parse(xhr.responseText); if(typeof(stats.maze) != "undefined" && stats.maze !== null){ document.getElementById('maze').innerHTML =stats.maze; document.getElementById('kol_kluch').innerHTML =stats.kol_kluch; location.reload(); } if(typeof(stats.maze_text) != "undefined" && stats.maze_text !== null){ document.getElementById('error').innerHTML =stats.maze_text; }}}}}

function lvl_maze(block,block2) { var xhr = new XMLHttpRequest(); xhr.open('GET','/maze_func.php?m=lvl&block='+block+'&block2='+block2, true);xhr.send();xhr.onreadystatechange = function() { if (xhr.readyState == 4) {if (xhr.status != 200) {location.reload();} else {stats = JSON.parse(xhr.responseText);if(typeof(stats.maze_text) != "undefined" && stats.maze_text !== null) {document.getElementById('error').innerHTML =stats.maze_text;} else {location.reload();}}}}}

function kluch_maze(block,block2) {var xhr = new XMLHttpRequest();xhr.open('GET','/maze_func.php?m=kluch&block='+block+'&block2='+block2, true);xhr.send();xhr.onreadystatechange = function() { if (xhr.readyState == 4) {if (xhr.status != 200) {location.reload();} else {stats = JSON.parse(xhr.responseText);if(typeof(stats.maze_text) != "undefined" && stats.maze_text !== null) {document.getElementById('maze_kl').innerHTML =', <img src="/images/maze/maze_kluch.png" alt="" width="16"/> 1';document.getElementById('maze_kluch').style.display ='none';}}}}}

function n_maze(block,block2) {var xhr = new XMLHttpRequest();xhr.open('GET','/maze_func.php?m=nagrada&block='+block+'&block2='+block2, true);xhr.send();xhr.onreadystatechange = function() { if (xhr.readyState == 4) {if (xhr.status != 200) {location.reload();} else {stats = JSON.parse(xhr.responseText);if(typeof(stats.maze_text) != "undefined" && stats.maze_text !== null) {document.getElementById('error').innerHTML =stats.maze_text;document.getElementById('n'+block+block2).style.display ='none';}}}}}

function sunduk_maze(block,block2) {var xhr = new XMLHttpRequest();xhr.open('GET','/maze_func.php?m=sunduk&block='+block+'&block2='+block2, true);xhr.send();xhr.onreadystatechange = function() {  if (xhr.readyState == 4) {if (xhr.status != 200) {location.reload();} else {stats = JSON.parse(xhr.responseText);if(typeof(stats.maze_text) != "undefined" && stats.maze_text !== null) {document.getElementById('maze').innerHTML =stats.maze_text;}}}}}

function hp_maze(block,block2) {var xhr = new XMLHttpRequest();xhr.open('GET','/maze_func.php?m=hp&block='+block+'&block2='+block2, true);xhr.send();xhr.onreadystatechange = function() { if (xhr.readyState == 4) {if (xhr.status != 200) {location.reload();} else {stats = JSON.parse(xhr.responseText);if(typeof(stats.maze_text) != "undefined" && stats.maze_text !== null) {document.getElementById('error').innerHTML =stats.maze_text;document.getElementById('n'+block+block2).style.display ='none';document.getElementById('kol_hp').innerHTML =stats.maze_hp;}}}}}
</script><?


$maze 
mysql_fetch_assoc(mysql_query("SELECT * FROM `maze` WHERE `id_user`='".$uid."' limit 1"));
if(
$maze['id'] == 0){
    if(!isset(
$_GET['ok'])){
        echo 
'<div class="block"><img src="/images/maze/maze.png" alt="" /><br/><a href="/maze?ok">Войти</a></div>';
        echo 
'<div class="block">
В сокровищнице можно найти золото, рубины, балы и секретный сундук. Подробнее <a href="#">здесь</a></div>'
;
    }else{
        
$kluch rand(1,25);
        
$maze_up rand(1,25);
        if(
$maze_up == $kluch$maze_up rand(1,25);
        if(
$maze_up == $kluch$maze_up rand(1,25);
        if(
$maze_up == $kluch$maze_up rand(1,25);
        
$tip mt_rand(1,3);
        
mysql_query("INSERT INTO `maze`(`id`,`id_user`,`hp`,`hp_max`,`kluch`,`maze`,`tip`)VALUES('','".$uid."','".num($user['vit'])."','".num($user['vit'])."','$kluch','$maze_up','tip')");
        
$open rand(2,3);
        
$open2 rand(2,3);
        
go("/maze");
    }
}else{
    if(
$maze['hp']>0){
        if(!isset(
$_GET['block']) or !isset($_GET['block2'])){
            if(
$maze['tip']==1){
                
$opened_maze = array('1_1' => '1_2','1_2' => '2_2','1_3' => '2_3','1_4' => '1_5','1_5' => '2_5','2_1' => '3_1','2_2' => '3_2','2_3' => '2_2','2_4' => '3_4','2_5' => '3_5','3_1' => '4_1','3_2' => '3_3','3_3' => '0','3_4' => '3_3','3_5' => '3_4','4_1' => '4_2','4_2' => '3_2','4_3' => '3_3','4_4' => '3_4','4_5' => '3_5','5_1' => '4_1','5_2' => '5_1','5_3' => '4_3','5_4' => '4_4','5_5' => '5_4');
            }elseif(
$maze['tip']==2){
                
$opened_maze = array('1_1' => '2_1','1_2' => '2_2','1_3' => '1_2','1_4' => '2_4','1_5' => '1_4','2_1' => '2_2','2_2' => '3_2','2_3' => '2_4','2_4' => '3_4','2_5' => '3_5','3_1' => '2_1','3_2' => '3_3','3_3' => '0','3_4' => '3_3','3_5' => '3_4','4_1' => '4_2','4_2' => '4_3','4_3' => '3_3','4_4' => '3_4','4_5' => '4_4','5_1' => '5_2','5_2' => '4_2','5_3' => '5_2','5_4' => '5_5','5_5' => '4_5');
            }else{
                
$opened_maze = array('1_1' => '2_1','1_2' => '2_2','1_3' => '2_3','1_4' => '2_4','1_5' => '2_5','2_1' => '2_2','2_2' => '3_2','2_3' => '2_2','2_4' => '2_5','2_5' => '3_5','3_1' => '3_2','3_2' => '3_3','3_3' => '0','3_4' => '4_4','3_5' => '3_4','4_1' => '4_2','4_2' => '3_2','4_3' => '4_2','4_4' => '4_3','4_5' => '3_5','5_1' => '4_1','5_2' => '5_3','5_3' => '4_3','5_4' => '5_3','5_5' => '5_4');
            }
            
            
$maze_block['3_3']=1;
            
$maze_opit['3_3']=0;
            
$maze_money['3_3']=0;
            
$maze_lovushka['3_3']=0;
            
$maze_hp['3_3']=0;
            
$q=mysql_query("SELECT SQL_CACHE *  FROM `maze_block` WHERE `id_user`='".$uid."' ");
            while(
$r mysql_fetch_assoc($q)){
                
$maze_block[''.$r['block'].'_'.$r['block2'].'']=1;
                
$maze_opit[''.$r['block'].'_'.$r['block2'].'']=$r['opit'];
                
$maze_money[''.$r['block'].'_'.$r['block2'].'']=$r['money'];
                
$maze_lovushka[''.$r['block'].'_'.$r['block2'].'']=$r['lovushka'];
                
$maze_hp[''.$r['block'].'_'.$r['block2'].'']=$r['hp'];
            }
            
            
?>
            <div id="error"></div>
            <div class="block"> Ключей <img src="/images/maze/keys.png" alt="" width="16"/>
            <span id="kol_kluch"><?= $user['maze_kluch'?></span>, 
            Осталось <img src="/images/ico/png/hp.png" alt="" width="16"/>
            <span id="kol_hp"><?= $maze['hp'?></span>
            <span id="maze_kl"></span>
            <?
            
            
if($maze['kluch']==0) echo', <img src="/images/maze/maze_kluch.png" alt="" width="16"/> 1';
            echo
'</div><hr/><div class="block"><div class="center">Этаж '.$maze['lvl'].'</div><div id="maze" class="center maze">';
            for(
$i=1;$i<26;$i++){
                
$block=ceil(($i/5));$block2=$i-($block-1)*5;
                if(isset(
$maze_block[''.$block.'_'.$block2.''])){
                    if(
$maze_lovushka[''.$block.'_'.$block2.'']!=0){
                        echo
'<a  class="block_s p_re" style="'.$opened_maze[''.$block.'_'.$block2.''].'" href="/maze?block='.$block.'&amp;block2='.$block2.'"><img src="/images/maze/open.png" width="20%" alt="" /><img id="n'.$block.''.$block2.'" class="p_ab" src="/images/maze/lovushka'.$maze_lovushka[''.$block.'_'.$block2.''].'.png" alt="" /></a>';
                    }elseif(
$i==$maze['maze']){
                        echo
'<a  class="block_s p_re" style="'.$opened_maze[''.$block.'_'.$block2.''].'" onclick="lvl_maze('.$block.','.$block2.');return false;"><img src="/images/maze/open.png" width="20%" alt="" /><img class="p_ab" src="/images/maze/'.($maze['kluch'] == 'maze_open':'maze_up').'.png" alt="" /></a>';
                    }elseif(
$i==$maze['kluch']){
                        echo
'<a  class="block_s p_re" style="'.$opened_maze[''.$block.'_'.$block2.''].'" onclick="kluch_maze('.$block.','.$block2.');return false;"><img src="/images/maze/open.png" width="20%" alt="" /><img id="maze_kluch" class="p_ab" src="/images/maze/maze_kluch.png" alt="" /></a>';
                    }elseif(
$i==$maze['sunduk']){
                        echo
'<a  class="block_s p_re" style="'.$opened_maze[''.$block.'_'.$block2.''].'" onclick="sunduk_maze('.$block.','.$block2.');return false;"><img src="/images/maze/open.png" width="20%" alt="" /><img id="maze_kluch" class="p_ab" src="/images/maze/sunduk.png" alt="" /></a>';
                    }elseif(
$maze_money[''.$block.'_'.$block2.'']!=0){
                        echo
'<a  class="block_s p_re" style="'.$opened_maze[''.$block.'_'.$block2.''].'" onclick="n_maze('.$block.','.$block2.');return false;"><img src="/images/maze/open.png" width="20%" alt="" /><img id="n'.$block.''.$block2.'" class="p_ab" src="/images/maze/money.png" alt="" /></a>';
                    }elseif(
$maze_opit[''.$block.'_'.$block2.'']!=0){
                        echo
'<a  class="block_s p_re" style="'.$opened_maze[''.$block.'_'.$block2.''].'" onclick="n_maze('.$block.','.$block2.');return false;"><img src="/images/maze/open.png" width="20%" alt="" /><img id="n'.$block.''.$block2.'" class="p_ab" src="/images/maze/opit.png" alt="" /></a>';
                    }elseif(
$maze_hp[''.$block.'_'.$block2.'']!=0){
                        echo
'<a  class="block_s p_re" style="'.$opened_maze[''.$block.'_'.$block2.''].'" onclick="hp_maze('.$block.','.$block2.');return false;"><img src="/images/maze/open.png" width="20%" alt="" /><img id="n'.$block.''.$block2.'" class="p_ab" src="/images/maze/maze_hp.png" alt="" /></a>';
                    }else{
                        echo
'<img class="block_s" src="/images/maze/open.png" width="20%" alt="" />';
                    }
                }else{
                    if(isset(
$maze_block[''.$opened_maze[''.$block.'_'.$block2.''].''])){
                        if(
$maze_lovushka[''.$opened_maze[''.$block.'_'.$block2.''].'']==0){
                            echo
'<a  class="ssilki1"  onclick="open_maze('.$block.','.$block2.');return false;"><img class="block_s" src="/images/maze/closed.png" width="100%" alt="" /></a>';
                        }else{
                            echo
'<span  class="ssilki1 p_re"><img class="block_s" src="/images/maze/closed.png" width="20%" alt="" /><img id="n'.$block.''.$block2.'" class="p_ab" src="/images/maze/block2.png" width="100%" alt="" /></span>';
                        }
                    }else{
                        echo
'<img class="block_s" src="/images/maze/block.png" width="20%" alt="" />';
                    }
                }
            }
            
            echo
'</div></div><div class="line"></div>';
            require_once 
'./system/footer.php';
            exit;
        }else{
            
//Выбираем направление//
            
if(isset($_GET['block'])){
                
$block=num($_GET['block']);
            }else{
                
$block=1;
            }
            
            if(
$block>25 or $block<1){
                
$block=1;
            }
            
            if(isset(
$_GET['block2'])){
                
$block2=num($_GET['block2']); 
            }else{
                
$block2=1;
            }
            
            if(
$block2>25 or $block2<1){
                
$block2=1;
            }
            
            
$maze_block mysql_fetch_assoc(mysql_query("SELECT * FROM `maze_block` WHERE `id_user`='".$uid."' and `block`='$block' and `block2`='$block2' and `lovushka`>0 limit 1"));
            if(
$maze_block['id']>0){
                if(!isset(
$_GET['t'])){
                    echo
'<div class="empty_block item_center"><img src="/images/maze/lovushka'.$maze_block['lovushka'].'_big.png" alt="" /><br/><br/><a href="/maze?block='.$block.'&amp;block2='.$block2.'&amp;t=1" ><img src="/images/maze/lovushka_left.png" alt="" /></a><a href="/maze?block='.$block.'&amp;block2='.$block2.'&amp;t=2" ><img src="/images/maze/lovushka_center.png" alt="" /></a><a href="/maze?block='.$block.'&amp;block2='.$block2.'&amp;t=3" ><img src="/images/maze/lovushka_right.png" alt="" /></a></div><div class="line"></div><div class="block_link"><a href="/maze" class="link"><img src="/images/ico/png/back.png" width="18"> Назад в Лабиринт </a></div><div class="line"></div>';
                    require_once 
'./system/footer.php';
                    exit;
                }else{
                    
// Результат вашого хода
                    
mysql_query("UPDATE `maze_block` SET `lovushka`='0' WHERE `id`='".num($maze_block['id'])."'  limit 1 ");
                    if(
rand(1,3)==$_GET['t']){
                        
mysql_query("UPDATE `maze` SET `passed_traps`=`passed_traps`+'1' WHERE `id`='".num($maze['id'])."'  limit 1 ");
                        echo
''.msg('<span style="color: #7afe4e;">Вы успешно прошли ловушку</span>').'';
                    }else{
                        
$uron=rand(1,3);
                        if(
$uron==1){
                            
$uron=num($maze['hp_max']*0.2);
                        }elseif(
$uron==2){
                            
$uron=num($maze['hp_max']*0.4);
                        }elseif(
$uron==3){
                            
$uron=num($maze['hp_max']*0.6);
                        }
                        
                        if(
$uron>$maze['hp']) $uron=$maze['hp'];
                        
mysql_query("UPDATE `maze` SET `hp`=`hp`-'$uron', `passed_traps`=`passed_traps`+'1' WHERE `id`='".num($maze['id'])."'  limit 1 ");
                        echo
''.msg('Ловушка вам нанесла <img src="/images/ico/png/hp.png" width="16">'.$uron.' урона').'';
                    }
                }
                
                echo
'<div class="empty_block item_center"><img src="/images/maze/lovushka'.$maze_block['lovushka'].'_big.png" alt="" /><br/><div class="link_center"><a href="/maze">Продолжить</a></div></div><div class="line"></div>';
            }else{
                
go("/maze");
            }
        }
        
//Если вы умерли//
    
}else{
        if(isset(
$_GET['end']) == true) {
            
mysql_query("DELETE FROM `maze_block` WHERE `id_user`='".num($user['id'])."' ");
            
mysql_query("DELETE FROM `maze` WHERE `id_user`='".num($user['id'])."' ");
            
header('location: /maze?ok');
        }
        echo
'<div class="empty_block item_center"><span style="color: #FF2400;">Ловушка сработала и нанесла вам смертельный урон. Лабиринт не пройден</span></div>'.msg('Вы дошли до 1 этажа').'<div class="empty_block item_center">Найдено: <img src="/images/ico/png/silver.png" width="16"> '.num($maze['silver']).' </br>Найдено: <img src="/images/ico/png/exp.png" width="16"> '.num($maze['exp']).' </br>Пройдено '.num($maze['passed_cells']).' клеток </br>Пройдено '.num($maze['passed_traps']).' ловушек <a href="/maze?end=true"><div class="button">Начать сначала</div></a></div><div class="line"></div>';
    }
}

require_once 
'./system/footer.php';
Онлайн: 5
Реклама