主题:  紧急求助:论坛的帖子无法编辑了

小白

职务:普通成员
等级:1
金币:0.0
发贴:41
#12005/12/14 22:31:58
我自己写的一段BBS的ASP代码,可是就是不明白为何帖子不能编辑,其他功能都可以!!!
源代码如下:
<!--#include file=../txlconst.asp-->
<!--#include file=../txlfun.asp-->
<!--#include file=bbsfun.asp-->
<!--#include file=../UbbCode.asp-->

<%
Dim const_txl_HomeUrl,announceid,announce_username,boardid,username,i
Dim tmpstr,goodflag,topflag,nowstat,tostat,dealuser
const_txl_HomeUrl="../"
username=Session("username")
announceid=Request("announceid")
call OpenDatabase
call txl_SiteHead(const_txlname&"-班级论坛-操作帖子")
Call main()
Response.Flush()
call online
call CloseDatabase
call SiteBottom
Response.Flush()
Sub main()
	If const_bbs_login_limit=1	Then	'论坛登录查看限制
		If session("username")="" Then
			errstr="<li>当前同学录状态已经设置为<font color=red>班级论坛只有登录之后才能看到</font>!</li>"
			errstr=errstr&"<li>你现在还没有登录或者会话超时,点<a href='../user/login.asp'>这里登录</a>!</li>"
			errstr=errstr&"<li>如果还有疑问请与管理员联系!</li>"
			Call printerror("查看班级论坛出错!",errstr,779)
			Exit Sub
		End If
	ElseIf const_bbs_login_limit=2 Then
		If session("username")="" Then
			errstr="<li>当前同学录状态已经设置为<font color=red>班级论坛只有班级成员和嘉宾有查看权限</font>!</li>"
			errstr=errstr&"<li>你现在还没有登录或者会话超时,点<a href='../user/login.asp'>这里登录</a>!</li>"
			errstr=errstr&"<li>如果还有疑问请与管理员联系!</li>"
			Call printerror("查看班级论坛出错!",errstr,779)
			Exit Sub
		End If
		If not (session("usertype")=3 or session("usertype")=4)  Then
			errstr="<li>当前同学录状态已经设置为<font color=red>班级论坛只有班级成员和嘉宾有查看权限</font>!</li>"
			errstr=errstr&"<li>你目前的身份没有该权限!</li>"
			errstr=errstr&"<li>如果还有疑问请与管理员联系!</li>"
			Call printerror("查看班级论坛出错!",errstr,779)
			Exit Sub
		End If
	End	If
	Dim Rs
	If	announceid="" or (not isnumeric(announceid)) Then
		Call printerror ("操作帖子出错!","<li>请不要传递非法的参数</li>",779) 
		exit sub
	End if
	announceid=Cint(announceid)
	set Rs=Conn.execute ("select boardid,username,goodflag,topflag from Announce where ID="&announceid)
	If rs.Eof Then
		Call printerror ("操作帖子出错!","<li>该帖子不存在</li>",779) 
		exit sub
	Else
		boardid=rs("boardid")
		announce_username=Rs("username")
		goodflag=rs("goodflag")
		topflag=rs("topflag")
	End If
	rs.close
	set rs=nothing
	If username="" and session("adminname")="" Then
		Call printerror ("操作帖子出错!","<li>操作帖子必须是登录成员或管理员!</li>",779) 
		exit sub
	End If
	Select Case Request.QueryString("action")
	Case "edit":	
		Call Edit
	Case "del":		
		Call del
	Case "jinghua":
		Call jinghua
	Case "makealltop": 
		Call makealltop
	Case "maketop":
		Call maketop
