private void SelectPass_Click(object sender, EventArgs e) { if (base.CheckCookie()) { string uid = Request["uid"]; if (uid != "") { if (CreditsFacade.GetCreditsUserGroupId(0f) != null) { int groupid = CreditsFacade.GetCreditsUserGroupId(0f).ID; //Users.UpdateUserGroupByUidList(groupid, uid); //IUser user = XUser.FindByID(uid.ToInt()); string[] array = uid.Split(','); for (int i = 0; i < array.Length; i++) { string value = array[i]; Int32 id = Convert.ToInt32(value); XUser user = XUser.FindByID(id); user.GroupID = groupid; user.Save(); CreditsFacade.UpdateUserCredits(id); } //Users.ClearUsersAuthstr(uid); XUser.ClearUsersAuthstr(uid); } if (this.sendemail.Checked) { Users.SendEmailForAccountCreateSucceed(uid); } base.RegisterStartupScript("PAGE", "window.location='forum_audituser.aspx';"); return; } base.RegisterStartupScript("", "<script>alert('请选择相应的用户!');window.location='forum_audituser.aspx';</script>"); } }
private void DeleteUser_Click(object sender, EventArgs e) { if (base.CheckCookie()) { string text = Request["uid"].Trim(','); if (text != "") { bool delposts = this.deltype.SelectedValue.IndexOf("1") < 0; bool delpms = this.deltype.SelectedValue.IndexOf("2") < 0; string[] array = text.Split(','); for (int i = 0; i < array.Length; i++) { string text2 = array[i]; if (text2 != "" && this.CheckSponser(Utility.ToInt(text2, 0)) && Utility.ToInt(text2, 0) > 1) { int userid = Utility.ToInt(text2, 0); User user = XUser.FindByID(userid); if (user.Delete(delposts, delpms)) { Sync.DeleteUsers(text2, ""); AdminVisitLog.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "后台删除用户", "用户名:批量用户删除"); 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>"); } }
public static User[] GetUserOnlinetime(String field) { var fi = _.Uid; switch (field.ToLower()) { case "thismonth": fi = _.Thismonth; break; case "total": fi = _.Total; break; default: throw new ArgumentOutOfRangeException("field", "非法参数" + field); //break; } var list = FindAll(null, fi.Desc(), null, 0, 20); var users = new User[list.Count]; for (int i = 0; i < list.Count; i++) { users[i] = User.FindByID(list[i].Uid); //users[i].OLTime = (Int32)list[i][fi]; users[i]["OnlineTime"] = (Int32)list[i][fi]; } return(users); }
public static int BuyTopic(int uid, int tid, int posterid, int price, float netamount) { //if (price > Scoresets.GetMaxIncPerTopic()) Scoresets.GetMaxIncPerTopic(); var user = User.FindByID(uid); if (user == null) { return(-2); } //if (GetUserExtCredits(user, Scoresets.GetTopicAttachCreditsTrans()) < (float)price) return -1; //BBX.Data.Users.BuyTopic(uid, tid, posterid, price, netamount, Scoresets.GetTopicAttachCreditsTrans()); //CreditsFacade.UpdateUserCredits(uid); //CreditsFacade.UpdateUserCredits(posterid); //return BBX.Data.PaymentLogs.CreatePaymentLog(uid, tid, posterid, price, netamount); var log = new PaymentLog(); log.Uid = uid; log.Tid = tid; log.AuthorID = posterid; log.BuyDate = DateTime.Now; log.Amount = (short)price; log.Netamount = (short)netamount; log.Insert(); throw new Exception("移植未完成!"); }
public int AddOnlineUser() { var user = User.FindByID(UserID); if (user != null) { user.OnlineState = 1; user.Save(); } // 避免多线程重复插入 lock (syncLock) { var online = Current; if (online == null) { Insert(); } else { this.ID = online.ID; Update(); } } if (ID > 2147483000) { ResetOnlineList(); } return(ID); }
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>"); } } }
public static MedalsLog Award(Int32 uid, Int32 medalid, Int32 adminuid, String ip, String reason) { var log = MedalsLog.FindByUidAndMid(uid, medalid); if (log == null) { log = new MedalsLog(); } log.Uid = uid; log.Medals = medalid; log.AdminID = adminuid; log.IP = ip; log.Actions = "授予"; log.Reason = reason; log.PostDateTime = DateTime.Now; var user = User.FindByID(uid); if (user != null) { log.UserName = user.ToString(); } user = User.FindByID(adminuid); if (user != null) { log.AdminName = user.ToString(); } log.Insert(); return(log); }
private static void DeleteExpiredOnlineUsers(Object state) { // 如果没有在线用户,则跳过 if (Meta.Count <= 0) { return; } var batSize = 100; // 分批删除在线用户的批大小 var timeOut = GeneralConfigInfo.Current.Onlinetimeout; if (timeOut < 0) { timeOut = -timeOut; } while (true) { using (var trans = Meta.CreateTrans()) { // 查出来一批过期用户 var list = FindAll(_.LastUpdateTime.IsNull() | _.LastUpdateTime < DateTime.Now.AddMinutes(-timeOut), null, null, 0, batSize); // 遍历删除 foreach (var item in list) { // 对于会员,设定最后活跃时间 if (item.UserID != -1) { var user = User.FindByID(item.UserID); if (user != null) { user.OnlineState = 0; if (item.LastUpdateTime > user.LastActivity) { user.LastActivity = item.LastUpdateTime; } user.Save(); } } item.Delete(); } trans.Commit(); // 如果不足批大小,说明后面没有过期在线用户了,删除 if (list.Count < batSize) { break; } } } }
public static void EditBanIp(string[] expiration, string[] hiddenexpiration, string[] hiddenid, int useradminid, int userid) { for (int i = 0; i < expiration.Length; i++) { var uid = Int32.Parse(hiddenid[i]); var user = User.FindByID(uid); if ((useradminid == 1 || userid == user.ID) && expiration[i] != hiddenexpiration[i]) { //BBX.Data.Ips.EditBanIp(hiddenid[i].ToString().ToInt(-1), expiration[i]); var ban = FindByID((Int16)uid); if (ban != null) { ban.Expiration = expiration[i].ToDateTime(); ban.Update(); } } } }
public static void SynchronizeOnlineTime(int uid) { var user = User.FindByID(uid); var olt = FindByUid(uid); if (olt == null) { olt = new OnlineTime(); olt.Total = user.OLTime; olt.LastUpdate = DateTime.Now; olt.Insert(); } else { user.OLTime = olt.Total; user.Save(); } }
public static int DeletePrivateMessages(bool isNew, Int32 postDateTime, string msgFromList, bool lowerUpper, string subject, string message, bool isUpdateUserNewPm) { var exp = _.ID > 0; if (isNew) { exp &= _.New == 0; } if (postDateTime >= 0) { exp &= _.PostDateTime >= DateTime.Now.AddDays(postDateTime); } if (!String.IsNullOrEmpty(msgFromList)) { exp &= _.Msgfrom.In(msgFromList.Split(",")); } if (!String.IsNullOrEmpty(subject)) { exp &= _.Subject.Contains(subject); } if (!String.IsNullOrEmpty(message)) { exp &= _.Message.Contains(message); } var list = FindAll(exp, null, null, 0, 0); list.Delete(); if (isUpdateUserNewPm) { foreach (var item in list) { var user = User.FindByID(item.MsgtoID); if (user != null) { user.Newpm = true; user.Update(); } } } return(list.Count); }
/// <summary>创建短消息</summary> /// <param name="savetosentbox">是否保存到发件箱</param> public void Create(Boolean savetosentbox = false) { this.Insert(); var user = User.FindByID(this.MsgtoID); if (user != null) { user.NewpmCount++; user.Newpm = true; user.Save(); } // 保存到发件箱 if (savetosentbox) { Folder = 1; this.Insert(); } }
private string CombinationUser(string userName, string targetUserName, int targetUid) { string result = ""; if (userName != "" && targetUserName != userName) { int userId = Users.GetUserId(userName); if (userId > 0) { //AdminUsers.CombinationUser(userId, targetUid); User src = XUser.FindByID(userId); User des = XUser.FindByID(targetUid); des.Credits += src.Credits; des.ExtCredits1 += src.ExtCredits1; des.ExtCredits2 += src.ExtCredits2; des.ExtCredits3 += src.ExtCredits3; des.ExtCredits4 += src.ExtCredits4; des.ExtCredits5 += src.ExtCredits5; des.ExtCredits6 += src.ExtCredits6; des.ExtCredits7 += src.ExtCredits7; des.ExtCredits8 += src.ExtCredits8; //Users.UpdateUser(userInfo2); des.Save(); //BBX.Data.Users.CombinationUser(TableList.CurrentTableName, userInfo2, userInfo); des.CombinationFrom(src); src.Delete(true, true); XForum.UpdateForumsFieldModerators(userName); AdminVisitLog.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "合并用户", "把用户" + userName + " 合并到" + targetUserName); } else { result = "用户:" + userName + "不存在!,"; } } return(result); }
void UpdateStatistic(Int32 count) { // 更新各地统计信息 var st = Statistic.Current; st.TotalPost += count; st.Save(); // 更新论坛统计 var fi = XForum.FindByID(Fid); if (fi == null) { throw new ArgumentNullException("Fid", "找不到ID=" + Fid + "的论坛"); } // 所有上级论坛帖子数增加 while (fi != null && fi.ID != 0) { fi.Posts += count; if (fi.LastPost.Date == DateTime.Now.Date) { fi.TodayPosts += count; } else { fi.TodayPosts = 1; } fi.LastTID = Tid; fi.LastTitle = TopicTitle; fi.LastPost = PostDateTime; fi.LastPoster = Poster; fi.LastPosterID = PosterID; fi.Save(); fi = fi.Parent; } // 更新用户统计 var user = User.FindByID(PosterID); if (user == null) { throw new ArgumentNullException("PosterID", "找不到ID=" + PosterID + "的发帖者"); } { user.LastPost = PostDateTime; user.LastPostID = ID; user.LastPostTitle = TopicTitle; user.Posts += count; user.LastActivity = DateTime.Now; user.Save(); } var tp = Topic.FindByID(Tid); if (Invisible == 0 && Layer > 0) { tp.Replies += count; } else if (Layer <= 0) { tp.Replies = 0; } tp.LastPost = PostDateTime; tp.LastPoster = Poster; tp.LastPosterID = PosterID; tp.LastPostID = ID; tp.Save(); }
protected override void ShowPage() { if (this.postid == 0) { base.AddErrLine("指定的主题不存在或已被删除或正在被审核,请返回."); return; } var postInfo = Post.FindByID(this.postid); if (postInfo == null) { base.AddErrLine("指定的主题不存在或已被删除或正在被审核,请返回."); return; } this.ip = postInfo.IP; this.iplocation = IPAddress.Parse(this.ip).GetAddress(); if (this.iplocation == null) { this.iplocation = "(IP数据库文件不存在,无法查询)"; } else { if (string.IsNullOrEmpty(this.iplocation)) { this.iplocation = "没有查询到该用户的地理所在地"; } } var topicInfo = Topic.FindByID(postInfo.Tid); if (topicInfo == null) { base.AddErrLine("不存在的主题ID"); return; } var forumInfo = Forums.GetForumInfo(postInfo.Fid); this.forumname = forumInfo.Name; this.pagetitle = topicInfo.Title; this.forumnav = ForumUtils.UpdatePathListExtname(forumInfo.Pathlist.Trim(), this.config.Extname); var adminGroupInfo = AdminGroup.FindByID(this.usergroupid); if (adminGroupInfo == null || !adminGroupInfo.AllowViewIP) { base.AddErrLine("你没有查看IP的权限"); return; } if (DNTRequest.GetString("action") == "ipban") { if (!adminGroupInfo.AllowBanIP) { base.AddErrLine("你无权禁止用户IP,请返回"); return; } if (Utils.InIPArray(DNTRequest.GetString("ip"), Utils.SplitString(this.config.Ipdenyaccess, "\n"))) { //Users.UpdateUserGroup(postInfo.Posterid, 6); XUser user = XUser.FindByID(postInfo.PosterID); user.GroupID = 6; user.Save(); base.AddErrLine("IP已在列表中存在,无需重复添加"); return; } var cfg = GeneralConfigInfo.Current; cfg.Ipdenyaccess += "\n" + DNTRequest.GetString("ip"); cfg.Save(); //if (GeneralConfigs.SetIpDenyAccess(DNTRequest.GetString("ip"))) { //Users.UpdateUserGroup(postInfo.Posterid, 6); XUser user = XUser.FindByID(postInfo.PosterID); user.GroupID = 6; user.Save(); base.SetUrl(base.ShowTopicAspxRewrite(topicInfo.ID, 0)); base.SetMetaRefresh(); base.SetShowBackLink(false); base.MsgForward("getip_succeed"); base.AddMsgLine("IP已加入到用户禁止列表中"); this.ispost = true; return; } //base.AddErrLine("未知原因,IP无法加到禁止列表中"); } }
public static Online CreateUser(int uid) { var Request = HttpContext.Current.Request; if (uid <= 0) { return(CreateGuestUser()); } var user = User.FindByID(uid); if (user == null) { return(CreateGuestUser()); } var online = new Online(); online.SetUser(user); online.SessionID = HttpContext.Current.Session.SessionID; online.IP = WebHelper.UserHost; online.UserAgent = HttpContext.Current.Request.UserAgent; //在页面上貌似没看到有显示这些时间的地方,因为要多查询几张表来查询时间,暂时先不做处理 //online.Lastpostpmtime = "1900-1-1 00:00:00"; //online.Lastsearchtime = "1900-1-1 00:00:00"; //online.LastUpdateTime = DateTime.Now; //online.Action = 0; //online.Lastactivity = 0; online.VerifyCode = CreateAuthStr(5, false); //int privateMessageCount = PrivateMessages.GetPrivateMessageCount(uid, 0, 1); var privateMessageCount = ShortMessage.GetPrivateMessageCount(uid, 0, 1); //int newNoticeCountByUid = Notices.GetNewNoticeCountByUid(uid); int newNoticeCountByUid = Notice.FindCountByUidAndNew(uid, 1); online.Newpms = (Int16)(privateMessageCount > 1000 ? 1000 : privateMessageCount); online.Newnotices = (Int16)(newNoticeCountByUid > 1000 ? 1000 : newNoticeCountByUid); //online.Olid = BBX.Data.OnlineUsers.CreateOnlineUserInfo(online, timeout); online.AddOnlineUser(); if (user.AdminID > 0 && user.AdminID < 4 && Notice.ReNewNotice(NoticeType.AttentionNotice, user.ID) == 0) { Notice.Create(user.ID, NoticeType.AttentionNotice, "请及时查看<a href=\"modcp.aspx?operation=attention&forumid=0\">需要关注的主题</a>"); } User.SetUserOnlineState(uid, true); var cookie = HttpContext.Current.Request.Cookies["bbx"]; if (cookie != null) { cookie["tpp"] = user.Tpp.ToString(); cookie["ppp"] = user.Ppp.ToString(); int num = cookie["expires"].ToInt(0); if (num > 0) { cookie.Expires = DateTime.Now.AddMinutes(num); } } var domain = GeneralConfigInfo.Current.CookieDomain; if (!domain.IsNullOrEmpty() && Request.Url.Host.IndexOf(domain) > -1 && IsValidDomain(Request.Url.Host)) { cookie.Domain = domain; } HttpContext.Current.Response.AppendCookie(cookie); return(online); }