Вход Регистрация
Файл: bloodlands.pw/admin/loc.php
Строк: 114
<?php
define
('cms'1);
$patch '../';
require_once 
$patch.'core.php'
if (
$user && $us['privilege'] == && $us['orden'] == 1) {

echo 
'<div class="pt">';
switch (
$_GET['a']){
default:
echo 
'<form class="form" action="?a=search" method="POST">№:<input type="text" name="num" maxlength="40" size="5"> <input type="submit" value="Ok"></form><br/>';

$all mysql_result(mysql_query("SELECT count(*) FROM `locations`"),0);
if(
$all 0){
$total intval(($all-1)/$us['kol'])+1;
$page abs(intval($_GET['page']));
if(empty(
$page) OR $page <= 0){
$page 1;
}
if(
$page $total){
$page $total;
}
$past intval($all/$us['kol']);
$start $page*$us['kol']-$us['kol'];
$top mysql_query("SELECT * FROM `locations` ORDER BY `num` DESC LIMIT ".$start.",".$us['kol']."");
while(
$res mysql_fetch_array($top)){
echo
'<a href="world.php?a=teleport&amp;id='.$res['num'].'">'.$res['title'].' ('.$res['num'].')['.$res['x'].';'.$res['y'].']<br/>
<a href="?a=edit&amp;id='
.$res['id'].'">[РЕД]</a> <a href="?a=del&amp;id='.$res['id'].'">[УДАЛ]</a><br/>';
}

navigation($all,$us['kol'],$page,'?',$total);
} else echo 
'<div class="error">Локаций не найдено!</div>';

echo
'<a href="?a=new">Добавить локацию</a><br/><br/>';
echo 
'<a href="index.php">В админку</a>';
break;

case 
'search':
$search filter($_POST['num']);
echo 
'<form class="form" action="?a=search" method="POST">№:<input type="text" name="num" maxlength="40" size="5"> <input type="submit" value="Ok"></form>';

if (empty(
$search))header('Location: index.php');
$error '';
if (
mb_strlen($search) > 40$error .= 'Неверная длина поля!<br/>';
if (
mysql_num_rows(mysql_query("SELECT `id` FROM `locations` WHERE `num` = '".$search."'")) == 0$error .='Локация не найдена!<br />';

if (empty(
$error)){
$res mysql_fetch_array(mysql_query("SELECT * FROM `locations` WHERE `num` = '".$search."'"));
if (!empty(
$res)) {
echo
'<a href="world.php?a=teleport&amp;id='.$res['num'].'">'.$res['title'].' ('.$res['num'].')['.$res['x'].';'.$res['y'].']<br/>
<a href="?a=edit&amp;id='
.$res['id'].'">[РЕД]</a> <a href="?a=del&amp;id='.$res['id'].'">[УДАЛ]</a><br/>';
echo
'<br/>';
} else echo 
'<div class="error">Локация не найдена!</div>';
} else echo 
'<div class="error">'.$error.'</div>';
echo 
'<a href="index.php">В админку</a>';
break;

case 
'edit':
if (isset(
$id)) $l mysql_fetch_array(mysql_query("SELECT * FROM `locations` WHERE `id` = '".$id."'"));
if(!
$l) {echo '<div class="error">Локация не найдена!</div>';include '../include/foot1.php';exit;}

if (isset(
$_POST['ok'])){
$title filter($_POST['title']);
$x filter($_POST['x']);
$y filter($_POST['y']);
$opis filter($_POST['opis']);
$img filter($_POST['img']);
$num filter($_POST['num']);
$color filter($_POST['color']);

if(!empty(
$title) && !empty($x) && !empty($y) && !empty($num) && !empty($color)){
if(isset(
$_POST['war'])) $war 1; else $war 0;
$ok mysql_query("UPDATE `locations` SET `color` = '".$color."', `title` = '".$title."', `x` = '".$x."', `y` = '".$y."', `opis` = '".$opis."', `img` = '".$img."', `num` = '".$num."', `war` = '".$war."' WHERE `id` = '".$id."'");
if(
$ok) echo 'Локация успешно изменена!<br/>';
} else echo
'<div class="error">Не заполнены важные поля!</div>';

} else echo 
'<form method="POST" action="?a=edit&amp;id='.$id.'"><b>X/Y:</b><br />
<input type="text" name="x" value="'
.$l['x'].'" size="7"> <input type="text" name="y" value="'.$l['y'].'" size="7"><br /><b>№ локации:</b><br />
<input type="text" name="num" value = "'
.$l['num'].'"><br /><b>Название:</b><br />
<input type="text" name="title" value = "'
.$l['title'].'"><br /><b>Описание:</b><br />
<input type="text" name="opis" value="'
.$l['opis'].'"><br /><b>URL картинки:</b><br />
<input type="text" name="img" value="'
.$l['img'].'"><br /><b>Цвет на карте:</b><br />
<input type="text" name="color" value="'
.$l['color'].'"><br />Нельзя напасть: <input name="war" type="checkbox"/><br/>
<input type="submit" name="ok" value="Изменить"></form>'
;

echo 
'<a href="index.php">В админку</a>';
break;

case 
'del':
if (isset(
$id)) $p mysql_fetch_array(mysql_query("SELECT * FROM `locations` WHERE `id` = '".$id."'"));

if(!
$p) {echo '<div class="error">Данная локация не найдена!</div>';include '../include/foot1.php';exit;}
if(
filter($_GET['ok']) != 'yes') echo'Вы действительно хотите удалить данную локацию?<br/><a href="?a=del&amp;id='.$id.'&amp;ok=yes">Подтвердить</a><br/><br/><a href="index.php">В админку</a>'; else {

$oki mysql_query("DELETE FROM `locations` WHERE `id` = '".$id."'");

if(
$oki) echo'Удаление успешно завершено!<br/><a href="index.php">В админку</a>';
}
break;

case 
'new':
if (isset(
$_POST['ok'])){
$title filter($_POST['title']);
$x filter($_POST['x']);
$y filter($_POST['y']);
$opis filter($_POST['opis']);
$img filter($_POST['img']);
$num filter($_POST['num']);
$color filter($_POST['color']);

$ok mysql_num_rows(mysql_query("SELECT `id` FROM `locations` WHERE `x` = '".$x."' AND `y` = '".$y."'"));
if(
$ok == 1){ echo '<div class="error">Данная локация уже существует!</div>';include '../include/foot1.php';exit;}

if(!empty(
$title) && !empty($x) && !empty($y) && !empty($num) && !empty($color)){
if(isset(
$_POST['war'])) $war 1; else $war 0;
$oki mysql_query("INSERT INTO `locations` SET `x` = '".$x."', `y` = '".$y."', `title` = '".$title."', `opis` = '".filter($_POST['opis'])."', `img` = '".filter($_POST['img'])."', `num` = '".$num."', `color` = '".$color."', `war` = '".$war."'");
if(
$oki) echo 'Локация успешно создана, координаты:  '.$x.';'.$y.'<br/>';
} else echo
'<div class="error">Не заполнены важные поля!</div>';

} else echo 
'<form method="POST" action=""><b>X/Y:</b><br />
<input type="text" name="x" size="7"> <input type="text" name="y" size="7"><br /><b>№ локации:</b><br />
<input type="text" name="num"><br /><b>Название:</b><br />
<input type="text" name="title"><br /><b>Описание:</b><br />
<input type="text" name="opis"><br /><b>URL картинки:</b><br />
<input type="text" name="img"><br /><b>Цвет на карте:</b><br />
<input type="text" name="color"><br />Нельзя напасть: <input name="war" type="checkbox"/><br/>
<input type="submit" name="ok" value="Добавить"></form>'
;

echo 
'<a href="index.php">В админку</a>';
break;
}

echo 
'</div>';
} else 
header('Location: '.$patch.'index.php');
include 
$patch.'include/foot1.php';
?>
Онлайн: 0
Реклама