End Select
End SUb
sub del
	dim master,limitflag
	limitflag=false
	master=""
	master=getbbsmaster(boardid)
	if isarray(master) Then
		for i=0 to ubound(master)
			If username=master(i) Then
				limitflag=true
				exit for
			End If
		next
	ElseIf master<>"" And username=master	Then
		limitflag=true
	ELseIF master="" Then
		limitflag=false
	End IF
	If session("adminname")<>"" Then limitflag=true
	If not(limitflag) Then 
		Call printerror ("操作帖子出错!","<li>你没有操作该功能的权限!</li>",779) 
		exit sub
	Else
		If Request("queren")<>"true" Then
			Response.write "<div align=center><br><font color=red>本操作正在删除论坛帖子,且不可恢复。你确实要进行该操作吗?<br>请点击下面的“确定”按钮继续执行操作,点击“取消”来撤消本次操作。</font><br><br>"
			Response.write "<input type=button value='确定' onclick=""javascript:window.location.href='?action=del&announceid="&announceid&"&queren=true'"">&nbsp;&nbsp;&nbsp;&nbsp;<input type=button value='取消' onclick='javascript:history.back()'><br><br></div>"
		Else
			conn.Execute ("delete from Announce where parentID="&announceid)	'删除回复帖
			conn.Execute ("delete from Announce where ID="&announceid)	'删除主题帖
			tmpstr="<li>已经成功删除标号为"&announceid&"的帖子,如果该帖子是主题帖,则该主题帖下面的回复帖也已经删除!</li>"
			tmpstr=tmpstr&"<li>回<a href='boardlist.asp?boardid="&boardid&"'>论坛列表</a>!</li>"
			Call	printsuc("删除论坛帖子成功!",tmpstr,779)
		End IF
	End If
end sub

Sub edit
	dim limitflag
	limitflag=false
	If session("adminname")<>"" Then 
		limitflag=true
		dealuser="管理员"
	End If
	If announce_username=username Then
		limitflag=true
		dealuser=username
	end if
	If not(limitflag) Then 
		Call printerror ("操作帖子出错!","<li>你没有操作该功能的权限!</li>",779) 
		exit sub
	Else
		If Request.Querystring("action2")="saveedit"	Then
			Call saveedit
		Else
			Call edit2
		End If
	End If
End Sub

Sub jinghua
	dim master,limitflag
	limitflag=false
	master=""
	master=getbbsmaster(boardid)
	if isarray(master) Then
		for i=0 to ubound(master)
			If username=master(i) Then
				limitflag=true
				exit for
			End If
		next
	ElseIf master<>"" And username=master	Then
		limitflag=true
	ELseIF master="" Then
		limitflag=false
	End IF
	If session("adminname")<>"" Then limitflag=true
	If goodflag=0 then 
		nowstat="<font color=red>“非精华帖”</font>"
		tostat="<font color=red>“精华帖”</font>"
	else
		nowstat="<font color=red>“精华帖”</font>"
		tostat="<font color=red>“非精华帖”</font>"
	end if
	If not(limitflag) Then 
		Call printerror ("操作帖子出错!","<li>你没有操作该功能的权限!</li>",779) 
		exit sub
	Else
		If Request("queren")<>"true" Then
			Response.write "<div align=center><br><font color=#000000>本操作设置帖子的状态,由"&nowstat&"设为"&tostat&",你确实要进行该操作吗?<br>请点击下面的“确定”按钮继续执行操作,点击“取消”来撤消本次操作。</font><br><br>"
			Response.write "<input type=button value='确定' onclick=""javascript:window.location.href='?action=jinghua&announceid="&announceid&"&queren=true'"">&nbsp;&nbsp;&nbsp;&nbsp;<input type=button value='取消' onclick='javascript:history.back()'><br><br></div>"
		Else
			conn.Execute ("update Announce set goodflag=1-goodflag where ID="&announceid)	'设置帖子状态
			tmpstr="<li>恭喜你,本次操作成功!</li>"
			tmpstr=tmpstr&"<li>已经成功将标号为"&announceid&"的帖子,将"&nowstat&"设置为"&tostat&"!</li>"
			tmpstr=tmpstr&"<li>回<a href='boardlist.asp?boardid="&boardid&"'>论坛列表</a>!</li>"
			Call	printsuc("设置论坛帖子成功!",tmpstr,779)
		End IF
	End If

