Example #1
0
        //public static DataTable GetUserListByGroupidList(string groupIdList)
        //{
        //    return BBX.Data.Users.GetUserListByGroupid(groupIdList);
        //}

        public static int SendPMByGroupidList(string groupidlist, int topnumber, ref int start_uid, string msgfrom, int msguid, int folder, string subject, string postdatetime, string message)
        {
            //DataTable userListByGroupid = BBX.Data.Users.GetUserListByGroupid(groupidlist, topnumber, start_uid);
            //foreach (DataRow dataRow in userListByGroupid.Rows)
            var list = User.FindAllByGroupID(groupidlist, start_uid, topnumber);

            foreach (var item in list)
            {
                var msg = new ShortMessage();
                msg.Msgfrom      = msgfrom.Replace("'", "''");
                msg.MsgfromID    = msguid;
                msg.Msgto        = item.Name.Replace("'", "''");
                msg.MsgtoID      = item.ID;
                msg.Folder       = (Int16)folder;
                msg.Subject      = subject;
                msg.PostDateTime = postdatetime.ToDateTime();
                msg.Message      = message;
                msg.Create(false);
                start_uid = msg.MsgtoID;

                var entity = Online.FindByUserID(msg.MsgtoID);
                //if (OnlineUsers.GetOlidByUid(msg.MsgtoID) > 0)
                if (entity != null)
                {
                    Users.UpdateUserNewPMCount(msg.MsgtoID, entity.ID);
                }
            }
            return(list.Count);
        }
