Файл: razd/anekdots/admin.php
Строк: 120
<?
include_once '../../sys/inc/start.php';
include_once '../../sys/inc/compress.php';
include_once '../../sys/inc/sess.php';
include_once '../../sys/inc/home.php';
include_once '../../sys/inc/settings.php';
include_once '../../sys/inc/db_connect.php';
include_once '../../sys/inc/ipua.php';
include_once '../../sys/inc/fnc.php';
include_once '../../sys/inc/user.php';
user_access('adm_mysql',null,'index.php?'.SID);
$set['title']='Анекдоты / Админка'; // заголовок страницы
include_once '../../sys/inc/thead.php';
title();
aut();
if (isset($_GET['act'])) {$act = htmlspecialchars(trim($_GET['act']));} else {$act = 'index';}
switch ($act):
### Главная страница
case "index":
if(user_access('audio_move_dir') || user_access('audio_del_dir')){
echo'<div class="mess">';
$set['p_str']=20;
echo'<img src = "img/dir_open.png"> Аудиоальбомы<br/>';
$k_post =mysql_result(mysql_query("SELECT count(*) FROM `audio_cat`"),0);
$k_page=k_page($k_post,$set['p_str']);
$page=page($k_page);
$start=$set['p_str']*$page-$set['p_str'];
if ($k_post==0){echo "Категорий не создано!";}
$q=mysql_query("SELECT * FROM `anek_dir` ORDER BY `num` DESC LIMIT " . $start . ", " . $set['p_str'] . "");
while ($data = mysql_fetch_assoc($q)){
$count =mysql_result(mysql_query("SELECT count(*) FROM `audio_file` WHERE `id_cat`='".$data['id']."'"),0);
echo'<img src = "img/dir.png" alt="!"> <a href = "index.php?act=cat&id='.$data['id'].'">'.$data['name'].'</a> ('.$count.') ';
echo'[<a href="?act=up&id='.$data['id'].'">Вверх</a>] | [<a href="?act=down&id='.$data['id'].'">Вниз</a>] | [<a href="?act=del&id='.$data['id'].'">Удалить</a>]<br/>';
}
echo'</div>';
}else{header("Location: index.php");}
break;
case "dels":
$id=intval($_GET['id']);
if(mysql_result(mysql_query("SELECT count(*) FROM `anek_list` WHERE `id`='".$id."'"),0)==0){header("Location: /audio/");}### Проверили есть ли каталог
$audio=mysql_fetch_assoc(mysql_query("SELECT * FROM `anek_list` WHERE `id`= $id LIMIT 1"));
if(isset($_GET['ok'])){
mysql_query("DELETE FROM `anek_list` WHERE `id` = '$id'");
header("Location: /razd/anekdots/");
}
echo "Удаление: ".output_text($audio['msg'])."<br />";
echo "<form method='post' action='?act=dels&id=".$id."&ok' >";
echo "<input class='submit' type='submit' value='Удалить' /> / <a href='/razd/anekdots/'>Отмена</a><br/>";
break;
case "del":
if(user_access('audio_del_dir')){
$id = intval($_GET['id']);
if(mysql_result(mysql_query("SELECT count(*) FROM `anek_dir` WHERE `id`='".$id."'"),0)==0){header("Location: /audio/");}### Проверили есть ли каталог
$catalog=mysql_fetch_assoc(mysql_query("SELECT * FROM `anek_dir` WHERE `id`= $id LIMIT 1"));
$q=mysql_query("SELECT * FROM `audio_file` WHERE `id_cat`='$id'");
while ($data = mysql_fetch_assoc($q)){
unlink(H.'audio/files/'.$data['id'].'.mp3');
mysql_query("DELETE FROM `audio_file` WHERE `id_cat` = '$id'");
}
mysql_query("DELETE FROM `anek_dir` WHERE `id` = '$id'");
header("Location: admin.php");
}else{header("Location: index.php");}
break;
### Папка вверх
case "up":
if(user_access('audio_move_dir')){
$id = intval($_GET['id']);
mysql_query("UPDATE `anek_dir` SET `num`=`num`+1 WHERE `id` = '$id' LIMIT 1");
header("Location: admin.php?act=index");
}else{header("Location: index.php");}
break;
### Папка вниз
case "down":
if(user_access('audio_move_dir')){
$id = intval($_GET['id']);
mysql_query("UPDATE `anek_dir` SET `num`=`num`-1 WHERE `id` = '$id' LIMIT 1");
header("Location: admin.php?act=index");
}else{header("Location: index.php");}
break;
### Создание папки
case "dir_add":
if(user_access('audio_move_dir')){
echo'<div class="mess">';
echo "<form action='?act=dir_save' method="post">";
echo "Название паки:<br />n";
echo "<input type='text' name='name'><br />";
echo "<input value="Добавить" name='save' type="submit" />n";
echo "</form>";
echo'</div>';
}else{header("Location: index.php");}
break;
case "dir_save":
if(user_access('audio_move_dir')){
$name = my_esc($_POST['name']);
mysql_query("INSERT INTO `anek_dir` (`name`) values('$name')");
header("Location: index.php?");
}else{header("Location: index.php");}
break;
default:
header("location: index.php?" . SID);
endswitch;
include_once '../../sys/inc/tfoot.php';
?>