End Sub


Sub makealltop
	dim master,limitflag
	limitflag=false
	master=""
	master=getbbsmaster(boardid)
	if isarray(master) Then
		for i=0 to ubound(master)
			If username=master(i) Then
				limitflag=true
				exit for
			End If
		next
	ElseIf master<>"" And username=master	Then
		limitflag=true
	ELseIF master="" Then
		limitflag=false
	End IF
	If session("adminname")<>"" Then limitflag=true
	'1为固顶
	'2为总固顶
	'3为普通
	If topflag=2 then 
		nowstat="<font color=red>“总固顶帖”</font>"
		tostat="<font color=red>“非总固顶帖”</font>"
	else
		nowstat="<font color=red>“非总固顶帖”</font>"
		tostat="<font color=red>“总固顶帖”</font>"
	end if
	If not(limitflag) Then 
		Call printerror ("操作帖子出错!","<li>你没有操作该功能的权限!</li>",779) 
		exit sub
	Else
		If Request("queren")<>"true" Then
			Response.write "<div align=center><br><font color=#000000>本操作设置帖子的状态,由"&nowstat&"设为"&tostat&",你确实要进行该操作吗?<br>请点击下面的“确定”按钮继续执行操作,点击“取消”来撤消本次操作。</font><br><br>"
			Response.write "<input type=button value='确定' onclick=""javascript:window.location.href='?action=makealltop&announceid="&announceid&"&queren=true'"">&nbsp;&nbsp;&nbsp;&nbsp;<input type=button value='取消' onclick='javascript:history.back()'><br><br></div>"
		Else
			If topflag=2 Then
				'取消总固顶
				conn.Execute ("update Announce set topflag=3 where ID="&announceid)	'设置帖子状态
			Else
				'加总固顶
				conn.Execute ("update Announce set topflag=2 where ID="&announceid)	'设置帖子状态
			End If
			tmpstr="<li>恭喜你,本次操作成功!</li>"
			tmpstr=tmpstr&"<li>已经成功将标号为"&announceid&"的帖子,将"&nowstat&"设置为"&tostat&"!</li>"
			tmpstr=tmpstr&"<li>回<a href='boardlist.asp?boardid="&boardid&"'>论坛列表</a>!</li>"
			Call	printsuc("设置论坛帖子成功!",tmpstr,779)
		End IF
	End If
End Sub

Sub maketop
	dim master,limitflag
	limitflag=false
	master=""
	master=getbbsmaster(boardid)
	if isarray(master) Then
		for i=0 to ubound(master)
			If username=master(i) Then
				limitflag=true
				exit for
			End If
		next
	ElseIf master<>"" And username=master	Then
		limitflag=true
	ELseIF master="" Then
		limitflag=false
	End IF
	If session("adminname")<>"" Then limitflag=true
	'1为固顶
	'2为总固顶
	'3为普通
	If topflag=1 then 
		nowstat="<font color=red>“固顶帖”</font>"
		tostat="<font color=red>“非固顶帖”</font>"
	else
		nowstat="<font color=red>“非固顶帖”</font>"
		tostat="<font color=red>“固顶帖”</font>"
	end if
	If not(limitflag) Then 
		Call printerror ("操作帖子出错!","<li>你没有操作该功能的权限!</li>",779) 
		exit sub
	Else
		If Request("queren")<>"true" Then
			Response.write "<div align=center><br><font color=#000000>本操作设置帖子的状态,由"&nowstat&"设为"&tostat&",你确实要进行该操作吗?<br>请点击下面的“确定”按钮继续执行操作,点击“取消”来撤消本次操作。</font><br><br>"
			Response.write "<input type=button value='确定' onclick=""javascript:window.location.href='?action=maketop&announceid="&announceid&"&queren=true'"">&nbsp;&nbsp;&nbsp;&nbsp;<input type=button value='取消' onclick='javascript:history.back()'><br><br></div>"
		Else
			If topflag=2 Then
				'取消固顶
				conn.Execute ("update Announce set topflag=3 where ID="&announceid)	'设置帖子状态
			Else
				'加固顶
				conn.Execute ("update Announce set topflag=1 where ID="&announceid)	'设置帖子状态
			End If
			tmpstr="<li>恭喜你,本次操作成功!</li>"
			tmpstr=tmpstr&"<li>已经成功将标号为"&announceid&"的帖子,将"&nowstat&"设置为"&tostat&"!</li>"
			tmpstr=tmpstr&"<li>回<a href='boardlist.asp?boardid="&boardid&"'>论坛列表</a>!</li>"
			Call	printsuc("设置论坛帖子成功!",tmpstr,779)
		End IF
	End If
