⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 #post.mo

📁 WAPmo手机网站管理平台是一款创建与管理维护WAP网站的的软件产品
💻 MO
字号:
Option Explicit

TBBS.AddLang "common|head|foot|error|post"
TBBS.SetNodes "env|user|forums"

TBBS.Page("name") = TBBS.Env("bbs_name")
TBBS.Vars("skin") = "default"

MyIO.PostBytes = atol(TBBS.Env("all_file_size")) * KBYTE
MyIO.FileBytes = atol(TBBS.Permit("upload_size")) * KBYTE

Select Case TBBS.Vars("handle")
Case "topic"
    TBBS.Module "#post_topic"
Case "reply"
    TBBS.Module "#post_reply"
Case "edit"
    TBBS.Module "#post_edit"
Case "vote"
    TBBS.Module "#post_vote"
Case Else
    TBBS.AddError "invalid_handle", Array()
End Select

Private Sub ParseUpload()
    Dim clsFile, clsCmd
    Dim lngID, intType
    Dim xmlParent, xmlNode
    Dim i
    Set clsCmd = MyKernel.Command(T_UPLOAD)
    Set xmlParent = TBBS.Element("files")
    i = 0
    For Each clsFile In MyIO.Items(ITEM_FILE)
        If Not reg_test("^file\d+$", "i", clsFile.Name) Then
            'pass
        ElseIf clsFile.FileName = "" Then
            'pass
        Else
            Select Case clsFile.State
            Case 1
                TBBS.AddHint "update_empty", Array(clsFile.FileName)
            Case 2
                TBBS.AddHint "upload_too_large", Array(clsFile.FileName)
            Case 3
                TBBS.AddHint "update_missing_ext", Array(clsFile.FileName)
            Case 4
                TBBS.AddHint "update_valid_image", Array(clsFile.FileName)
            Case 5
                TBBS.AddHint "upload_deny", Array(clsFile.FileName)
            Case 0
                If Not ValidUpload() Then
                    TBBS.AddHint "upload_too_much", Array(clsFile.FileName)
                Else
                    i = i + 1
                    If i > atoi(TBBS.Permit("upload_once")) Then
                        TBBS.AddHint "upload_once_too_much", Array(clsFile.FileName, TBBS.Permit("upload_once"), TBBS.Permit("upload_size"))
                    Else
                        lngID = atoi(Mid(clsFile.Name, 5))
                        intType = TBBS.FileType(clsFile.FileExt)
                        clsCmd.CommandType = "INSERT"
                        clsCmd.Add "userid", MyKernel.Memory("seqid")
                        clsCmd.Add "username", MyKernel.Memory("username")
                        clsCmd.Add "forumid", TBBS.Forum("crt.seqid")
                        clsCmd.Add "forumname", TBBS.Forum("crt.name")
                        clsCmd.Add "topicid", TBBS.Vars("topicid")
                        clsCmd.Add "topictitle", TBBS.Vars("topictitle")
                        clsCmd.Add "upname", reg_match("([^/\\]+)$", "", clsFile.FileName)(0)
                        clsCmd.Add "uppath", GetUploadPath(clsFile)
                        clsCmd.Add "upsize", clsFile.Size
                        clsCmd.Add "upext", clsFile.FileExt
                        clsCmd.Add "uptype", intType
                        clsCmd.Add "width", clsFile.Width
                        clsCmd.Add "height", clsFile.Height
                        clsCmd.Add "source", IIf(TBBS.NetType = "web", 0, 1)
                        clsCmd.Add "cent", atol(MyIO.Form("cent" & lngID))
                        clsCmd.Add "coin", atol(MyIO.Form("coin" & lngID))
                        clsCmd.Add "intro", Left(MyIO.Form("intro" & lngID), 255)
                        clsCmd.Add "uptime", TBBS.Vars("time")
                        clsCmd.Exec
                        Set xmlNode = xmlParent.appendChild(TBBS.Create("file"))
                        xmlNode.setAttribute "id", lngID
                        xmlNode.setAttribute "uid", MyKernel.DB.GetIdentity(T_UPLOAD)
                        Set xmlNode = Nothing
                        Select Case intType
                        Case TBBS_IMAGE
                            MyKernel.Memory("images") = atol(MyKernel.Memory("images")) + 1
                        Case TBBS_RING
                            MyKernel.Memory("rings") = atol(MyKernel.Memory("rings")) + 1
                        Case TBBS_VIDEO
                            MyKernel.Memory("videos") = atol(MyKernel.Memory("videos")) + 1
                        Case TBBS_SOFT
                            MyKernel.Memory("softs") = atol(MyKernel.Memory("softs")) + 1
                        End Select
                        If atol(MyKernel.Memory("lastupload")) < TBBS.Vars("date") Then
                            MyKernel.Memory("uploads") = 1
                        Else
                            MyKernel.Memory("uploads") = atol(MyKernel.Memory("uploads")) + 1
                        End If
                        MyKernel.Memory("lastupload") = TBBS.Vars("time")
                    End If
                End If
            End Select
        End If
    Next
    Set xmlParent = Nothing
    Set clsCmd = Nothing
    If i > 0 Then
        Set clsCmd = MyKernel.Command(T_USER)
        clsCmd.CommandType = "UPDATE"
        clsCmd.Where = "seqid=" & MyKernel.Memory("seqid")
        clsCmd.Add "images", MyKernel.Memory("images")
        clsCmd.Add "rings", MyKernel.Memory("rings")
        clsCmd.Add "videos", MyKernel.Memory("videos")
        clsCmd.Add "softs", MyKernel.Memory("softs")
        clsCmd.Add "uploads", MyKernel.Memory("uploads")
        clsCmd.Add "lastupload", MyKernel.Memory("lastupload")
        clsCmd.Exec
        Set clsCmd = Nothing
    End If
End Sub

Private Function ValidUpload()
    If MyKernel.Memory("lastupload") < TBBS.Vars("date") Then
        ValidUpload = CBool(atol(TBBS.Permit("upload_max")) > 0)
    Else
        ValidUpload = CBool(atol(MyKernel.Memory("uploads")) < atol(TBBS.Permit("upload_max")))
    End If
End Function

Private Function FormatUpload(ByVal lngID)
    Dim xmlParent, xmlNode
    Set xmlParent = TBBS.Element("files")
    Set xmlNode = xmlParent.selectSingleNode("file[@id = " & lngID & "]")
    If Not xmlNode Is Nothing Then
        FormatUpload = "[upload]" & xmlNode.getAttribute("uid") & "[/upload]"
    Else
        FormatUpload = "[local]" & lngID & "[/local]"
    End If
    Set xmlNode = Nothing
    Set xmlParent = Nothing
End Function

Private Function GetUploadPath(clsFile)
    Dim strPath, strFile
    strFile = str_format("upload/$0/$1_$2.$3", Array(FormatTime(TBBS.Vars("time"), "Ymd"), FormatTime(TBBS.Vars("time"), "His"), MD5(clsFile.FileName), clsFile.FileExt))
    DetectFile TBBS.MapPath("."), strFile
    clsFile.SaveToFile TBBS.MapPath(strFile)
    GetUploadPath = Mid(strFile, 8)
End Function

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -