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

Размер файла: 5.2Kb
  1. <?php
  2. /**********************************
  3. * @package: PerfCMS *
  4. * @year: 2012 *
  5. * @author: Artas *
  6. * @link: http://perfcms.ru *
  7. **********************************/
  8. $locate = 'in_forum';
  9. if(!isset($_GET['topic_id'])) { header('Location:/forum/'); }
  10. $topic_id = abs(intval($_GET['topic_id']));
  11. if($db->query("SELECT * FROM `forum_pt` WHERE `topic_id` = '". $topic_id ."'")->rowCount() == 0) {
  12. $title = $lang->word('forum');
  13. require_once(SYS.'/view/header.php');
  14. $tpl->div('menu', $lang->word('topic_not_exists'));
  15. $tpl->div('block', NAV.' <a href="/forum/">'. $lang->word('forum') .'</a><br/>' . HICO .' <a href="/">'. $lang->word('home') .'</a>');
  16. require_once(SYS.'/view/footer.php');
  17. exit;
  18. }
  19. $topict = $db->query("SELECT * FROM `forum_t` WHERE `id` = '". $topic_id ."'")->fetch();
  20. $title = $topict['name'] .' | '.$lang->word('forum');
  21. require_once(SYS.'/view/header.php');
  22. $tpl->div('title', $topict['name'] .' | '.$lang->word('forum'));
  23. $tpl->div('menu', (isset($user) && $topict['closed'] == 0 ? NAV .'<a href="/forum/add_post/'. $topic_id .'"/>'. $lang->word('add_message') .'</a><br/>' : NULL));
  24. $topic_r = $db->query("SELECT * FROM `forum_pt` WHERE `topic_id` = '". $topic_id ."'")->rowCount();
  25. $pages = new Paginator($topic_r, $ames);
  26. if($topic_r == 0) {
  27. echo $tpl->div('menu', $lang->word('no_posts'));
  28. }
  29. else {
  30. $topic_q = $db->query("SELECT * FROM `forum_pt` WHERE `topic_id` = '". $topic_id ."' ORDER BY time ASC LIMIT $start, $ames");
  31. while($topic = $topic_q->fetch()) {
  32. $tpl->div('post', nick($topic['user_id']).' (<small><span class="gray">'. rtime($topic['time']).'</span></small>) '.(isset($user) ? '['.($user['id'] != $topic['user_id'] ? '<a href="/forum/'.(isset($user) && $settings['fast_mess'] == 'yes' ? 'topic' : 'add_post/'). $topic['topic_id'] .'/?page=end&amp;reply_to='.tnick($topic['user_id']).'">'. $lang->word('reply').'</a> | <a href="/forum/'.(isset($user) && $settings['fast_mess'] == 'yes' ? 'topic' : 'add_post/'). $topic['topic_id'] .'/?page=end&amp;quote='. $topic['id'] .'">'. $lang->word('quote').'</a>': NULL) . ($user['level'] == 3 || $user['level'] >= 5 || $user['id'] == $topic['user_id'] ? ' <a href="/forum/delete_post/'.$topic['id'].'/'.$topic['topic_id'].'/">'.img('delete.png').'</a> | <a href="/forum/edit_post/'.$topic['id'].'/'.$topic['topic_id'].'/">'.img('edit.png').'</a>' : NULL).']':NULL).'<br/> '. output($topic['text']) .'</a>'. ($topic['count_edit'] > 0?'<small style="font-size: xx-small"><br />_______________<br />Last edit: '. date('d.m.Y, H:i', $topic['edit_time']) .' by '. tnick($topic['edit_user_id']) .'. Total: '. $topic['count_edit'] .' times</small><br/>':NULL) .'
  33. '.(!empty($topic['file']) ? '<br/>_______________<br/><a href="/files/forum/'.$topic['file'].'">'.$topic['file'].'</a> ('.size($topic['file_size']).')' : NULL).'');
  34. }
  35. $pages->view('/forum/topic'. $topic_id .'/?');
  36. }
  37. if(isset($user) && $settings['fast_mess'] == 'yes' && $topict['closed'] == 0) {
  38. $tpl->div('menu', '<form action="/forum/add_post/'. $_GET['topic_id'] .'/?act=create" method="post">
  39. <b>'. $lang->word('message') .'</b>:<br/>
  40. <textarea name="text" rows="5" cols="26">'.(isset($_GET['reply_to']) ? '[b]'.$_GET['reply_to'].'[/b], ' : NULL) . (isset($_GET['quote']) ? "[b]".tnick($db->query("SELECT user_id FROM `forum_pt` WHERE `topic_id` = '". $topic_id ."' AND `id` = '". $_GET['quote'] ."'")->fetchColumn())."[/b] ".date('d.m.Y, H:i', $db->query("SELECT time FROM `forum_pt` WHERE `topic_id` = '". $topic_id ."' AND `id` = '". $_GET['quote'] ."'")->fetchColumn())."\n[quote]\n".preg_replace('/\[quote\]|\[\/quote\]/i', '', $db->query("SELECT text FROM `forum_pt` WHERE `topic_id` = '". $topic_id ."' AND `id` = '". abs(intval($_GET['quote'])) ."'")->fetchColumn())."\n[/quote] " : NULL) .'</textarea><br/>
  41. <input name="create" type="submit" value="'. $lang->word('create') .'" /><br/>
  42. </form>');
  43. }
  44. echo '<div class="block">';
  45. if(isset($user) && $topict['closed'] == 0) { echo ''.NAV .'<a href="/forum/add_post/'. $topic_id .'"/>'. $lang->word('add_message') .'</a><br/>'; }
  46. if(($user['level']>=5 || $user['id'] == $db->query("SELECT user_id FROM `forum_pt` WHERE `topic_id` = '". $topict['id']."' ORDER BY time ASC LIMIT 1")->fetchColumn()) && $topict['closed'] == 0) { echo NAV . '<a href="/forum/topic/close/'. $topict['id'].'/">'. $lang->word('close') .'</a><br/>'; } elseif(($user['level']>=5 || $user['id'] == $db->query("SELECT user_id FROM `forum_pt` WHERE `topic_id` = '". $topict['id']."' ORDER BY time ASC LIMIT 1")->fetchColumn()) && $topict['closed'] == 1) { echo NAV . '<a href="/forum/topic/open/'. $topict['id'].'/">'. $lang->word('open') .'</a><br/>'; }
  47. if($user['level']>=6 && $topict['attach'] == 0) { echo NAV . '<a href="/forum/topic/attach/'. $topict['id'].'/">'. $lang->word('attach') .'</a><br/>'; } elseif($user['level']>=6 && $topict['attach'] == 1) { echo NAV . '<a href="/forum/topic/unpin/'. $topict['id'].'/">'. $lang->word('unpin') .'</a><br/>'; }
  48. echo '</div>';
  49. $tpl->div('block', NAV.' <a href="/forum/cat/'. $topict['cat_id'] .'/">'.$db->query("SELECT name FROM `forum_c` WHERE `id` = '". $topict['cat_id']."'")->fetchColumn().'</a><br/>' . HICO .' <a href="/">'. $lang->word('home') .'</a>');
  50. require_once(SYS.'/view/footer.php');
  51. ?>