|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
缺点:安全性不是太差了,还行,只要你充分利用系统自带的工具;唯一缺点就是执行效率慢,如何进行网站优化以后,效果会比较好。Toviewalivedemonstrationofthisforum,clickViewDemo.
Tocreatethisforumonyourserver,youwillneedtocreateaMicrosoftAccessDatabasenamed
discuss.mdb.Youwillalsoneedtocreateasingletableinthisdatabasenamedmessagesthathasthe
followingfields:
m_id--Anautonumberfield
m_email--Atextfield
m_subject--Atextfield
m_message--AMemofield
m_entrydate--ADate/TimefieldwithdefaultvalueofNOW()
m_numReplies--ANumberfieldwithdefaultvalueof0
m_reply--ANumberfieldwithdefaultvalueof-1
Listing1.0-discuss.asp
-----------------------------------
<html>
<head><title>Discussion</title></head>
<framesetrows="30,*">
<frameframeborder="no"scrolling="no"src="discusslogo.asp"marginheight=2marginwidth=5>
<framename="topframe"src="discussframes.asp">
</frameset>
</html>
-----------------------------------------
Listing2.0-discussframes.asp
-------------------------------------------------
<!--#INCLUDEFILE="discussfuncs.asp"-->
<%
page=TRIM(request("pg"))
addm=TRIM(request("addm"))
email=TRIM(request("email"))
subject=TRIM(request("subject"))
message=TRIM(request("message"))
IFaddm""THEN
IFemail=""THEN
showError"Youdidnotenteryouremailaddress","post.asp"
ENDIF
IFsubject=""THEN
showError"Youdidnotenterasubjectforyourmessage","post.asp"
ENDIF
IFmessage=""THEN
showError"Youdidnotenteramessage","post.asp"
ENDIF
IFINSTR(email,".")=0ORINSTR(email,"@")=0THEN
showError"Youdidnotenteravalidemailaddress","post.asp"
ENDIF
readyDBCon
SetRS=Server.CreateObject("ADODB.Recordset")
RS.ActiveConnection=Con
RS.CursorType=adOpenStatic
RS.LockType=adLockOptimistic
RS.Open"SELECT*FROMmessagesWHERE11",Con
RS.AddNew
RS("m_email")=email
RS("m_subject")=subject
RS("m_message")=message
RS("m_reply")=addm
RS.Update
RS.Close
IFaddm"-1"THEN
Con.Execute"UPDATEmessagesSETm_numreplies=m_numreplies+1WHEREm_id="&addm
ENDIF
ENDIF
%>
<html>
<head><title>frameset</title>
<framesetrows="300,*">
<framemarginheight="3"marginwidth="5"frameborder="no"scrolling="yes"src="messagelist.asp?
pg=<%=page%>">
<framename="message"marginwidth="0"marginheight="0"frameborder="no"scrolling="auto"
src="message.asp?id=<%=addm%>&pg=<%=page%>">
</frameset>
</html>
------------------------------------------------------
Listing3.0-discussfuncs.asp
-------------------------------------------------------
<%
dbPath="d:discuss.mdb"
messagesApage=5
DefineConstants
adOpenStatic=3
adLockOptimistic=3
DeclareGlobalVariables
DIMCon
SUBreadyDBCon
IFCon=""THEN
SetCon=Server.CreateObject("adodb.Connection")
Con.Open"PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATASOURCE="&dbPath
ENDIF
ENDSUB
FUNCTIONshowUser(theEmail)
whereA=INSTR(theEmail,"@")
showUser=Server.HTMLEncode(LEFT(theEmail,whereA-1))
ENDFUNCTION
FUNCTIONformatOutput(theText)
theText=Server.HTMLEncode(theText)
theText=REPLACE(theText,vbNewline&vbNewline,"<p>")
theText=REPLACE(theText,vbNewline,"<br>")
formatOutput=theText
ENDFUNCTION
subshowError(errorMessage,backpage)
%>
<html>
<head><title>Problem</title></head>
<bodybgcolor="lightyellow">
<center>
<tablewidth="400"border=0cellpadding=4cellspacing=0>
<tr>
<td>
<fontface="Arial"size="4"color="red"><b>
Therewasaproblemwiththemessageyouentered:</b></font>
<p><fontface="Arial"size="3"color="blue"><b>
<%=errorMessage%>.Pleaseclickthebuttonbelowtocorrectthisproblem</b></font>
<formmethod="post"action="<%=backpage%>">
<%
foreachthinginRequest.Form
%>
<inputname="<%=thing%>"type="hidden"value="<%=Server.HTMLEncode(Request(
thing))%>">
<%
next
%>
<inputtype="submit"value="Back">
</form>
</td>
</tr>
</table>
</body>
</head>
<%
Response.End
endsub
%>
Listing4.0-discusslogo.asp
-------------------------------------------
<html>
<head><title>logo</title></head>
<bodybgcolor="darkgreen"marginheight=0topmargin=0>
<tableborder=0cellpadding=0cellspacing=0width="100%">
<tr>
<td>
<fontface="Arial"size="2"color="#ffffff"><b>MicrosoftAccessForum</b></font>
</td>
</tr>
</table>
</body>
</html>
Listing5.0-message.asp
------------------------------------
<!--#INCLUDEFILE="discussfuncs.asp"-->
<%
id=TRIM(Request("id"))
IFid="-1"THENid=""
page=TRIM(Request("pg"))
%>
<html>
<head><title>message</title></head>
<bodybgcolor="#ffffff">
<%
IFid=""THEN
%>
<tablewidth="100%"height="100%"cellpadding=0cellspacing=0border=0>
<tr>
<tdvalign="center"align="center">
<fontface="Arial"size="3"color="blue">
<b>Selectamessagetoreadbyclickingononeofthesubjectsabove</b>
</font>
</td>
</tr>
</table>
<%
ELSE
readyDBCon
SETRS=Server.CreateObject("ADODB.Recordset")
RS.ActiveConnection=Con
RS.CursorType=adOpenStatic
RS.Open"select*FROMmessagesWHEREm_id="&id&"ORm_reply="&id&"orderbym_id"
mCount=0
WHILENOTRS.EOF
%>
<tablewidth="100%"border=0cellpadding=2cellspacing=0bgcolor="yellow">
<tr>
<td>
<b>Author:</b><%=showUser(RS("m_email"))%>
</td>
<tdalign="right">
<b>DatePosted:</b><%=RS("m_entrydate")%>
</td>
</tr>
<tr>
<tdcolspan=2>
<b>Subject:</b><%=Server.HTMLEncode(RS("m_subject"))%>
</td>
</tr>
</table>
<tablewidth="100%"cellpadding=4cellspacing=0border=0>
<tr>
<td>
<fontface="Arial"size="2">
<%=formatOutput(RS("m_message"))%>
</font>
<P>
<ahref="post.asp?id=<%=id%>&pg=<%=page%>"target="topframe">ReplyToThis
Message</a>
</td>
</tr>
</table>
<%ifmcount=0THEN%>
<aname="replies"></a>
<%ENDIF%>
<%
RS.MoveNext
WEND
ENDIF
%>
</body>
</html>
----------------------------------------
Listing6.0-messagelist.asp
-------------------------------------------
<!--#INCLUDEFILE="discussfuncs.asp"-->
<html>
<head><title>MessageList</title></head>
<bodybgcolor="#eeeeee">
<tablewidth="100%"border=0cellpadding=4cellspacing=0>
<tr>
<tdalign="right">
<ahref="post.asp"target="topframe"><fontface="Arial"size="2"><i>PostNew
Message</i></font></a>
</td>
</tr>
</table>
<%
page=Request("pg")
IFpage=""THENpage=1
readydbCon
SETRS=Server.CreateObject("ADODB.Recordset")
RS.ActiveConnection=Con
RS.CursorType=adOpenStatic
RS.Open"selectm_id,m_email,m_subject,m_numreplies,m_entrydateFROMmessagesWHEREm_reply=-1ORDER
bym_idDESC"
RS.PageSize=messagesApage
RS.AbsolutePage=page
IFRS.EOFTHEN
%>
<fontface="Arial">Therearenomessages</font>
<%
ELSE
%>
<tablewidth="100%"border=0cellpadding=4cellspacing=0>
<tr>
<td>
<fontsize="2"color="darkgreen"><b>AUTHOR</b></font>
</td>
<td>
<fontsize="2"color="darkgreen"><b>SUBJECT</b></font>
</td>
<td>
<fontsize="2"color="darkgreen"><b>REPLIES</b></font>
</td>
<td>
<fontsize="2"color="darkgreen"><b>DATEPOSTED</b></font>
</td>
</tr>
<%
WHILENOTRS.EOFandcounter<RS.PageSize
%>
<tr>
<td><fontsize="2"><%=showUser(RS("m_email"))%></font></td>
<td><ahref="message.asp?id=<%=RS("m_id")%>&pg=<%=page%>"target="message"><font
size="2"><%=Server.HTMLEncode(RS("m_subject"))%></font></a></td>
<td>
<fontsize="2"><%=RS("m_numreplies")%></font>
<%IFcINT(RS("m_numreplies"))>0THEN%>
<ahref="message.asp?id=<%=RS("m_id")%>&pg=<%=page%>#replies"
target="message"><fontsize="2">view</font></a>
<%ENDIF%>
</td>
<td><fontsize="2"><%=RS("m_entrydate")%></font></td>
</tr>
<%
counter=counter+1
RS.MoveNext
WEND
%>
</table>
<%
IFRS.PageCount>1THEN
%>
<p><fontsize="2"color="#666666">ViewPage:</font>
<%
FORi=1toRS.PageCount
IFi=cINT(page)THEN
%>
<fontsize="2"><b><%=i%></b></font>
<%
ELSE
%>
<ahref="discussframes.asp?pg=<%=i%>"target="topframe"><fontsize="2"><%=i%></font></a>
<%
ENDIF
NEXT
ENDIF
ENDIF
RS.Close
Con.Close
%>
</body>
</html>
----------------------------------------------
Listing7.0-post.asp
-------------------------------
<%
page=TRIM(Request("pg"))
id=TRIM(Request("id"))
email=TRIM(Request("email"))
subject=TRIM(Request("subject"))
message=TRIM(Request("message"))
%>
<HTML>
<HEAD>
<TITLE>Post</TITLE>
</HEAD>
<BODYbgcolor="#000000">
<formmethod="post"action="discussframes.asp"target="topframe">
<inputname="pg"type="hidden"value="<%=page%>">
<%IFid=""THEN%>
<inputname="addm"type="hidden"value="-1">
<%ELSE%>
<inputname="addm"type="hidden"value="<%=id%>">
<%ENDIF%>
<center>
<tablewidth="640"cellpadding="4"cellspacing=0border=0>
<tr>
<tdalign="right"nowrap>
<fontface="Arial"size="2"color="yellow"><b>YourEmailAddress:</b></font>
</td>
<td>
<inputname="email"size="60"maxlength="255"value="<%=Server.HTMLEncode(email)%>">
</td>
</tr>
<tr>
<tdalign="right">
<fontface="Arial"size="2"color="yellow"><b>MessageSubject:</b></font>
</td>
<td>
<inputname="subject"size="60"maxlength="50"value="<%=Server.HTMLEncode(subject)%>">
</td>
</tr>
<tr>
<tdalign="right"valign="top">
<fontface="Arial"size="2"color="yellow"><b>Message:</b></font>
</td>
<td>
<textareaname="message"cols="60"rows="13"wrap="virtual"><%=Server.HTMLEncode(message)%
></textarea>
</td>
</tr>
<tr>
<tdalign="right"colspan=2>
<tableborder=0cellpadding=2cellspacing=0>
<tr>
<td>
<inputtype="submit"value="PostMessage"style="color:blue;font-family:Arial;font-
weight:bold">
</td>
</form>
<formaction="discussframes.asp"target="topframe">
<td>
<inputtype="submit"value="CancelMessage"style="color:blue;font-family:Arial;font-
weight:bold">
</td>
</tr>
</table>
</td>
</tr>
</table>
</BODY>
</HTML>
国内有些大的CRM厂商的ASP就写得不错.无论是概念还是它里面用JAVASCRIPT的能力.并不是说现在的程序员用了ASP.NET来写程序就可以说自己高档了 |
|