session_start(); require_once('functions.php'); if (!isset($_SESSION['uid'])) { header('Location: index.php'); exit; } if ($user->room == 51) { header('location: city.php'); exit; } $forest = db::c()->query('SELECT `id`, `room`, `room_id`, `time`, `user`, `data` FROM `forest` WHERE `user` = ?i', $user['id'])->fetch_assoc(); $error = ''; $map_page = ''; if (empty($forest['id'])) { exit('Ошибка. Сообщите Администрации. Код ошибки : 00.'); } function loadmap_cell() { global $forest; $dat = unserialize($forest['data']); $dat = ['Up' => $dat[$forest['room']]['Up'], 'Down' => $dat[$forest['room']]['Down'], 'Left' => $dat[$forest['room']]['Left'], 'Right' => $dat[$forest['room']]['Right']]; return $dat; } $map_user = loadmap_cell(); if ($_GET['exit_forest'] == 'true') { if ($forest['room']) { #db::c()->query('DELETE FROM `forest_bots` WHERE `user` = ?i AND `group` = ?i', $user['id'], $forest['id']); #db::c()->query('DELETE FROM `forest_items` WHERE `user` = ?i AND `group` = ?i', $user['id'], $forest['id']); db::c()->query('UPDATE `users`,`online` SET `users`.`room` = 51, `online`.`room` = 51 WHERE `online`.`id` = `users`.`id` AND `online`.`id` = ?i', $user['id']); db::c()->query('DELETE FROM `forest` WHERE `user` = ?i', $user['id']); unset($forest); } else { $error = 'Выхода тут нет ...'; } } echo $map_user['Down'] . ' = ' . $map_user['Right']; if ($_GET['move'] == 'true') { if ($_GET['Dir'] == 'Up') { if ($map_user['Up'] == 1) { $forest['room'] = 'cell_' . ($forest['room_id'] - 5); $forest['room_id'] = $forest['room_id'] - 5; } else { $error = 'Ошибка. Сообщите Администрации. Код ошибки : 01.'; } } elseif ($_GET['Dir'] == 'Down') { if ($map_user['Down'] == 1) { $forest['room'] = 'cell_' . ($forest['room_id'] + 5); $forest['room_id'] = $forest['room_id'] + 5; } else { $error = 'Ошибка. Сообщите Администрации. Код ошибки : 02.'; } } elseif ($_GET['Dir'] == 'Left') { if ($map_user['Left'] == 1) { $forest['room'] = 'cell_' . ($forest['room_id'] - 1); $forest['room_id'] = $forest['room_id'] - 1; } else { $error = 'Ошибка. Сообщите Администрации. Код ошибки : 03.'; } } elseif ($_GET['Dir'] == 'Right') { if ($map_user['Right'] == 1) { $forest['room'] = 'cell_' . ($forest['room_id'] + 1); $forest['room_id'] = $forest['room_id'] + 1; } else { $error = 'Ошибка. Сообщите Администрации. Код ошибки : 04.'; } } else { $error = 'Not in this life'; } if (empty($error)) db::c()->query('UPDATE `forest` SET `room` = "?s", `room_id` = ?i WHERE `id` = ?i', $forest['room'], $forest['room_id'], $forest['id']); } if ($map_user['Right'] == 1) $map_page = << MAP; if ($map_user['Left'] == 1) $map_page = << MAP; if ($map_user['Down'] == 1) $map_page = << MAP; if ($map_user['Up'] == 1) $map_page = << MAP; ?>