2022-06-06 21:30:34 +00:00
< ? php
2022-08-25 11:23:36 +00:00
if ( $_SERVER [ 'HTTP_X_REQUESTED_WITH' ] == 'XMLHttpRequest' && isset ( $_POST [ 'id' ])) {
define ( 'GAME' , true );
include_once ( '../_incl_data/__config.php' );
include_once ( '../_incl_data/class/__db_connect.php' );
$u = User :: start ();
if ( isset ( $_POST [ 'gox' ]) && isset ( $_POST [ 'goy' ])) {
2023-01-10 16:29:32 +00:00
echo 'Переходим на: X = ' . $_POST [ 'gox' ] . ', Y = ' . $_POST [ 'goy' ] . '<script>top.xxx=' . (( int ) $_POST [ 'gox' ]) . ';top.yyy=' . (( int ) $_POST [ 'goy' ]) . ';top.xn=' . (( int ) $_POST [ 'gox' ]) . ';top.yn=' . (( int ) $_POST [ 'goy' ]) . ';</script>' ;
2022-08-25 11:23:36 +00:00
$_POST [ 'x' ] = $_POST [ 'gox' ];
$_POST [ 'y' ] = $_POST [ 'goy' ];
}
$u -> info [ 'x' ] = 0 + ( int ) $_POST [ 'x' ];
$u -> info [ 'y' ] = 0 + ( int ) $_POST [ 'y' ];
$dn [ 'id2' ] = ( int ) $_POST [ 'ddid' ];
2023-01-10 16:29:32 +00:00
//бой с ботом
2022-08-25 11:23:36 +00:00
function addBot ( $isd , $col , $dt )
{
global $u , $c , $code ;
$vrs = explode ( '&' , $dt );
$vr = [];
$k = 0 ;
while ( $k < count ( $vrs )) {
$ex = explode ( '=' , $vrs [ $k ]);
$vr [ $ex [ 0 ]] = $ex [ 1 ];
$k ++ ;
}
}
$md5 = 0 ;
$map = '' ;
$obj = '' ;
$objd = '' ;
$usr = '' ;
$js = '' ;
$gg = 0 ;
$pix = mysql_fetch_array (
mysql_query (
'SELECT * FROM `dungeon_map` WHERE `id_dng` = "' . (( int ) $_POST [ 'ddid' ]) . '" AND `x`=' . $u -> info [ 'x' ] . ' AND `y`=' . $u -> info [ 'y' ] . ' LIMIT 1'
)
);
if ( isset ( $_POST [ 'adminion' ]) && $u -> info [ 'admin' ] > 0 ) {
2023-01-10 16:29:32 +00:00
//Админка
2022-08-25 11:23:36 +00:00
$act = explode ( '|$|' , $_POST [ 'action' ]);
if ( $act [ 0 ] == 'save_go' ) {
$act = explode ( '|!|' , $act [ 1 ]);
$mx = $act [ 0 ];
$my = $act [ 1 ];
$mpx = mysql_fetch_array (
mysql_query (
'SELECT * FROM `dungeon_map` WHERE `id_dng` = "' . $dn [ 'id2' ] . '" AND `x`=' . mysql_real_escape_string (
$mx
) . ' AND `y`=' . mysql_real_escape_string ( $my ) . ' LIMIT 1'
)
);
if ( isset ( $mpx [ 'id' ])) {
$i = 2 ;
while ( $i <= 10 ) {
if ( $act [ $i ] == 'true' ) {
$act [ $i ] = 1 ;
} else {
$act [ $i ] = 0 ;
}
$i ++ ;
}
mysql_query (
' UPDATE `dungeon_map` SET
`go_1` = " ' . mysql_real_escape_string( $act[2] ) . ' " ,
`go_2` = " ' . mysql_real_escape_string( $act[3] ) . ' " ,
`go_3` = " ' . mysql_real_escape_string( $act[4] ) . ' " ,
`go_4` = " ' . mysql_real_escape_string( $act[5] ) . ' " ,
`go_5` = " ' . mysql_real_escape_string( $act[6] ) . ' " ,
`no_bot` = " ' . mysql_real_escape_string( $act[7] ) . mysql_real_escape_string(
$act [ 8 ]
) . mysql_real_escape_string ( $act [ 9 ]) . mysql_real_escape_string ( $act [ 10 ]) . ' "
WHERE `id` = " ' . $mpx['id'] . ' " LIMIT 1 '
);
$js .= 'closeAdminion();' ;
}
} elseif ( $act [ 0 ] == 'select_image' ) {
2023-01-10 16:29:32 +00:00
//смена изображения клетки
2022-08-25 11:23:36 +00:00
$act = explode ( '|!|' , $act [ 1 ]);
$img = $act [ 0 ];
$mx = $act [ 1 ];
$my = $act [ 2 ];
$mpx = mysql_fetch_array (
mysql_query (
'SELECT * FROM `dungeon_map` WHERE `id_dng` = "' . $dn [ 'id2' ] . '" AND `x`=' . mysql_real_escape_string (
$mx
) . ' AND `y`=' . mysql_real_escape_string ( $my ) . ' LIMIT 1'
)
);
if ( isset ( $mpx [ 'id' ])) {
$mpx [ 'style' ] = $img ;
$cx = [ 0 => '1111' ,
1 => '1110' ,
2 => '1011' ,
3 => '1101' ,
4 => '0111' ,
5 => '1100' ,
6 => '0110' ,
7 => '1001' ,
8 => '0011' ,
9 => '0001' ,
10 => '0100' ,
11 => '0010' ,
12 => '1000' ,
13 => '1010' ,
14 => '0101' ,
15 => '0000' ,
16 => '' ];
mysql_query (
'UPDATE `dungeon_map` SET `style` = "' . mysql_real_escape_string (
$mpx [ 'style' ]
) . '", `st` = "' . mysql_real_escape_string (
$cx [ $mpx [ 'style' ]]
) . '" WHERE `id` = "' . $mpx [ 'id' ] . '" LIMIT 1'
);
$js .= 'closeAdminion();' ;
} else {
2023-01-10 16:29:32 +00:00
//создаем клетку
2022-08-25 11:23:36 +00:00
$go1 = 0 ;
$go2 = 0 ;
$go3 = 0 ;
$go4 = 0 ;
$go5 = 1 ;
$cx = [ 0 => '00000' ,
1 => '00001' ,
2 => '10001' ,
3 => '01001' ,
4 => '00011' ,
5 => '00101' ,
6 => '10011' ,
7 => '10101' ,
8 => '01011' ,
9 => '01101' ,
10 => '01111' ,
11 => '10111' ,
12 => '11101' ,
13 => '11011' ,
14 => '11001' ,
15 => '00111' ,
16 => '11111' ];
$go1 = $cx [ $img + 1 ][ 0 ];
$go2 = $cx [ $img + 1 ][ 1 ];
$go3 = $cx [ $img + 1 ][ 2 ];
$go4 = $cx [ $img + 1 ][ 3 ];
$go5 = $cx [ $img + 1 ][ 4 ];
$cx = [ 0 => '1111' ,
1 => '1110' ,
2 => '1011' ,
3 => '1101' ,
4 => '0111' ,
5 => '1100' ,
6 => '0110' ,
7 => '1001' ,
8 => '0011' ,
9 => '0001' ,
10 => '0100' ,
11 => '0010' ,
12 => '1000' ,
13 => '1010' ,
14 => '0101' ,
15 => '0000' ,
16 => '' ];
$ins = mysql_query (
'INSERT INTO `dungeon_map` (`st`,`go_1`,`go_2`,`go_3`,`go_4`,`go_5`,`id_dng`,`x`,`y`,`style`) VALUES ("' . $cx [ $img ][ 0 ] . $cx [ $img ][ 1 ] . $cx [ $img ][ 2 ] . $cx [ $img ][ 3 ] . '","' . $go1 . '","' . $go2 . '","' . $go3 . '","' . $go4 . '","' . $go5 . '","' . $dn [ 'id2' ] . '","' . mysql_real_escape_string (
$mx
) . '","' . mysql_real_escape_string ( $my ) . '","' . mysql_real_escape_string ( $img ) . '")'
);
if ( ! $ins ) {
2023-01-10 16:29:32 +00:00
echo 'Ошибка создания части лабиринта' ;
2022-08-25 11:23:36 +00:00
}
}
} elseif ( $act [ 0 ] == 'delete' ) {
2023-01-10 16:29:32 +00:00
//Удаляем клетку
2022-08-25 11:23:36 +00:00
$act = explode ( '|!|' , $act [ 1 ]);
$mx = $act [ 0 ];
$my = $act [ 1 ];
$mpx = mysql_fetch_array (
mysql_query (
'SELECT * FROM `dungeon_map` WHERE `id_dng` = "' . $dn [ 'id2' ] . '" AND `x`=' . mysql_real_escape_string (
$mx
) . ' AND `y`=' . mysql_real_escape_string ( $my ) . ' LIMIT 1'
)
);
if ( isset ( $mpx [ 'id' ])) {
mysql_query ( 'DELETE FROM `dungeon_map` WHERE `id` = "' . $mpx [ 'id' ] . '" LIMIT 1;' );
$js .= 'closeAdminion();' ;
}
}
}
$x = $u -> info [ 'x' ];
$y = $u -> info [ 'y' ];
2023-01-10 16:29:32 +00:00
//генерируем карту
2022-08-25 11:23:36 +00:00
$fmd5 = '' ;
2023-01-10 16:29:32 +00:00
//пользователи
2022-08-25 11:23:36 +00:00
2023-01-10 16:29:32 +00:00
//координаты игрока
2022-08-25 11:23:36 +00:00
$fmd5 .= $x . '_' . $y . '=' ;
$sp = mysql_query (
'SELECT * FROM `dungeon_map` WHERE `id_dng` = "' . $dn [ 'id2' ] . '" AND ((`x`<=' . ( $x + 5 ) . ' AND `x`>=' . ( $x - 5 ) . ') AND (`y`<=' . ( $y + 4 ) . ' AND `y`>=' . ( $y - 4 ) . ')) LIMIT 100'
);
while ( $pl = mysql_fetch_array ( $sp )) {
$map .= $pl [ 'id' ] . '=' . $pl [ 'x' ] . '=' . $pl [ 'y' ] . '=' . $pl [ 'style' ] . '=' . $pl [ 'go' ] . '=' . $pl [ 'go_1' ] . '=' . $pl [ 'go_2' ] . '=' . $pl [ 'go_3' ] . '=' . $pl [ 'go_4' ] . '=' . $pl [ 'go_5' ] . '=' . $pl [ 'no_bot' ][ 0 ] . '=' . $pl [ 'no_bot' ][ 1 ] . '=' . $pl [ 'no_bot' ][ 2 ] . '=' . $pl [ 'no_bot' ][ 3 ] . '|' ;
$fmd5 .= $pl [ 'id' ] . '=' ;
}
$map .= 'end' ;
2023-01-10 16:29:32 +00:00
//предметы на клетке
2022-08-25 11:23:36 +00:00
$itms = '' ;
$sp = mysql_query (
'SELECT * FROM `dungeon_items` WHERE `dn` = "' . $dn [ 'id' ] . '" AND `x` = "' . $x . '" AND `y` = "' . $y . '" AND `take` = "0" LIMIT 100'
);
while ( $pl = mysql_fetch_array ( $sp )) {
$itm = mysql_fetch_array (
mysql_query ( 'SELECT * FROM `items_main` WHERE `id` = "' . $pl [ 'item_id' ] . '" LIMIT 1' )
);
if ( isset ( $itm [ 'id' ])) {
2023-03-31 18:30:14 +00:00
$itms .= '<a href=\\"#\\" onClick=\\"takeItem(' . $pl [ 'id' ] . '); return false;\\"><img style=\\"margin:3px;\\" src=\\"//img.new-combats.tech/i/items/' . $itm [ 'img' ] . '\\" title=\\"Подобрать "' . $itm [ 'name' ] . '"\\" \></a>' ;
2022-08-25 11:23:36 +00:00
$fmd5 .= $pl [ 'id' ] . '=' ;
}
}
if ( $itms != '' ) {
2023-01-10 16:29:32 +00:00
$itms = '<Br><b style=\\"color:#8f0000;\\">Предметы в локации:</b><br><br>' . $itms ;
2022-08-25 11:23:36 +00:00
$js .= 'document.getElementById(\'items\').innerHTML = "' . $itms . '";' ;
} else {
$js .= 'document.getElementById(\'items\').innerHTML = "";' ;
}
$fmd5 = md5 ( $fmd5 );
if ( $fmd5 != $_POST [ 'mdf' ]) {
2023-01-10 16:29:32 +00:00
//обновляем данные
2022-08-25 11:23:36 +00:00
echo '<script> ' ;
echo $js ;
echo ' users = "' . $mus . '";' ;
echo ' obj = "' . $objd . '";' ;
echo ' mapNew = "' . $map . '";' ;
echo ' md = "' . $fmd5 . '";' ;
echo ' xn = ' . $u -> info [ 'x' ] . '; yn = ' . $u -> info [ 'y' ] . '; refleshMapDate();' ;
echo '</script>' ;
}
2022-06-06 21:30:34 +00:00
}