portal_topic.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: portal_topic.php 33660 2013-07-29 07:51:05Z nemohou $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. if($_GET['diy']=='yes' && !$_G['group']['allowaddtopic'] && !$_G['group']['allowmanagetopic']) {
  12. $_GET['diy'] = '';
  13. showmessage('topic_edit_nopermission');
  14. }
  15. $topicid = $_GET['topicid'] ? intval($_GET['topicid']) : 0;
  16. if($topicid) {
  17. $topic = C::t('portal_topic')->fetch($topicid);
  18. } elseif($_GET['topic']) {
  19. $topic = C::t('portal_topic')->fetch_by_name($_GET['topic']);
  20. }
  21. if(empty($topic)) {
  22. showmessage('topic_not_exist');
  23. }
  24. if($topic['closed'] && !$_G['group']['allowmanagetopic'] && !($topic['uid'] == $_G['uid'] && $_G['group']['allowaddtopic'])) {
  25. showmessage('topic_is_closed');
  26. }
  27. if($_GET['diy'] == 'yes' && $topic['uid'] != $_G['uid'] && !$_G['group']['allowmanagetopic']) {
  28. $_GET['diy'] = '';
  29. showmessage('topic_edit_nopermission');
  30. }
  31. if(!empty($_G['setting']['makehtml']['flag']) && $topic['htmlmade'] && !isset($_G['makehtml']) && empty($_GET['diy'])) {
  32. dheader('location:'.fetch_topic_url($topic));
  33. }
  34. $topicid = intval($topic['topicid']);
  35. C::t('portal_topic')->increase($topicid, array('viewnum' => 1));
  36. $navtitle = $topic['title'];
  37. $metadescription = empty($topic['summary']) ? $topic['title'] : $topic['summary'];
  38. $metakeywords = empty($topic['keyword']) ? $topic['title'] : $topic['keyword'];
  39. $attachtags = $aimgs = array();
  40. list($seccodecheck, $secqaacheck) = seccheck('publish');
  41. if(isset($_G['makehtml'])) {
  42. helper_makehtml::portal_topic($topic);
  43. }
  44. $file = 'portal/portal_topic_content:'.$topicid;
  45. $tpldirectory = '';
  46. $primaltplname = $topic['primaltplname'];
  47. if(strpos($primaltplname, ':') !== false) {
  48. list($tpldirectory, $primaltplname) = explode(':', $primaltplname);
  49. }
  50. $topicurl = fetch_topic_url($topic);
  51. include template('diy:'.$file, NULL, $tpldirectory, NULL, $primaltplname);
  52. function portaltopicgetcomment($topcid, $limit = 20, $start = 0) {
  53. global $_G;
  54. $topcid = intval($topcid);
  55. $limit = intval($limit);
  56. $start = intval($start);
  57. $data = array();
  58. if($topcid) {
  59. $query = C::t('portal_comment')->fetch_all_by_id_idtype($topcid, 'topicid', 'dateline', 'DESC', $start, $limit);
  60. foreach($query as $value) {
  61. if($value['status'] == 0 || $value['uid'] == $_G['uid'] || $_G['adminid'] == 1) {
  62. $data[$value['cid']] = $value;
  63. }
  64. }
  65. }
  66. return $data;
  67. }
  68. ?>