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

Размер файла: 1.78Kb
  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_files` WHERE `id` = '$file_id'")->rowCount() == 0 || $user['level'] < 4)
  11. {
  12. header('location: /downloads/');
  13. exit;
  14. }
  15. $filei = $db->query("SELECT * FROM `downloads_files` WHERE `id` = '". $file_id ."'")->fetch();
  16. if(isset($_GET['act']) && $_GET['act'] == 'save')
  17. {
  18. $name = mb_substr(input($_POST['file_name']), 0, 100);
  19. $desc = input($_POST['file_desc']);
  20. if(!empty($name) && !empty($desc))
  21. {
  22. $db->query("UPDATE `downloads_files` SET `name` = '$name', `description` = '$desc' WHERE `id` = '$file_id'");
  23. header('location: /downloads/file/'.$file_id);
  24. exit;
  25. }
  26. }
  27. $title = $lang->word('dl_edit_file').' | '.$lang->word('downloads');
  28. require_once(SYS.'/view/header.php');
  29. $tpl->div('title', $lang->word('dl_add_file'));
  30. echo '<div class="menu">
  31. <form action="/downloads/file_edit/'.$file_id.'?act=save" method="post">
  32. '.$lang->word('dl_file_name').':<br/>
  33. <input type="text" value="'.$filei['name'].'" name="file_name" /><br/>
  34. '.$lang->word('dl_file_desc').':<br/>
  35. <textarea name="file_desc" rows="5" cols="25">'.$filei['description'].'</textarea><br/>
  36. <input type="submit" value="'. $lang->word('save') .'" />
  37. </form>
  38. </div>';
  39. $tpl->div('block', img('nav.png') . ' <a href="/downloads/file/'.$file_id.'">'. $lang->word('back') .'</a><br/>'
  40. . img('download.png') . ' <a href="/downloads/">'. $lang->word('downloads') .'</a><br/>'
  41. . HICO .' <a href="/">'. $lang->word('home') .'</a>');
  42. require_once(SYS.'/view/footer.php');
  43. ?>