-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththread.inc.php
40 lines (29 loc) · 1.52 KB
/
thread.inc.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
<?php
include('./source/plugin/iltc_open/public.php');
if(IS_GET){
if(isset($_G['gp_fid'])) $fid = $_G['gp_fid'];
else showError('Missing Parameter');
//TODO:Chech whether user is allowed to view this threads.
//Get Forum
$query = DB::query("SELECT name, threads, posts FROM ".DB::table('forum_forum')." WHERE fid = $fid AND status = 1 LIMIT 1");
$result['forum'] = DB::fetch($query);
if($result['forum'] == false) showError('No Forum Found', 'error');
$result['forum']['name'] = iconv("GBK", "UTF-8", $result['forum']['name']);
$page = isset($_G['gp_page']) ? $_G['gp_page'] : 1;
$limit = isset($_G['gp_limit']) ? $_G['gp_limit'] : 20;
$sql = "SELECT thread.tid, thread.author, thread.authorid, thread.subject, thread.dateline, lastpost, lastposter, views, replies, message FROM "
.DB::table('forum_thread thread').", ".DB::table('forum_post post')
." WHERE thread.fid = $fid AND thread.displayorder >= 0 AND thread.tid = post.tid AND post.first = 1 ORDER BY thread.lastpost DESC LIMIT ".(($page - 1) * $limit).", $limit";
$query = DB::query($sql);
if(($temp = DB::fetch($query)) == false) showError('No Thread Found', 'error');
do {
$temp['author'] = iconv("GBK", "UTF-8", $temp['author']);
$temp['subject'] = iconv("GBK", "UTF-8", $temp['subject']);
$temp['lastposter'] = iconv("GBK", "UTF-8", $temp['lastposter']);
$temp['message'] = iconv("GBK", "UTF-8", $temp['message']);
$result['threads'][] = $temp;
} while($temp = DB::fetch($query));
}else{
var_dump($access_info);
}
showResult($result, 'success');