End Sub

Sub Edit2
	Dim rs
	set rs=conn.execute ("select * from Announce where Id="&Announceid)
%>
<script>
	  function addcontent(str1,str2)
	{
		form1.Form_Content.focus();
		if ((document.selection)&&(document.selection.type== "Text"))
		{
			var range= document.selection.createRange();
			var ch_text=range.text;
			range.text= str1 + ch_text + str2;
		} 
		else
		{
			document.form1.Form_Content.value=document.form1.Form_Content.value+str1+str2;
			form1.Form_Content.focus();
		}
	}

	  function check_walkman_form(walkman_frm)
	  {
	  //walkman编写
	  if (walkman_frm.Form_Content.value==""){
	  	alert("请输入内容!");
		walkman_frm.Form_Content.focus();
		return false
	  }
	   var maxlength=4000
	  if (walkman_frm.Form_Content.value.length>maxlength){
	  	alert("内容不能大于"+maxlength+"!,当前长度"+walkman_frm.Form_Content.value.length);
		walkman_frm.Form_Content.focus();
		return false
	  }
	  return true
	  }
	  </script><form name="form1" method="post" action="" onkeydown="if(event.keyCode==13 && event.ctrlKey){if(check_walkman_form(this)){this.submit();}}">
  <table width="100%"  border="1" cellpadding="1" cellspacing="0" bordercolor="#D7F4F7" bgcolor="#FFFFFF" class="liu">
    <tr bgcolor="#576F9F"> 
      <td colspan="2" style="padding-left:5px;color:#FFFFFF; font-weight:bold;line-height:1.5;"><a name="reply"></a>编辑帖子</td>
    </tr>
    <tr> 
      <td width="21%" class="rig">贴子标题:</td>
      <td width="79%" class="content"><input name="Form_Title" type="text" id="Form_Title" value="<%=rs("title")%>" size="45" readonly="true"> 
        <font color=red>标题不能修改</font> </td>
    </tr>
    <tr> 
      <td class="rig">插入UBB标签:</td>
      <td class="content"><a href="javascript:addcontent('[b]','[/b]');" title=粗体><img src="../images/ubb/bold.GIF" width="20" height="20" align="absmiddle" border=0></a> 
        <a href="javascript:addcontent('[i]','[/i]');" title=斜体><img src="../images/ubb/italicize.GIF" width="20" height="20" align="absmiddle" border=0></a> 
        <a href="javascript:addcontent('[u]','[/u]');" title=下划线><img src="../images/ubb/underline.GIF" width="20" height="20" align="absmiddle" border=0></a> 
        <a href="javascript:addcontent('[ALIGN=CENTER]','[/ALIGN]');" title=居中><img src="../images/ubb/center.GIF" width="20" height="20" align="absmiddle" border=0></a> 
        <a href="javascript:addcontent('[URL]','[/URL]');" title=链接><img src="../images/ubb/url1.GIF" width="20" height="20" align="absmiddle" border=0></a> 
        <a href="javascript:addcontent('[EMAIL]','[/EMAIL]');" title=邮件><img src="../images/ubb/email1.GIF" width="20" height="20" align="absmiddle" border=0></a> 
        <a href="javascript:addcontent('[IMGA]','[/IMGA]');" title=图片><img src="../images/ubb/image.GIF" width="20" height="20" align="absmiddle" border=0></a> 
        <a href="javascript:addcontent('[FLASH]','[/FLASH]');" title=Flash><img src="../images/ubb/swf.GIF" width="20" height="20" align="absmiddle" border=0></a> 
        <a href="javascript:addcontent('[code]','
');" title=代码><img src="../images/ubb/code.GIF" width="20" height="20" align="absmiddle" border=0></a>
<a href="javascript:addcontent('
引用:
','
');" title=引用><img src="../images/ubb/quote1.GIF" width="20" height="20" align="absmiddle" border=0></a>
<a href="javascript:addcontent('','');" title=飞行><img src="../images/ubb/fly.GIF" width="20" height="20" align="absmiddle" border=0></a>
<a href="javascript:addcontent('[MOVE]','[/MOVE]');" title=移动><img src="../images/ubb/move.GIF" width="20" height="20" align="absmiddle" border=0></a>
<a href="javascript:addcontent('[GLOW=255,RED,2]','[/GLOW]');" title=发光><img src="../images/ubb/glow.GIF" width="20" height="20" align="absmiddle" border=0></a>
<a href="javascript:addcontent('[SHADOW=255,RED,2]','[/SHADOW]');" title=阴影><img src="../images/ubb/shadow.GIF" width="20" height="20" align="absmiddle" border=0></a>
<a href="javascript:addcontent('','');" title=3号字><img src="../images/ubb/size3.GIF" width="20" height="20" align="absmiddle" border=0></a>
<a href="javascript:addcontent('','');" title=蓝色字><img src="../images/ubb/blue.gif" width="20" height="20" align="absmiddle" border=0></a>
<a href="javascript:addcontent('','');" title=红色字><img src="../images/ubb/red.GIF" width="20" height="20" align="absmiddle" border=0></a>
<a href="javascript:addcontent('[MP=320,240]','[/MP]');" title=插入Media文件><img src="../images/ubb/media.gif" width="20" height="20" align="absmiddle" border=0></a>
<a href="javascript:addcontent('[RM=320,240]','[/RM]');" title=插入RealPlay文件><img src="../images/ubb/real.gif" width="20" height="20" align="absmiddle" border=0></a></td>
</tr>
<tr bordercolor="#666666">
<td class="tar">插入表情,时间</td>
<td height="22" class="content">&nbsp;&nbsp;<a href="javascript:addcontent('[em01]','');"><img src="../images/UBBicon/em01.GIF" width="20" height="20" align="absmiddle" border=0></a>
<a href="javascript:addcontent('[em02]','');"><img src="../images/UBBicon/em02.GIF" width="20" height="20" align="absmiddle" border=0></a>
<a href="javascript:addcontent('[em03]','');"><img src="../images/UBBicon/em03.GIF" width="20" height="20" align="absmiddle" border=0></a>
<a href="javascript:addcontent('[em04]','');"><img src="../images/UBBicon/em04.GIF" width="20" height="20" align="absmiddle" border=0></a>
<a href="javascript:addcontent('[em05]','');"><img src="../images/UBBicon/em05.GIF" width="20" height="20" align="absmiddle" border=0></a>
<a href="javascript:addcontent('[em06]','');"><img src="../images/UBBicon/em06.GIF" width="20" height="20" align="absmiddle" border=0></a>
<a href="javascript:addcontent('[em07]','');"><img src="../images/UBBicon/em07.GIF" width="20" height="20" align="absmiddle" border=0></a>
<a href="javascript:addcontent('[em08]','');"><img src="../images/UBBicon/em08.GIF" width="20" height="20" align="absmiddle" border=0></a>
<a href="javascript:addcontent('[em09]','');"><img src="../images/UBBicon/em09.GIF" width="20" height="20" align="absmiddle" border=0></a>
<a href="javascript:addcontent('[em10]','');"><img src="../images/UBBicon/em10.GIF" width="20" height="20" align="absmiddle" border=0></a>
<a href="javascript:addcontent('[em11]','');"><img src="../images/UBBicon/em11.GIF" width="20" height="20" align="absmiddle" border=0></a>
<a href="javascript:addcontent('[em12]','');"><img src="../images/UBBicon/em12.GIF" width="20" height="20" align="absmiddle" border=0></a>
<a href="javascript:addcontent('[em13]','');"><img src="../images/UBBicon/em13.GIF" width="20" height="20" align="absmiddle" border=0></a>
<a href="javascript:addcontent('[em14]','');"><img src="../images/UBBicon/em14.GIF" width="20" height="20" align="absmiddle" border=0></a>
<a href="javascript:var d; d=new Date();addcontent(d.getYear()+'-'+rightStr('0'+(d.getMonth()+1),2)+'-'+rightStr('0'+d.getDate(),2)+' '+rightStr('0'+d.getHours(),2)+':'+rightStr('0'+d.getMinutes(),2)+':'+rightStr('0'+d.getSeconds(),2),'');" title="插入时间">T</a>
</td>
</tr>
<tr>
<td class="rig"><span class="style1">注意:</span><br>
帖子内容不要超过4000;<br>
HTML标记 不支持;<br>
UBB代码 支持<br> <span class="style2"> (Ctrl+Enter提交)</span> <br> <a href="../ubbhelp.asp" target="_blank">内容支持插入UBB标签<br>
使用方法请参考帮助 <span class="style2"> </span></a></td>
<td class="content"><textarea name="Form_Content" cols="75" rows="10" id="Form_Content"><%=rs("content"%></textarea></td>
</tr>
<tr>
<td height="40" colspan="2" align="center" class="td1"> <input type="reset" name="Submit3" value="重 填">
 
<input type="submit" name="Submit2" value="提 交" onClick="return">
<span style="font-weight:bold;color:#FF0000;">(Ctrl+Enter提交)</span></td>
</tr>
</table>
</form>
<%
rs.close
set rs=nothing
End Sub
Sub saveedit
    Dim rs,content,parentID
    content=Trim(Request.Form("Form_Content")
    if content="" or isnull(content) Then
        printerror "修改论坛帖子出错","<li>请输入帖子内容!</li>",779
        exit sub
    end if
    set rs=Server.CreateObject("Adodb.Recordset"
    rs.open "select * from Announce where id="&announceid,conn,1,3
        rs("content"=content
        rs("printcontent"=UBBCode(content,1)
        rs("changestr"=rs("changestr"&"<br>此帖子被"&dealuser&"于"&now()&"编辑过"
        parentID=rs("parentID"
    rs.update
    rs.close
    set rs=nothing
    if parentID=0 Then parentID=announceid
    tmpstr="<li>恭喜你,本次操作成功!</li>"
    tmpstr=tmpstr&"<li>已经成功编辑标号为"&announceid&"的帖子!</li>"
    tmpstr=tmpstr&"<li>回<a href='announce.asp?boardid="&boardid&"&announceid="&parentID&"'>刚编辑过的帖子</a>!</li>"
    tmpstr=tmpstr&"<li>回<a href='boardlist.asp?boardid="&boardid&"'>论坛列表</a>!</li>"
    Call printsuc("编辑论坛帖子成功!",tmpstr,779)
End Sub
%>[/code]

编辑历史:[此帖最近一次被 allinhands 编辑过(编辑时间:2005-12-19 20:43:21)]


sdawenye

职务:普通成员
等级:1
金币:0.0
发贴:16
#22005/12/19 19:01:34
太长了吧



sdawenye

职务:普通成员
等级:1
金币:0.0
发贴:16
#32005/12/19 19:02:48
有些看不明白啊



缺缺

职务:管理员
等级:8
金币:41.0
发贴:9620
#42005/12/19 20:44:45
代码太长,没有可读性