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

Размер файла: 1.68Kb
  1. <?php
  2. /**********************************
  3. * @package: PerfCMS *
  4. * @year: 2012 *
  5. * @author: Artas *
  6. * @link: http://perfcms.pp.ua *
  7. **********************************/
  8. $locate = 'in_share';
  9. $edit_topic = $db->query("SELECT * FROM `share_files` WHERE `id` = '". abs(intval($_GET['id'])) ."'")->fetch();
  10. if(!isset($user) || $user['id'] != $edit_topic['user_id'] || $user['level'] < 4 || !isset($_GET['id']))
  11. {
  12. go('/');
  13. }
  14. if($db->query("SELECT * FROM `share_files` WHERE `id` = '". abs(intval($_GET['id'])) ."'")->rowCount() == 0) {
  15. go('/share/');
  16. }
  17. if(isset($_POST['edit']) && $_GET['act'] == 'edit') {
  18. $name = substr(input($_POST['name']), 0, 99);
  19. $text = substr(input($_POST['text']), 0, 5000);
  20.  
  21. $db->query("UPDATE `share_files` SET `name` = '".$name."', `text` = '". $text ."' WHERE `id` = '". abs(intval($_GET['id'])) ."'");
  22. go('/share/file/'. abs(intval(abs(intval($_GET['id'])))));
  23. // print_r($db->errorInfo());
  24. }
  25. $title = $lang->word('edit');
  26. require_once(SYS.'/view/header.php');
  27. $tpl->div('title', $lang->word('edit'));
  28. echo '<form action="/share/edit_file/'. abs(intval($_GET['id'])) .'/?act=edit" method="post">
  29. <div class="menu">
  30. <b>'. $lang->word('name') .'</b>:<br/>
  31. <input name="name" type="text" value="'. $edit_topic['name'] .'" /><br/>
  32. <b>'. $lang->word('about') .'</b>:<br/>
  33. <textarea name="text" rows="5" cols="26">'. $edit_topic['text'] .'</textarea><br/>
  34. <input name="edit" type="submit" value="'. $lang->word('edit') .'" /><br/>
  35. </div>
  36. </form>';
  37. $tpl->div('block', NAV .'<a href="/share/">'. $lang->word('share') .'</a><br/>' . HICO .'<a href="/">'. $lang->word('home').'</a>');
  38. require_once(SYS.'/view/footer.php');
  39. ?>