Просмотр файла modules/forum/edit_topic.php

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