space_debate.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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: space_debate.php 28220 2012-02-24 07:52:50Z zhengqingpeng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. $minhot = $_G['setting']['feedhotmin']<1?3:$_G['setting']['feedhotmin'];
  12. $page = empty($_GET['page'])?1:intval($_GET['page']);
  13. if($page<1) $page=1;
  14. $id = empty($_GET['id'])?0:intval($_GET['id']);
  15. $opactives['debate'] = 'class="a"';
  16. if(empty($_GET['view'])) $_GET['view'] = 'we';
  17. $_GET['order'] = empty($_GET['order']) ? 'dateline' : $_GET['order'];
  18. $perpage = 20;
  19. $perpage = mob_perpage($perpage);
  20. $start = ($page-1)*$perpage;
  21. ckstart($start, $perpage);
  22. $list = $userlist = array();
  23. $count = $pricount = 0;
  24. $gets = array(
  25. 'mod' => 'space',
  26. 'uid' => $space['uid'],
  27. 'do' => 'debate',
  28. 'view' => $_GET['view'],
  29. 'order' => $_GET['order'],
  30. 'type' => $_GET['type'],
  31. 'fuid' => $_GET['fuid'],
  32. 'searchkey' => $_GET['searchkey']
  33. );
  34. $theurl = 'home.php?'.url_implode($gets);
  35. $multi = '';
  36. $f_index = '';
  37. $ordersql = 't.dateline DESC';
  38. $need_count = true;
  39. $join = $authorid = $replies = 0;
  40. $displayorder = null;
  41. $subject = '';
  42. if($_GET['view'] == 'me') {
  43. if($_GET['type'] == 'reply') {
  44. $authorid = $space['uid'];
  45. $join = true;
  46. } else {
  47. $authorid = $space['uid'];
  48. }
  49. $viewtype = in_array($_GET['type'], array('orig', 'reply')) ? $_GET['type'] : 'orig';
  50. $typeactives = array($viewtype => ' class="a"');
  51. } else {
  52. space_merge($space, 'field_home');
  53. if($space['feedfriend']) {
  54. $fuid_actives = array();
  55. require_once libfile('function/friend');
  56. $fuid = intval($_GET['fuid']);
  57. if($fuid && friend_check($fuid, $space['uid'])) {
  58. $authorid = $fuid;
  59. $fuid_actives = array($fuid=>' selected');
  60. } else {
  61. $authorid = explode(',', $space['feedfriend']);
  62. $theurl = "home.php?mod=space&uid=$space[uid]&do=$do&view=we";
  63. }
  64. $query = C::t('home_friend')->fetch_all_by_uid($space['uid'], 0, 100, true);
  65. foreach($query as $value) {
  66. $userlist[] = $value;
  67. }
  68. } else {
  69. $need_count = false;
  70. }
  71. }
  72. $actives = array($_GET['view'] =>' class="a"');
  73. if($need_count) {
  74. if($_GET['view'] != 'me') {
  75. $displayorder = 0;
  76. }
  77. if($searchkey = stripsearchkey($_GET['searchkey'])) {
  78. $subject = $searchkey;
  79. $searchkey = dhtmlspecialchars($searchkey);
  80. }
  81. $count = C::t('forum_thread')->count_by_special(5, $authorid, $replies, $displayorder, $subject, $join);
  82. if($count) {
  83. $dids = $special = $multitable = $tids = array();
  84. require_once libfile('function/post');
  85. foreach(C::t('forum_thread')->fetch_all_by_special(5, $authorid, $replies, $displayorder, $subject, $join, $start, $perpage) as $value) {
  86. $value['dateline'] = dgmdate($value['dateline']);
  87. if($_GET['view'] == 'me' && $_GET['type'] == 'reply' && $page == 1 && count($special) < 2) {
  88. $value['message'] = messagecutstr($value['message'], 200);
  89. $special[$value['tid']] = $value;
  90. } else {
  91. if($page == 1 && count($special) < 2) {
  92. $tids[$value['posttableid']][$value['tid']] = $value['tid'];
  93. $special[$value['tid']] = $value;
  94. } else {
  95. $list[$value['tid']] = $value;
  96. }
  97. }
  98. $dids[$value['tid']] = $value['tid'];
  99. }
  100. if($tids) {
  101. foreach($tids as $postid => $tid) {
  102. foreach(C::t('forum_post')->fetch_all_by_tid(0, $tid) as $value) {
  103. $special[$value['tid']]['message'] = messagecutstr($value['message'], 200);
  104. }
  105. }
  106. }
  107. if($dids) {
  108. foreach(C::t('forum_debate')->fetch_all($dids) as $value) {
  109. $value['negavotesheight'] = $value['affirmvotesheight'] = '8px';
  110. if($value['affirmvotes'] || $value['negavotes']) {
  111. $allvotes = $value['affirmvotes'] + $value['negavotes'];
  112. $value['negavotesheight'] = round($value['negavotes']/$allvotes * 100, 2).'%';
  113. $value['affirmvotesheight'] = round($value['affirmvotes']/$allvotes * 100, 2).'%';
  114. }
  115. if($list[$value['tid']]) {
  116. $list[$value['tid']] = array_merge($value, $list[$value['tid']]);
  117. } elseif($special[$value['tid']]) {
  118. $special[$value['tid']] = array_merge($value, $special[$value['tid']]);
  119. }
  120. }
  121. }
  122. $multi = multi($count, $perpage, $page, $theurl);
  123. }
  124. }
  125. if($_G['uid']) {
  126. if($_GET['view'] == 'all') {
  127. $navtitle = lang('core', 'title_view_all').lang('core', 'title_debate');
  128. } elseif($_GET['view'] == 'me') {
  129. $navtitle = lang('core', 'title_my_debate');
  130. } else {
  131. $navtitle = lang('core', 'title_friend_debate');
  132. }
  133. } else {
  134. if($_GET['order'] == 'hot') {
  135. $navtitle = lang('core', 'title_top_debate');
  136. } else {
  137. $navtitle = lang('core', 'title_newest_debate');
  138. }
  139. }
  140. include_once template("diy:home/space_debate");
  141. ?>