protected void Page_Load(object sender, EventArgs e) { if (function.isAjax()) { string action = Request.Form["action"]; string value = Request.Form["value"]; string msg = ""; int pid = 0, id = 0; string result = "1" + ":" + Pid; M_UserInfo user = buser.GetLogin(); switch (action) { case "DeleteMsg": //删除 id = Convert.ToInt32(value); result = barBll.UpdateStatus(barBll.SelReturnModel(id).CateID, id.ToString(), (int)ZLEnum.ConStatus.Recycle) ? "ok" :"failed"; break; case "AddReply": //回复 pid = Convert.ToInt32(value.Split(':')[0]); msg = value.Split(':')[1]; barBll.Insert(FillMsg(msg, pid, Pid)); break; case "AddReply2": //回复用户,需要切换为Json pid = Convert.ToInt32(value.Split('$')[0]); msg = value.Split('$')[1]; barBll.Insert(FillMsg(msg, pid, Pid)); break; case "AddColl": if (user != null && user.UserID > 0) { result = barBll.LikeTie(DataConvert.CLng(value), user.UserID, 1)?"1":"0"; } else { result = "-1"; } break; case "ReColl": if (user != null && user.UserID > 0) { result = barBll.LikeTie(DataConvert.CLng(value), user.UserID, 2) ? "1" : "0"; } break; } Response.Write(result); Response.Flush(); Response.End(); } HideTlp = "你当前没有登录,请<a href='/User/Login.aspx?returnUrl=/" + CreateUrl(2, Pid) + "'>登录</a>后查看该贴"; if (!IsPostBack) { MyBind(); } }
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)); } }
public IActionResult Post_Add() { //Mid,CateID M_UserInfo mu = tuBll.GetLogin(); //buser.GetLogin(); if (mu.Status != 0) { return(WriteErr("您的账户已被锁定,无法进行发帖、回复等操作!")); } int pid = DataConvert.CLng(RequestEx["pid"]); string title = Request.Form["MsgTitle_T"]; string msg = Request.Form["MsgContent_T"]; //如果内容来源于手机编辑器,则合并图片与转化表情 if (DataConvert.CStr(Request.Form["editor"]).Equals("mbeditor")) { msg = msg.Replace("\r\n", "<br />"); string imgs = Request.Form["txt_bar"], emotions = Request.Form["ImgFace_Hid"]; if (!string.IsNullOrEmpty(emotions)) { string imgTlp = "<img src='/Plugins/Ueditor/dialogs/emotion/{0}' class='imgface_img' />"; DataTable dt = JsonHelper.JsonToDT(emotions); foreach (DataRow dr in dt.Rows) { msg = msg.Replace(dr["title"].ToString(), string.Format(imgTlp, dr["realurl"].ToString())); } } if (!string.IsNullOrEmpty(imgs) && !imgs.Equals("[]")) { string imgHtml = ""; string imgTlp = "<img src='{0}'>"; //[{"url":"/UploadFiles/User/user/admin1/20180627EvVVMk.jpg","desc":""}] DataTable dt = JsonHelper.JsonToDT(imgs); foreach (DataRow dr in dt.Rows) { imgHtml += string.Format(imgTlp, DataConvert.CStr(dr["url"])); } msg += "<div>" + imgHtml + "</div>"; } } string base64Msg = StrHelper.CompressString(msg); string rurl = RequestEx["rurl"];//操作完成后返回哪个链接 bool auth_barowner = false; if (pid > 0)//回复主贴 { M_Guest_Bar pmod = barBll.SelReturnModel(pid); CateID = pmod.CateID; } if (Mid > 0)//编辑贴子 { barMod = barBll.SelReturnModel(Mid); CateID = barMod.CateID; } M_GuestBookCate cateMod = cateBll.SelReturnModel(CateID); if (cateMod == null) { return(WriteErr("栏目不存在")); } rurl = string.IsNullOrEmpty(rurl) ? "/PClass?id=" + cateMod.CateID : rurl; auth_barowner = cateMod.IsBarOwner(mu.UserID); if (Mid > 0)//编辑 { if (barMod.CUser != mu.UserID && !auth_barowner) { return(WriteErr("你无权修改该内容")); } barMod.Title = title; barMod.SubTitle = GetSubTitle(ref msg); barMod.MsgContent = base64Msg; barBll.UpdateByID(barMod); } else { if (pid < 1 && string.IsNullOrEmpty(title)) { return(WriteErr("贴子标题不能为空!")); } if (!ZoomlaSecurityCenter.VCodeCheck(RequestEx["VCode_hid"], RequestEx["VCode"])) { return(WriteErr("验证码不正确")); } if (!auth_barowner)//非管理员需要检测权限和接受限制 { //是否可在该版块发贴子 if (!authBll.AuthCheck(cateMod, mu, "send")) { return(WriteErr("你无权在[" + cateMod.CateName + "]版块发布贴子")); } //是否有时间限制 M_Guest_Bar lastMod = barBll.SelLastModByUid(mu); 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 (mu.UserID > 0 && (DateTime.Now - mu.RegTime).TotalMinutes < usertime)//匿名用户不受此限 { int minute = usertime - (int)(DateTime.Now - mu.RegTime).TotalMinutes; return(WriteErr("新注册用户" + 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; return(WriteErr("你发贴太快了," + minute + "分钟后才能再次发贴", "javascript:history.go(-1);")); } } barMod = FillMsg(title, msg, pid, 0, cateMod); barMod.ID = barBll.Insert(barMod); if (pid < 1) { rurl = "/PItem?ID=" + barMod.ID; } if (cateMod.Status == 1 && mu.UserID > 0 && cateMod.SendScore > 0)//是否需审核 { buser.AddMoney(mu.UserID, cateMod.SendScore, M_UserExpHis.SType.Point, string.Format("{0} {1}在版面:{2}发表主题:{3},赠送{4}分", DateTime.Now, mu.UserName, cateMod.CateName, barMod.Title, cateMod.SendScore)); } } return(Redirect(rurl)); }
public void Post_Add() { //Mid,CateID M_UserInfo mu = tuBll.GetLogin(); //buser.GetLogin(); if (mu.Status != 0) { function.WriteErrMsg("您的账户已被锁定,无法进行发帖、回复等操作!"); return; } int pid = DataConvert.CLng(Request.QueryString["pid"]); string title = Request.Form["MsgTitle_T"]; string msg = Request.Form["MsgContent_T"]; string base64Msg = StrHelper.CompressString(msg); string rurl = Request["rurl"];//操作完成后返回哪个链接 bool auth_barowner = false; if (pid > 0)//回复主贴 { M_Guest_Bar pmod = barBll.SelReturnModel(pid); CateID = pmod.CateID; } if (Mid > 0)//编辑贴子 { barMod = barBll.SelReturnModel(Mid); CateID = barMod.CateID; } M_GuestBookCate cateMod = cateBll.SelReturnModel(CateID); if (cateMod == null) { function.WriteErrMsg("栏目不存在"); return; } rurl = string.IsNullOrEmpty(rurl) ? "/PClass?id=" + cateMod.CateID : rurl; auth_barowner = cateMod.IsBarOwner(mu.UserID); if (Mid > 0)//编辑 { if (barMod.CUser != mu.UserID && !auth_barowner) { function.WriteErrMsg("你无权修改该内容"); return; } barMod.Title = title; barMod.SubTitle = GetSubTitle(ref msg); barMod.MsgContent = base64Msg; barBll.UpdateByID(barMod); } else { if (pid < 1 && string.IsNullOrEmpty(title)) { function.WriteErrMsg("贴子标题不能为空!"); return; } if (!ZoomlaSecurityCenter.VCodeCheck(Request["VCode_hid"], Request["VCode"])) { function.WriteErrMsg("验证码不正确"); return; } if (!auth_barowner)//非管理员需要检测权限和接受限制 { //是否可在该版块发贴子 if (!authBll.AuthCheck(cateMod, mu, "send")) { function.WriteErrMsg("你无权在[" + cateMod.CateName + "]版块发布贴子"); return; } //是否有时间限制 M_Guest_Bar lastMod = barBll.SelLastModByUid(mu); 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 (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);"); return; } 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);"); return; } } barMod = FillMsg(title, msg, pid, 0, cateMod); barBll.Insert(barMod); if (cateMod.Status == 1 && mu.UserID > 0 && cateMod.SendScore > 0)//是否需审核 { buser.AddMoney(mu.UserID, cateMod.SendScore, M_UserExpHis.SType.Point, string.Format("{0} {1}在版面:{2}发表主题:{3},赠送{4}分", DateTime.Now, mu.UserName, cateMod.CateName, barMod.Title, cateMod.SendScore)); } } Response.Redirect(rurl); return; }