Просмотр файла modules/share/delete_file.php

Размер файла: 1.62Kb
  1. <?php
  2. /**********************************
  3. * @package: PerfCMS *
  4. * @year: 2012 *
  5. * @author: Artas *
  6. * @link: http://perfcms.pp.ua *
  7. **********************************/
  8. $locate = 'in_share';
  9. $file = $db->query("SELECT * FROM `share_files` WHERE `id` = '". abs(intval($_GET['file_id'])) ."'")->fetch();
  10. if(!isset($user) || $user['id'] != $file['user_id'] || $user['level'] < 4)
  11. {
  12. header('location: /');
  13. exit;
  14. }
  15. if(isset($_GET['file_id'])) {
  16. if(isset($_POST['yes'])) {
  17. unlink(ROOT .'/files/share/'. $db->query("SELECT path_name FROM `share_files` WHERE `id` = '". abs(intval($_GET['file_id'])) ."'")->fetchColumn() .'');
  18. $cat_id = $db->query("SELECT cat_id FROM `share_files` WHERE `id` = '". abs(intval($_GET['file_id'])) ."'")->fetchColumn();
  19. $db->query("DELETE FROM `share_files` WHERE `id` = '". abs(intval($_GET['file_id'])) ."'");
  20. go('/share/folder/'.$cat_id .'/');
  21. } elseif(isset($_POST['no'])) {
  22. go('/share/file/'.abs(intval($_GET['file_id'])).'/');
  23. }
  24. $title = $lang->word('delete');
  25. require_once(SYS.'/view/header.php');
  26. $tpl->div('title', $lang->word('delete'));
  27. echo '<form action="/share/delete_file/?file_id='. abs(intval($_GET['file_id'])) .'" method="post">
  28. <div class="menu">
  29. <b>'. $lang->word('r_sure') .'</b><br/>
  30. <input name="yes" type="submit" value="'. $lang->word('yyes') .'" /> <input name="no" type="submit" value="'. $lang->word('yno') .'" /><br/>
  31. </div>
  32. </form>';
  33. $tpl->div('block', NAV .'<a href="/share/">'. $lang->word('share') .'</a><br/>' . HICO .'<a href="/">'. $lang->word('home').'</a>');
  34. require_once(SYS.'/view/footer.php');
  35. } else { go('/'); }
  36. ?>