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