-
Notifications
You must be signed in to change notification settings - Fork 0
/
list.php
139 lines (138 loc) · 3.82 KB
/
list.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
<!DOCTYPE html>
<html>
<head>
<title>帖子列表</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8"></meta>
<link rel="stylesheet" type="text/css" href="style/style.css">
<?php
require_once './conn/board.dao.php';
require_once './conn/topic.dao.php';
require_once './conn/reply.dao.php';
error_reporting(0);
?>
</head>
<body>
<?php
echo do_html_head();
?>
<div>
<!-- 导航 -->
<br/>
<div>
<?php
$boardId = $_GET["boardId"];
//echo $boardId;
$curPage = $_GET["currentPage"];
$boardName = ""; //版块名称
$curBoard = array(); //当前版块信息
$msg = ""; //出错信息
if(isset($boardId)){ //判断版块是否存在
$curBoard = findBoard($boardId);
if(count($curBoard) >= 0){
$boardName = $curBoard["boardName"];
} else {
$msg = "版块不存在";
}
} else {
$msg = "版块编号不存在";
}
if($msg != ""){
header("location: ../error.php?msg=$msg"); //转入出错页面
}
// 分页所需变量
$topicList = findListTopic($curPage+1, $boardId); //分页取指定版块帖子列表
$topicNums = findCountTopic($boardId); //统计版块帖子数
$pageSize = $GLOBALS["cfg"]["server"]["page_size"]; //页面容量
//print_r($topicList);
//print_r($curBoard);
//echo $topicNums;
//echo $pageSize;
//计算总页数
if($topicNums%$pageSize == 0){
$pages = $topicNums/$pageSize;
} else {
$pages = (int)($topicNums/$pageSize) + 1;
}
//$pages = $topicNums % $pageSize == 0 ? $topicNums/$pageSize : (int)($topicNums/$pageSize)+1;
//echo $pages;
//生成页面导航代码
$explor = <<<HTML_STR
>><b><a href="index.php">论坛首页</a></b>
>><b><a href="list.php?boardId=$boardId & currentPage=0">$boardName</a></b>
HTML_STR;
echo $explor;
?>
</div>
<br/>
<!-- 发新帖链接 -->
<div>
<a href="post.php?boardId=<?php echo $boardId ?>"><img src="image/post.gif" name="td_post" border="0" id="td_post"></a>
</div>
<br/>
<!-- 分页处理 -->
<?php
$html_page = "";
if($curPage < 1){ //判断是否为第一页
$html_page = "上一页|";
} else { //不为第一页
$curPage --;
$html_page .= "<a href='list.php?boardId=$boardId & currentPage=$curPage'>上一页</a>|";
$curPage ++;
}
if( ($curPage+1)>= $pages){ //判断是否为最后一页
$html_page .= "下一页";
} else { //不为最后一页
$curPage ++;
$html_page .= "<a href='list.php?boardId=$boardId & currentPage=$curPage'>下一页</a>|";
$curPage --;
}
$tmp = $curPage + 1;
$html_page .= "|当前第 $tmp 页/共 $pages 页";
echo $html_page;
?>
</div>
<br/>
<div class="t">
<table cellspacing="0" cellpadding="0" width="100%">
<tr>
<th class="h" style="width: 100%" colspan="4">
<span> </span>
</th>
</tr>
<tr class="tr2">
<td> </td>
<td width="80%" align="center">文章</td>
<td width="10%" align="center">作者</td>
<td width="10%" align="center">回复</td>
</tr>
<!-- 主题列表 -->
<?php
$html_topic = "";
foreach ($topicList as $topic) {
$title = $topic["title"];
$uName = $topic["uName"];
$topicId = $topic["topicId"];
$replyCount = findCountReply($topicId);
//帖子列表HTML字符串
$html_topic .= <<<HTML_TABLE
<tr class="tr3">
<td>
<img src="image/topic.gif" border=0>
</td>
<td style="fonz-size: 15px">
<a href="detail.php?boardId=$boardId¤tPage=$curPage¤tReplyPage=0&topicId=$topicId">$title</a>
</td>
<td align="center">$uName</td>
<td align="center">$replyCount</td>
</tr>
HTML_TABLE;
}
echo $html_topic;
?>
</table>
</div>
<?php
echo do_html_footer();
?>
</body>
</html>