private void DelUserInfo_Click(object sender, EventArgs e) { if (base.CheckCookie()) { int uid = DNTRequest.GetInt("uid", -1); if (this.AllowDeleteUser(this.userid, uid)) { bool delposts = this.deltype.SelectedValue.IndexOf("1") < 0; bool delpms = this.deltype.SelectedValue.IndexOf("2") < 0; User user = XUser.FindByID(uid); if (user.Delete(delposts, delpms)) { Sync.DeleteUsers(uid.ToString(), ""); Avatars.DeleteAvatar(uid.ToString()); XForum.UpdateForumsFieldModerators(this.userName.Text); Online.DeleteUserByUid(this.userInfo.ID); AdminVisitLog.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "后台删除用户", "用户名:" + this.userName.Text); base.RegisterStartupScript("PAGE", "window.location.href='usergrid.aspx?condition=" + Request["condition"] + "';"); return; } base.RegisterStartupScript("", "<script>alert('操作失败');window.location.href='usergrid.aspx?condition=" + Request["condition"] + "';</script>"); return; } else { base.RegisterStartupScript("", "<script>alert('操作失败,你要删除的用户是创始人用户或是其它管理员,因此不能删除!');window.location.href='usergrid.aspx?condition=" + Request["condition"] + "';</script>"); } } }
private void DelUserInfo_Click(object sender, EventArgs e) { #region 除指定用户信息 if (this.CheckCookie()) { int uid = DNTRequest.GetInt("uid", -1); if (!AllowEditUserInfo(uid, true)) { return; } if (AllowDeleteUser(this.userid, uid)) { bool delpost = !(deltype.SelectedValue.IndexOf("1") >= 0); bool delpms = !(deltype.SelectedValue.IndexOf("2") >= 0); if (SpacePluginProvider.GetInstance() != null) { SpacePluginProvider.GetInstance().Delete(uid); } if (AlbumPluginProvider.GetInstance() != null) { AlbumPluginProvider.GetInstance().Delete(uid); } if (AdminUsers.DelUserAllInf(uid, delpost, delpms)) { //删除用户同步 Discuz.Forum.Sync.DeleteUsers(uid.ToString(), ""); //ManyouApplications.AddUserLog(uid, UserLogActionEnum.Delete); //删除该用户头像 Avatars.DeleteAvatar(uid.ToString()); AdminUsers.UpdateForumsFieldModerators(userName.Text); OnlineUsers.DeleteUserByUid(userInfo.Uid); //移除该用户的在线信息,使之退出 AdminVistLogs.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "后台删除用户", "用户名:" + userName.Text); base.RegisterStartupScript("PAGE", "window.location.href='global_usergrid.aspx?condition=" + DNTRequest.GetString("condition") + "';"); } else { base.RegisterStartupScript("", "<script>alert('操作失败');window.location.href='global_usergrid.aspx?condition=" + DNTRequest.GetString("condition") + "';</script>"); } } else { base.RegisterStartupScript("", "<script>alert('操作失败,你要删除的用户是创始人用户或是其它管理员,因此不能删除!');window.location.href='global_usergrid.aspx?condition=" + DNTRequest.GetString("condition") + "';</script>"); } } #endregion }
private void DelUserInfo_Click(object sender, EventArgs e) { if (base.CheckCookie()) { int @int = DNTRequest.GetInt("uid", -1); if (!this.AllowEditUserInfo(@int, true)) { return; } if (this.AllowDeleteUser(this.userid, @int)) { bool delposts = this.deltype.SelectedValue.IndexOf("1") < 0; bool delpms = this.deltype.SelectedValue.IndexOf("2") < 0; if (SpacePluginProvider.GetInstance() != null) { SpacePluginProvider.GetInstance().Delete(@int); } if (AlbumPluginProvider.GetInstance() != null) { AlbumPluginProvider.GetInstance().Delete(@int); } if (AdminUsers.DelUserAllInf(@int, delposts, delpms)) { Sync.DeleteUsers(@int.ToString(), ""); Avatars.DeleteAvatar(@int.ToString()); AdminUsers.UpdateForumsFieldModerators(this.userName.Text); OnlineUsers.DeleteUserByUid(this.userInfo.ID); AdminVisitLog.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "后台删除用户", "用户名:" + this.userName.Text); base.RegisterStartupScript("PAGE", "window.location.href='global_usergrid.aspx?condition=" + Request["condition"] + "';"); return; } base.RegisterStartupScript("", "<script>alert('操作失败');window.location.href='global_usergrid.aspx?condition=" + Request["condition"] + "';</script>"); return; } else { base.RegisterStartupScript("", "<script>alert('操作失败,你要删除的用户是创始人用户或是其它管理员,因此不能删除!');window.location.href='global_usergrid.aspx?condition=" + Request["condition"] + "';</script>"); } } }
private void SaveUserInfo_Click(object sender, EventArgs e) { #region 保存用户信息 if (this.CheckCookie()) { int uid = DNTRequest.GetInt("uid", -1); string errorInfo = ""; if (!AllowEditUserInfo(uid, true)) { return; } if (userName.Text != ViewState["username"].ToString()) { if (AdminUsers.GetUserId(userName.Text) > 0) { base.RegisterStartupScript("", "<script>alert('您所输入的用户名已被使用过, 请输入其他的用户名!');</script>"); return; } } if (userName.Text == "") { base.RegisterStartupScript("", "<script>alert('用户名不能为空!');</script>"); return; } if (groupid.SelectedValue == "0") { base.RegisterStartupScript("", "<script>alert('您未选中任何用户组!');</script>"); return; } userInfo = AdminUsers.GetUserInfo(uid); userInfo.Username = userName.Text; userInfo.Nickname = nickname.Text; userInfo.Accessmasks = Convert.ToInt32(accessmasks.SelectedValue); //当用户组发生变化时则相应更新用户的管理组字段 if (userInfo.Groupid.ToString() != groupid.SelectedValue) { userInfo.Adminid = UserGroups.GetUserGroupInfo(int.Parse(groupid.SelectedValue)).Radminid; } //userInfo.Avatarshowid = 0; if ((bday.Text == "0000-00-00") || (bday.Text == "0000-0-0") | (bday.Text.Trim() == "")) { userInfo.Bday = ""; } else { if (!Utils.IsDateString(bday.Text.Trim())) { base.RegisterStartupScript("", "<script>alert('用户生日不是有效的日期型数据!');</script>"); return; } else { userInfo.Bday = bday.Text; } } if (!Users.ValidateEmail(email.Text, uid)) { base.RegisterStartupScript("", "<script>alert('当前用户的邮箱地址已被使用过, 请输入其他的邮箱!');</script>"); return; } userInfo.Email = email.Text; userInfo.Gender = Convert.ToInt32(gender.SelectedValue); //userInfo.Groupexpiry = Convert.ToInt32(groupexpiry.Text);后台操作为永久禁言和永久禁访 userInfo.Groupexpiry = 0; userInfo.Extgroupids = extgroupids.GetSelectString(","); if ((groupid.SelectedValue != "1") && (userInfo.Uid == BaseConfigs.GetFounderUid)) { base.RegisterStartupScript("", "<script>alert('创始人的所属用户组不能被修改为其它组!');window.location.href='global_edituser.aspx?uid=" + DNTRequest.GetString("uid") + "';</script>"); return; } userInfo.Groupid = Convert.ToInt32(groupid.SelectedValue); userInfo.Invisible = Convert.ToInt32(invisible.SelectedValue); userInfo.Joindate = joindate.Text; userInfo.Lastactivity = lastactivity.Text; userInfo.Lastip = lastip.Text; userInfo.Lastpost = lastpost.Text; userInfo.Lastvisit = lastvisit.Text; userInfo.Newpm = Convert.ToInt32(newpm.SelectedValue); userInfo.Newsletter = (ReceivePMSettingType)GetNewsLetter(); userInfo.Oltime = Convert.ToInt32(oltime.Text); userInfo.Pageviews = Convert.ToInt32(pageviews.Text); userInfo.Pmsound = Convert.ToInt32(pmsound.Text); userInfo.Posts = Convert.ToInt32(posts.Text); userInfo.Ppp = Convert.ToInt32(ppp.Text); userInfo.Regip = regip.Text; userInfo.Digestposts = Convert.ToInt32(digestposts.Text); if (secques.SelectedValue == "1") { userInfo.Secques = ""; //清空安全码 } userInfo.Showemail = Convert.ToInt32(showemail.SelectedValue); userInfo.Sigstatus = Convert.ToInt32(sigstatus.SelectedValue); userInfo.Templateid = Convert.ToInt32(templateid.SelectedValue); userInfo.Tpp = Convert.ToInt32(tpp.Text); if (Utils.IsNumeric(extcredits1.Text.Replace("-", ""))) { userInfo.Extcredits1 = float.Parse(extcredits1.Text); } else { base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>"); return; } if (Utils.IsNumeric(extcredits2.Text.Replace("-", ""))) { userInfo.Extcredits2 = float.Parse(extcredits2.Text); } else { base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>"); return; } if (Utils.IsNumeric(extcredits3.Text.Replace("-", ""))) { userInfo.Extcredits3 = float.Parse(extcredits3.Text); } else { base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>"); return; } if (Utils.IsNumeric(extcredits4.Text.Replace("-", ""))) { userInfo.Extcredits4 = float.Parse(extcredits4.Text); } else { base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>"); return; } if (Utils.IsNumeric(extcredits5.Text.Replace("-", ""))) { userInfo.Extcredits5 = float.Parse(extcredits5.Text); } else { base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>"); return; } if (Utils.IsNumeric(extcredits6.Text.Replace("-", ""))) { userInfo.Extcredits6 = float.Parse(extcredits6.Text); } else { base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>"); return; } if (Utils.IsNumeric(extcredits7.Text.Replace("-", ""))) { userInfo.Extcredits7 = float.Parse(extcredits7.Text); } else { base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>"); return; } if (Utils.IsNumeric(extcredits8.Text.Replace("-", ""))) { userInfo.Extcredits8 = float.Parse(extcredits8.Text); } else { base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>"); return; } //根据公式计算用户的总积分,并更新 userInfo.Credits = CreditsFacade.GetUserCreditsByUserInfo(userInfo); //判断用户组是否为积分用户组。如果是的话,就用当前积分更新。 if (UserGroups.IsCreditUserGroup(userInfo.Groupid)) { userInfo.Groupid = CreditsFacade.GetCreditsUserGroupId(userInfo.Credits).Groupid; } //用户扩展信息 userInfo.Website = website.Text; userInfo.Icq = icq.Text; userInfo.Qq = qq.Text; userInfo.Yahoo = yahoo.Text; userInfo.Msn = msn.Text; userInfo.Skype = skype.Text; userInfo.Location = location.Text; userInfo.Customstatus = customstatus.Text; //userInfo.Avatar = avatar.Text; //userInfo.Avatarheight = Convert.ToInt32(avatarheight.Text); //userInfo.Avatarwidth = Convert.ToInt32(avatarwidth.Text); userInfo.Bio = bio.Text; if (signature.Text.Length > UserGroups.GetUserGroupInfo(userInfo.Groupid).Maxsigsize) { errorInfo = "更新的签名长度超过 " + UserGroups.GetUserGroupInfo(userInfo.Groupid).Maxsigsize + " 字符的限制,未能更新。"; } else { userInfo.Signature = signature.Text; //签名UBB转换HTML PostpramsInfo _postpramsinfo = new PostpramsInfo(); _postpramsinfo.Showimages = UserGroups.GetUserGroupInfo(userInfo.Groupid).Allowsigimgcode; _postpramsinfo.Sdetail = signature.Text; userInfo.Sightml = UBB.UBBToHTML(_postpramsinfo); } userInfo.Realname = realname.Text; userInfo.Idcard = idcard.Text; userInfo.Mobile = mobile.Text; userInfo.Phone = phone.Text; userInfo.Medals = DNTRequest.GetString("medalid"); if (IsEditUserName.Checked && userName.Text != ViewState["username"].ToString()) { AdminUsers.UserNameChange(userInfo, ViewState["username"].ToString()); //用户重命名同步 Discuz.Forum.Sync.RenameUser(userInfo.Uid, ViewState["username"].ToString(), userInfo.Username, ""); } if (AdminUsers.UpdateUserAllInfo(userInfo)) { OnlineUsers.DeleteUserByUid(userInfo.Uid); //移除该用户的在线信息,使之重建在线表信息 if (ViewState["Groupid"].ToString() != userInfo.Groupid.ToString()) { if (userInfo.Groupid == 4) { if (AlbumPluginProvider.GetInstance() != null) { AlbumPluginProvider.GetInstance().Ban(userInfo.Uid); } if (SpacePluginProvider.GetInstance() != null) { SpacePluginProvider.GetInstance().Ban(userInfo.Uid); } } else { if (AlbumPluginProvider.GetInstance() != null) { AlbumPluginProvider.GetInstance().UnBan(userInfo.Uid); } if (SpacePluginProvider.GetInstance() != null) { SpacePluginProvider.GetInstance().UnBan(userInfo.Uid); } } } //if (userName.Text != ViewState["username"].ToString()) //{ // AdminUsers.UserNameChange(userInfo, ViewState["username"].ToString()); //} //删除头像 if (delavart.Checked) { Avatars.DeleteAvatar(userInfo.Uid.ToString()); } AdminVistLogs.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "后台编辑用户", "用户名:" + userName.Text); if (errorInfo == "") { base.RegisterStartupScript("PAGE", "window.location.href='global_usergrid.aspx?condition=" + DNTRequest.GetString("condition") + "';"); } else { base.RegisterStartupScript("PAGE", "alert('" + errorInfo + "');window.location.href='global_usergrid.aspx?condition=" + DNTRequest.GetString("condition") + "';"); } } else { base.RegisterStartupScript("", "<script>alert('操作失败');window.location.href='global_usergrid.aspx?condition=" + DNTRequest.GetString("condition") + "';</script>"); } } #endregion }
private void SaveUserInfo_Click(object sender, EventArgs e) { if (base.CheckCookie()) { int @int = DNTRequest.GetInt("uid", -1); string text = ""; if (!this.AllowEditUserInfo(@int, true)) { return; } if (this.userName.Text != this.ViewState["username"].ToString() && Users.GetUserId(this.userName.Text) > 0) { base.RegisterStartupScript("", "<script>alert('您所输入的用户名已被使用过, 请输入其他的用户名!');</script>"); return; } if (this.userName.Text == "") { base.RegisterStartupScript("", "<script>alert('用户名不能为空!');</script>"); return; } if (this.groupid.SelectedValue == "0") { base.RegisterStartupScript("", "<script>alert('您未选中任何用户组!');</script>"); return; } this.userInfo = Users.GetUserInfo(@int); this.userInfo.Name = this.userName.Text; this.userInfo.NickName = this.nickname.Text; this.userInfo.AccessMasks = Convert.ToInt32(this.accessmasks.SelectedValue); if (this.userInfo.GroupID.ToString() != this.groupid.SelectedValue) { this.userInfo.AdminID = UserGroup.FindByID(int.Parse(this.groupid.SelectedValue)).RadminID; } if (this.bday.Text == "0000-00-00" || (this.bday.Text == "0000-0-0" | this.bday.Text.Trim() == "")) { this.userInfo.Bday = ""; } else { if (!Utils.IsDateString(this.bday.Text.Trim())) { base.RegisterStartupScript("", "<script>alert('用户生日不是有效的日期型数据!');</script>"); return; } this.userInfo.Bday = this.bday.Text; } if (!Users.ValidateEmail(this.email.Text, @int)) { base.RegisterStartupScript("", "<script>alert('当前用户的邮箱地址已被使用过, 请输入其他的邮箱!');</script>"); return; } this.userInfo.Email = this.email.Text; this.userInfo.Gender = Convert.ToInt32(this.gender.SelectedValue); this.userInfo.GroupExpiry = 0; this.userInfo.ExtGroupIds = this.extgroupids.GetSelectString(","); if (this.groupid.SelectedValue != "1" && this.userInfo.ID == BaseConfigs.GetFounderUid) { base.RegisterStartupScript("", "<script>alert('创始人的所属用户组不能被修改为其它组!');window.location.href='global_edituser.aspx?uid=" + Request["uid"] + "';</script>"); return; } this.userInfo.GroupID = Convert.ToInt32(this.groupid.SelectedValue); this.userInfo.Invisible = Convert.ToInt32(this.invisible.SelectedValue); this.userInfo.JoinDate = DateTime.Parse(this.joindate.Text); this.userInfo.LastActivity = DateTime.Parse(this.lastactivity.Text); this.userInfo.LastIP = this.lastip.Text; this.userInfo.LastPost = DateTime.Parse(this.lastpost.Text); this.userInfo.LastVisit = DateTime.Parse(this.lastvisit.Text); this.userInfo.Newpm = Convert.ToInt32(this.newpm.SelectedValue); //this.userInfo.NewsLetter = (ReceivePMSettingType)this.GetNewsLetter(); this.userInfo.NewsLetter = this.GetNewsLetter(); this.userInfo.OLTime = Convert.ToInt32(this.oltime.Text); this.userInfo.PageViews = Convert.ToInt32(this.pageviews.Text); this.userInfo.Pmsound = Convert.ToInt32(this.pmsound.Text); this.userInfo.Posts = Convert.ToInt32(this.posts.Text); this.userInfo.Ppp = Convert.ToInt32(this.ppp.Text); this.userInfo.RegIP = this.regip.Text; this.userInfo.DigestPosts = Convert.ToInt32(this.digestposts.Text); if (this.secques.SelectedValue == "1") { this.userInfo.Secques = ""; } this.userInfo.ShowEmail = Convert.ToInt32(this.showemail.SelectedValue); this.userInfo.Sigstatus = Convert.ToInt32(this.sigstatus.SelectedValue); this.userInfo.TemplateID = Convert.ToInt32(this.templateid.SelectedValue); this.userInfo.Tpp = Convert.ToInt32(this.tpp.Text); if (!Utils.IsNumeric(this.extcredits1.Text.Replace("-", ""))) { base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>"); return; } this.userInfo.ExtCredits1 = float.Parse(this.extcredits1.Text); if (!Utils.IsNumeric(this.extcredits2.Text.Replace("-", ""))) { base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>"); return; } this.userInfo.ExtCredits2 = float.Parse(this.extcredits2.Text); if (!Utils.IsNumeric(this.extcredits3.Text.Replace("-", ""))) { base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>"); return; } this.userInfo.ExtCredits3 = float.Parse(this.extcredits3.Text); if (!Utils.IsNumeric(this.extcredits4.Text.Replace("-", ""))) { base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>"); return; } this.userInfo.ExtCredits4 = float.Parse(this.extcredits4.Text); if (!Utils.IsNumeric(this.extcredits5.Text.Replace("-", ""))) { base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>"); return; } this.userInfo.ExtCredits5 = float.Parse(this.extcredits5.Text); if (!Utils.IsNumeric(this.extcredits6.Text.Replace("-", ""))) { base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>"); return; } this.userInfo.ExtCredits6 = float.Parse(this.extcredits6.Text); if (!Utils.IsNumeric(this.extcredits7.Text.Replace("-", ""))) { base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>"); return; } this.userInfo.ExtCredits7 = float.Parse(this.extcredits7.Text); if (!Utils.IsNumeric(this.extcredits8.Text.Replace("-", ""))) { base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>"); return; } this.userInfo.ExtCredits8 = float.Parse(this.extcredits8.Text); this.userInfo.Credits = CreditsFacade.GetUserCreditsByUserInfo(this.userInfo); //if (UserGroups.IsCreditUserGroup(this.userInfo.GroupID)) if (userInfo.Group.IsCreditUserGroup) { var g = CreditsFacade.GetCreditsUserGroupId((float)this.userInfo.Credits); this.userInfo.GroupID = g.ID; userInfo.Group = g; } var uf = userInfo.Field; uf.Website = this.website.Text; uf.Icq = this.icq.Text; uf.qq = this.qq.Text; uf.Yahoo = this.yahoo.Text; uf.Msn = this.msn.Text; uf.Skype = this.skype.Text; uf.Location = this.location.Text; uf.Customstatus = this.customstatus.Text; uf.Bio = this.bio.Text; if (this.signature.Text.Length > userInfo.Group.MaxSigSize) { text = "更新的签名长度超过 " + userInfo.Group.MaxSigSize + " 字符的限制,未能更新。"; } else { uf.Signature = this.signature.Text; PostpramsInfo postpramsInfo = new PostpramsInfo(); postpramsInfo.Showimages = userInfo.Group.AllowSigimgCode ? 1 : 0; postpramsInfo.Sdetail = this.signature.Text; uf.Sightml = UBB.UBBToHTML(postpramsInfo); } uf.RealName = this.realname.Text; uf.Idcard = this.idcard.Text; uf.Mobile = this.mobile.Text; uf.Phone = this.phone.Text; uf.Medals = Request["medalid"]; if (this.IsEditUserName.Checked && this.userName.Text != this.ViewState["username"].ToString()) { throw new NotImplementedException("UserNameChange"); //AdminUsers.UserNameChange(this.userInfo, this.ViewState["username"].ToString()); Sync.RenameUser(this.userInfo.ID, this.ViewState["username"].ToString(), this.userInfo.Name, ""); } if (userInfo.Save() > 0) { OnlineUsers.DeleteUserByUid(this.userInfo.ID); if (this.ViewState["GroupID"].ToString() != this.userInfo.GroupID.ToString()) { if (this.userInfo.GroupID == 4) { if (AlbumPluginProvider.GetInstance() != null) { AlbumPluginProvider.GetInstance().Ban(this.userInfo.ID); } if (SpacePluginProvider.GetInstance() != null) { SpacePluginProvider.GetInstance().Ban(this.userInfo.ID); } } else { if (AlbumPluginProvider.GetInstance() != null) { AlbumPluginProvider.GetInstance().UnBan(this.userInfo.ID); } if (SpacePluginProvider.GetInstance() != null) { SpacePluginProvider.GetInstance().UnBan(this.userInfo.ID); } } } if (this.delavart.Checked) { Avatars.DeleteAvatar(this.userInfo.ID.ToString()); } AdminVisitLog.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "后台编辑用户", "用户名:" + this.userName.Text); if (text == "") { base.RegisterStartupScript("PAGE", "window.location.href='global_usergrid.aspx?condition=" + Request["condition"] + "';"); return; } base.RegisterStartupScript("PAGE", "alert('" + text + "');window.location.href='global_usergrid.aspx?condition=" + Request["condition"] + "';"); return; } else { base.RegisterStartupScript("", "<script>alert('操作失败');window.location.href='global_usergrid.aspx?condition=" + Request["condition"] + "';</script>"); } } }