📄 #handle.mo
字号:
Option Explicit
TBBS.AddLang "common|head|foot|error|handle"
TBBS.SetNodes "env|user|forums"
TBBS.Page("name") = TBBS.Env("bbs_name")
TBBS.Vars("skin") = "default"
Call main
Private Sub doGet()
If Not ValidManage() Then Exit Sub
TBBS.Vars("handle_name") = TBBS.Lang("handle_" & TBBS.Vars("handle"))
TBBS.Vars("cent") = 0
TBBS.Vars("coin") = 0
TBBS.Vars("witchery") = 0
TBBS.Vars("disxp") = 0
Select Case TBBS.Vars("handle")
Case "lock"
TBBS.Vars("locktype") = 1
Case "upgrade"
Case "drop"
Case "omit"
TBBS.Vars("omittype") = 1
TBBS.Vars("cent") = -5
TBBS.Vars("coin") = -12
TBBS.Vars("witchery") = -2
Case "top"
TBBS.Vars("toptype") = 1
Case "soul"
TBBS.Vars("soultype") = 1
TBBS.Vars("cent") = 20
TBBS.Vars("coin") = 25
TBBS.Vars("witchery") = 15
Case "shield"
TBBS.Vars("shieldtype") = 1
TBBS.Vars("cent") = -20
TBBS.Vars("coin") = -25
TBBS.Vars("witchery") = -15
Case "assess"
End Select
End Sub
Private Function ValidManage()
ValidManage = False
If Not TBBS.CheckForum("crt", Request.QueryString("fid")) Then
TBBS.AddError "missing_forum", Array()
ElseIf Not TBBS.CheckTopic(Request.QueryString("id")) Then
TBBS.AddError "missing_topic", Array()
ElseIf atol(TBBS.Forum("crt.seqid")) <> atol(TBBS.Topic("forumid")) Then
TBBS.AddError "missing_topic", Array()
Else
Call TBBS.SetTopicNav(True)
TBBS.AddNav "", TBBS.Lang("manage_topic")
Call TBBS.SetMaster
If TBBS.Attr("user", "master") <> "1" Then
TBBS.AddError "ps_manage_topic", Array()
ElseIf Not InString("lock|upgrade|drop|omit|top|soul|shield|assess", TBBS.Vars("handle"), True) Then
TBBS.AddError "invalid_handle", Array()
ElseIf InString("lock|upgrade|drop|omit|top", TBBS.Vars("handle"), True) And atol(TBBS.Topic("follow")) > 0 Then
TBBS.AddError "topic_handle_invalid", Array()
Else
ValidManage = True
End If
End If
End Function
Private Sub doRedirect()
Dim arr1, arr2, strURL
Dim lngRows, intSize
lngRows = atol(TBBS.Topic("serial"))
intSize = 10
arr1 = Array("fid", "id", "page")
If atol(TBBS.Topic("follow")) > 0 Then
arr2 = Array(TBBS.Forum("crt.seqid"), TBBS.Topic("follow"), GetPageNum(lngRows, intSize))
Else
arr2 = Array(TBBS.Forum("crt.seqid"), TBBS.Topic("seqid"), GetPageNum(lngRows, intSize))
End If
strURL = "$(URL)#topic$(ID)"
strURL = Replace(strURL, "$(URL)", GetURL("topic.asp", arr1, arr2))
strURL = Replace(strURL, "$(ID)", TBBS.Topic("seqid"))
TBBS.Redirect strURL
End Sub
Private Sub doPost()
If Not ValidManage() Then Exit Sub
Dim arr
TBBS.Vars("handle_name") = TBBS.Lang("handle_" & TBBS.Vars("handle"))
TBBS.Vars("locktype") = atoi(MyIO.Form("locktype"))
TBBS.Vars("omittype") = atoi(MyIO.Form("omittype"))
TBBS.Vars("toptype") = atoi(MyIO.Form("toptype"))
TBBS.Vars("soultype") = atoi(MyIO.Form("soultype"))
TBBS.Vars("shieldtype") = atoi(MyIO.Form("shieldtype"))
arr = MyIO.FormArray("reason")
TBBS.Vars("reason") = Join(arr, Empty)
TBBS.Vars("disxp") = atoi(MyIO.Form("disxp"))
If TBBS.Vars("disxp") = 1 Then
TBBS.Vars("cent") = 0
TBBS.Vars("coin") = 0
TBBS.Vars("witchery") = 0
Else
TBBS.Vars("cent") = atoi(MyIO.Form("cent"))
TBBS.Vars("coin") = atoi(MyIO.Form("coin"))
TBBS.Vars("witchery") = atoi(MyIO.Form("witchery"))
End If
TBBS.Vars("sms") = Trim(MyIO.Form("sms"))
TBBS.Vars("state") = 1
If arr(0) <> "" And Not InString(TBBS.Env("handle_reason"), arr(0), True) Then
TBBS.AddHint "missing_reason", Array()
ElseIf TBBS.Vars("reason") = "" Then
TBBS.AddHint "missing_reason", Array()
Else
TBBS.Vars("reason1") = Trim(arr(0))
TBBS.Vars("reason2") = Trim(arr(1))
Select Case TBBS.Vars("handle")
Case "lock"
Call doPostLock
Case "upgrade"
Call doPostUpgrade
Case "drop"
Call doPostDrop
Case "omit"
Call doPostOmit
Case "top"
Call doPostTop
Case "soul"
Call doPostSoul
Case "shield"
Call doPostShield
Case "assess"
Call doPostAssess
End Select
If TBBS.Vars("sms") <> "" Then
TBBS.SendMessage MyKernel.Memory("username"), TBBS.Topic("username"), GetMessageTitle(), TBBS.Vars("sms"), False
End If
TBBS.Vars("state") = 2
Call setHandleLog
If TBBS.Vars("handle") = "omit" Then
TBBS.Redirect "forum.asp?id=" & TBBS.Forum("crt.seqid")
Else
Call doRedirect
End If
TBBS.AddHint "handle_ok", Array()
TBBS.AddHint "redirect", Array(TBBS.Vars("redirect"))
End If
End Sub
Private Function GetMessageTitle()
GetMessageTitle = str_format(TBBS.Lang("handle_sms_title"), Array(TBBS.Env("bbs_name"), TBBS.Vars("handle_name")))
End Function
Private Sub setHandleLog()
Dim clsCmd, arr(5)
arr(0) = TBBS.Vars("handle_name")
arr(1) = TBBS.Vars("reason")
arr(2) = TBBS.Forum("crt.id")
arr(3) = TBBS.Forum("crt.name")
arr(4) = TBBS.Topic("seqid")
arr(5) = TBBS.Topic("title")
Set clsCmd = MyKernel.Command("WM_LOG")
clsCmd.CommandType = "INSERT"
clsCmd.Add "username", MyKernel.Memory("username")
clsCmd.Add "log", str_format(TBBS.Lang("handle_log"), arr)
clsCmd.Add "cent", TBBS.Vars("cent")
clsCmd.Add "coin", TBBS.Vars("coin")
clsCmd.Add "witchery", TBBS.Vars("witchery")
clsCmd.Add "intime", TBBS.Vars("time")
clsCmd.Add "inip", MyIO.Env("REMOTE_ADDR")
Set clsCmd = Nothing
End Sub
Private Sub doPostLock()
If atoi(TBBS.Topic("locked")) = TBBS.Vars("locktype") Then Exit Sub
Dim strSQL
strSQL = "UPDATE $(Table) SET LOCKED=$(Locked) WHERE SEQID=$(SeqID)"
strSQL = Replace(strSQL, "$(Table)", T_TOPIC)
strSQL = Replace(strSQL, "$(Locked)", TBBS.Vars("locktype"))
strSQL = Replace(strSQL, "$(SeqID)", TBBS.Topic("seqid"))
MyKernel.DB.Exec strSQL
End Sub
Private Sub doPostUpgrade()
Dim strSQL
strSQL = "UPDATE $(Table) SET LASTPOSTTIME=$(Timeval) WHERE SEQID=$(SeqID)"
strSQL = Replace(strSQL, "$(Table)", T_TOPIC)
strSQL = Replace(strSQL, "$(Timeval)", TBBS.Vars("time"))
strSQL = Replace(strSQL, "$(SeqID)", TBBS.Topic("seqid"))
MyKernel.DB.Exec strSQL
End Sub
Private Sub doPostDrop()
Dim strSQL, lngTime
strSQL = "SELECT MIN(LASTPOSTTIME) FROM $(Table)"
strSQL = Replace(strSQL, "$(Table)", T_TOPIC)
lngTime = atol(MyKernel.DB.GetRow(strSQL))
If lngTime > 0 Then
strSQL = "UPDATE $(Table) SET LASTPOSTTIME=$(Timeval) WHERE SEQID=$(SeqID)"
strSQL = Replace(strSQL, "$(Table)", T_TOPIC)
strSQL = Replace(strSQL, "$(Timeval)", lngTime - 1)
strSQL = Replace(strSQL, "$(SeqID)", TBBS.Topic("seqid"))
MyKernel.DB.Exec strSQL
End If
End Sub
Private Sub doPostOmit()
Dim strSQL
strSQL = "DELETE FROM $(Table) WHERE SEQID=$(SeqID) OR FOLLOW=$(SeqID)"
strSQL = Replace(strSQL, "$(Table)", T_TOPIC)
strSQL = Replace(strSQL, "$(SeqID)", TBBS.Topic("seqid"))
MyKernel.DB.Exec strSQL
End Sub
Private Sub doPostTop()
If atoi(TBBS.Topic("toptype")) = TBBS.Vars("toptype") Then Exit Sub
Dim strSQL
strSQL = "UPDATE $(Table) SET TOPTYPE=$(TopType) WHERE SEQID=$(SeqID)"
strSQL = Replace(strSQL, "$(Table)", T_TOPIC)
strSQL = Replace(strSQL, "$(TopType)", TBBS.Vars("toptype"))
strSQL = Replace(strSQL, "$(SeqID)", TBBS.Topic("seqid"))
MyKernel.DB.Exec strSQL
Call UpdateTopCache(TBBS.Topic("toptype"))
Call UpdateTopCache(TBBS.Vars("toptype"))
End Sub
Private Sub UpdateTopCache(ByVal intType)
Dim arr, lngPID, lngID
arr = Split(TBBS.Forum("crt.mark"), "_")
lngPID = arr(0)
lngID = arr(UBound(arr))
Select Case atoi(intType)
Case TBBS_TOP_CURRENT
TBBS.SetTopCache TBBS_TOP_CURRENT, lngID
Case TBBS_TOP_PARENT
TBBS.SetTopCache TBBS_TOP_PARENT, lngPID
Case TBBS_TOP_ALL
TBBS.SetTopCache TBBS_TOP_ALL, 0
End Select
End Sub
Private Sub doPostSoul()
If atoi(TBBS.Topic("soul")) = TBBS.Vars("soultype") Then Exit Sub
Dim strSQL
strSQL = "UPDATE $(Table) SET SOULED=$(Soul) WHERE SEQID=$(SeqID)"
strSQL = Replace(strSQL, "$(Table)", T_TOPIC)
strSQL = Replace(strSQL, "$(Soul)", TBBS.Vars("soultype"))
strSQL = Replace(strSQL, "$(SeqID)", TBBS.Topic("seqid"))
MyKernel.DB.Exec strSQL
If TBBS.Vars("soultype") = 0 Then
TBBS.Env("index_soul") = atol(TBBS.Env("index_soule")) - 1
Else
TBBS.Env("index_soul") = atol(TBBS.Env("index_soule")) + 1
End If
End Sub
Private Sub doPostShield()
If atoi(TBBS.Topic("shield")) = TBBS.Vars("shieldtype") Then Exit Sub
Dim strSQL
strSQL = "UPDATE $(Table) SET SHIELD=$(Shield) WHERE SEQID=$(SeqID)"
strSQL = Replace(strSQL, "$(Table)", T_TOPIC)
strSQL = Replace(strSQL, "$(Shield)", TBBS.Vars("shieldtype"))
strSQL = Replace(strSQL, "$(SeqID)", TBBS.Topic("seqid"))
MyKernel.DB.Exec strSQL
End Sub
Private Sub doPostAssess()
Dim strSQL
Dim arr(3), tmp
arr(0) = Replace(TBBS.Vars("reason"), "|", "")
arr(1) = TBBS.Vars("cent")
arr(2) = TBBS.Vars("coin")
arr(3) = TBBS.Vars("witchery")
strSQL = "UPDATE $(Table) SET ASSESS='$(Assess)' WHERE SEQID=$(SeqID)"
strSQL = Replace(strSQL, "$(Table)", T_TOPIC)
strSQL = Replace(strSQL, "$(Assess)", SafeString(Join(arr, "|")))
strSQL = Replace(strSQL, "$(SeqID)", TBBS.Topic("seqid"))
MyKernel.DB.Exec strSQL
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -