
Public Sub main()
    If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
        Call doPost
    Else
        Call doGet
    End If
End Sub

Private Sub doGet()
    Response.Charset = "utf-8"
    Response.ContentType = "text/xml"
    Dim strTarget
    Dim strName
    Dim lngSeqId
    strTarget = LCase(Request.QueryString("Target"))
    strName = LCase(Request.QueryString("Name"))
    lngSeqId = atol(Request.QueryString("SeqId"))
    Select Case strTarget
    Case "site"
        If strName = "logo" Then
            ClearImage "logo"
            MyKernel.Config("SiteLogo") = ""
            Push "OK"
        ElseIf strName = "backimage" Then
            ClearImage "backimage"
            MyKernel.Config("BackImage") = ""
            Push "OK"
        ElseIf strName = "backsound" Then
            ClearFile "backsound", "AllowRing"
            MyKernel.Config("BackSound") = ""
            Push "OK"
        Else
            Push "δ֪[" & strTarget & "." & strName & "]"
        End If
    Case "staple"
        If lngSeqId = 0 Then
            Push "ѡҪɾļ"
        ElseIf strName = "icon" Then
            ClearImage "icon" & lngSeqId
            SafeExecute "UPDATE " & T_STAPLE & " SET Icon='' WHERE SeqId=" & lngSeqId
            Push "OK"
        ElseIf strName = "logo" Then
            ClearImage "logo" & lngSeqId
            SafeExecute "UPDATE " & T_STAPLE & " SET Logo='' WHERE SeqId=" & lngSeqId
            Push "OK"
        Else
            Push "δ֪[" & strTarget & "." & strName & "]"
        End If
    Case "matter"
        If lngSeqId = 0 Then
            Push "ѡҪɾز"
        ElseIf strName = "jad" Or strName = "preview" Then
            DeleteMatter strName, lngSeqId
        Else
            Push "δ֪[" & strTarget & "." & strName & "]"
        End If
    Case Else:
        Push "δ֪[" & strTarget & "]"
    End Select
End Sub

Private Sub doPost()
End Sub

Private Sub DeleteMatter(ByVal strHandle, ByVal lngId)
    Dim objMatter
    Dim strName
    Dim strPath
    Set objMatter = MyKernel.Table(T_MATTER)
    If objMatter.Exec("*", "SeqId=" & atol(lngId)) Then
        strName = getMatterName(objMatter.Item("Category")) & "/" & FormatTime(getDate(objMatter.Item("Intime")), "YYYYMMDD") & "/" & Hex(objMatter.Item("Mark"))
        If strHandle = "jad" Then
            strPath = MyKernel.MapPath("images/" & strName & ".jad")
            If VBSRE.FSO.FileExists(strPath) Then
                VBSRE.FSO.DeleteFile strPath
            End If
        Else
            ClearImage strName & "P"
            ClearImage strName & "F"
            ClearImage strName
            SafeExecute "UPDATE " & T_MATTER & " SET Preview='' WHERE SeqId=" & objMatter.Item("SeqId")
        End If
        Push "OK"
    Else
        Push "δҲҪɾ" & IIf(strHandle = "jad", "JAD ļ", "ԤͼƬ")
    End If
    Set objMatter = Nothing
End Sub
