📄 savepost.asp
字号:
<!--#include file="conn.asp"-->
<!--#include file="inc/const.asp"-->
<!--#include file="inc/dv_clsother.asp"-->
<!--#include file="inc/md5.asp"-->
<!--#include file="inc/ubblist.asp"-->
<!--#include file="inc/Email.asp"-->
<%
Dim MyPost
Dim postbuyuser,bgcolor,abgcolor
Dvbbs.Loadtemplates("post")
Set MyPost = New Dvbbs_Post
Dvbbs.Stats = MyPost.ActionName
Dvbbs.Nav()
Dvbbs.Head_var 1,Dvbbs.Board_Data(4,0),"",""
MyPost.Save_CheckData
Set MyPost = Nothing
Dvbbs.ActiveOnline
Dvbbs.Footer
Class Dvbbs_Post
Public Action,ActionName,Star,Page,IsAudit,TotalUseTable,ToAction,TopicMode,Reuser
Private AnnounceID,ReplyID,ParentID,RootID,Topic,Content,char_changed,signflag,mailflag,iLayer,iOrders
Private TopTopic,IsTop,LastPost,LastPost_1,UpLoadPic_n,ihaveupfile,smsuserlist,upfileinfo
Private UserName,UserPassWord,UserPost,GroupID,UserClass,DateAndTime,DateTimeStr,Expression,MyLastPostTime,LastPostTimes
Private LockTopic,MyLockTopic,MyIsTop,MyIsTopAll,MyTopicMode,Child
Private CanLockTopic,CanTopTopic,CanTopTopic_a,CanEditPost,Rs,SQL,i,IsAuditcheck
Private vote,votetype,votenum,votetimeout,voteid,isvote
Private Sub Class_Initialize()
If Dvbbs.Board_Setting(0)="1" And Not Dvbbs.Master Then
Response.redirect "showerr.asp?action=lock&boardid="&dvbbs.boardID&""
End If
If Dvbbs.IsReadonly() And Not Dvbbs.Master Then Response.redirect "showerr.asp?action=readonly&boardid="&dvbbs.boardID&""
Action = Request("Action")
TotalUseTable = Dvbbs.NowUseBBS
Select Case Action
Case "snew"
Action = 5
ActionName = template.Strings(1)
If Dvbbs.GroupSetting(3)="0" Then Dvbbs.AddErrCode(70)
Case "sre"
Action = 6
ActionName = template.Strings(3)
If Dvbbs.GroupSetting(5)="0" then Dvbbs.AddErrCode(71)
Case "svote"
Action = 7
ActionName = template.Strings(5)
If Dvbbs.GroupSetting(8)="0" then Dvbbs.AddErrCode(56)
Case "sedit"
Action = 8
ActionName = template.Strings(7)
Case Else
Action = 1
ActionName = template.Strings(0)
End Select
Star = Request("star")
If Star = "" Or Not IsNumeric(Star) Then Star = 1
Star = Clng(Star)
Page = Request("page")
If Page = "" Or Not IsNumeric(Page) Then Page = 1
Page = Clng(Page)
IsAudit = Cint(Dvbbs.Board_Setting(3))
Reuser=False'此变量标识是否更名发贴
End Sub
'通用判断
Public Function Chk_Post()
If Dvbbs.Board_Setting(43)="1" Then Dvbbs.AddErrCode(72)
If Dvbbs.Board_Setting(1)="1" and Dvbbs.GroupSetting(37)="0" Then Dvbbs.AddErrCode(26)
If Dvbbs.UserID>0 Then
If Clng(Dvbbs.GroupSetting(52))>0 And DateDiff("s",Dvbbs.MyUserInfo(14),Now)<Clng(Dvbbs.GroupSetting(52))*60 Then Response.redirect "showerr.asp?ErrCodes=<li>"&Replace(template.Strings(21),"{$timelimited}",Dvbbs.GroupSetting(52))&"&action=OtherErr"
If Dvbbs.GroupSetting(62)<>"0" And Not Action = 8 Then
If Clng(Dvbbs.GroupSetting(62))<=Clng(Dvbbs.UserToday(0)) Then Response.redirect "showerr.asp?ErrCodes=<li>"&Replace(template.Strings(27),"{$topiclimited}",Dvbbs.GroupSetting(62))&"&action=OtherErr"
End If
End If
If Dvbbs.GroupSetting(3)="0" And (Action = 5 Or Action = 7) Then Response.redirect "showerr.asp?ErrCodes=<li>您没有发表新主题的权限&action=OtherErr"
If Dvbbs.GroupSetting(5)="0" And (Action = 6) Then Response.redirect "showerr.asp?ErrCodes=<li>您没有回复别人贴子的权限&action=OtherErr"
End Function
'判断用户是否有编辑权限且提取相关信息
Public Function Get_Edit_PermissionInfo()
Dim old_user
If Action = 4 Then
Set Rs=Dvbbs.Execute("select b.username,b.topic,b.body,b.dateandtime,u.UserGroupID,b.signflag,b.emailflag from "&TotalUseTable&" b,[dv_user] u where b.postuserid=u.userid and b.RootID="&AnnounceID&" and b.AnnounceID="&replyID)
Else
Set Rs=Dvbbs.Execute("select b.username,b.topic,b.body,b.dateandtime,u.UserGroupID,b.signflag,b.emailflag from "&TotalUseTable&" b,[dv_user] u where b.postuserid=u.userid and b.RootID="&RootID&" and b.AnnounceID="&AnnounceID)
End If
If Rs.Eof And Rs.Bof Then
Dvbbs.AddErrCode(48)
Else
If Action = 4 Then
signflag=Rs("signflag")
mailflag=Rs("emailflag")
Topic=rs("topic")
If Topic<>"" Then Topic = Server.HtmlEncode(Topic)
Content=rs("body")
old_user=rs("username")
Else
If Clng(Dvbbs.forum_setting(50))>0 then
If Datediff("s",rs("dateandtime"),Now())>Clng(Dvbbs.forum_setting(50))*60 then
Content = Content+chr(13)+chr(10)+char_changed+chr(13)
End If
Else
Content = Content+chr(13)+chr(10)+char_changed+chr(13)
End If
End If
If Clng(Dvbbs.forum_setting(51))>0 and not (Dvbbs.master or Dvbbs.boardmaster or Dvbbs.superboardmaster) Then
If DateDiff("s",rs("dateandtime"),Now())>Clng(Dvbbs.forum_setting(51))*60 then Response.redirect "showerr.asp?ErrCodes=<li>"&Replace(Replace(template.Strings(22),"{$posttime}",Datediff("s",rs("dateandtime"),Now())/60),"{$etlimited}",Dvbbs.forum_setting(51))&"&action=OtherErr"
End If
If Rs("username")=Dvbbs.membername Then
If Dvbbs.GroupSetting(10)="0" then
Dvbbs.AddErrCode(74)
CanEditPost=False
Else
CanEditPost=True
End If
Else
If (Dvbbs.master or Dvbbs.superboardmaster or Dvbbs.boardmaster) and Dvbbs.GroupSetting(23)="1" then
CanEditPost=True
Else
CanEditPost=False
End If
If Cint(Dvbbs.UserGroupID) > 3 And Dvbbs.GroupSetting(23)="1" Then CanEditPost=true
If Dvbbs.GroupSetting(23)="1" and Dvbbs.founduserPer Then
CanEditPost=True
ElseIf Dvbbs.GroupSetting(23)="0" And Dvbbs.founduserPer Then
CanEditPost=False
End If
If Cint(Dvbbs.UserGroupID) < 4 And Cint(Dvbbs.UserGroupID) = rs("UserGroupID") Then
Dvbbs.AddErrCode(75)
ElseIf Cint(Dvbbs.UserGroupID) < 4 and Cint(Dvbbs.UserGroupID) > rs("UserGroupID") Then
Dvbbs.AddErrCode(76)
End If
If Not CanEditPost Then Dvbbs.AddErrCode(77)
End If
End If
Set Rs=Nothing
Dvbbs.ShowErr()
If Action = 4 Then Dvbbs.MemberName=old_user
End Function
'返回判断和参数
Public Function Get_M_Request()
AnnounceID = Request("ID")
If AnnounceID = "" Or Not IsNumeric(AnnounceID) Then Dvbbs.AddErrCode(30)
Dvbbs.ShowErr()
AnnounceID = Clng(AnnounceID)
End Function
Rem ------------------------
Rem 保存部分函数开始
Rem ------------------------
'检查数据,提取数据,获得贴子数据表名等。
Public Sub Save_CheckData()
Chk_Post()
CheckfromScript()
Dim mysessiondata
Content=Dvbbs.Checkstr(Request.Form("body"))
'把提交的数据保存到session
mysessiondata=Session(Dvbbs.CacheName & "UserID")
mysessiondata(37)=Content
Session(Dvbbs.CacheName & "UserID")=mysessiondata
If Dvbbs.Board_Setting(4)="1" Then
If Not Dvbbs.CodeIsTrue() Then
Response.redirect "showerr.asp?ErrCodes=<li>验证码校验失败,2秒后自动返回上一页面。&action=OtherErr&autoreload=1"
End If
End If
Expression=Dvbbs.Checkstr(Request.Form("Expression"))
If Expression="" Then Expression="face1.gif"
Topic=Dvbbs.Checkstr(Trim(Request.Form("topic")))
'Content=Dvbbs.Checkstr(Request.Form("Content"))
signflag=Dvbbs.Checkstr(Trim(Request.Form("signflag")))
mailflag=Dvbbs.Checkstr(Trim(Request.Form("emailflag")))
MyTopicMode=Dvbbs.Checkstr(Trim(Request.Form("topicximoo")))
MyLockTopic=Dvbbs.Checkstr(Trim(Request.Form("locktopic")))
Myistop=Dvbbs.Checkstr(Trim(Request.Form("istop")))
Myistopall=Dvbbs.Checkstr(Trim(Request.Form("istopall")))
TopicMode=Request.Form("topicmode")
If Dvbbs.strLength(topic)> CLng(Dvbbs.Board_Setting(45)) Then Response.redirect "showerr.asp?ErrCodes=<li>"&Replace(template.Strings(23),"{$topiclimited}",Dvbbs.Board_Setting(45))&"<BR>2秒后自动返回上一页面。&action=OtherErr&autoreload=1"
If Dvbbs.strLength(Content) > CLng(Dvbbs.Board_Setting(16)) Then Response.redirect "showerr.asp?ErrCodes=<li>"&Replace(template.Strings(24),"{$bodylimited}",Dvbbs.Board_Setting(16))&"<BR>2秒后自动返回上一页面。&action=OtherErr&autoreload=1"
REM 2004-4-23添加限制帖子内容最小字节数,下次在模板中添加。Dvbbs.YangZheng
If Dvbbs.strLength(Content) < CLng(Dvbbs.Board_Setting(52)) And Not CLng(Dvbbs.Board_Setting(52)) = 0 Then Response.redirect "showerr.asp?ErrCodes=<li>"&Replace(template.Strings(24),"大于{$bodylimited}","小于"&Dvbbs.Board_Setting(52))&"<BR>2秒后自动返回上一页面。&action=OtherErr&autoreload=1"
Dim testContent
testContent=Content
testContent=Html2Ubb(testContent)
testContent=Replace(testContent,vbNewLine,"")
testContent=Replace(testContent," ","")
testContent=Replace(testContent," ","")
If testContent="" Then Response.redirect "showerr.asp?ErrCodes=<li>您没有填写内容,或因当前不支持HTML模式,内容被自动过滤<BR>2秒后自动返回上一页面。&action=OtherErr&autoreload=1"
If Not IsNumeric(mailflag) Or mailflag="" Then mailflag=0
If TopicMode<>"" and IsNumeric(TopicMode) Then TopicMode=Cint(TopicMode) Else TopicMode=0
mailflag=CInt(mailflag)
If signflag="yes" Then
signflag=1
Else
signflag=0
End If
If Request.form("upfilerename")<>"" Then
ihaveupfile=1
upfileinfo=Replace(Request.form("upfilerename"),"'","")
upfileinfo=Replace(upfileinfo,";","")
upfileinfo=Replace(upfileinfo,"--","")
upfileinfo=Replace(upfileinfo,")","")
Dim fixid,upfilelen
fixid=Replace(upfileinfo," ","")
fixid=Replace(fixid,",","")
If Not IsNumeric(fixid) Then ihaveupfile=0
upfilelen=len(upfileinfo)
upfileinfo=left(upfileinfo,upfilelen-1)
Else
ihaveupfile=0
End If
voteid=0
isvote=0
If Action = 7 Then
votetype=Dvbbs.Checkstr(request.Form("votetype"))
If IsNumeric(votetype)=0 or votetype="" Then votetype=0
vote=Dvbbs.Checkstr(trim(Replace(request.Form("vote"),"|","")))
Dim j,k,vote_1,votelen,votenumlen
If vote="" Then
Dvbbs.AddErrCode(81)
Else
vote=split(vote,chr(13)&chr(10))
j=0
For i = 0 To ubound(vote)
If Not (vote(i)="" Or vote(i)=" ") Then
vote_1=""&vote_1&""&vote(i)&"|"
j=j+1
End If
If i>cint(Dvbbs.Board_Setting(32))-2 Then Exit For
Next
For k = 1 to j
votenum=""&votenum&"0|"
Next
votelen=len(vote_1)
votenumlen=len(votenum)
votenum=left(votenum,votenumlen-1)
vote=left(vote_1,votelen-1)
End If
If Not IsNumeric(request("votetimeout")) Then
Dvbbs.AddErrCode(82)
Else
If request("votetimeout")="0" Then
votetimeout=dateadd("d",9999,Now())
Else
votetimeout=dateadd("d",request("votetimeout"),Now())
End If
votetimeout=Replace(Replace(CSTR(votetimeout+Dvbbs.Forum_Setting(0)/24),"上午",""),"下午","")
End If
End If
If Action = 5 Or Action = 7 Then
CanLockTopic=False
CanTopTopic=False
CanTopTopic_a=False
If Topic="" Then Response.redirect "showerr.asp?ErrCodes=<li>您忘记填写标题<BR>2秒后自动返回上一页面。&action=OtherErr&autoreload=1"
'减少判断,如果不为固顶,锁定等等的操作的话,不检查权限。
If MyLockTopic="yes" Or Myistopall="yes" Or Myistop="yes" Then
'判断用户是否有固顶/解除固顶帖子权限
If (dvbbs.master or dvbbs.superboardmaster or dvbbs.boardmaster) Then
If Dvbbs.GroupSetting(21)="1" Then CanTopTopic=True
If Dvbbs.GroupSetting(20)="1" Then CanLockTopic=True
End If
If Dvbbs.GroupSetting(21)="1" and Cint(Dvbbs.UserGroupID)>3 Then CanTopTopic=True
If Dvbbs.FoundUserPer and Dvbbs.GroupSetting(21)="1" Then
CanTopTopic=True
ElseIf Dvbbs.FoundUserPer and Dvbbs.GroupSetting(21)="0" Then
CanTopTopic=False
End If
'判断用户是否有总固顶帖子权限
If (dvbbs.master or dvbbs.superboardmaster or dvbbs.boardmaster) and Dvbbs.GroupSetting(38)="1" Then CanTopTopic_a=True
If Dvbbs.GroupSetting(38)="1" and Cint(Dvbbs.UserGroupID)>3 Then CanTopTopic_a=True
If Dvbbs.FoundUserPer and Dvbbs.GroupSetting(38)="1" Then
CanTopTopic_a=True
ElseIf Dvbbs.FoundUserPer and Dvbbs.GroupSetting(38)="0" Then
CanTopTopic_a=False
End If
End If
If MyLockTopic="yes" Then
MyLockTopic=1
Else
MyLockTopic=0
End If
If Myistopall="yes" Then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -