Просмотр файла modules/downloads/delete_attachment.php

Размер файла: 1.91Kb
  1. <?php
  2. /**********************************
  3. * @package: PerfCMS *
  4. * @year: 2012 *
  5. * @author: Artas *
  6. * @link: http://perfcms.org.ua *
  7. **********************************/
  8. $locate = 'in_downloads';
  9. $file_id = abs(intval($_GET['id']));
  10. if(!isset($file_id) && $db->query("SELECT * FROM `downloads_archive` WHERE `id` = '$file_id'")->rowCount() == 0 || $user['level'] < 4)
  11. {
  12. header('location: /downloads/');
  13. exit;
  14. }
  15. $filei = $db->query("SELECT * FROM `downloads_archive` WHERE `id` = '". $file_id ."'")->fetch();
  16. $fila = $db->query("SELECT * FROM `downloads_files` WHERE `id` = '". $filei['file_id'] ."'")->fetch();
  17. $root_dir = $db->query("SELECT `server_path` FROM `downloads` WHERE `id` = '". abs(intval($fila['ref_id'])) ."'")->fetchColumn();
  18. if(isset($_GET['act']) && $_GET['act'] == 'delete')
  19. {
  20. if(isset($_POST['yes']))
  21. {
  22. unlink(ROOT.'/files/downloads/'.$root_dir.'/'.$fila['server_dir'].'/'.$filei['server_name']);
  23. $db->query("DELETE FROM `downloads_archive` WHERE `id` = '". $file_id ."'");
  24. header('location: /downloads/');
  25. exit;
  26. }
  27. elseif(isset($_POST['no']))
  28. {
  29. header('location: /downloads/file/'.$filei['from_id']);
  30. exit;
  31. }
  32. }
  33. $title = $lang->word('dl_delete_file').' | '.$lang->word('downloads');
  34. require_once(SYS.'/view/header.php');
  35. $tpl->div('title', $lang->word('dl_delete_file'));
  36. echo '<div class="post">
  37. <form action="/downloads/delete_attachment/'.$file_id.'?act=delete" method="post">
  38. '.$lang->word('dl_file_delete_attention').' <b>'.$filei['name'].'</>?<br/>
  39. <input type="submit" name="yes" value="'. $lang->word('yyes') .'" /> <input type="submit" name="no" value="'. $lang->word('yno') .'" />
  40. </form>
  41. </div>';
  42. $tpl->div('block', img('download.png') . ' <a href="/downloads/">'. $lang->word('downloads') .'</a><br/>'
  43. . HICO .' <a href="/">'. $lang->word('home') .'</a>');
  44. require_once(SYS.'/view/footer.php');
  45. ?>