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

📄 #post_topic.mo

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

If TBBS.Permit("post_topic") = 0 Then
    TBBS.AddError "ps_post_topic", Array()
ElseIf Not TBBS.CheckForum("crt", Request.QueryString("fid")) Then
    TBBS.AddError "missing_forum", Array()
Else
    Call TBBS.SetForumNav(True)
    TBBS.AddNav "", TBBS.Lang("new_topic")
    TBBS.Page("name") = TBBS.GetNav()
    TBBS.AddOnline TBBS.Forum("crt.seqid"), TBBS.Page("name")
    TBBS.Vars("handle_name") = TBBS.Lang("new_topic")
    TBBS.Vars("action_addr") = "post.asp?handle=topic&fid=" & TBBS.Forum("crt.seqid")
    TBBS.Vars("failed") = TBBS.Lang("topic_failed")
    Call main()
End If

Private Sub doGet()
    TBBS.Vars("state") = 0
End Sub

Private Sub doPost()
    Dim clsCmd
    If TBBS.Forum("crt.allow") = "" Then
        MyIO.Allow = TBBS.Env("allow")
    Else
        MyIO.Allow = TBBS.Forum("crt.allow")
    End If
    TBBS.Vars("state") = 1
    TBBS.Vars("title") = Trim(MyIO.Form("title"))
    TBBS.Vars("content") = SafeHTML(MyIO.Form("content"))
    TBBS.Vars("face") = atoi(MyIO.Form("face"))
    If Not TBBS.CheckValidate("post") Then
        TBBS.AddHint "invalid_validate", Array()
    ElseIf TBBS.Vars("title") = "" Then
        TBBS.AddHint "empty_title", Array()
    ElseIf Len(TBBS.Vars("title")) < atol(TBBS.Env("topic_title_min_size")) Then
        TBBS.AddHint "topic_title_too_short", Array(TBBS.Env("topic_title_min_size"))
    ElseIf Len(TBBS.Vars("title")) > atol(TBBS.Env("topic_title_max_size")) Then
        TBBS.AddHint "topic_title_too_long", Array(TBBS.Env("topic_title_max_size"))
    ElseIf Trim(TBBS.Vars("content")) = "" Then
        TBBS.AddHint "empty_content", Array()
    ElseIf Len(TBBS.Vars("content")) < atol(TBBS.Env("topic_content_min_size")) Then
        TBBS.Addhint "topic_content_too_short", Array(TBBS.Env("topic_content_min_size"))
    ElseIf Len(TBBS.Vars("content")) > atol(TBBS.Env("topic_content_max_size")) Then
        TBBS.AddHint "topic_content_too_long", Array(TBBS.Env("topic_content_max_size"))
    ElseIf TodayPosts() > atol(TBBS.Env("max_posts")) And atol(TBBS.Env("max_posts")) > 0 Then
        TBBS.AddHint "topic_too_much", Array(TBBS.Env("max_posts"))
    ElseIf TBBS.Vars("time") - atol(MyKernel.Memory("LastPostTime")) < atol(TBBS.Env("topic_interval")) Then
        TBBS.AddHint "topic_interval", Array(TBBS.Env("topic_interval"))
    Else
        Set clsCmd = MyKernel.Command(T_TOPIC)
        clsCmd.CommandType = "INSERT"
        clsCmd.Add "forumid", TBBS.Forum("crt.seqid")
        clsCmd.Add "forumname", TBBS.Forum("crt.name")
        clsCmd.Add "topictype", 0
        clsCmd.Add "title", TBBS.Vars("title")
        clsCmd.Add "content", TBBS.Vars("content")
        clsCmd.Add "face", TBBS.Vars("face")
        clsCmd.Add "userid", MyKernel.Memory("SeqId")
        clsCmd.Add "username", MyKernel.Memory("UserName")
        clsCmd.Add "follow", 0
        clsCmd.Add "posttime", TBBS.Vars("time")
        clsCmd.Add "postip", MyIO.Env("REMOTE_ADDR")
        clsCmd.Add "lastposttime", TBBS.Vars("time")
        clsCmd.Add "hits", 0
        clsCmd.Add "replies", 0
        clsCmd.Add "toptype", 0
        clsCmd.Add "state", 0
        clsCmd.Add "locked", 0
        clsCmd.Add "souled", 0
        clsCmd.Add "omited", 0
        clsCmd.Add "shield", 0
        clsCmd.Add "serial", 0
        clsCmd.Add "source", IIf(TBBS.NetType = "web", 0, 1)
        clsCmd.Add "mark", TBBS.Forum("crt.mark")
        clsCmd.Exec
        Set clsCmd = Nothing
        TBBS.Vars("identity") = MyKernel.DB.GetIdentity(T_TOPIC)
        TBBS.Vars("topicid") = TBBS.Vars("identity")
        TBBS.Vars("topictitle") = TBBS.Vars("title")
        Call ParseUpload
        If reg_test("\[local\](\d+)\[/local\]", "i", TBBS.Vars("content")) Then
            Set clsCmd = MyKernel.Command(T_TOPIC)
            clsCmd.CommandType = "UPDATE"
            clsCmd.Where = "seqid=" & TBBS.Vars("identity")
            clsCmd.Add "content", preg_replace("\[local\](\d+)\[/local\]", "gi", "FormatUpload($1)", TBBS.Vars("content"))
            clsCmd.Exec
            Set clsCmd = Nothing
        End If
        Set clsCmd = MyKernel.Command(T_FORUM)
        clsCmd.CommandType = "UPDATE"
        clsCmd.Where = "seqid=" & TBBS.Forum("crt.seqid")
        clsCmd.Add "lastpostid", TBBS.Vars("identity")
        clsCmd.Add "lastposttime", TBBS.Vars("time")
        clsCmd.Add "lastpostuserid", MyKernel.Memory("seqid")
        clsCmd.Add "lastpostusername", MyKernel.Memory("username")
        clsCmd.Add "lastposttitle", TBBS.Vars("title")
        clsCmd.Add "topics", atol(TBBS.Forum("crt.topics")) + 1
        If atol(TBBS.Forum("crt.lastposttime")) < TBBS.Vars("date") Then
            clsCmd.Add "todayposts", 1
        Else
            clsCmd.Add "todayposts", atol(TBBS.Forum("crt.todayposts")) + 1
        End If
        clsCmd.Exec
        Set clsCmd = Nothing
        TBBS.SetXMLCache "Forums"
        TBBS.SetXMLCache "TopicNew"
        MyKernel.Memory("topics") = atol(MyKernel.Memory("topics")) + 1
        If atol(MyKernel.Memory("LastPostTime")) < TBBS.Vars("date") Then
            MyKernel.Memory("todayposts") = 1
        Else
            MyKernel.Memory("todayposts") = atol(MyKernel.Memory("todayposts")) + 1
        End If
        MyKernel.Memory("lastposttime") = TBBS.Vars("time")
        MyKernel.Memory("coin") = atol(MyKernel.Memory("coin")) + TBBS.XPEnv("coin", "topic")
        MyKernel.Memory("cent") = atol(MyKernel.Memory("cent")) + TBBS.XPEnv("cent", "topic")
        MyKernel.Memory("witchery") = atol(MyKernel.Memory("witchery")) + TBBS.XPEnv("witchery", "topic")
        Set clsCmd = MyKernel.Command(T_USER)
        clsCmd.CommandType = "UPDATE"
        clsCmd.Where = "seqid=" & MyKernel.Memory("seqid")
        clsCmd.Add "topics", MyKernel.Memory("topics")
        clsCmd.Add "lastposttime", TBBS.Vars("time")
        clsCmd.Add "todayposts", MyKernel.Memory("todayposts")
        clsCmd.Add "coin", MyKernel.Memory("coin")
        clsCmd.Add "cent", MyKernel.Memory("cent")
        clsCmd.Add "witchery", MyKernel.Memory("witchery")
        clsCmd.Exec
        Set clsCmd = Nothing
        TBBS.Env("index_today") = atol(TBBS.Env("index_today")) + 1
        TBBS.Env("index_topic") = atol(TBBS.Env("index_topic")) + 1
        TBBS.Vars("state") = 2
        TBBS.Redirect "topic.asp?fid=" & TBBS.Forum("crt.seqid") & "&id=" & TBBS.Vars("identity")
        TBBS.AddHint "topic_ok", Array()
        TBBS.Addhint "back_new_topic", Array(TBBS.Vars("redirect"))
        TBBS.AddHint "back_forum", Array(TBBS.Forum("crt.seqid"))
        TBBS.AddHint "back_home", Array(TBBS.Env("bbs_name"))
    End If
    Session.Contents.Remove "validate"
End Sub

Private Function TodayPosts()
    If atol(MyKernel.Memory("lastposttime")) < TBBS.Vars("date") Then
        TodayPosts = 0
    Else
        TodayPosts = atol(MyKernel.Memory("todayposts"))
    End If
End Function

⌨️ 快捷键说明

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