一个BBS的源代码(二)

' 打开数据库
Set Con = Server.CreateObject("ADODB.Connection")
Con.Open "asp" , Application("ConASP_RuntimeUserName") , Application("ConASP_RuntimePassword")

Set RecBBS = Server.CreateObject("ADODB.RecordSet")
Set RecReply = Server.CreateObject("ADODB.RecordSet")
Set RecMember = Server.CreateObject("ADODB.RecordSet")

%>

 1<html>
 2<head>
 3<meta content="Microsoft Visual Studio 6.0" name="GENERATOR"/>
 4<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
 5<title>经验交流</title>
 6<style type="TEXT/CSS">   
 7td {   
 8color: #ffffff;   
 9font-size: 9pt;   
10}   
11td.menu {   
12color: #000000;   
13background-color: #f0f0d0;   
14font-size: 12pt;   
15}   
16input {   
17color: #000000;   
18font-size: 9pt;   
19border-top: 1px solid;   
20border-left: 1px solid;   
21border-right: 1px solid;   
22border-bottom: 1px solid;   
23}   
24select {   
25color: #000000;   
26font-size: 9pt;   
27border-top: 1px solid;   
28border-left: 1px solid;   
29border-right: 1px solid;   
30border-bottom: 1px solid;   
31}   
32textarea {   
33color: #000000;   
34font-size: 9pt;   
35border-top: 1px solid;   
36border-left: 1px solid;   
37border-right: 1px solid;   
38border-bottom: 1px solid;   
39}   
40a:link {   
41text-decoration: none;   
42}   
43a:visited {   
44text-decoration: none;   
45}   
46a:hover {   
47text-decoration: underline;   
48}   
49</style>
50</head>
51<body bgcolor="#c0c0c0">
52<p>
53<table align="center" bgcolor="#d0d0d0" border="1" bordercolordark="#f0f0f0" bordercolorlight="#505050" cellpadding="5" cellspacing="0" height="400" valign="top" width="600">
54<tr>
55<td valign="top">   

Job = Request("Job")
If Job = "" Then Job = "List"

'==============================
Select Case Job
'==============================

'=============================
Case "List"
'==============================
' 显示文章

 1  
 2<table align="center" border="0" cellpadding="1" cellspacing="0" width="650">
 3<tr>
 4<td>
 5<table align="center" bgcolor="#f0f0d0" border="0" cellpadding="2" cellspacing="0" width="100%">
 6<tr>
 7<td class="menu" valign="top">
 8<a href="/">飞林庄</a>-&gt;<a href="```
 9= ASP_FILE_NAME 
10```">经验交流</a>
11</td>
12<td class="menu"></td>
13<td align="right" class="menu">
14<form action="```
15= ASP_FILE_NAME 
16```" method="get">
17<input name="Job" type="hidden" value="List"/>   
18[<a href="```
19= ASP_FILE_NAME 
20```?Job=Write">发表文章</a>][<a href="```
21= ASP_FILE_NAME 
22```?Job=Apply">申请账号</a>]   
23<input id="Keyword" maxlength="20" name="Keyword" size="18"/>
24<input type="Submit" value="主题搜索"/>
25</form>
26</td>
27</tr>
28</table>
29</td>
30</tr>
31</table>
32<table align="center" bgcolor="#000000" border="0" cellpadding="1" cellspacing="1" width="650">   

If Request("Keyword") &lt;&gt; "" Then KeyWord = Request("Keyword") Else KeyWord = ""

If Request("Page") = "" Then
If IsNumeric( Session("BBS_Page") ) Then
Page = Int(Session("BBS_Page"))
Else
Page = 1
End If
Else
Page = Int(Request("Page"))
End If
If Page &lt; 1 Then Page = 1

RecBBS.PageSize = ListSize

SQL = "SELECT * FROM bbs "
If KeyWord &lt;&gt; "" Then
SQL = SQL + "WHERE [题目] LIKE '%" &amp; KeyWord &amp; "%' "
End If
SQL = SQL + "ORDER BY [序号] DESC"
RecBBS.Open SQL , Con , 3

PageCount = RecBBS.PageCount
RecordCount = RecBBS.RecordCount

If Page &gt; PageCount Then Page = PageCount

Session("BBS_Page") = Page

If Not RecBBS.EOF Then

1<tr>
2<td>作者</td>
3<td>题目</td>
4<td>回复</td>
5<td>点击</td>
6<td>时间</td></tr>   

RecBBS.AbsolutePage = Page
For iRec = 1 To ListSize
If Not RecBBS.EOF Then

 1<tr>
 2<td>```
 3= Server.HTMLEncode( RecBBS.Fields("作者") ) 
 4```</td>
 5<td>
 6<a <="" ``````="" href="```
 7= ASP_FILE_NAME 
 8```?Job=Content&amp;Which=```
 9= RecBBS.Fields(" if="" keyword="" 序号")=""&gt; "" Then Response.Write "&amp;amp;Keyword=" &amp;amp; KeyWord 
10```"&gt;   

= Server.HTMLEncode( RecBBS.Fields("题目") )

 1</a>
 2</td>
 3<td>```
 4= Server.HTMLEncode( RecBBS.Fields("回复") ) 
 5```</td>
 6<td>```
 7= Server.HTMLEncode( RecBBS.Fields("点击") ) 
 8```</td>
 9<td>```
10= Server.HTMLEncode( RecBBS.Fields("时间") ) 
11```</td></tr>
12</table></td></tr>   

RecBBS.MoveNext
Else
Response.Write " <tr><td> </td><td> </td><td> </td><td> </td><td> </td></tr>" &amp; Chr(13)
End If
Next
Else

1No Record   

End If

RecBBS.Close

1</table>
2<table align="center" border="0" cellpadding="1" cellspacing="0" width="650">
3<tr>
4<td class="menu">   
5共有 ```
6= PageCount 
7``` 页 ```
8= RecordCount 
9``` 篇文章   

If Page &gt; 1 Then
Response.Write "<a "="" "?job='List&amp;Page="' &="" <="" asp_file_name="" href="" if="" keyword="" page-1=""> "" Then Response.Write "&amp;Keyword=" &amp; KeyWord
Response.Write """&gt;"
End If

1上一页   

If Page &gt; 1 Then Response.Write "</a>"

If Page &lt; PageCount Then
Response.Write "<a "="" "?job='List&amp;Page="' &="" <="" asp_file_name="" href="" if="" keyword="" page+1=""> "" Then Response.Write "&amp;Keyword=" &amp; KeyWord
Response.Write """&gt;"
End If

1下一页   

If Page &lt; PageCount Then Response.Write "</a>"

1<a href="javascript:window.open('```
2= ASP_FILE_NAME 
3```?Job=List&amp;Page=' + Page.value , '_self')">   
4转到</a>第<input id="Page" maxlength="4" name="Page" size="4"/>页   

Response.Write Page &amp; "/" &amp; PageCount

1</td>
2</tr>
3</table>
4
5
6   
7  
8&lt;%</p></body></html>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus