protected void Page_Load(object sender, EventArgs e) { User u = UserAction.opuser; if (u.ID <= 0) { Js.AlertAndChangUrl("对不起,您没有登录,请登陆后进行投稿!", "/"); return; } UserGroup g = UserGroupView.GetModelByID(u.Group.ToS()); if (g.MaxPost <= 0) { Js.AlertAndGoback("对不起,您没有投稿的权限!如有疑问,请联系管理员"); return; } lb_UserName.Text = u.UserName; txt_Author.Text = u.UserName; if (!IsPostBack) { var cls = NewsAction.NewsClass; cls = cls.Where(p => p.EnablePost && p.IsLeafClass && p.ModelID == 1).ToList(); ddl_Class.DataSource = cls; ddl_Class.DataTextField = "ClassName"; ddl_Class.DataValueField = "id"; ddl_Class.DataBind(); } LoadInfo(); }
protected void Page_Load(object sender, EventArgs e) { try { if (UserGroupView.GetModelByID(UserAction.opuser.Group.ToS()).MaxPost > 0) { PostLink = "<a href='/e/post/PostNews.aspx'>投递文章</a>"; } } catch { } }
protected void LoadInfo() { ddl_RegForm.DataSource = UserFormView.GetModelList(); ddl_RegForm.DataTextField = "FormName"; ddl_RegForm.DataValueField = "ID"; ddl_RegForm.DataBind(); int id = WS.RequestInt("id"); Voodoo.Model.UserGroup g = UserGroupView.GetModelByID(id.ToS()); if (g.ID < 0) { return; } txt_GroupName.Text = g.GroupName; txt_grade.Text = g.Grade.ToS(); txt_MaxPost.Text = g.MaxPost.ToS(); chk_PostAotuAudit.Checked = g.PostAotuAudit; chk_EnableReg.Checked = g.EnableReg; chk_RegAutoAudit.Checked = g.RegAutoAudit; ddl_RegForm.SelectedValue = g.RegForm.ToS(); }
protected void Page_Load(object sender, EventArgs e) { User u = UserAction.opuser; if (u.ID <= 0) { Js.AlertAndChangUrl("对不起,您没有登录,请登陆后进行提问!", "/"); return; } UserGroup g = UserGroupView.GetModelByID(u.Group.ToS()); if (g.MaxPost <= 0) { Js.AlertAndGoback("对不起,您没有提问的权限!如有疑问,请联系管理员"); return; } if (!IsPostBack) { var cls = NewsAction.NewsClass; cls = cls.Where(p => p.EnablePost && p.IsLeafClass && p.ModelID == 3).ToList(); ddl_Class.DataSource = cls; ddl_Class.DataTextField = "ClassName"; ddl_Class.DataValueField = "id"; ddl_Class.DataBind(); int rclass = WS.RequestInt("class"); if (rclass > 0) { ddl_Class.SelectedValue = rclass.ToS(); ddl_Class.Enabled = false; } } }
protected void btn_Save_Click(object sender, EventArgs e) { int id = WS.RequestInt("id"); Voodoo.Model.UserGroup g = UserGroupView.GetModelByID(id.ToS()); g.GroupName = txt_GroupName.Text; g.Grade = txt_grade.Text.ToInt32(); g.MaxPost = txt_MaxPost.Text.ToInt32(); g.PostAotuAudit = chk_PostAotuAudit.Checked; g.EnableReg = chk_EnableReg.Checked; g.RegAutoAudit = chk_RegAutoAudit.Checked; g.RegForm = ddl_RegForm.SelectedValue.ToInt32(); if (g.ID > 0) { UserGroupView.Update(g); } else { UserGroupView.Insert(g); } Js.AlertAndChangUrl("保存成功!", "GroupList.aspx"); }
/// <summary> /// 用户注册 /// </summary> /// <param name="user"></param> /// <returns></returns> public Result UserRegister(User user) { SysSetting setting = BasePage.SystemSetting; Result r = new Result(); if (!setting.EnableReg)//不允许注册 { r.Success = false; r.Text = "系统关闭了用户注册功能!"; return(r); } if (UserView.Exist(string.Format("UserName='******'", user.UserName))) { r.Success = false; r.Text = "这个账号已经存在,请重新选择!"; return(r); } if (user.UserName.Length > setting.MaxUserName || user.UserName.Length < setting.MinUserName) { r.Success = false; r.Text = string.Format("账号长度请设置在{0}和{1}之间", setting.MinUserName, setting.MaxUserName); return(r); } //密码经过MD5加密后无法验证长度 //系统保留词 string[] userNameFilter = setting.UserNameFilter.Trim().Split(','); foreach (string k in userNameFilter) { if (user.UserName.Contains(k)) { r.Success = false; r.Text = "账号中存在系统保留词,请重新设置"; return(r); } } if (setting.EmailCheck) { if (UserView.Exist(string.Format("Email='{0}'", user.Email))) { r.Success = false; r.Text = "您设置的邮箱账号已经在系统中注册,系统不允许重复注册"; return(r); } } //用户默认分组 if (user.Group <= 0) { user.Group = setting.RegisterDefaultGroup; } UserGroup g = UserGroupView.GetModelByID(user.Group.ToS()); user.Enable = g.RegAutoAudit; //注册时间间隔 user.RegIP = WS.GetIP(); var ipusers = UserView.GetModelList(string.Format("RegIP='{0}'", user.RegIP)).OrderByDescending(p => p.RegTime); if (ipusers.Count() > 0) { User _lastUser = ipusers.First(); if (_lastUser != null && (DateTime.Now - _lastUser.RegTime).TotalMinutes < Convert.ToDouble(setting.RegTimeSpan.ToDecimal())) { r.Success = false; r.Text = "您的注册动作过于频繁,请稍后重试!"; return(r); } } user.RegTime = DateTime.Now; user.Cent = setting.RegCent; user.LastLoginIP = WS.GetIP(); user.LastLoginTime = DateTime.Now; UserView.Insert(user); r.Success = true; r.Text = "注册成功!"; return(r); }
protected void Page_Load(object sender, EventArgs e) { int formID = UserGroupView.GetModelByID(WS.RequestString("group")).RegForm; formString = UserFormView.GetModelByID(formID.ToS()).Content; }
/// <summary> /// 用户投稿 /// </summary> /// <param name="news"></param> /// <param name="user"></param> /// <returns></returns> public static Result UserPost(News news, User user) { Result r = new Result(); UserGroup g = UserGroupView.GetModelByID(user.Group.ToS()); int maxPost = 0; try { maxPost = g.MaxPost; } catch { } //验证用户是否允许投稿 if (maxPost <= 0) { r.Success = false; r.Text = "对不起,您没有投稿的权限!"; return(r); } //验证本日投稿数是否已经过多 int todayPost = NewsView.Count(string.Format("AutorID={0}", user.ID)); if (todayPost > maxPost && news.ID <= 0) { r.Success = false; r.Text = "对不起,您本日投稿数量已经达到最大限制,请明天继续!"; return(r); } //验证标题是否为空 if (news.Title.IsNullOrEmpty()) { r.Success = false; r.Text = "文章标题不能为空"; return(r); } //验证栏目 if (news.ClassID <= 0) { r.Success = false; r.Text = "栏目不能为空!"; return(r); } news.Audit = g.PostAotuAudit; news.AutorID = user.ID; if (news.Author.IsNullOrEmpty()) { news.Author = user.UserName; } if (news.ID > 0) { NewsView.Update(news); } else { NewsView.Insert(news); } user.Cent += NewsView.GetNewsClass(news).PostAddCent; UserView.Update(user); r.Success = true; r.Text = "投递成功!"; return(r); }
protected void btn_Save_Click(object sender, EventArgs e) { User u = UserAction.opuser; UserGroup g = UserGroupView.GetModelByID(u.Group.ToS()); if (FileUpload1.FileName.IsNullOrEmpty()) { Js.AlertAndGoback("为提高您文章的排名,请选择一张标题图片"); return; } #region 图片 SysSetting ss = BasePage.SystemSetting; HttpPostedFile file = Request.Files["FileUpload1"]; string FileName = file.FileName.GetFileNameFromPath(); //文件名 string ExtName = file.FileName.GetFileExtNameFromPath(); //扩展名 string NewName = @string.GetGuid() + ExtName; //新文件名 if (!ExtName.Replace(".", "").IsInArray(ss.FileExtNameFilter.Split(','))) { Js.AlertAndGoback("不允许上传此类文件"); return; } if (file.ContentLength > ss.MaxPostFileSize) { Js.AlertAndGoback("文件太大"); return; } string Folder = ss.FileDir + "/" + DateTime.Now.ToString("yyyy-MM-dd") + "/"; //文件目录 string FolderShotCut = Folder + "ShortCut/"; //缩略图目录 string FilePath = Folder + NewName; //文件路径 string FilePath_ShortCut = FolderShotCut + NewName; //缩略图路径 file.SaveAs(Server.MapPath(FilePath), true); ImageHelper.MakeThumbnail(Server.MapPath(FilePath), Server.MapPath(FilePath_ShortCut), 105, 118, "Cut"); FileInfo savedFile = new FileInfo(Server.MapPath(FilePath)); Voodoo.Model.File f = new Voodoo.Model.File(); f.FileDirectory = ss.FileDir; f.FileExtName = ExtName; f.FilePath = FilePath; f.FileSize = (savedFile.Length / 1024).ToInt32(); //f.FileType= f.SmallPath = FilePath_ShortCut; f.UpTime = DateTime.Now; FileView.Insert(f); #endregion News n = new News(); n.Author = txt_Author.Text.TrimDbDangerousChar(); n.AutorID = UserAction.opuser.ID; n.ClassID = ddl_Class.SelectedValue.ToInt32(); n.ClickCount = 0; n.Content = txt_Content.Text.TrimDbDangerousChar(); n.Description = txt_Description.Text.TrimDbDangerousChar(); n.DownCount = 0; n.EnableReply = false; n.FTitle = txtFtitle.Text.TrimDbDangerousChar(); n.KeyWords = txt_Keyword.Text.TrimDbDangerousChar(); n.ModelID = 0; n.NavUrl = ""; n.NewsTime = DateTime.Now; n.SetTop = false; n.Source = txt_Source.Text.TrimDbDangerousChar(); n.Title = txt_Title.Text.TrimDbDangerousChar(); n.TitleColor = "000"; n.TitleImage = FilePath;//上传图片 n.ZtID = 0; n.Audit = g.PostAotuAudit; n.FileForder = DateTime.Now.ToString("yyyy-MM-dd"); n.ID = WS.RequestInt("id"); Result r = NewsAction.UserPost(n, UserAction.opuser); if (r.Success) { Js.AlertAndChangUrl(r.Text, "PostList.aspx"); } else { Js.AlertAndGoback(r.Text); } }