private void StopTalk_Click(object sender, EventArgs e) { if (Request["uid"] != "") { string text = "0" + Request["uid"]; string[] array = text.Split(','); string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string s = array2[i]; int num = int.Parse(s); if (num != 0) { if (SpacePluginProvider.GetInstance() != null) { SpacePluginProvider.GetInstance().Ban(num); } if (AlbumPluginProvider.GetInstance() != null) { AlbumPluginProvider.GetInstance().Ban(num); } OnlineUsers.DeleteUserByUid(num); } } Users.UpdateUserToStopTalkGroup(text); base.RegisterStartupScript("PAGE", "window.location.href='global_usergrid.aspx';"); return; } base.RegisterStartupScript("", "<script>alert('请选择相应的用户!');window.location.href='global_usergrid.aspx';</script>"); }
private void StopTalk_Click(object sender, EventArgs e) { #region 禁言 if (DNTRequest.GetString("uid") != "") { string uidlist = "0" + DNTRequest.GetString("uid"); string[] uids = uidlist.Split(','); foreach (string uid in uids) { int iuid = int.Parse(uid); if (iuid != 0) { OnlineUsers.DeleteUserByUid(iuid); } } DatabaseProvider.GetInstance().SetStopTalkUser(uidlist); base.RegisterStartupScript("PAGE", "window.location.href='global_usergrid.aspx';"); } else { base.RegisterStartupScript("", "<script>alert('请选择相应的用户!');window.location.href='global_usergrid.aspx';</script>"); } #endregion }
/// <summary>从门户后台管理自动登录</summary> private bool AutoLogin(string returnUrl) { var token = this.Request.QueryString["token"]; if (token.IsNullOrEmpty()) { return(false); } var userId = this.Context.GetPortalMgmtUserId(token); if (userId.IsNullOrEmpty()) { return(false); } var nUserId = 0; if (!int.TryParse(userId, out nUserId)) { return(false); } var user = this.Context.GetPortalMgmtUser(nUserId); if (user == null) { return(false); } var admin = Users.GetUserInfo(user.USERNAME); var context = this.Context.GetHttpContextWrapper(); var config = GeneralConfigs.GetConfig(); if (admin == null) { var principal = new PKSPrincipal(); var identity = new PKSIdentity(); identity.Name = user.USERNAME; identity.Email = user.EMAIL; identity.PhoneNumber = user.PHONENUMBER; principal.Identity = identity; admin = context.CreateUser(config, principal, true); } else if (admin.Adminid != 1 || admin.Groupid != 1) { admin.Adminid = 1; admin.Groupid = 1; admin.Authtime = Utils.GetDateTime(); AdminUsers.UpdateUserAllInfo(admin); //移除该用户的在线信息,使之重建在线表信息 OnlineUsers.DeleteUserByUid(admin.Uid); } var adminGroup = AdminUserGroups.AdminGetUserGroupInfo(admin.Groupid); ForumUtils.WriteUserCookie(admin.Uid, ForumExtension.ExpireMinutes, config.Passwordkey); this.Context.AddAdminCookie(config, admin.Uid, admin.Password, admin.Secques, ForumExtension.ExpireMinutes); SoftInfo.LoadSoftInfo(); AdminVistLogs.InsertLog(admin.Uid, admin.Username, admin.Groupid, adminGroup.Grouptitle, DNTRequest.GetIP(), "后台管理员登陆", ""); return(true); }
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 StopTalk_Click(object sender, EventArgs e) { #region 设置禁言 if (this.CheckCookie()) { userInfo = AdminUsers.GetUserInfo(DNTRequest.GetInt("uid", -1)); if (!AllowEditUserInfo(DNTRequest.GetInt("uid", -1), true)) { return; } if (ViewState["Groupid"].ToString() != "4") //当用户不是系统禁言组时 { if (userInfo.Uid > 1) //判断是不是当前uid是不是系统初始化时生成的uid { if (AlbumPluginProvider.GetInstance() != null) { AlbumPluginProvider.GetInstance().Ban(userInfo.Uid); } if (SpacePluginProvider.GetInstance() != null) { SpacePluginProvider.GetInstance().Ban(userInfo.Uid); } Users.UpdateUserToStopTalkGroup(userInfo.Uid.ToString()); base.RegisterStartupScript("PAGE", "window.location.href='global_edituser.aspx?uid=" + userInfo.Uid + "&condition=" + DNTRequest.GetString("condition") + "';"); } else { base.RegisterStartupScript("", "<script>alert('操作失败,你要禁言的用户是系统初始化时的用户,因此不能操作!');window.location.href='global_edituser.aspx?uid=" + userInfo.Uid + "&condition=" + DNTRequest.GetString("condition") + "';</script>"); } } else { if (CreditsFacade.GetCreditsUserGroupId(0) != null) { int tmpGroupID = CreditsFacade.GetCreditsUserGroupId(userInfo.Credits).Groupid; Users.UpdateUserGroup(userInfo.Uid, tmpGroupID); base.RegisterStartupScript("PAGE", "window.location.href='global_edituser.aspx?uid=" + userInfo.Uid + "&condition=" + DNTRequest.GetString("condition") + "';"); } else { base.RegisterStartupScript("", "<script>alert('操作失败,系统未能找到合适的用户组来调整当前用户所处的组!');window.location.href='global_edituser.aspx?uid=" + userInfo.Uid + "&condition=" + DNTRequest.GetString("condition") + "';</script>"); } } OnlineUsers.DeleteUserByUid(userInfo.Uid); } #endregion }
private void StopTalk_Click(object sender, EventArgs e) { if (base.CheckCookie()) { this.userInfo = Users.GetUserInfo(DNTRequest.GetInt("uid", -1)); if (!this.AllowEditUserInfo(DNTRequest.GetInt("uid", -1), true)) { return; } if (this.ViewState["GroupID"].ToString() != "4") { if (this.userInfo.ID > 1) { if (AlbumPluginProvider.GetInstance() != null) { AlbumPluginProvider.GetInstance().Ban(this.userInfo.ID); } if (SpacePluginProvider.GetInstance() != null) { SpacePluginProvider.GetInstance().Ban(this.userInfo.ID); } Users.UpdateUserToStopTalkGroup(this.userInfo.ID.ToString()); base.RegisterStartupScript("PAGE", "window.location.href='global_edituser.aspx?uid=" + this.userInfo.ID + "&condition=" + Request["condition"] + "';"); } else { base.RegisterStartupScript("", "<script>alert('操作失败,你要禁言的用户是系统初始化时的用户,因此不能操作!');window.location.href='global_edituser.aspx?uid=" + this.userInfo.ID + "&condition=" + Request["condition"] + "';</script>"); } } else { if (CreditsFacade.GetCreditsUserGroupId(0f) != null) { int groupId = CreditsFacade.GetCreditsUserGroupId((float)this.userInfo.Credits).ID; Users.UpdateUserGroup(this.userInfo.ID, groupId); base.RegisterStartupScript("PAGE", "window.location.href='global_edituser.aspx?uid=" + this.userInfo.ID + "&condition=" + Request["condition"] + "';"); } else { base.RegisterStartupScript("", "<script>alert('操作失败,系统未能找到合适的用户组来调整当前用户所处的组!');window.location.href='global_edituser.aspx?uid=" + this.userInfo.ID + "&condition=" + Request["condition"] + "';</script>"); } } OnlineUsers.DeleteUserByUid(this.userInfo.ID); } }
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 }
protected override void ShowPage() { pagetitle = "用户控制面板"; if (!IsLogin()) { return; } if (DNTRequest.IsPost()) { if (ForumUtils.IsCrossSitePost()) { AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。"); return; } ValidateInfo(); if (IsErr()) { return; } if (page_err == 0) { UserInfo oldUserInfo = Users.GetUserInfo(userid); UserInfo userInfo = oldUserInfo.Clone(); //需要判断签名是否修改过 sig = oldUserInfo.Sightml; userInfo.Uid = userid; userInfo.Username = username; userInfo.Nickname = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("nickname"))); userInfo.Gender = DNTRequest.GetInt("gender", 0); userInfo.Realname = DNTRequest.GetHtmlEncodeString("realname"); userInfo.Idcard = DNTRequest.GetHtmlEncodeString("idcard"); userInfo.Mobile = DNTRequest.GetHtmlEncodeString("mobile"); userInfo.Phone = DNTRequest.GetHtmlEncodeString("phone"); userInfo.Email = DNTRequest.GetHtmlEncodeString("email").Trim().ToLower(); if (userInfo.Email != oldUserInfo.Email && !Users.ValidateEmail(userInfo.Email, userid)) { AddErrLine("Email: \"" + userInfo.Email + "\" 已经被其它用户注册使用"); return; } userInfo.Bday = DNTRequest.GetHtmlEncodeString("bday"); userInfo.Showemail = DNTRequest.GetInt("showemail", 1); if (DNTRequest.GetString("website").IndexOf(".") > -1 && !DNTRequest.GetString("website").ToLower().StartsWith("http")) { userInfo.Website = Utils.HtmlEncode("http://" + DNTRequest.GetString("website")); } else { userInfo.Website = DNTRequest.GetHtmlEncodeString("website"); } userInfo.Icq = DNTRequest.GetHtmlEncodeString("icq"); userInfo.Qq = DNTRequest.GetHtmlEncodeString("qq"); userInfo.Yahoo = DNTRequest.GetHtmlEncodeString("yahoo"); userInfo.Msn = DNTRequest.GetHtmlEncodeString("msn"); userInfo.Skype = DNTRequest.GetHtmlEncodeString("skype"); userInfo.Location = DNTRequest.GetHtmlEncodeString("location"); userInfo.Bio = ForumUtils.BanWordFilter(DNTRequest.GetHtmlEncodeString("bio")); PostpramsInfo postPramsInfo = new PostpramsInfo(); postPramsInfo.Usergroupid = usergroupid; postPramsInfo.Attachimgpost = config.Attachimgpost; postPramsInfo.Showattachmentpath = config.Showattachmentpath; postPramsInfo.Hide = 0; postPramsInfo.Price = 0; //获取提交的内容并进行脏字和Html处理 postPramsInfo.Sdetail = ForumUtils.BanWordFilter(DNTRequest.GetHtmlEncodeString("signature"));; postPramsInfo.Smileyoff = 1; postPramsInfo.Bbcodeoff = 1 - usergroupinfo.Allowsigbbcode; postPramsInfo.Parseurloff = 1; postPramsInfo.Showimages = usergroupinfo.Allowsigimgcode; postPramsInfo.Allowhtml = 0; postPramsInfo.Signature = 1; postPramsInfo.Smiliesinfo = Smilies.GetSmiliesListWithInfo(); postPramsInfo.Customeditorbuttoninfo = null; postPramsInfo.Smiliesmax = config.Smiliesmax; postPramsInfo.Signature = 1; userInfo.Sightml = UBB.UBBToHTML(postPramsInfo); if (sig != userInfo.Sightml) { Sync.UpdateSignature(userid, userInfo.Username, userInfo.Sightml, ""); } if (userInfo.Sightml.Length >= 1000) { AddErrLine("您的签名转换后超出系统最大长度, 请返回修改"); return; } userInfo.Signature = postPramsInfo.Sdetail; userInfo.Sigstatus = DNTRequest.GetInt("sigstatus", 0) != 0 ? 1 : 0; if (CheckModified(oldUserInfo, userInfo)) { Users.UpdateUserProfile(userInfo); Sync.UpdateProfile(userInfo.Uid, userInfo.Username, ""); } OnlineUsers.DeleteUserByUid(userid); //删除在线表中的信息,使之重建该用户在线表信息 //ManyouApplications.AddUserLog(userid, UserLogActionEnum.Update); ForumUtils.WriteCookie("sigstatus", userInfo.Sigstatus.ToString()); SetUrl("usercpprofile.aspx"); SetMetaRefresh(); SetShowBackLink(true); AddMsgLine("修改个人档案完毕"); } } else { pagename += action == "" ? "" : "?action=" + action; UserInfo userInfo = Users.GetUserInfo(userid);//olid avatarFlashParam = Utils.GetRootUrl(BaseConfigs.GetForumPath) + "images/common/camera.swf?nt=1&inajax=1&appid=" + Utils.MD5(userInfo.Username + userInfo.Password + userInfo.Uid + olid) + "&input=" + DES.Encode(userid + "," + olid, config.Passwordkey) + "&ucapi=" + Utils.UrlEncode(Utils.GetRootUrl(BaseConfigs.GetForumPath) + "tools/ajax.aspx"); avatarImage = Avatars.GetAvatarUrl(userid); } }
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>"); } } }
/// <summary> /// 获取用户id /// </summary> /// <returns></returns> private ShortUserInfo GetShortUserInfo(string postusername, string postpassword, string mobile, string email) { //postpassword = !Utils.StrIsNullOrEmpty(loginauth) ? // DES.Decode(loginauth.Replace("[", "+"), config.Passwordkey) : // DNTRequest.GetString("password"); //postusername = Utils.StrIsNullOrEmpty(postusername) ? DNTRequest.GetString("username") : postusername; int uid = -1; switch (config.Passwordmode) { case 1: //动网兼容模式 { if (config.Secques == 1 && (!Utils.StrIsNullOrEmpty(loginauth) || !loginsubmit)) { uid = Users.CheckDvBbsPasswordAndSecques(postusername, postpassword, DNTRequest.GetFormInt("question", 0), DNTRequest.GetString("answer")); } else { uid = Users.CheckDvBbsPassword(postusername, postpassword); } break; } case 0: //默认模式 { if (config.Secques == 1 && (!Utils.StrIsNullOrEmpty(loginauth) || !loginsubmit)) { uid = Users.CheckPasswordAndSecques(postusername, postpassword, true, DNTRequest.GetFormInt("question", 0), DNTRequest.GetString("answer")); } else { #region 原始登录 //原始的登录 // uid = Users.CheckPassword(postusername, postpassword, true); #endregion #region 现在的登录 //现在的登录 uid = Users.GetUserId(postusername); if (uid > 0) //更新用户手机号、邮箱 { #region 更新用户手机号、邮箱 UserInfo oldUserInfo = Users.GetUserInfo(uid); UserInfo userInfo = oldUserInfo.Clone(); //需要判断签名是否修改过 string sig = oldUserInfo.Sightml; //保存旧的签名 userInfo.Uid = uid; userInfo.Username = postusername; //当前登录的用户名 #region 基本资料 //userInfo.Realname = DNTRequest.GetString("realname"); //userInfo.Gender = DNTRequest.GetInt("gender", 0); //userInfo.Bday = Utils.HtmlEncode(DNTRequest.GetString("bday")); //userInfo.Location = Utils.HtmlEncode(DNTRequest.GetString("location")); //userInfo.Idcard = DNTRequest.GetString("idcard"); //userInfo.Nickname = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("nickname"))); //userInfo.Bio = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("bio"))); #endregion #region 联系方式 userInfo.Mobile = mobile; //userInfo.Phone = DNTRequest.GetString("phone"); userInfo.Email = email; //if (userInfo.Email != oldUserInfo.Email && !Users.ValidateEmail(userInfo.Email, userid)) //{ // AddErrLine("Email: \"" + userInfo.Email + "\" 已经被其它用户注册使用"); // return; //} //userInfo.Showemail = DNTRequest.GetInt("showemail", 1); //if (DNTRequest.GetString("website").IndexOf(".") > -1 && !DNTRequest.GetString("website").ToLower().StartsWith("http")) // userInfo.Website = Utils.HtmlEncode("http://" + DNTRequest.GetString("website")); //else // userInfo.Website = Utils.HtmlEncode(DNTRequest.GetString("website")); //userInfo.Msn = Utils.HtmlEncode(DNTRequest.GetString("msn")); //userInfo.Qq = Utils.HtmlEncode(DNTRequest.GetString("qq")); //userInfo.Skype = Utils.HtmlEncode(DNTRequest.GetString("skype")); //userInfo.Icq = Utils.HtmlEncode(DNTRequest.GetString("icq")); //userInfo.Yahoo = Utils.HtmlEncode(DNTRequest.GetString("yahoo")); #endregion //PostpramsInfo postPramsInfo = new PostpramsInfo(); //postPramsInfo.Usergroupid = usergroupid; //postPramsInfo.Attachimgpost = config.Attachimgpost; //postPramsInfo.Showattachmentpath = config.Showattachmentpath; //postPramsInfo.Hide = 0; //postPramsInfo.Price = 0; ////获取提交的内容并进行脏字和Html处理 ////postPramsInfo.Sdetail = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("signature"))); ; //postPramsInfo.Smileyoff = 1; //postPramsInfo.Bbcodeoff = 1 - usergroupinfo.Allowsigbbcode; //postPramsInfo.Parseurloff = 1; //postPramsInfo.Showimages = usergroupinfo.Allowsigimgcode; //postPramsInfo.Allowhtml = 0; //postPramsInfo.Signature = 1; //postPramsInfo.Smiliesinfo = Smilies.GetSmiliesListWithInfo(); //postPramsInfo.Customeditorbuttoninfo = null; //postPramsInfo.Smiliesmax = config.Smiliesmax; //postPramsInfo.Signature = 1; //userInfo.Sightml = UBB.UBBToHTML(postPramsInfo); //if (sig != userInfo.Sightml) //{ // Sync.UpdateSignature(userid, userInfo.Username, userInfo.Sightml, ""); //} //if (userInfo.Sightml.Length >= 1000) //{ // AddErrLine("您的签名转换后超出系统最大长度, 请返回修改"); // return; //} //userInfo.Signature = postPramsInfo.Sdetail; //userInfo.Sigstatus = DNTRequest.GetInt("sigstatus", 0) != 0 ? 1 : 0; if (CheckModified(oldUserInfo, userInfo)) { Users.UpdateUserProfile(userInfo); Sync.UpdateProfile(userInfo.Uid, userInfo.Username, ""); } OnlineUsers.DeleteUserByUid(userid); //删除在线表中的信息,使之重建该用户在线表信息 //ManyouApplications.AddUserLog(userid, UserLogActionEnum.Update); ForumUtils.WriteCookie("sigstatus", userInfo.Sigstatus.ToString()); //SetUrl("usercpprofile.aspx"); //SetMetaRefresh(); //SetShowBackLink(true); //AddMsgLine("修改个人档案完毕"); #endregion } else //注册新用户 { #region 注册新用户 //如果提交了用户注册信息... InviteCodeInfo inviteCode = null; string tmpUserName = postusername; //string email = email; string tmpBday = string.Empty; UserInfo userInfo = CreateUser(tmpUserName, email, tmpBday, mobile); #region 发送欢迎信息 if (config.Welcomemsg == 1) { // 收件箱 PrivateMessageInfo privatemessageinfo = new PrivateMessageInfo(); privatemessageinfo.Message = config.Welcomemsgtxt; privatemessageinfo.Subject = "欢迎您的加入! (请勿回复本信息)"; privatemessageinfo.Msgto = userInfo.Username; privatemessageinfo.Msgtoid = userInfo.Uid; privatemessageinfo.Msgfrom = PrivateMessages.SystemUserName; privatemessageinfo.Msgfromid = 0; privatemessageinfo.New = 1; privatemessageinfo.Postdatetime = Utils.GetDateTime(); privatemessageinfo.Folder = 0; PrivateMessages.CreatePrivateMessage(privatemessageinfo, 0); } #endregion #region 发送同步数据给应用程序 //发送同步数据给应用程序 Sync.UserRegister(userInfo.Uid, userInfo.Username, userInfo.Password, ""); Statistics.ReSetStatisticsCache(); if (inviteCode != null) { Invitation.UpdateInviteCodeSuccessCount(inviteCode.InviteId); if (config.Regstatus == 3) { if (inviteCode.SuccessCount + 1 >= inviteCode.MaxCount) { Invitation.DeleteInviteCode(inviteCode.InviteId); } } } if (config.Regverify == 0) { UserCredits.UpdateUserCredits(userInfo.Uid); ForumUtils.WriteUserCookie(userInfo, -1, config.Passwordkey); OnlineUsers.UpdateAction(olid, UserAction.Register.ActionID, 0, config.Onlinetimeout); } #endregion uid = Users.GetUserId(postusername); #endregion } #endregion } break; } default: //第三方加密验证模式 { return((ShortUserInfo)Users.CheckThirdPartPassword(postusername, postpassword, DNTRequest.GetFormInt("question", 0), DNTRequest.GetString("answer"))); } } if (uid != -1) { Users.UpdateTrendStat(TrendType.Login); } return(uid > 0 ? Users.GetShortUserInfo(uid) : null); }