Example #2
0
        //public static int GetOnlineAllUserCount()
        //{
        //    //int onlineUserCountCacheMinute = GeneralConfigInfo.Current.OnlineUserCountCacheMinute;
        //    //if (onlineUserCountCacheMinute == 0)
        //    {
        //        //return BBX.Data.OnlineUsers.GetOnlineAllUserCount();
        //        return Online.Meta.Count;
        //    }
        //    //var cacheService = XCache.Current;
        //    //int num = TypeConverter.ObjectToInt(cacheService.RetrieveObject("/Forum/OnlineUserCount"));
        //    //if (num != 0)
        //    //{
        //    //    return num;
        //    //}
        //    ////num = BBX.Data.OnlineUsers.GetOnlineAllUserCount();
        //    //num = Online.Meta.Count;
        //    //XCache.Add("/Forum/OnlineUserCount", num, onlineUserCountCacheMinute * 60);
        //    //return num;
        //}

        //public static int GetCacheOnlineAllUserCount()
        //{
        //    int num = TypeConverter.StrToInt(Utils.GetCookie("onlineusercount"), 0);
        //    if (num == 0)
        //    {
        //        num = Online.Meta.Count;
        //        Utils.WriteCookie("onlineusercount", num.ToString(), 3);
        //    }
        //    return num;
        //}

        //public static EntityList<Online> GetOnlineUserList(int totaluser, out int guest, out int user, out int invisibleuser)
        //{
        //    //DataTable onlineUserListTable = BBX.Data.OnlineUsers.GetOnlineUserListTable();
        //    var list = Online.FindAllWithCache();
        //    var st = Statistic.Current;
        //    //int num = Statistic.GetInt("highestonlineusercount");
        //    if (totaluser > st.HighestOnlineUserCount)
        //    {
        //        //Statistic.UpdateStatistics("highestonlineusercount", totaluser);
        //        //Statistic.UpdateStatistics("highestonlineusertime", DateTime.Now);
        //        //Statistic.ReSetStatisticsCache();

        //        st.HighestOnlineUserCount = totaluser;
        //        st.HighestOnlineUserTime = DateTime.Now;
        //        st.Update();
        //    }
        //    //user = BBX.Data.OnlineUsers.GetOnlineUserCount();
        //    user = list.Count;
        //    //if (EntLibConfigInfo.Current != null && EntLibConfigInfo.Current.Cacheonlineuser.Enable)
        //    //{
        //    //    invisibleuser = BBX.Data.OnlineUsers.GetInvisibleOnlineUserCount();
        //    //}
        //    //else
        //    {
        //        //DataRow[] array = list.Select("invisible=1");
        //        invisibleuser = list.ToList().Count(e => e.Invisible == 1);
        //    }
        //    guest = totaluser > user ? totaluser - user : 0;
        //    return list;
        //}

        //public static void UpdatePostPMTime(int olid)
        //{
        //    if (GeneralConfigInfo.Current.Onlineoptimization != 1)
        //    {
        //        BBX.Data.OnlineUsers.UpdatePostPMTime(olid);
        //    }
        //}

        //public static void UpdateInvisible(int olid, int invisible)
        //{
        //    if (GeneralConfigInfo.Current.Onlineoptimization != 1)
        //    {
        //        BBX.Data.OnlineUsers.UpdateInvisible(olid, invisible);
        //    }
        //}

        //public static void UpdatePassword(int olid, string password)
        //{
        //    BBX.Data.OnlineUsers.UpdatePassword(olid, password);
        //}

        //public static int DeleteRows(int olid)
        //{
        //    //return BBX.Data.OnlineUsers.DeleteRows(olid);
        //    var online = Online.FindByID(olid);
        //    if (online == null) return 0;

        //    return online.Delete();
        //}

        //public static List<Online> GetForumOnlineUserCollection(int forumid, out int totaluser, out int guest, out int user, out int invisibleuser)
        //{
        //    var list = Online.FindAllByForumID(forumid);
        //    guest = 0;
        //    invisibleuser = 0;
        //    totaluser = list.Count;
        //    foreach (var item in list)
        //    {
        //        if (item.UserID == -1)
        //        {
        //            guest++;
        //        }
        //        if (item.Invisible == 1)
        //        {
        //            invisibleuser++;
        //        }
        //    }
        //    user = totaluser - guest;

        //    return list;
        //}

        //public static List<Online> GetOnlineUserCollection(out int totaluser, out int guest, out int user, out int invisibleuser)
        //{
        //    var list = Online.FindAllWithCache();
        //    user = 0;
        //    invisibleuser = 0;
        //    if (GeneralConfigInfo.Current.Whosonlinecontract == 0)
        //        totaluser = list.Count;
        //    else
        //        totaluser = Online.Meta.Count;

        //    foreach (var item in list)
        //    {
        //        if (item.UserID > 0) user++;
        //        if (item.Invisible == 1) invisibleuser++;
        //    }
        //    var st = Statistic.Current;
        //    if (totaluser > st.HighestOnlineUserCount)
        //    {
        //        st.HighestOnlineUserCount = totaluser;
        //        st.HighestOnlineUserTime = DateTime.Now;
        //        st.Update();
        //    }
        //    guest = totaluser > user ? (totaluser - user) : 0;

        //    return list;
        //}

        //public static void UpdateOnlineTime(int oltimespan, int uid)
        //{
        //    if (oltimespan != 0)
        //    {
        //        if (Utils.StrIsNullOrEmpty(Utils.GetCookie("lastactivity", "onlinetime")))
        //        {
        //            Utils.WriteCookie("lastactivity", "onlinetime", Environment.TickCount.ToString());
        //        }
        //        int num = Environment.TickCount - TypeConverter.StrToInt(Utils.GetCookie("lastactivity", "onlinetime"), Environment.TickCount);
        //        if (num <= 0 || num >= oltimespan * 60 * 1000)
        //        {
        //            //BBX.Data.OnlineUsers.UpdateOnlineTime(oltimespan, uid);
        //            OnlineTime.UpdateOnlineTime(oltimespan, uid);
        //            Utils.WriteCookie("lastactivity", "onlinetime", Environment.TickCount.ToString());
        //            num = Environment.TickCount - TypeConverter.StrToInt(Utils.GetCookie("lastactivity", "oltime"), Environment.TickCount);
        //            if (Utils.StrIsNullOrEmpty(Utils.GetCookie("lastactivity", "oltime")) || num <= 0 || num >= 2 * oltimespan * 60 * 1000)
        //            {
        //                //BBX.Data.OnlineUsers.SynchronizeOnlineTime(uid);
        //                OnlineTime.SynchronizeOnlineTime(uid);
        //                Utils.WriteCookie("lastactivity", "oltime", Environment.TickCount.ToString());
        //            }
        //        }
        //    }
        //}

        public static int GetOlidByUid(int uid)
        {
            //return BBX.Data.OnlineUsers.GetOlidByUid(uid);
            if (uid <= 0)
            {
                return(uid);
            }
            var online = Online.FindByUserID(uid);

            return(online != null ? online.ID : -1);
        }
