forked from eKing-one/phpBB-WAP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviewforum.php
422 lines (356 loc) · 13.2 KB
/
viewforum.php
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
<?php
/**
* @package phpBB-WAP
* @copyright (c) phpBB Group
* @Оптимизация под WAP: Гутник Игорь ( чел ).
* @简体中文:中文phpBB-WAP团队
* @license http://opensource.org/licenses/gpl-license.php
**/
/**
* 这是一款自由软件, 您可以在 Free Software Foundation 发布的
* GNU General Public License 的条款下重新发布或修改; 您可以
* 选择目前 version 2 这个版本(亦可以选择任何更新的版本,由
* 你喜欢)作为新的牌照.
**/
define('IN_PHPBB', true);
define('ROOT_PATH', './');
include(ROOT_PATH . 'common.php');
if ( isset($_GET[POST_FORUM_URL]) || isset($_POST[POST_FORUM_URL]) )
{
$forum_id = ( isset($_GET[POST_FORUM_URL]) ) ? intval($_GET[POST_FORUM_URL]) : intval($_POST[POST_FORUM_URL]);
}
else if ( isset($_GET['forum']))
{
$forum_id = intval($_GET['forum']);
}
else
{
$forum_id = '';
}
if ( !empty($forum_id) )
{
$sql = "SELECT *
FROM " . FORUMS_TABLE . "
WHERE forum_id = $forum_id";
if ( !($result = $db->sql_query($sql)) )
{
trigger_error('Could not obtain forums information', E_USER_WARNING);
}
}
else
{
trigger_error('论坛不存在', E_USER_ERROR);
}
if ( !($forum_row = $db->sql_fetchrow($result)) )
{
trigger_error('论坛不存在', E_USER_ERROR);
}
$userdata = $session->start($user_ip, $forum_id);
init_userprefs($userdata);
$start = get_pagination_start($board_config['topics_per_page']);
$is_auth = array();
$is_auth = auth(AUTH_ALL, $forum_id, $userdata, $forum_row);
if ( !$is_auth['auth_read'] || !$is_auth['auth_view'] )
{
if ( !$userdata['session_logged_in'] )
{
$redirect = POST_FORUM_URL . "=$forum_id" . ( ( isset($start) ) ? "&start=$start" : '' );
login_back("viewforum.php?$redirect");
}
$message = ( !$is_auth['auth_view'] ) ? '论坛不存在' : '对不起,仅 ' . $is_auth['auth_read_type'] . ' 可以阅读主题';
trigger_error($message, E_USER_ERROR);;
}
if ( $is_auth['auth_mod'] && $board_config['prune_enable'] )
{
if ( $forum_row['prune_next'] < time() && $forum_row['prune_enable'] )
{
include(ROOT_PATH . 'includes/functions/prune.php');
require(ROOT_PATH . 'includes/functions/admin.php');
auto_prune($forum_id);
}
}
$topics_count = ( $forum_row['forum_topics'] ) ? $forum_row['forum_topics'] : 1;
if (isset($_GET['marrow']))
{
$sql = "SELECT SQL_CALC_FOUND_ROWS t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time
FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u2
WHERE t.forum_id = $forum_id
AND t.topic_poster = u.user_id
AND p.post_id = t.topic_first_post_id
AND p2.post_id = t.topic_last_post_id
AND u2.user_id = p2.poster_id
AND t.topic_marrow = " . POST_MARROW . "
ORDER BY t.topic_type DESC, t.topic_last_post_id DESC
LIMIT $start, ".$board_config['topics_per_page'];
if ( !($result = $db->sql_query($sql)) )
{
trigger_error('Could not obtain topic information', E_USER_WARNING);
}
// 统计精华帖子
$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);
page_header($forum_row['forum_name'] . '的精华帖子');
if ($total_topics = $db->sql_numrows($result))
{
$i = 0;
while( $topic_marrow = $db->sql_fetchrow($result) )
{
// 主题标题
$topic_title = ( count($orig_word) ) ? str_replace($orig_word, $replacement_word, $topic_marrow['topic_title']) : $topic_marrow['topic_title'];
$topic_type = $topic_marrow['topic_type'];
$views = $topic_marrow['topic_views'];
$replies = $topic_marrow['topic_replies'];
// 公告帖子
if( $topic_type == POST_ANNOUNCE )
{
$topic_type = make_style_image('topic_announcement', '公告帖子', '【告】');
}
// 置顶帖子
else if( $topic_type == POST_STICKY )
{
$topic_type = make_style_image('topic_sticky', '置顶帖子', '【顶】');
}
// 普通贴子
else
{
$topic_type = '';
}
// 投票
if( $topic_marrow['topic_vote'] )
{
$topic_type = make_style_image('topic_poll', '投票帖子', '【投】');
}
// 从其他论坛移动过来的帖子
if( $topic_marrow['topic_status'] == TOPIC_MOVED )
{
$topic_type = make_style_image('topic_move', '移动过来的帖子', '【移】');
$topic_id = $topic_marrow['topic_moved_id'];
}
// 附件图标
if (intval($topic_marrow['topic_attachment']) == 0 || (!($is_auth['auth_download'] && $is_auth['auth_view'])) || intval($board_config['disable_mod']) || $board_config['topic_icon'] == '')
{
$attachment_image = '';
}
else
{
$attachment_image = '<img src="' . $board_config['topic_icon'] . '" alt="附" title="带有附件的帖子"/>';
}
$topic_id = $topic_marrow['topic_id'];
$row_class = (($i % 2) == 0) ? 'row1' : 'row2';
$view_topic_url = append_sid("viewtopic.php?" . POST_TOPIC_URL . "=$topic_id");
$last_post_author = ( $topic_marrow['id2'] == ANONYMOUS ) ? ( ($topic_marrow['post_username2'] != '' ) ? $topic_marrow['post_username2'] . ' ' : '匿名用户' . ' ' ) : $topic_marrow['user2'] ;
$s_last_post = '<a href="' . append_sid("viewtopic.php?" . POST_POST_URL . '=' . $topic_marrow['topic_last_post_id']) . '#' . $topic_marrow['topic_last_post_id'] . '">»</a>';
$nomer_posta = $i + $start + 1;
$template->assign_block_vars('topicrow', array(
'ROW_CLASS' => $row_class,
'TOPIC_TITLE' => $topic_title,
'TOPIC_TYPE' => $topic_type,
'REPLIES' => $replies,
'VIEWS' => $views,
'TOPIC_ATTACHMENT_IMG' => $attachment_image,
'NOMER_POSTA' => $nomer_posta,
'LAST_POST_AUTHOR' => $last_post_author,
'S_LAST_POST' => $s_last_post,
'U_VIEW_TOPIC' => $view_topic_url)
);
$i++;
}
}
else
{
$template->assign_block_vars('switch_no_topics', array() );
}
$db->sql_freeresult($result);
$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);
page_jump();
$template->set_filenames(array(
'body' => 'viewforum_marrow.tpl')
);
// 计算出查询的记录总数
$sql = 'SELECT found_rows() AS rowcount';
if ( !$result = $db->sql_query($sql) )
{
trigger_error('无法统计在线用户!', E_USER_WARNING);
}
$total_marrow = $db->sql_fetchrow($result);
$total_all_marrow = $total_marrow['rowcount'];
$template->assign_vars(array(
'FORUM_NAME' => $forum_row['forum_name'],
'U_VIEW_FORUM' => append_sid("viewforum.php?" . POST_FORUM_URL ."=$forum_id"),
'U_FORUM' => append_sid('forum.php'),
'PAGINATION' => generate_pagination("viewforum.php?" . POST_FORUM_URL . "=$forum_id&marrow&", $total_all_marrow, $board_config['topics_per_page'], $start))
);
$template->pparse('body');
page_footer();
}
// 获取公告帖子
$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_time, p.post_username
FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . USERS_TABLE . " u2
WHERE t.forum_id = $forum_id
AND t.topic_poster = u.user_id
AND p.post_id = t.topic_last_post_id
AND p.poster_id = u2.user_id
AND t.topic_type = " . POST_ANNOUNCE . "
ORDER BY t.topic_last_post_id DESC ";
if ( !($result = $db->sql_query($sql)) )
{
trigger_error('Could not obtain topic information', E_USER_WARNING);
}
$topic_rowset = array();
$total_announcements = 0;
while( $row = $db->sql_fetchrow($result) )
{
$topic_rowset[] = $row;
$total_announcements++;
}
$db->sql_freeresult($result);
// 获取帖子
$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time
FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u2
WHERE t.forum_id = $forum_id
AND t.topic_poster = u.user_id
AND p.post_id = t.topic_first_post_id
AND p2.post_id = t.topic_last_post_id
AND u2.user_id = p2.poster_id
AND t.topic_type <> " . POST_ANNOUNCE . "
ORDER BY t.topic_type DESC, t.topic_last_post_id DESC
LIMIT $start, ".$board_config['topics_per_page'];
if ( !($result = $db->sql_query($sql)) )
{
trigger_error('Could not obtain topic information', E_USER_WARNING);
}
$total_topics = 0;
while( $row = $db->sql_fetchrow($result) )
{
$topic_rowset[] = $row;
$total_topics++;
}
$db->sql_freeresult($result);
$total_topics += $total_announcements;
$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);
$u_modcp = '';
if ($is_auth['auth_mod'])
{
$u_modcp = append_sid('modcp.php?' . POST_FORUM_URL . '=' . $forum_id . '&start=' . $start . '&sid=' . $userdata['session_id']);
$template->assign_block_vars('modcp', array('U_MODCP' => $u_modcp,) );
}
$template->assign_vars(array(
'U_FORUMCP' => append_sid('forumcp.php?' . POST_FORUM_URL . '=' . $forum_id),
'FORUM_ID' => $forum_id,
'FORUM_NAME' => $forum_row['forum_name'],
'U_POST_NEW_TOPIC' => append_sid("posting.php?mode=newtopic&" . POST_FORUM_URL . "=$forum_id"),
'U_CLASS' => append_sid('viewclass.php?mode=list&' . POST_FORUM_URL . '=' . $forum_id),
'U_MARROW' => append_sid('viewforum.php?' . POST_FORUM_URL . '=' . $forum_id . '&marrow'),
'U_VIEW_FORUM' => append_sid("viewforum.php?" . POST_FORUM_URL ."=$forum_id"),
'S_SEARCH_ACTION' => append_sid('bbs/search_topic.php?' . POST_FORUM_URL . '=' . $forum_id))
);
define('SHOW_ONLINE', true);
$page_title = $forum_row['forum_name'];
page_header($page_title);
page_jump();
// 使用论坛的模块
require_once ROOT_PATH . 'includes/class/forum_module.php';
$forum_module = new Forum_module($forum_id);
// 显示论坛的顶部
$forum_module->display_top();
$template->set_filenames(array(
'body' => 'viewforum_body.tpl')
);
if( $total_topics )
{
for($i = 0; $i < $total_topics; $i++)
{
$topic_id = $topic_rowset[$i]['topic_id'];
$topic_title = ( count($orig_word) ) ? str_replace($orig_word, $replacement_word, $topic_rowset[$i]['topic_title']) : $topic_rowset[$i]['topic_title'];
$views = $topic_rowset[$i]['topic_views'];
$replies = $topic_rowset[$i]['topic_replies'];
$topic_type = $topic_rowset[$i]['topic_type'];
//$topic_time = $topic_rowset[$i]['topic_time'];
// 公告帖子
if( $topic_type == POST_ANNOUNCE )
{
$topic_type = make_style_image('topic_announcement', '公告帖子', '【告】');
$row_class = 'bold';
}
// 置顶帖子
else if( $topic_type == POST_STICKY )
{
$topic_type = make_style_image('topic_sticky', '置顶帖子', '【顶】');
$row_class = 'bold';
}
// 普通贴子
else
{
$topic_type = '';
$row_class = 'medium';
}
// 投票
if( $topic_rowset[$i]['topic_vote'] )
{
$topic_type = make_style_image('topic_poll', '投票帖子', '【投】');
}
// 从其他论坛移动过来的帖子
if( $topic_rowset[$i]['topic_status'] == TOPIC_MOVED )
{
$topic_type = make_style_image('topic_move', '移动过来的帖子', '【移】');
$topic_id = $topic_rowset[$i]['topic_moved_id'];
}
// 附件图标
if (intval($topic_rowset[$i]['topic_attachment']) == 0 || (!($is_auth['auth_download'] && $is_auth['auth_view'])) || intval($board_config['disable_mod']) || $board_config['topic_icon'] == '')
{
$attachment_image = '';
}
else
{
$attachment_image = '<img src="' . $board_config['topic_icon'] . '" alt="附" title="带有附件的帖子"/>';
}
if ($topic_rowset[$i]['topic_marrow'] == POST_MARROW)
{
$topic_marrow = make_style_image('topic_marrow', '精华帖子', '【精】');
}
else
{
$topic_marrow = '';
}
$view_topic_url = append_sid("viewtopic.php?" . POST_TOPIC_URL . "=$topic_id");
$last_post_author = ( $topic_rowset[$i]['id2'] == ANONYMOUS ) ? ( ($topic_rowset[$i]['post_username2'] != '' ) ? $topic_rowset[$i]['post_username2'] . ' ' : '匿名用户' . ' ' ) : $topic_rowset[$i]['user2'] ;
$s_last_post = '<a href="' . append_sid("viewtopic.php?" . POST_POST_URL . '=' . $topic_rowset[$i]['topic_last_post_id']) . '#' . $topic_rowset[$i]['topic_last_post_id'] . '">»</a>';
$nomer_posta = $i + $start + 1;
$row_color = ( !($i % 2) ) ? 'row1' : 'row2';
$template->assign_block_vars('topicrow', array(
'ROW_CLASS' => $row_class,
'ROW_COLOR' => $row_color,
'REPLIES' => $replies,
'VIEWS' => $views,
'TOPIC_ATTACHMENT_IMG' => $attachment_image,
'TOPIC_TITLE' => $topic_title,
'TOPIC_TYPE' => $topic_type,
'TOPIC_MARROW' => $topic_marrow,
'NOMER_POSTA' => $nomer_posta,
'LAST_POST_AUTHOR' => $last_post_author,
'S_LAST_POST' => $s_last_post,
'U_VIEW_TOPIC' => $view_topic_url)
);
}
$template->assign_vars(array(
'PAGINATION' => generate_pagination("viewforum.php?" . POST_FORUM_URL . "=$forum_id", $topics_count, $board_config['topics_per_page'], $start))
);
}
else
{
$no_topics_msg = ( $forum_row['forum_status'] == FORUM_LOCKED ) ? '该论坛已经锁定,不能发表新主题、帖子、回复主题和编辑发贴' : '论坛中还没有贴子,点击 发表新贴 链接发表贴子';
$template->assign_vars(array(
'L_NO_TOPICS' => $no_topics_msg)
);
$template->assign_block_vars('switch_no_topics', array() );
}
// 显示论坛的底部
$forum_module->display_bottom();
$template->pparse('body');
page_footer();
?>