viewthread.php
10.3 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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: viewthread.php 35159 2014-12-23 02:22:03Z nemohou $
*/
if (!defined('IN_MOBILE_API')) {
exit('Access Denied');
}
$_GET['mod'] = 'viewthread';
include_once 'forum.php';
class mobile_api {
function common() {
}
function output() {
global $_G, $thread;
if ($GLOBALS['hiddenreplies']) {
foreach ($GLOBALS['postlist'] as $k => $post) {
if (!$post['first'] && $_G['uid'] != $post['authorid'] && $_G['uid'] != $_G['forum_thread']['authorid'] && !$_G['forum']['ismoderator']) {
$GLOBALS['postlist'][$k]['message'] = lang('plugin/mobile', 'mobile_post_author_visible');
$GLOBALS['postlist'][$k]['attachments'] = array();
}
}
}
$_G['thread']['lastpost'] = dgmdate($_G['thread']['lastpost']);
$_G['thread']['ordertype'] = $GLOBALS['ordertype'];
$_G['thread']['recommend'] = $_G['uid'] && C::t('forum_memberrecommend')->fetch_by_recommenduid_tid($_G['uid'], $_G['tid']) ? 1 : 0;
if (!empty($_GET['viewpid'])) {
$GLOBALS['postlist'][$_GET['viewpid']] = $GLOBALS['post'];
}
if ($GLOBALS['rushreply']) {
$_G['thread']['rushreply'] = $GLOBALS['rushreply'];
$_G['thread']['rushresult'] = $GLOBALS['rushresult'];
}
foreach ($GLOBALS['comments'] as $pid => $comments) {
$comments = mobile_core::getvalues($comments, array('/^\d+$/'), array('id', 'tid', 'pid', 'author', 'authorid', 'dateline', 'comment', 'avatar'));
foreach ($comments as $k => $c) {
$comments[$k]['avatar'] = avatar($c['authorid'], 'small', true);
$comments[$k]['dateline'] = dgmdate($c['dateline'], 'u');
}
$GLOBALS['comments'][$pid] = $comments;
}
$variable = array(
'thread' => $_G['thread'],
'fid' => $_G['fid'],
'postlist' => array_values(mobile_core::getvalues($GLOBALS['postlist'], array('/^\d+$/'), array('pid', 'tid', 'author', 'first', 'dbdateline', 'dateline', 'username', 'adminid', 'memberstatus', 'authorid', 'username', 'groupid', 'memberstatus', 'status', 'message', 'number', 'memberstatus', 'groupid', 'attachment', 'attachments', 'attachlist', 'imagelist', 'anonymous', 'position', 'rewardfloor', 'replycredit'))),
'allowpostcomment' => $_G['setting']['allowpostcomment'],
'comments' => $GLOBALS['comments'],
'commentcount' => $GLOBALS['commentcount'],
'ppp' => $_G['ppp'],
'setting_rewriterule' => $_G['setting']['rewriterule'],
'setting_rewritestatus' => $_G['setting']['rewritestatus'],
'forum_threadpay' => $_G['forum_threadpay'],
'cache_custominfo_postno' => $_G['cache']['custominfo']['postno'],
);
if (!empty($GLOBALS['threadsortshow'])) {
$optionlist = array();
foreach ($GLOBALS['threadsortshow']['optionlist'] AS $key => $val) {
$val['optionid'] = $key;
$optionlist[] = $val;
}
if (!empty($optionlist)) {
$GLOBALS['threadsortshow']['optionlist'] = $optionlist;
$GLOBALS['threadsortshow']['threadsortname'] = $_G['forum']['threadsorts']['types'][$thread['sortid']];
}
}
$threadsortshow = mobile_core::getvalues($GLOBALS['threadsortshow'], array('/^(?!typetemplate).*$/'));
if (!empty($threadsortshow)) {
$variable['threadsortshow'] = $threadsortshow;
}
foreach ($variable['postlist'] as $k => $post) {
if (!$_G['forum']['ismoderator'] && $_G['setting']['bannedmessages'] & 1 && (($post['authorid'] && !$post['username']) || ($_G['thread']['digest'] == 0 && ($post['groupid'] == 4 || $post['groupid'] == 5 || $post['memberstatus'] == '-1')))) {
$message = lang('forum/template', 'message_banned');
} elseif (!$_G['forum']['ismoderator'] && $post['status'] & 1) {
$message = lang('forum/template', 'message_single_banned');
} elseif ($GLOBALS['needhiddenreply']) {
$message = lang('forum/template', 'message_ishidden_hiddenreplies');
} elseif ($post['first'] && $_G['forum_threadpay']) {
$message = lang('forum/template', 'pay_threads') . ' ' . $GLOBALS['thread']['price'] . ' ' . $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][1]]['unit'] . $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][1]]['title'];
} elseif ($_G['forum_discuzcode']['passwordlock']) {
$message = lang('forum/template', 'message_password_exists');
} else {
$message = '';
}
if ($message) {
$variable['postlist'][$k]['message'] = $message;
}
if ($post['anonymous'] && !$_G['forum']['ismoderator']) {
$variable['postlist'][$k]['username'] = $variable['postlist'][$k]['author'] = $_G['setting']['anonymoustext'];
$variable['postlist'][$k]['adminid'] = $variable['postlist'][$k]['groupid'] = $variable['postlist'][$k]['authorid'] = 0;
if ($post['first']) {
$variable['thread']['authorid'] = 0;
}
}
if (strpos($variable['postlist'][$k]['message'], '[/tthread]') !== FALSE) {
$matches = array();
preg_match('/\[tthread=(.+?),(.+?)\](.*?)\[\/tthread\]/', $variable['postlist'][$k]['message'], $matches);
$variable['postlist'][$k]['message'] = preg_replace('/\[tthread=(.+?)\](.*?)\[\/tthread\]/', lang('plugin/qqconnect', 'connect_tthread_message', array('username' => $matches[1], 'nick' => $matches[2])), $variable['postlist'][$k]['message']);
}
$variable['postlist'][$k]['message'] = preg_replace("/<a\shref=\"([^\"]+?)\"\starget=\"_blank\">\[viewimg\]<\/a>/is", "<img src=\"\\1\" />", $variable['postlist'][$k]['message']);
$variable['postlist'][$k]['message'] = mobile_api::_findimg($variable['postlist'][$k]['message']);
if ($GLOBALS['aimgs'][$post['pid']]) {
$imagelist = array();
foreach ($GLOBALS['aimgs'][$post['pid']] as $aid) {
$extra = '';
$url = mobile_api::_parseimg('', $GLOBALS['postlist'][$post['pid']]['attachments'][$aid]['url'] . $GLOBALS['postlist'][$post['pid']]['attachments'][$aid]['attachment'], '');
if ($GLOBALS['postlist'][$post['pid']]['attachments'][$aid]['thumb']) {
$extra = 'file="' . $url . '" ';
$url .= '.thumb.jpg';
}
$extra .= 'attach="' . $post['pid'] . '" ';
if (strexists($variable['postlist'][$k]['message'], '[attach]' . $aid . '[/attach]')) {
$variable['postlist'][$k]['message'] = str_replace('[attach]' . $aid . '[/attach]', mobile_image($url, $extra), $variable['postlist'][$k]['message']);
unset($variable['postlist'][$k]['attachments'][$aid]);
} elseif (!in_array($aid, $_G['forum_attachtags'][$post['pid']])) {
$imagelist[] = $aid;
}
}
$variable['postlist'][$k]['imagelist'] = $imagelist;
}
$variable['postlist'][$k]['message'] = preg_replace("/\[attach\]\d+\[\/attach\]/i", '', $variable['postlist'][$k]['message']);
$variable['postlist'][$k]['message'] = preg_replace('/( ){2,}/', '', $variable['postlist'][$k]['message']);
$variable['postlist'][$k]['dateline'] = strip_tags($post['dateline']);
$variable['postlist'][$k]['groupiconid'] = mobile_core::usergroupIconId($post['groupid']);
}
if (!empty($GLOBALS['polloptions'])) {
$variable['special_poll']['polloptions'] = $GLOBALS['polloptions'];
$variable['special_poll']['expirations'] = $GLOBALS['expirations'];
$variable['special_poll']['multiple'] = $GLOBALS['multiple'];
$variable['special_poll']['maxchoices'] = $GLOBALS['maxchoices'];
$variable['special_poll']['voterscount'] = $GLOBALS['voterscount'];
$variable['special_poll']['visiblepoll'] = $GLOBALS['visiblepoll'];
$variable['special_poll']['allowvote'] = $_G['group']['allowvote'];
$variable['special_poll']['remaintime'] = $thread['remaintime'];
}
if (!empty($GLOBALS['rewardprice'])) {
$variable['special_reward']['rewardprice'] = $GLOBALS['rewardprice'] . ' ' . $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][2]]['title'];
$variable['special_reward']['bestpost'] = $GLOBALS['bestpost'];
}
if (!empty($GLOBALS['trades'])) {
$variable['special_trade'] = $GLOBALS['trades'];
}
if (!empty($GLOBALS['debate'])) {
$variable['special_debate'] = $GLOBALS['debate'];
}
if (!empty($GLOBALS['activity'])) {
$variable['special_activity'] = $GLOBALS['activity'];
$variable['special_activity']['allapplynum'] = $GLOBALS['allapplynum'];
if ($_G['setting']['activitycredit'] && $GLOBALS['activity']['credit'] && !$GLOBALS['applied']) {
$variable['special_activity']['creditcost'] = $GLOBALS['activity']['credit'] . ' ' . $_G['setting']['extcredits'][$_G['setting']['activitycredit']]['title'];
}
$setting = array();
foreach ($GLOBALS['activity']['ufield']['userfield'] as $field) {
$setting[$field] = $_G['cache']['profilesetting'][$field];
}
$variable['special_activity']['joinfield'] = mobile_core::getvalues($setting, array('/./'), array('fieldid', 'formtype', 'available', 'title', 'formtype', 'choices'));
$variable['special_activity']['userfield'] = $GLOBALS['ufielddata']['userfield'];
$variable['special_activity']['extfield'] = $GLOBALS['ufielddata']['extfield'];
$variable['special_activity']['basefield'] = mobile_core::getvalues($GLOBALS['applyinfo'], array('message', 'payment'));
$variable['special_activity']['closed'] = $GLOBALS['activityclose'];
if ($GLOBALS['applied'] && $GLOBALS['isverified'] < 2) {
if (!$GLOBALS['isverified']) {
$variable['special_activity']['status'] = 'wait';
} else {
$variable['special_activity']['status'] = 'joined';
}
if (!$GLOBALS['activityclose']) {
$variable['special_activity']['button'] = 'cancel';
}
} elseif (!$GLOBALS['activityclose']) {
if ($GLOBALS['isverified'] != 2) {
$variable['special_activity']['status'] = 'join';
} else {
$variable['special_activity']['status'] = 'complete';
}
$variable['special_activity']['button'] = 'join';
}
}
$variable['forum']['password'] = $variable['forum']['password'] ? '1' : '0';
mobile_core::result(mobile_core::variable($variable));
}
function _findimg($string) {
return preg_replace('/(<img src=\")(.+?)(\".*?\>)/ise', "mobile_api::_parseimg('\\1', '\\2', '\\3')", $string);
}
function _parseimg($before, $img, $after) {
$before = stripslashes($before);
$after = stripslashes($after);
if (!in_array(strtolower(substr($img, 0, 6)), array('http:/', 'https:', 'ftp://'))) {
global $_G;
$img = $_G['siteurl'] . $img;
}
return $before . $img . $after;
}
}
?>