Example #3
0
        private void RedirectAPILogin(ApplicationInfo appInfo)
        {
            string   text = DNTRequest.GetFormString("expires");
            DateTime date;

            if (text.IsNullOrEmpty())
            {
                date = BBX.Entity.User.FindByID(this.userid).LastVisit.ToUniversalTime().AddSeconds(Convert.ToDouble(Utils.GetCookie("bbx", "expires")));
            }
            else
            {
                date = DateTime.UtcNow.AddSeconds(Convert.ToDouble(text));
            }
            text = Utils.ConvertToUnixTimestamp(date).ToString();
            string next = DNTRequest.GetString("next");

            //this.olid = OnlineUsers.GetOlidByUid(this.userid);
            //if (this.olid > 0)
            //{
            //    this.oluserinfo = Online.FindByID(this.olid);
            //}
            this.oluserinfo = Online.FindByUserID(this.userid);
            string arg;

            if (this.oluserinfo == null)
            {
                arg = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            }
            else
            {
                arg = oluserinfo.LastUpdateTime.ToString("yyyy-MM-dd HH:mm:ss");
            }
            string text2 = DES.Encode(string.Format("{0},{1},{2}", this.olid, arg, text), appInfo.Secret.Substring(0, 10)).Replace("+", "[");

            HttpContext.Current.Response.Redirect(string.Format("{0}{1}auth_token={2}{3}", new object[]
            {
                appInfo.CallbackUrl,
                (appInfo.CallbackUrl.IndexOf("?") > 0) ? "&" : "?",
                text2,
                (String.IsNullOrEmpty(next)) ? next : ("&next=" + next)
            }));
        }
Example #4
0
        public static void CompareOldAndNewModerator(string oldmoderators, string newmoderators, int currentfid)
        {
            if (oldmoderators == null || String.IsNullOrEmpty(oldmoderators))
            {
                return;
            }
            string[] array = oldmoderators.Split(',');
            for (int i = 0; i < array.Length; i++)
            {
                string name = array[i];
                if (name != "" && ("," + newmoderators + ",").IndexOf("," + name + ",") < 0)
                {
                    var user = User.FindByName(name);
                    if (user != null)
                    {
                        int uid     = user.ID;
                        int adminid = user.AdminID;
                        //DataTable uidInModeratorsByUid = BBX.Data.Moderators.GetUidInModeratorsByUid(currentfid, uid);
                        //if (uidInModeratorsByUid.Rows.Count == 0 && adminid != 1)
                        if (adminid != 1 && Moderator.FindByUidAndFid(uid, currentfid) == null)
                        {
                            var ug = CreditsFacade.GetCreditsUserGroupId((float)user.Credits);
                            //BBX.Data.Users.UpdateUserOnlineInfo(ug.ID, uid);
                            //BBX.Data.Users.UpdateUserOtherInfo(ug.ID, uid);
                            user.AdminID = 0;
                            user.GroupID = ug.ID;
                            user.Save();

                            var online = Online.FindByUserID(user.ID);
                            if (online != null)
                            {
                                online.AdminID = 0;
                                online.GroupID = ug.ID;
                                online.Save();
                            }
                        }
                    }
                }
            }
        }
