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

Размер файла: 2.82Kb
  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(!isset($_GET['cat_id'])) { go('/forum/'); }
  10. $cat_id = abs(intval($_GET['cat_id']));
  11. if($db->query("SELECT * FROM `forum_c` WHERE `id` = '". $cat_id ."'")->rowCount() == 0) {
  12. $title = $lang->word('forum');
  13. require_once(SYS.'/view/header.php');
  14. $tpl->div('menu', $lang->word('subforum_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. $topicc = $db->query("SELECT * FROM `forum_c` WHERE `id` = '". $cat_id ."'")->fetch();
  20. $title = $topicc['name'] .' | '.$lang->word('forum');
  21. require_once(SYS.'/view/header.php');
  22. $tpl->div('title', $topicc['name'] .' | '.$lang->word('forum'));
  23. $topic_r = $db->query("SELECT * FROM `forum_t` WHERE `cat_id` = '". $cat_id ."'")->rowCount();
  24. $pages = new Paginator($topic_r, $ames);
  25. if($topic_r == 0) {
  26. echo $tpl->div('menu', $lang->word('no_topics'));
  27. }
  28. else {
  29. $topic_q = $db->query("SELECT * FROM `forum_t` WHERE `cat_id` = '". $cat_id ."' ORDER BY attach DESC, time_last_post DESC LIMIT $start, $ames");
  30. while($topic = $topic_q->fetch()) {
  31. echo '<div class="menu">';
  32. if ($topic['closed'] == 1 && $topic['attach'] == 1) echo img('pin-closed.png');
  33. else if ($topic['attach'] == 1) echo img('pin.png');
  34. else if ($topic['closed'] == 1) echo img('topic_closed.png');
  35. else echo img('topic.png');
  36. $topic_a = $db->query("SELECT * FROM `forum_pt` WHERE `topic_id` = '". $topic['id']."' ORDER BY time DESC LIMIT 1")->fetch();
  37. echo '<a href="/forum/topic'. $topic['id'] .'/">'. $topic['name'] .'</a> ('. $db->query("SELECT id FROM `forum_pt` WHERE `topic_id` = '". $topic['id'] ."'")->rowCount().')<a href="/forum/topic'. $topic['id'] .'/?page=end">»</a> '. ($user['level'] >= 5 ? ' [<a href="/forum/delete_topic/'.$topic['id'].'/">'.img('delete.png').'</a> | <a href="/forum/edit_topic/'.$topic['id'].'/">'.img('edit.png').'</a>]' : NULL) .'<br/> [<small class="gray">'. tnick($topic_a['user_id']).' / '. rtime($topic_a['time']).'</small>]
  38. </div>';
  39. }
  40. $pages->view('/forum/cat/'. $cat_id .'?');
  41. }
  42. $fid = $db->query("SELECT f_id FROM `forum_c` WHERE `id` = '". $cat_id ."'")->fetchColumn();
  43. $tpl->div('block', (isset($user) ? NAV.' <a href="/forum/add_topic/'. $cat_id .'/">'. $lang->word('create_topic') .'</a><br/>' : NULL) . NAV . ' <a href="/forum/'. $fid .'/">'. $db->query("SELECT name FROM `forum` WHERE `id` = '". $fid ."'")->fetchColumn().'</a><br/>' . NAV . ' <a href="/forum/">'. $lang->word('forum') .'</a><br/>' . HICO .' <a href="/">'. $lang->word('home') .'</a>');
  44. require_once(SYS.'/view/footer.php');
  45. ?>