Ejemplo n.º 1
0
    protected void PostMsg_Btn_Click(object sender, EventArgs e)
    {
        M_UserInfo mu = tpuser_Bll.GetLogin();//barBll.GetUser();

        if (mu.Status != 0)
        {
            function.WriteErrMsg("您的账户已被锁定,无法进行发帖、回复等操作!");
        }
        M_Guest_Bar     lastMod   = barBll.SelLastModByUid(mu);
        M_GuestBookCate catemod   = guestBll.GetCate(CateID);
        BarOption       baroption = GuestConfig.GuestOption.BarOption.Find(v => v.CateID == CateID);
        int             usertime  = baroption == null ? 120 : baroption.UserTime;
        int             sendtime  = baroption == null?5:baroption.SendTime;

        if (!ZoomlaSecurityCenter.VCodeCheck(Request.Form["VCode_hid"], VCode.Text.Trim()))
        {
            function.WriteErrMsg("验证码不正确", "/" + B_Guest_Bar.CreateUrl(1, CateID, CPage));
        }
        else if (catemod.IsBarOwner(mu.UserID))
        {
        }
        else if (mu.UserID > 0 && (DateTime.Now - mu.RegTime).TotalMinutes < usertime)//匿名用户不受此限
        {
            int minute = usertime - (int)(DateTime.Now - mu.RegTime).TotalMinutes;
            function.WriteErrMsg("新注册用户" + usertime + "分钟内不能发贴,你还需要" + minute + "分钟", "javascript:history.go(-1);");
        }
        else if (lastMod != null && (DateTime.Now - lastMod.CDate).TotalMinutes < sendtime)
        {
            int minute = sendtime - (int)(DateTime.Now - lastMod.CDate).TotalMinutes;
            function.WriteErrMsg("你发贴太快了," + minute + "分钟后才能再次发贴", "javascript:history.go(-1);");
        }
        string msg = MsgContent_T.Text;

        GetSubTitle(ref msg);
        catemod = guestBll.SelReturnModel(CateID);
        barMod  = FillMsg(MsgTitle_T.Text, msg, catemod);
        int id = barBll.Insert(barMod);

        if (catemod.Status == 1 && mu.UserID > 0) //是否需审核
        {
            if (catemod.IsPlat == 1)              //分享到能力中心
            {
                string siteurl = "http://" + Request.Url.Authority + "/";
                string url     = B_Guest_Bar.CreateUrl(2, id);
                string cateurl = B_Guest_Bar.CreateUrl(1, catemod.CateID);
                msgBll.InsertMsg(string.Format(forwardTlp, barMod.Title, siteurl + url, siteurl + url, catemod.CateName, siteurl + cateurl));
            }
            buser.ChangeVirtualMoney(mu.UserID, new M_UserExpHis()
            {
                score     = catemod.SendScore,
                ScoreType = (int)M_UserExpHis.SType.Point,
                detail    = string.Format("{0} {1}在版面:{2}发表主题:{3},赠送{4}分", DateTime.Now, mu.UserName, catemod.CateName, MsgTitle_T.Text.Trim(), catemod.SendScore)
            });
            Response.Redirect("/" + B_Guest_Bar.CreateUrl(2, id));
        }
        else
        {
            Response.Redirect("/" + B_Guest_Bar.CreateUrl(1, CateID));
        }
    }