Просмотр файла download/include/del_cat.php

Размер файла: 2.2Kb
  1. <?php
  2.  
  3. include H.'engine/includes/head.php';
  4. if ($admin) {
  5. if ($sql->query("SELECT COUNT(*) FROM `down_files` WHERE `type` = 1 AND`refid` = '$id'")->result() || !$sql->query("SELECT * FROM `down_files` WHERE `type` = 1 AND `id` = '$id' LIMIT 1")->num_rows())
  6. {
  7. echo 'Системная ошибка<br /><a href="index.php">К категориям</a>';
  8. include H.'engine/includes/foot.php';
  9. }
  10. $res = $sql->fetch();
  11. if (isset($_GET['yes'])) {
  12. $sql->query("SELECT * FROM `down_files` WHERE `refid` = '$id'");
  13. while ($res_down = $sql->fetch()) {
  14. if (is_dir($screenroot . '/' . $res_down['id'])) {
  15. $dir_clean = opendir($screenroot . '/' . $res_down['id']);
  16. while ($file = readdir($dir_clean)) {
  17. if ($file != '.' && $file != '..') {
  18. @unlink($screenroot . '/' . $res_down['id'] . '/' . $file);
  19. }
  20. }
  21. closedir($dir_clean);
  22. rmdir($screenroot . '/' . $res_down['id']);
  23. }
  24. $sql->query("SELECT * FROM `down_more` WHERE `refid` = '" . $res_down['id'] . "'");
  25. while ($res_file_more = $sql->fetch()) {
  26. @unlink($res_down['dir'] . '/' . $res_file_more['name']);
  27. }
  28. @unlink('about/' . $res_down['id']. '.txt');
  29. @unlink($res_down['dir'] . '/' . $res_down['name']);
  30. $sql->multi("DELETE FROM `down_more` WHERE `refid`='" . $res_down['id'] . "';DELETE FROM `down_comms` WHERE `refid`='" . $res_down['id'] . "'");
  31. }
  32. $sql->query("DELETE FROM `down_files` WHERE `refid` = '$id' OR `id` = '$id'");
  33. rmdir($res['down'] . '/' . $res['name']);
  34. if (file_exists(H.'engine/files/tmp/download[dir='.$id.'].swc'))
  35. unlink(H.'engine/files/tmp/download[dir='.$id.'].swc');
  36. header('location: index.php?id=' . $res['refid']);
  37. }
  38. else {
  39. echo '<div class="err">Вы действительно хотите удалить каталог?<br /> <a href="index.php?act=del_cat&amp;id=' . $id . '&amp;yes">Удалить</a> | <a href="index.php?id=' . $id . '">Отмена</a></div>';
  40. }
  41. }
  42. else {
  43. header('Location: /?err');
  44. }