Файл: panel/locations.php
Строк: 328
<?php
include_once ('../core/base.php');
$header = 'Локации';
include_once ('../core/head.php');
falseauth();
adm();
if($u['admin'] == 3){
echo '<div class="b">';
switch($_GET['act']){
default:
echo '<div class="title">Список локаций</div>';
$count = $base -> query("SELECT * FROM `locations`") -> num_rows;
$k_page = k_page($count,100);
$page = page($k_page);
$start = 100 * $page - 100;
$sql = $base -> query("SELECT * FROM `locations` ORDER BY `id` ASC LIMIT $start,100");
if($count > 0){
while($loc = $sql -> fetch_assoc()){
echo '<a class="btn" style="width: 90%; display: inline-block;" href="/panel/locations/'.$loc['id'].'/"><img src="/images/locations/worlds/'.$loc['world'].'/'.$loc['image'].'.png" width="32px"> '.$loc['name'].' X: '.$loc['x'].' | Y: '.$loc['y'].'</a>';
//echo ' <a class="btn" style="display: inline-block" href="/panel/locations/'.$loc['id'].'/delete/"><img src="/images/icons/no.png"></a>';
}
if($count > '10'){
echo str('?',$k_page,$page);
}
}else{
echo '<br/><center>Локаций нет.</center>';
}
echo '<br/><a class="btn" href="/panel/locations/new/"><img src="/images/icons/admin.png"> Создать локацию</a>';
break;
case 'new':
if(isset($_REQUEST['success'])){
$name = fl($_POST['name']);
$world = fl($_POST['world']);
$location_type = fl($_POST['location_type']);
$x = fl($_POST['x']);
$y = fl($_POST['y']);
$image = fl($_POST['image']);
$block_up = fl($_POST['block_up']);
$block_down = fl($_POST['block_down']);
$block_left = fl($_POST['block_left']);
$block_right = fl($_POST['block_right']);
$city = fl($_POST['city']);
$pk = fl($_POST['pk']);
$arena = fl($_POST['arena']);
$equipment_shop = fl($_POST['equipment_shop']);
$potion_shop = fl($_POST['potion_shop']);
$jewelry_shop = fl($_POST['jewelry_shop']);
$trader = fl($_POST['trader']);
$clanhall = fl($_POST['clanhall']);
$tavern = fl($_POST['tavern']);
$enchanter = fl($_POST['enchanter']);
$smith = fl($_POST['smith']);
$hotel = fl($_POST['hotel']);
$warehouse = fl($_POST['warehouse']);
$bank = fl($_POST['bank']);
$academy = fl($_POST['academy']);
$workshop = fl($_POST['workshop']);
$teleport_to_world = fl($_POST['teleport_to_world']);
$teleport_to_x = fl($_POST['teleport_to_x']);
$teleport_to_y = fl($_POST['teleport_to_y']);
$boss = fl($_POST['boss']);
$image = fl($_POST['image']);
if(empty($name)) error('Введите название локации.');
elseif(empty($world)) error('Введите мир.');
elseif(empty($location_type)) error('Введите тип локации.');
elseif(empty($x)) error('Введите координату X.');
elseif(empty($y)) error('Введите координату Y.');
elseif(empty($image)) error('Введите изображение локации.');
else{
$base -> query("INSERT INTO `locations` SET
`name` = '$name',
`world` = '$world',
`location_type` = '$location_type',
`x` = '$x',
`y` = '$y',
`image` = '$image',
`block_up` = '$block_up',
`block_down` = '$block_down',
`block_left` = '$block_left',
`block_right` = '$block_right',
`city` = '$city',
`pk` = '$pk',
`arena` = '$arena',
`equipment_shop` = '$equipment_shop',
`potion_shop` = '$potion_shop',
`jewelry_shop` = '$jewelry_shop',
`trader` = '$trader',
`clanhall` = '$clanhall',
`tavern` = '$tavern',
`enchanter` = '$enchanter',
`smith` = '$smith',
`hotel` = '$hotel',
`warehouse` = '$warehouse',
`bank` = 'bank',
`academy` = '$academy',
`workshop` = '$workshop',
`teleport_to_world` = '$teleport_to_world',
`teleport_to_x` = '$teleport_to_x',
`teleport_to_y` = '$teleport_to_y',
`boss` = '$boss',
`boss_image` = '$boss_image'");
$_SESSION['message'] = 'Локация успешно создана.';
header('location: /panel/locations/');
exit;
}
}
echo '<div class="title">Создать локацию</div>';
echo '<center>';
echo '<form action="" method="POST">';
echo 'Название:<br/>';
echo '<input type="text" name="name" /> <br/>';
echo 'Мир:<br/>';
echo '<input type="text" name="world" /> <br/>';
echo 'Тип локации:<br/>';
echo '<input type="text" name="location_type" /> <br/>';
echo 'X:<br/>';
echo '<input type="text" name="x" /> <br/>';
echo 'Y:<br/>';
echo '<input type="text" name="y" /> <br/>';
echo 'Изображение:<br/>';
echo '<input type="text" name="image" /> <br/>';
echo '<input type = "checkbox" name = "block_up" value = "1">Ход вверх заблокирован<br/>';
echo '<input type = "checkbox" name = "block_down" value = "1">Ход вниз заблокирован<br/>';
echo '<input type = "checkbox" name = "block_left" value = "1">Ход влево заблокирован<br/>';
echo '<input type = "checkbox" name = "block_right" value = "1">Ход вправо заблокирован<br/>';
echo 'Город:<br/>';
echo '<input type="text" name="city" /> <br/>';
echo 'PK:<br/>';
echo '<input type="text" name="pk" /> <br/>';
echo 'Арена:<br/>';
echo '<input type="text" name="arena" /> <br/>';
echo 'Магазин снаряжения:<br/>';
echo '<input type="text" name="equipment_shop" /> <br/>';
echo 'Лавка зельевара:<br/>';
echo '<input type="text" name="potion_shop" /> <br/>';
echo 'Ювелирная лавка:<br/>';
echo '<input type="text" name="jewelry_shop" /> <br/>';
echo 'Купец:<br/>';
echo '<input type="text" name="trader" /> <br/>';
echo 'Ратуша:<br/>';
echo '<input type="text" name="clanhall" /> <br/>';
echo 'Таверна:<br/>';
echo '<input type="text" name="tavern" /> <br/>';
echo 'Зачарователь:<br/>';
echo '<input type="text" name="enchanter" /> <br/>';
echo 'Кузнец:<br/>';
echo '<input type="text" name="smith" /> <br/>';
echo 'Гостиница:<br/>';
echo '<input type="text" name="hotel" /> <br/>';
echo 'Склад, Хранилище:<br/>';
echo '<input type="text" name="warehouse" /> <br/>';
echo 'Банк:<br/>';
echo '<input type="text" name="bank" /> <br/>';
echo 'Академия:<br/>';
echo '<input type="text" name="academy" /> <br/>';
echo 'Мастерская:<br/>';
echo '<input type="text" name="workshop" /> <br/>';
echo 'Телепорт к миру:<br/>';
echo '<input type="text" name="teleport_to_world" /> <br/>';
echo 'Телепорт к X:<br/>';
echo '<input type="text" name="teleport_to_x" /> <br/>';
echo 'Телепорт к Y:<br/>';
echo '<input type="text" name="teleport_to_y" /> <br/>';
echo 'Босс:<br/>';
echo '<input type="text" name="boss" /> <br/>';
echo 'Изображение босса:<br/>';
echo '<input type="text" name="boss_image" /> <br/>';
echo '<input type="submit" name="success" value="Создать">';
echo '</form>';
echo '</center>';
echo '<a class="btn" href="/panel/locations/"><img src="/images/icons/back.png"> Назад</a>';
break;
case 'edit':
$id = fl($_GET['id']);
$loc = $base -> query('SELECT * FROM `locations` WHERE `id` = "'.$id.'"') -> fetch_assoc();
if(isset($_REQUEST['success'])){
$name = fl($_POST['name']);
$world = fl($_POST['world']);
$location_type = fl($_POST['location_type']);
$x = fl($_POST['x']);
$y = fl($_POST['y']);
$image = fl($_POST['image']);
$block_up = fl($_POST['block_up']);
$block_down = fl($_POST['block_down']);
$block_left = fl($_POST['block_left']);
$block_right = fl($_POST['block_right']);
$city = fl($_POST['city']);
$pk = fl($_POST['pk']);
$arena = fl($_POST['arena']);
$equipment_shop = fl($_POST['equipment_shop']);
$potion_shop = fl($_POST['potion_shop']);
$jewelry_shop = fl($_POST['jewelry_shop']);
$trader = fl($_POST['trader']);
$clanhall = fl($_POST['clanhall']);
$tavern = fl($_POST['tavern']);
$enchanter = fl($_POST['enchanter']);
$smith = fl($_POST['smith']);
$hotel = fl($_POST['hotel']);
$warehouse = fl($_POST['warehouse']);
$bank = fl($_POST['bank']);
$academy = fl($_POST['academy']);
$workshop = fl($_POST['workshop']);
$teleport_to_world = fl($_POST['teleport_to_world']);
$teleport_to_x = fl($_POST['teleport_to_x']);
$teleport_to_y = fl($_POST['teleport_to_y']);
$boss = fl($_POST['boss']);
$image = fl($_POST['image']);
if(empty($name)) error('Введите название локации.');
elseif(empty($world)) error('Введите мир.');
elseif(empty($location_type)) error('Введите тип локации.');
elseif(empty($image)) error('Введите изображение локации.');
else{
$base -> query("UPDATE `locations` SET
`name` = '$name',
`world` = '$world',
`location_type` = '$location_type',
`x` = '$x',
`y` = '$y',
`image` = '$image',
`block_up` = '$block_up',
`block_down` = '$block_down',
`block_left` = '$block_left',
`block_right` = '$block_right',
`city` = '$city',
`pk` = '$pk',
`arena` = '$arena',
`equipment_shop` = '$equipment_shop',
`potion_shop` = '$potion_shop',
`jewelry_shop` = '$jewelry_shop',
`trader` = '$trader',
`clanhall` = '$clanhall',
`tavern` = '$tavern',
`enchanter` = '$enchanter',
`smith` = '$smith',
`hotel` = '$hotel',
`warehouse` = '$warehouse',
`bank` = 'bank',
`academy` = '$academy',
`workshop` = '$workshop',
`teleport_to_world` = '$teleport_to_world',
`teleport_to_x` = '$teleport_to_x',
`teleport_to_y` = '$teleport_to_y',
`boss` = '$boss',
`boss_image` = '$boss_image' WHERE `id` = '".$loc['id']."'");
$_SESSION['message'] = 'Локация успешно сохранена.';
header('location: /location/');
exit;
}
}
echo '<div class="title">'.$loc['name'].'</div>';
echo '<center>';
echo '<img src="/images/locations/worlds/'.$loc['world'].'/'.$loc['image'].'.png"><br/>';
echo '<form action="" method="POST">';
echo 'Название:<br/>';
echo '<input type="text" name="name" value="'.$loc['name'].'"/> <br/>';
echo 'Мир:<br/>';
echo '<input type="text" name="world" value="'.$loc['world'].'"/> <br/>';
echo 'Тип локации:<br/>';
echo '<input type="text" name="location_type" value="'.$loc['location_type'].'"/> <br/>';
echo 'X:<br/>';
echo '<input type="text" name="x" value="'.$loc['x'].'"/> <br/>';
echo 'Y:<br/>';
echo '<input type="text" name="y" value="'.$loc['y'].'"/> <br/>';
echo 'Изображение:<br/>';
echo '<input type="text" name="image" value="'.$loc['image'].'"/> <br/>';
echo 'Ход вверх заблокирован:<br/>';
echo '<input type="text" name="block_up" value="'.$loc['block_up'].'"/> <br/>';
echo 'Ход вниз заблокирован:<br/>';
echo '<input type="text" name="block_down" value="'.$loc['block_down'].'"/> <br/>';
echo 'Ход влево заблокирован:<br/>';
echo '<input type="text" name="block_left" value="'.$loc['block_left'].'"/> <br/>';
echo 'Ход вправо заблокирован:<br/>';
echo '<input type="text" name="block_right" value="'.$loc['block_right'].'"/> <br/>';
echo 'Город:<br/>';
echo '<input type="text" name="city" value="'.$loc['city'].'"/> <br/>';
echo 'PK:<br/>';
echo '<input type="text" name="pk" value="'.$loc['pk'].'"/> <br/>';
echo 'Арена:<br/>';
echo '<input type="text" name="arena" value="'.$loc['arena'].'"/> <br/>';
echo 'Магазин снаряжения:<br/>';
echo '<input type="text" name="equipment_shop" value="'.$loc['equipment_shop'].'"/> <br/>';
echo 'Лавка зельевара:<br/>';
echo '<input type="text" name="potion_shop" value="'.$loc['potion_shop'].'"/> <br/>';
echo 'Ювелирная лавка:<br/>';
echo '<input type="text" name="jewelry_shop" value="'.$loc['jewelry_shop'].'"/> <br/>';
echo 'Купец:<br/>';
echo '<input type="text" name="trader" value="'.$loc['trader'].'"/> <br/>';
echo 'Ратуша:<br/>';
echo '<input type="text" name="clanhall" value="'.$loc['clanhall'].'"/> <br/>';
echo 'Таверна:<br/>';
echo '<input type="text" name="tavern" value="'.$loc['tavern'].'"/> <br/>';
echo 'Зачарователь:<br/>';
echo '<input type="text" name="enchanter" value="'.$loc['enchanter'].'"/> <br/>';
echo 'Кузнец:<br/>';
echo '<input type="text" name="smith" value="'.$loc['smith'].'"/> <br/>';
echo 'Гостиница:<br/>';
echo '<input type="text" name="hotel" value="'.$loc['hotel'].'"/> <br/>';
echo 'Склад, Хранилище:<br/>';
echo '<input type="text" name="warehouse" value="'.$loc['warehouse'].'"/> <br/>';
echo 'Банк:<br/>';
echo '<input type="text" name="bank" value="'.$loc['bank'].'"/> <br/>';
echo 'Академия:<br/>';
echo '<input type="text" name="academy" value="'.$loc['academy'].'"/> <br/>';
echo 'Мастерская:<br/>';
echo '<input type="text" name="workshop" value="'.$loc['workshop'].'"/> <br/>';
echo 'Телепорт к миру:<br/>';
echo '<input type="text" name="teleport_to_world" value="'.$loc['teleport_to_world'].'"/> <br/>';
echo 'Телепорт к X:<br/>';
echo '<input type="text" name="teleport_to_x" value="'.$loc['teleport_to_x'].'"/> <br/>';
echo 'Телепорт к Y:<br/>';
echo '<input type="text" name="teleport_to_y" value="'.$loc['teleport_to_y'].'"/> <br/>';
echo 'Босс:<br/>';
echo '<input type="text" name="boss" value="'.$loc['boss'].'"/> <br/>';
echo 'Изображение босса:<br/>';
echo '<input type="text" name="boss_image" value="'.$loc['boss_image'].'"/> <br/>';
echo '<input type="submit" name="success" value="Сохранить">';
echo '</form>';
echo '</center>';
echo '<a class="btn" href="/panel/locations/"><img src="/images/icons/back.png"> Назад</a>';
break;
case 'delete':
$id = fl($_GET['id']);
$loc = $base -> query('SELECT `id` FROM `locations` WHERE `id` = "'.$id.'"') -> fetch_assoc();
if($loc > 0) $base -> query('DELETE FROM `locations` WHERE `id` = "'.$loc['id'].'"');
$_SESSION['message'] = 'Локация успешно удалена.';
header('location: /panel/locations/');
exit;
break;
}
echo '</div>';
}else{
header('Location: /panel/');
exit;
}
include_once ('../core/foot.php');
?>