File size: 3.16Kb
<?php
$pp=@$_GET['pp'];
$pp=valid_number($pp);
$res=mysql_query("SELECT *
FROM `category`");
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title>Админ панель->Управление категориями</title>
'.$css.'
</head>';
if (!mysql_num_rows($res))
{echo '<div class="rekl">Нет ни одной категории!</div>';}
echo '<div class="zag" align="center"><form method="post" action="'.htmlspecialchars($_SERVER['REQUEST_URI']).'">
Название<br/>
<input type="text" name="cat_name">
<input type="hidden" name="from" value="'.$pp.'"><br/>
<input type="submit" value="Создать">
</form></div>';
if (!empty($_POST))
{
$n=trim($_POST['cat_name']);
$from=$_POST['from'];
$time=time();
mysql_query("INSERT INTO `category`
(`id`, `name`, `from`, `one_time`, `update`,`count`)
VALUES ('', '$n', '$from', '$time', '$time', '0')");
}
///----------------------------------Удаление-----------------------------------------///
if (isset($_GET['dell']))
{$dellete=$_GET['dell'];
mysql_query("DELETE FROM `category` WHERE `id` = '$dellete' LIMIT 1");}
///-----------------------------------------------------------------------------------///
echo '<div class="c">';
///------------------------------Переименование---------------------------------------///
if (isset($_GET['rename']))
{
$rename=$_GET['rename'];
if (isset($_POST['new_name']))
{
$new_name=$_POST['new_name'];
mysql_query("UPDATE `category` SET
`name` = '$new_name'
WHERE `id` = '$rename'
LIMIT 1");
}
$ren=mysql_query("SELECT * FROM `category` WHERE `id`='$rename' LIMIT 1");
$arr_ren = mysql_fetch_assoc($ren);
echo '<a href="?p=1&password='.$_GET['password'].'&pp='.$pp.'">Отмена</a><form method="post" action="'.htmlspecialchars($_SERVER['REQUEST_URI']).'">
<input type="text" name="new_name" value="'.htmlspecialchars($arr_ren['name']).'">
<input type="submit" value="Ок">
</form>';
}
///------------------------------------------------------------------------------------///
///--------------------------------------------Очистка---------------------------------///
if (isset($_GET['clear']))
{
$clear=$_GET['clear'];
mysql_query("UPDATE `category` SET
`array` = '',
`count` = '0'
WHERE `id` = '$clear'
LIMIT 1");
echo 'Выполнено!<br/><br/>';
}
///------------------------------------------------------------------------------------///
$res=mysql_query("SELECT *
FROM `category`
WHERE `from`='$pp'");
while ($arr = mysql_fetch_assoc($res))
{
echo '»<a href="?p=1&password='.$_GET['password'].'&pp='.$arr['id'].'">'.$arr['name'].'</a>(<a href="?p=1&password='.$_GET['password'].'&pp='.$pp.'&clear='.$arr['id'].'">Clear</a>|<a href="?p=1&password='.$_GET['password'].'&pp='.$pp.'&rename='.$arr['id'].'">Rename</a>|<a href="?p=1&password='.$_GET['password'].'&pp='.$pp.'&dell='.$arr['id'].'">Del</a>)('.$arr['count'].')<br/>
';
}
echo '</div>';
echo '<div class="kon" align="center"><a href="?p=0&password='.$_GET['password'].'">В админ панель</a></div>
</html>';
?>