Example #5
0
        public static void UpdateBanUser(int groupid, string groupexpiry, int uid)
        {
            //BBX.Data.Users.UpdateBanUser(groupid, groupexpiry, uid);
            var user = User.FindByID(uid);

            if (user != null)
            {
                user.GroupID     = groupid;
                user.GroupExpiry = groupexpiry.ToInt();
                user.Save();
            }
            var online = Online.FindByUserID(uid);

            if (online != null)
            {
                online.GroupID = groupid;
                online.Update();
            }

            var notice = new Notice();

            notice.New = 1;
            if (groupid == 4)
            {
                notice.Type = (Int32)NoticeType.BanPostNotice;
            }
            if (groupid == 5)
            {
                notice.Type = (Int32)NoticeType.BanVisitNotice;
            }

            notice.PostDateTime = DateTime.Now;
            notice.Poster       = DNTRequest.GetFormString("uname");
            notice.PosterID     = uid;
            notice.Uid          = uid;
            notice.Note         = DNTRequest.GetFormString("reason") + "截至到" + groupexpiry + "到期";
            //Notices.CreateNoticeInfo(noticeInfo);
            notice.Insert();
        }
Example #6
0
        public void SendPM()
        {
            if (pm == null)
            {
                pm = new ShortMessage();
            }

            if (this.useradminid == 1)
            {
                this.pm.Message = DNTRequest.GetHtmlEncodeString("message");
                this.pm.Subject = DNTRequest.GetHtmlEncodeString("subject");
            }
            else
            {
                this.pm.Message = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("message")));
                this.pm.Subject = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("subject")));
            }
            if (this.useradminid != 1 && (ForumUtils.HasBannedWord(this.pm.Message) || ForumUtils.HasBannedWord(this.pm.Subject) || ForumUtils.HasAuditWord(this.pm.Message) || ForumUtils.HasAuditWord(this.pm.Subject)))
            {
                string arg = (ForumUtils.GetBannedWord(this.pm.Message) == string.Empty) ? ForumUtils.GetBannedWord(this.pm.Subject) : ForumUtils.GetBannedWord(this.pm.Message);
                base.AddErrLine(string.Format("对不起, 您提交的内容包含不良信息 <font color=\"red\">{0}</font>, 因此无法提交, 请返回修改!", arg));
                return;
            }
            string text = "," + Users.GetUserInfo(this.msgtoid).Ignorepm + ",";

            if (text.IndexOf("{ALL}") >= 0 || text.IndexOf("," + this.username + ",") >= 0)
            {
                base.AddErrLine("短消息发送失败!");
                return;
            }
            this.pm.Message   = ForumUtils.BanWordFilter(this.pm.Message);
            this.pm.Subject   = ForumUtils.BanWordFilter(this.pm.Subject);
            this.pm.Msgto     = DNTRequest.GetString("msgto");
            this.pm.MsgtoID   = this.msgtoid;
            this.pm.Msgfrom   = this.username;
            this.pm.MsgfromID = this.userid;
            if (!Utils.StrIsNullOrEmpty(DNTRequest.GetString("savetousercpdraftbox")))
            {
                this.CreatePM(2, 0, "usercpdraftbox.aspx", "已将消息保存到草稿箱");
                return;
            }
            if (!Utils.StrIsNullOrEmpty(DNTRequest.GetString("savetosentbox")))
            {
                this.CreatePM(0, 1, "usercpsentbox.aspx", "发送完毕, 且已将消息保存到发件箱");
            }
            else
            {
                this.CreatePM(0, 0, "usercpinbox.aspx", "发送完毕");
            }
            if (!base.IsErr())
            {
                Online.UpdatePostPMTime(this.olid);
                //int olidByUid = OnlineUsers.GetOlidByUid(this.pm.MsgtoID);
                //if (olidByUid > 0)
                var entity = Online.FindByUserID(pm.MsgtoID);
                if (entity != null)
                {
                    Users.UpdateUserNewPMCount(this.pm.MsgtoID, entity.ID);
                }
            }
        }