ASP技术在论坛中的运用。(八) (建论坛的完整程序,吐血推荐!!!!)

本文介绍了一个基于ASP的论坛版务管理系统的设计与实现。系统利用Session和Cookie进行斑竹身份验证,确保只有经过验证的斑竹才能进行版务操作。文章详细展示了如何使用ASP连接数据库、查询未发表文章列表及文章详情。
部署运行你感兴趣的模型镜像
导读:
  使用Session来保持对斑竹的身份验证,这必须要求客户端浏览器的cookie被打开了。因为Session是通过cookie来实现的。在这儿,把看板ID赋给Session变量beenthere,表明斑竹已经通过了身份验证。在后面的每个版务处理的页面中,都要检查beenthere是否和相应的看版ID相符。
  url="boardmanager.ASP?boardid=" &boardid
  response.redirect url
  初学ASP的时候总是为response.redirect这个方法感到困惑,屡用不爽,现在我来告诉你一些技巧。使用它之前,必须通过response.buffer=true来让ASP页面使用缓冲区。这时,在ASP被解释成HTML代码之前,它是放在缓冲区中的,而不直接被发送的客户端浏览器。还有一个必须要知道的是:在使用response.redirect之前,是不能有任何实际的HTML代码被发送到客户端浏览器的,否则就会出错。当然也有变通的方法,如果在response.redirect之前已经有HTML代码被解释出来,可以用response.clear方法来清除缓冲区,然后就可以使用它来进行重定向了。
  end if
  %>
  
  下面的页面,就是在上面身份验证通过后重定向的目标:boardmanager.ASP。它将列出了所有别有被处理的文章。
  < %
  boardid=request("boardid")
  if session("beenthere")<  boardid=request("boardid")
  if session("beenthere")< >boardid then response.redirect "forums.ASP"
  这就是检验斑竹身份的地方,因为前面已经通过cookie在斑竹的浏览器中作了标记,现在我们就能够通过seesion来辨认斑竹的身份了。如果标志不符,就会通过response.redirect返回到最开始的登陆页面。如果斑竹浏览器的cookie没有打开,那么seesion(“beenthere“)的值会为空,同样也无法进入这个页面。
  Set conn = Server.CreateObject("ADODB.Connection")
  conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" &Server.MapPath("bbssystem.mdb")
  Set cmd = Server.CreateObject("ADODB.Command")
  Set cmd.ActiveConnection = conn
  sql="select 名称 from 看板列表 where id=" &boardid
  set rs=conn.execute(sql)
  boardname=rs("名称")
  cmd.commandtext="未发表文章列表"
  ReDim param(0) ' 声明
  param(0) = CLng(boardid) ' CInt 不可忽略
  Set rs = cmd.Execute( ,param )
  set cmd=nothing
  %>
  < HTML>
  < head>
  < title>版务处理< /title>
  < meta http-equiv="Content-Type" content="text/HTML; charset=gb2312">
  < /head>
  < body bgcolor="#FFFFFF">
  < h1 align="center">< %=boardname%>板板务管理< /h1>
  < hr>
  < %
  if rs.eof or rs.bof then response.write "<  if rs.eof or rs.bof then response.write "
?>  response.end
  %>
  如果没有新文章被网友发布,这给出相应的提示,并用response.end来结束此页的显示。
  < table width="90%" border="0" cellspacing="0" cellpadding="0" align="center" >
  
  主题< /td>
  文章标题< /td>
  作者< /td>
  日期< /td>
  
  <%

  do

  topicid=rs("主题id")

   articleid=rs("文章id")

   data=rs("日期")

  datastr=cstr(year(data)) &"-" &cstr(month(data)) &"-" &cstr(day(data))

  author=rs("作者")

   articlename=rs("标题")

   topicname=rs("主题")

  

  response.write "<  do

  topicid=rs("主题id")

  articleid=rs("文章id")

  data=rs("日期")

  datastr=cstr(year(data)) &"-" &cstr(month(data)) &"-" &cstr(day(data))

  author=rs("作者")

  articlename=rs("标题")

  topicname=rs("主题")

  

  response.write "< td>< a href=../../qtopic.ASP?topicid="& topicid &">"&topicname &"< /td>"

  response.write "< a href=../../managearticle.ASP?articleid="& articleid &"&boardid=" &boardid &">"&articlename &"< /td>"

  response.write "< a href=../../qauthor.ASP?author="& author &">"&author &"< /td>"

  response.write "" &datastr &"< /tr>"

  rs.movenext

  loop until rs.eof

  %>
  < /table>
  < /HTML>
  < %
  set rs=nothing
  conn.close
  set conn=nothing
  %>
  < /body>
  当点击了相应文章的联结后,就进入此文章的处理页面managearticle.ASP:
  < %
  articleid=request("articleid")
  boardid=request("boardid")
  if session("beenthere")<  articleid=request("articleid")
  boardid=request("boardid")
  if session("beenthere")< >boardid then response.redirect "forums.ASP"
  Set conn = Server.CreateObject("ADODB.Connection")
  conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" &Server.MapPath("bbssystem.mdb")
  Set cmd = Server.CreateObject("ADODB.Command")
  Set cmd.ActiveConnection = conn
  cmd.CommandText = "按id查询文章"
  ReDim param(0) ' 声明
  param(0) = CLng(articleid) ' CInt 不可忽略
  Set rs = cmd.Execute( ,param )
  author=rs("作者id")
  title=rs("标题")
  data=rs("日期")
  rate=rs("推荐度")
  boardid=rs("看板id")
  topicid=rs("主题id")
  boardname=rs("看板名")
  topicname=rs("主题名")
  content=rs("内容")
  content=replace(content,vbCrlf,"< /p>< p>")
  content="< p>" &content &"

"
  set cmd=nothing
  %>
  < HTML>
  < head>
  < title>Untitled Document< /title>
  < meta http-equiv="Content-Type" content="text/HTML; charset=gb2312">
  < /head>
  < body bgcolor="#E9E9E4">
  < table width="89%" border="0" cellspacing="0" cellpadding="0" align="center">
  
  作者:< font color="#FF3366">< a href=../../"qauthor.ASP?author=< %=author%>"> <%=author%> < /font> 发表日期:< font color="#FF3333">< %=data%>< /font>
  看板:< font color="#FF3333">< a href=../../"qboard.ASP?boardid=< %=board

本文转自
http://study.qqcf.com/web/243/29064.htm

您可能感兴趣的与本文相关的镜像

LobeChat

LobeChat

AI应用

LobeChat 是一个开源、高性能的聊天机器人框架。支持语音合成、多模态和可扩展插件系统。支持一键式免费部署私人ChatGPT/LLM 网络应用程序。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值