Файл: test.masteram.us/audio/admin.php
Строк: 75
<?
include '../Core.php';
include_once 'config.php';
$set['title']='Аудиоальбомы / Админка'; // заголовок страницы
include_once '../sys/inc/thead.php';
title();
if (isset($_GET['act'])) {$act = power($_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 `audio_cat` 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 "del":
if(user_access('audio_del_dir')){
$id = intval($_GET['id']);
if(mysql_result(mysql_query("SELECT count(*) FROM `audio_cat` WHERE `id`='".$id."'"),0)==0){header("Location: /audio/");}### Проверили есть ли каталог
$catalog=mysql_fetch_assoc(mysql_query("SELECT * FROM `audio_cat` 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 `audio_cat` 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 `audio_cat` 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 `audio_cat` 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'<img src = "img/dir_open.png"> Аудиоальбомы<br/>';
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 `audio_cat` (`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';
?>