/// <summary>
		/// Copies the elements of the specified <see cref="OnlineUserInfo">OnlineUserInfo</see> array to the end of the collection.
		/// </summary>
		/// <param name="value">An array of type <see cref="OnlineUserInfo">OnlineUserInfo</see> containing the Components to add to the collection.</param>
		public void AddRange(OnlineUserInfo[] value) 
		{
			for (int i = 0;	(i < value.Length); i = (i + 1)) 
			{
				this.Add(value[i]);
			}
		}
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                config = GeneralConfigs.GetConfig();

                // 如果IP访问列表有设置则进行判断
                if (config.Adminipaccess.Trim() != "")
                {
                    string[] regctrl = Utils.SplitString(config.Adminipaccess, "\n");
                    if (!Utils.InIPArray(DNTRequest.GetIP(), regctrl))
                    {
                        Context.Response.Redirect(BaseConfigs.GetForumPath + "admin/syslogin.aspx");
                        return;
                    }
                }

                //获取当前用户的在线信息
                OnlineUserInfo oluserinfo = new OnlineUserInfo();
                try
                {
                    oluserinfo = OnlineUsers.UpdateInfo(config.Passwordkey, config.Onlinetimeout);
                }
                catch
                {
                    Thread.Sleep(2000);
                    oluserinfo = OnlineUsers.UpdateInfo(config.Passwordkey, config.Onlinetimeout);
                }


                #region 进行权限判断

                UserGroupInfo usergroupinfo = AdminUserGroups.AdminGetUserGroupInfo(oluserinfo.Groupid);
                if (oluserinfo.Userid <= 0 || usergroupinfo.Radminid != 1)
                {
                    Context.Response.Redirect(BaseConfigs.GetForumPath + "admin/syslogin.aspx");
                    return;
                }

                string secques = Users.GetUserInfo(oluserinfo.Userid).Secques;
                // 管理员身份验证
                if (Context.Request.Cookies["dntadmin"] == null || Context.Request.Cookies["dntadmin"]["key"] == null || ForumUtils.GetCookiePassword(Context.Request.Cookies["dntadmin"]["key"].ToString(), config.Passwordkey) != (oluserinfo.Password + secques + oluserinfo.Userid.ToString()))
                {
                    Context.Response.Redirect(BaseConfigs.GetForumPath + "admin/syslogin.aspx");
                    return;
                }
                else
                {
                    HttpCookie cookie = HttpContext.Current.Request.Cookies["dntadmin"];
                    cookie.Values["key"] = ForumUtils.SetCookiePassword(oluserinfo.Password + secques + oluserinfo.Userid.ToString(), config.Passwordkey);
                    cookie.Expires = DateTime.Now.AddMinutes(30);
                    HttpContext.Current.Response.AppendCookie(cookie);
                }

                #endregion
                
            }
        }
Exemple #3
0
 /// <summary>
 /// 执行在线用户向表及缓存中添加的操作。
 /// </summary>
 /// <param name="onlineuserinfo">在组用户信息内容</param>
 /// <returns>添加成功则返回刚刚添加的olid,失败则返回0</returns>
 public static int CreateOnlineUserInfo(OnlineUserInfo onlineuserinfo, int timeout)
 {
     return DatabaseProvider.GetInstance().AddOnlineUser(onlineuserinfo, timeout, GeneralConfigs.GetConfig().Deletingexpireduserfrequency);
 }
Exemple #4
0
        /// <summary>
        /// ִ�������û�������������ӵIJ�����
        /// </summary>
        /// <param name="onlineuserinfo">�����û���Ϣ����</param>
        /// <returns>��ӳɹ��򷵻ظո���ӵ�olid,ʧ���򷵻�0</returns>
        public int AddOnlineUser(OnlineUserInfo onlineuserinfo, int timeout)
        {
            System.Diagnostics.Debug.WriteLine("AddOnlineUser()");
            //��ʶ��Ҫ�����û�����״̬��0��ʾ��Ҫ����
            int onlinestate = 1;
            //string strDelTimeOutSql = "";
            // ���timeoutΪ������������Ҫ��ȷ�����û��Ƿ����ߵ�״̬
            if (timeout > 0)
            {
                if (onlineuserinfo.Userid > 0)
                {
                    onlinestate = 0;
                    //strDelTimeOutSql = string.Format("{0}UPDATE [{1}users] SET [onlinestate]=1 WHERE [uid]={2};", strDelTimeOutSql, BaseConfigs.GetTablePrefix, onlineuserinfo.Userid.ToString());
                }
            }
            else
            {
                timeout = timeout * -1;
            }

            if (timeout > 9999)
            {
                timeout = 9999;
            }

            DbParameter[] parms = {
                                       DbHelper.MakeInParam("@onlinestate",DbType.Int32,4,onlinestate),
                                       DbHelper.MakeInParam("@userid",DbType.Int32,4,onlineuserinfo.Userid),
                                       DbHelper.MakeInParam("@ip",DbType.AnsiString,15,onlineuserinfo.Ip),
                                       DbHelper.MakeInParam("@username",DbType.String,40,onlineuserinfo.Username),
                                       DbHelper.MakeInParam("@nickname",DbType.String,40,onlineuserinfo.Nickname),
                                       DbHelper.MakeInParam("@password",DbType.AnsiString,32,onlineuserinfo.Password),
                                       DbHelper.MakeInParam("@groupid",DbType.Int16,2,onlineuserinfo.Groupid),
                                       DbHelper.MakeInParam("@olimg",DbType.AnsiString,80,onlineuserinfo.Olimg),
                                       DbHelper.MakeInParam("@adminid",DbType.Int16,2,onlineuserinfo.Adminid),
                                       DbHelper.MakeInParam("@invisible",DbType.Int16,2,onlineuserinfo.Invisible),
                                       DbHelper.MakeInParam("@action",DbType.Int16,2,onlineuserinfo.Action),
                                       DbHelper.MakeInParam("@lastactivity",DbType.Int16,2,onlineuserinfo.Lastactivity),
                                       DbHelper.MakeInParam("@lastposttime",DbType.DateTime,8,DateTime.Parse(onlineuserinfo.Lastposttime)),
                                       DbHelper.MakeInParam("@lastpostpmtime",DbType.DateTime,8,DateTime.Parse(onlineuserinfo.Lastpostpmtime)),
                                       DbHelper.MakeInParam("@lastsearchtime",DbType.DateTime,8,DateTime.Parse(onlineuserinfo.Lastsearchtime)),
                                       DbHelper.MakeInParam("@lastupdatetime",DbType.DateTime,8,DateTime.Parse(onlineuserinfo.Lastupdatetime)),
                                       DbHelper.MakeInParam("@forumid",DbType.Int32,4,onlineuserinfo.Forumid),
                                       DbHelper.MakeInParam("@forumname",DbType.String,50,""),
                                       DbHelper.MakeInParam("@titleid",DbType.Int32,4,onlineuserinfo.Titleid),
                                       DbHelper.MakeInParam("@title",DbType.String,80,""),
                                       DbHelper.MakeInParam("@verifycode",DbType.AnsiString,10,onlineuserinfo.Verifycode),
                                       DbHelper.MakeInParam("@newpms",DbType.Int16,2,onlineuserinfo.Newpms),
                                       DbHelper.MakeInParam("@newnotices",DbType.Int16,2,onlineuserinfo.Newnotices)
                                   };
            //int olid = Utils.StrToInt(DbHelper.ExecuteScalar(CommandType.Text, strDelTimeOutSql + "INSERT INTO [" + BaseConfigs.GetTablePrefix + "online] ([userid],[ip],[username],[nickname],[password],[groupid],[olimg],[adminid],[invisible],[action],[lastactivity],[lastposttime],[lastpostpmtime],[lastsearchtime],[lastupdatetime],[forumid],[forumname],[titleid],[title],[verifycode],[newpms],[newnotices])VALUES(@userid,@ip,@username,@nickname,@password,@groupid,@olimg,@adminid,@invisible,@action,@lastactivity,@lastposttime,@lastpostpmtime,@lastsearchtime,@lastupdatetime,@forumid,@forumname,@titleid,@title,@verifycode,@newpms,@newnotices);SELECT SCOPE_IDENTITY()", parms).ToString(), 0);
            if (onlinestate == 0)
            {
                DbHelper.ExecuteNonQuery(CommandType.Text, string.Format("UPDATE [{0}users] SET [onlinestate]=1 WHERE [uid]=@userid", BaseConfigs.GetTablePrefix), parms);
            }
            string sql = string.Format("INSERT INTO [{0}online] ([userid],[ip],[username],[nickname],[password],[groupid],[olimg],[adminid],[invisible],[action],[lastactivity],[lastposttime],[lastpostpmtime],[lastsearchtime],[lastupdatetime],[forumid],[forumname],[titleid],[title],[verifycode],[newpms],[newnotices])VALUES(@userid,@ip,@username,@nickname,@password,@groupid,@olimg,@adminid,@invisible,@action,@lastactivity,@lastposttime,@lastpostpmtime,@lastsearchtime,@lastupdatetime,@forumid,@forumname,@titleid,@title,@verifycode,@newpms,@newnotices);SELECT last_insert_rowid()", BaseConfigs.GetTablePrefix);
            int olid = Utils.StrToInt(DbHelper.ExecuteScalar(CommandType.Text, sql, parms), 0);

            //ϵͳ�м��5����֮�ڲ���������û�
            if (_lastRemoveTimeout == 0 || (System.Environment.TickCount - _lastRemoveTimeout) > 300000)
            {
                DeleteExpiredOnlineUsers(timeout);
                _lastRemoveTimeout = System.Environment.TickCount;
            }
            // ���idֵ̫�����ؽ����߱�
            if (olid > 2147483000)
            {
                CreateOnlineTable();
                //DbHelper.ExecuteNonQuery(CommandType.Text, strDelTimeOutSql + "INSERT INTO [" + BaseConfigs.GetTablePrefix + "online] ([userid],[ip],[username],[nickname],[password],[groupid],[olimg],[adminid],[invisible],[action],[lastactivity],[lastposttime],[lastpostpmtime],[lastsearchtime],[lastupdatetime],[forumid],[titleid],[verifycode])VALUES(@userid,@ip,@username,@nickname,@password,@groupid,@olimg,@adminid,@invisible,@action,@lastactivity,@lastposttime,@lastpostpmtime,@lastsearchtime,@lastupdatetime,@forumid,@forumname,@titleid,@title,@verifycode);SELECT SCOPE_IDENTITY()", parms);
                if (onlinestate == 0)
                {
                    DbHelper.ExecuteNonQuery(CommandType.Text, string.Format("UPDATE [{0}users] SET [onlinestate]=1 WHERE [uid]=@userid", BaseConfigs.GetTablePrefix), parms);
                }
                DbHelper.ExecuteNonQuery(CommandType.Text, sql, parms);
                return 1;
            }

            return 0;
            //return (int)DbHelper.ExecuteDataset(CommandType.Text, "SELECT [olid] FROM ["+BaseConfigFactory.GetTablePrefix+"online] WHERE [userid]=" + __onlineuserinfo.Userid.ToString()).Tables[0].Rows[0][0];
        }
Exemple #5
0
        /// <summary>
        /// 增加一个会员信息到在线列表中。用户login.aspx或在线用户信息超时,但用户仍在线的情况下重新生成用户在线列表
        /// </summary>
        /// <param name="uid"></param>
        private static OnlineUserInfo CreateUser(int uid, int timeout)
        {
            OnlineUserInfo onlineuserinfo = new OnlineUserInfo();
            if (uid > 0)
            {
                ShortUserInfo ui = Users.GetShortUserInfo(uid);
                if (ui != null)
                {
                    onlineuserinfo.Userid = uid;
                    onlineuserinfo.Username = ui.Username.Trim();
                    onlineuserinfo.Nickname = ui.Nickname.Trim();
                    onlineuserinfo.Password = ui.Password.Trim();
                    onlineuserinfo.Groupid = short.Parse(ui.Groupid.ToString());
                    onlineuserinfo.Olimg = GetGroupImg(short.Parse(ui.Groupid.ToString()));
                    onlineuserinfo.Adminid = short.Parse(ui.Adminid.ToString());
                    onlineuserinfo.Invisible = short.Parse(ui.Invisible.ToString());
                    onlineuserinfo.Ip = DNTRequest.GetIP();
                    onlineuserinfo.Lastposttime = "1900-1-1 00:00:00";
                    onlineuserinfo.Lastpostpmtime = "1900-1-1 00:00:00";
                    onlineuserinfo.Lastsearchtime = "1900-1-1 00:00:00";
                    onlineuserinfo.Lastupdatetime = Utils.GetDateTime();
                    onlineuserinfo.Action = 0;
                    onlineuserinfo.Lastactivity = 0;
                    onlineuserinfo.Verifycode = ForumUtils.CreateAuthStr(5, false);

                    int newPms = PrivateMessages.GetPrivateMessageCount(uid, 0, 1);
                    int newNotices = Notices.GetNewNoticeCountByUid(uid);
                    onlineuserinfo.Newpms = short.Parse(newPms > 1000 ? "1000" : newPms.ToString());
                    onlineuserinfo.Newnotices = short.Parse(newNotices > 1000 ? "1000" : newNotices.ToString());
                    //onlineuserinfo.Newfriendrequest = short.Parse(Friendship.GetUserFriendRequestCount(uid).ToString());
                    //onlineuserinfo.Newapprequest = short.Parse(ManyouApplications.GetApplicationInviteCount(uid).ToString());
                    onlineuserinfo.Olid = Discuz.Data.OnlineUsers.CreateOnlineUserInfo(onlineuserinfo, timeout);


                    //给管理人员发送关注通知
                    if (ui.Adminid > 0 && ui.Adminid < 4)
                    {
                        if (Discuz.Data.Notices.ReNewNotice((int)NoticeType.AttentionNotice, ui.Uid) == 0)
                        {
                            NoticeInfo ni = new NoticeInfo();
                            ni.New = 1;
                            ni.Note = "请及时查看<a href=\"modcp.aspx?operation=attention&forumid=0\">需要关注的主题</a>";
                            ni.Postdatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                            ni.Type = NoticeType.AttentionNotice;
                            ni.Poster = "";
                            ni.Posterid = 0;
                            ni.Uid = ui.Uid;
                            Notices.CreateNoticeInfo(ni);
                        }
                    }
                    Discuz.Data.OnlineUsers.SetUserOnlineState(uid, 1);

                    HttpCookie cookie = HttpContext.Current.Request.Cookies["dnt"];
                    if (cookie != null)
                    {
                        cookie.Values["tpp"] = ui.Tpp.ToString();
                        cookie.Values["ppp"] = ui.Ppp.ToString();
                        if (HttpContext.Current.Request.Cookies["dnt"]["expires"] != null)
                        {
                            int expires = TypeConverter.StrToInt(HttpContext.Current.Request.Cookies["dnt"]["expires"].ToString(), 0);
                            if (expires > 0)
                            {
                                cookie.Expires = DateTime.Now.AddMinutes(TypeConverter.StrToInt(HttpContext.Current.Request.Cookies["dnt"]["expires"].ToString(), 0));
                            }
                        }
                    }

                    string cookieDomain = GeneralConfigs.GetConfig().CookieDomain.Trim();
                    if (!Utils.StrIsNullOrEmpty(cookieDomain) && HttpContext.Current.Request.Url.Host.IndexOf(cookieDomain) > -1 && ForumUtils.IsValidDomain(HttpContext.Current.Request.Url.Host))
                        cookie.Domain = cookieDomain;
                    HttpContext.Current.Response.AppendCookie(cookie);
                }
                else
                {
                    onlineuserinfo = CreateGuestUser(timeout);
                }
            }
            else
            {
                onlineuserinfo = CreateGuestUser(timeout);
            }
            return onlineuserinfo;
        }
Exemple #6
0
        /// <summary>
        /// BasePage类构造函数
        /// </summary>
        public BaseController()
        {
            m_starttick = DateTime.Now;
            if (recordPageView)
                PageViewStatistic(pagename);

            config = GeneralConfigs.GetConfig();
            if (SpacePluginProvider.GetInstance() == null)
                config.Enablespace = 0;
            if (AlbumPluginProvider.GetInstance() == null)
                config.Enablealbum = 0;
            if (MallPluginProvider.GetInstance() == null)
                config.Enablemall = 0;

            LoadUrlConfig();
            userid = Utils.StrToInt(ForumUtils.GetCookie("userid"), -1);

            //清空当前页面查询统计
#if DEBUG
            Discuz.Data.DbHelper.QueryCount = 0;
            Discuz.Data.DbHelper.QueryDetail = "";
#endif
            // 如果启用游客页面缓存,则对游客输出缓存页
            if (userid == -1 && config.Guestcachepagetimeout > 0 && GetUserCachePage(pagename))
                return;

            AddMetaInfo(config.Seokeywords, config.Seodescription, config.Seohead);

            if (config.Nocacheheaders == 1)
            {
                System.Web.HttpContext.Current.Response.BufferOutput = false;
                System.Web.HttpContext.Current.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
                System.Web.HttpContext.Current.Response.Cache.SetExpires(DateTime.Now.AddDays(-1));
                System.Web.HttpContext.Current.Response.Expires = 0;
                System.Web.HttpContext.Current.Response.CacheControl = "no-cache";
                System.Web.HttpContext.Current.Response.Cache.SetNoStore();
            }

            //当为forumlist.aspx或forumindex.aspx,可能出现在线并发问题,这时系统会延时2秒
            if ((pagename != "forumlist.aspx") && (pagename != "forumindex.aspx"))
                oluserinfo = OnlineUsers.UpdateInfo(config.Passwordkey, config.Onlinetimeout);
            else
            {
                try
                {
                    oluserinfo = OnlineUsers.UpdateInfo(config.Passwordkey, config.Onlinetimeout);
                }
                catch
                {
                    System.Threading.Thread.Sleep(2000);
                    oluserinfo = OnlineUsers.UpdateInfo(config.Passwordkey, config.Onlinetimeout);
                }
            }

            if (config.PostTimeStorageMedia == 1 && Utils.GetCookie("lastposttime") != "")//如果最后发帖时间cookie不为空,则在此修改用户的该属性
                oluserinfo.Lastposttime = Utils.GetCookie("lastposttime");

            userid = oluserinfo.Userid;
            usergroupid = oluserinfo.Groupid;
            username = oluserinfo.Username;
            password = oluserinfo.Password;
            userkey = password.Length > 16 ? password.Substring(4, 8).Trim() : "";
            lastposttime = oluserinfo.Lastposttime;
            lastpostpmtime = oluserinfo.Lastpostpmtime;
            lastsearchtime = oluserinfo.Lastsearchtime;
            olid = oluserinfo.Olid;

            isopenconnect = DiscuzCloud.GetCloudServiceEnableStatus("connect");
            isbindconnect = isopenconnect ? DiscuzCloud.OnlineUserIsBindConnect(userid) : false;

            //确保头像可以取到
            if (userid > 0)
                useravatar = Avatars.GetAvatarUrl(userid, AvatarSize.Small);

            if (Utils.InArray(DNTRequest.GetString("selectedtemplateid"), Templates.GetValidTemplateIDList()))
                templateid = DNTRequest.GetInt("selectedtemplateid", 0);
            else if (Utils.InArray(Utils.GetCookie(Utils.GetTemplateCookieName()), Templates.GetValidTemplateIDList()))
                templateid = Utils.StrToInt(Utils.GetCookie(Utils.GetTemplateCookieName()), config.Templateid);

            if (templateid == 0)
                templateid = config.Templateid;

            pmsound = Utils.StrToInt(ForumUtils.GetCookie("pmsound"), 0);

            //已登录用户检测用户组状态,如果是禁言或禁止访问状态时间到期,则自动解禁
            if (usergroupid == 4 || usergroupid == 5)
            {

                //int groupExpiry = Users.GetShortUserInfo(userid).Groupexpiry;
                //if (groupExpiry != 0 && groupExpiry <= Utils.StrToInt(DateTime.Now.ToString("yyyyMMdd"), 0))
                //{
                //    //先改为第一个积分组
                //    usergroupid = 11;
                //    //usergroupinfo = UserGroups.GetUserGroupInfo(usergroupid);
                //    Users.UpdateUserGroup(userid, 11);
                //}

                ShortUserInfo userInfo = Users.GetShortUserInfo(userid);
                if (userInfo.Groupexpiry != 0 && userInfo.Groupexpiry <= Utils.StrToInt(DateTime.Now.ToString("yyyyMMdd"), 0))
                {
                    UserGroupInfo groupInfo = CreditsFacade.GetCreditsUserGroupId(userInfo.Credits);
                    usergroupid = groupInfo.Groupid != 0 ? groupInfo.Groupid : usergroupid;
                    Users.UpdateUserGroup(userid, usergroupid);
                }
            }

            usergroupinfo = UserGroups.GetUserGroupInfo(usergroupid);

            // 取得用户权限id,1管理员,2超版,3版主,0普通组,-1特殊组
            useradminid = usergroupinfo.Radminid;
            string tips = ForumUtils.GetUserCreditsCookie(userid, usergroupinfo.Grouptitle);
            if (tips != "")
            {
                string[] userinfotipsList = tips.Split(',');//因为考虑到应用程序做单点登录时获取不到userinfotips,封装了此方法
                userinfotips = "<p><a class=\"drop\" onmouseover=\"showMenu(this.id);\" href=\"" + BaseConfigs.GetForumPath + "usercpcreditspay.aspx\" id=\"extcreditmenu\">" + userinfotipsList[0] + "</a> ";
                userinfotips += "<span class=\"pipe\">|</span>用户组: <a class=\"xi2\" id=\"g_upmine\" href=\"" + BaseConfigs.GetForumPath + "usercp.aspx\">" + userinfotipsList[1].Split(':')[1] + "</a></p>";
                userinfotips += "<ul id=\"extcreditmenu_menu\" class=\"p_pop\" style=\"display:none;\">";
                for (int i = 2; i < userinfotipsList.Length; i++)
                {
                    userinfotips += string.Format("<li><a> {0}</a></li>", userinfotipsList[i]);
                }
                userinfotips += "</ul>";
            }

            mainnavigation = Navs.GetNavigationString(userid, useradminid);
            subnavigation = Navs.GetSubNavigation();
            mainnavigationhassub = Navs.GetMainNavigationHasSub();
            // 如果论坛关闭且当前用户请求页面不是登录页面且用户非管理员, 则跳转至论坛关闭信息页
            if (config.Closed == 1 && pagename != "login.aspx" && pagename != "logout.aspx" && pagename != "register.aspx" && useradminid != 1)
            {
                ShowMessage(1);
                return;
            }

            if (!Utils.InArray(pagename, "attachment.aspx"))//加入附件页面判断减少性能消耗
                onlineusercount = (userid != -1) ? OnlineUsers.GetOnlineAllUserCount() : OnlineUsers.GetCacheOnlineAllUserCount();

            //校验用户是否可以访问论坛
            if (!ValidateUserPermission())
                return;

            //更新用户在线时长
            if (userid != -1 && !Utils.InArray(pagename, "attachment.aspx"))//加入附件页面判断减少性能消耗
                OnlineUsers.UpdateOnlineTime(config.Oltimespan, userid);
            Discuz.Entity.TemplateInfo templateInfo = Templates.GetTemplateItem(templateid);
            templatepath = templateInfo.Directory;
            if (templateInfo.Templateurl.ToLower().StartsWith("http://"))
            {
                imagedir = templateInfo.Templateurl.TrimEnd('/') + "/images";
                cssdir = templateInfo.Templateurl.TrimEnd('/');
            }
            else
            {
                imagedir = forumpath + "templates/" + templateInfo.Directory + "/images";
                cssdir = forumpath + "templates/" + templateInfo.Directory;
            }
            if (EntLibConfigs.GetConfig() != null && !Utils.StrIsNullOrEmpty(EntLibConfigs.GetConfig().Topicidentifydir))
                topicidentifydir = EntLibConfigs.GetConfig().Topicidentifydir.TrimEnd('/');
            else
                topicidentifydir = forumpath + "images/identify";

            if (EntLibConfigs.GetConfig() != null && !Utils.StrIsNullOrEmpty(EntLibConfigs.GetConfig().Posticondir))
                posticondir = EntLibConfigs.GetConfig().Posticondir.TrimEnd('/');
            else
                posticondir = forumpath + "images/posticons";



            if (EntLibConfigs.GetConfig() != null && !Utils.StrIsNullOrEmpty(EntLibConfigs.GetConfig().Jsdir))
                jsdir = EntLibConfigs.GetConfig().Jsdir.TrimEnd('/');
            else
                jsdir = rooturl + "javascript";

            nowdate = Utils.GetDate();
            nowtime = Utils.GetTime();
            nowdatetime = Utils.GetDateTime();
            ispost = DNTRequest.IsPost();
            isget = DNTRequest.IsGet();
            link = "";
            script = "";

            templatelistboxoptions = Caches.GetTemplateListBoxOptionsCache();

            string originalTemplate = string.Format("<li><a href=\"###\" onclick=\"window.location.href='{0}showtemplate.aspx?templateid={1}'\">",
                                   "", BaseConfigs.GetForumPath, templateid);
            string newTemplate = string.Format("<li class=\"current\"><a href=\"###\" onclick=\"window.location.href='{0}showtemplate.aspx?templateid={1}'\">",
                                     BaseConfigs.GetForumPath, templateid);
            templatelistboxoptions = templatelistboxoptions.Replace(originalTemplate, newTemplate);

            isLoginCode = config.Seccodestatus.Contains("login.aspx");
            //当该页面设置了验证码检验,并且当前用户的用户组没有给予忽略验证码的权限,则isseccode=true;
            isseccode = Utils.InArray(pagename, config.Seccodestatus) && usergroupinfo.Ignoreseccode == 0;


            headerad = Advertisements.GetOneHeaderAd("", 0);
            footerad = Advertisements.GetOneFooterAd("", 0);

            //设定当前页面的显示样式
            if (config.Allowchangewidth == 0)
                Utils.WriteCookie("allowchangewidth", "");

            if (pagename != "website.aspx")
            {
                if (Utils.GetCookie("allowchangewidth") == "0" || (string.IsNullOrEmpty(Utils.GetCookie("allowchangewidth")) && config.Showwidthmode == 1))
                    isnarrowpage = true;
            }

            //校验验证码
            if (isseccode && ispost && !ValidateVerifyCode())
                return;

            newtopicminute = config.Viewnewtopicminute;
        }
Exemple #7
0
        private static OnlineUserInfo LoadSingleOnlineUser(IDataReader reader)
        {
            OnlineUserInfo info = new OnlineUserInfo();
            info.Olid = Int32.Parse(reader["olid"].ToString());
            info.Userid = Int32.Parse(reader["userid"].ToString());
            info.Ip = reader["ip"].ToString();
            info.Username = reader["username"].ToString();
            //info.Tickcount = Int32.Parse(reader["tickcount"].ToString());
            info.Nickname = reader["nickname"].ToString();
            info.Password = reader["password"].ToString();
            info.Groupid = Int16.Parse(reader["groupid"].ToString() == "" ? "10" : reader["groupid"].ToString());
            info.Adminid = Int16.Parse(reader["adminid"].ToString() == "" ? "1" : reader["adminid"].ToString());

            switch(info.Adminid)
            {
                case 1:
                    info.Olimg = "<img src=\"images/groupicons/admin.gif\" />";
                    break;
                case 2:
                    info.Olimg = "<img src=\"images/groupicons/supermoder.gif\" />";
                    break;
                case 3:
                    info.Olimg = "<img src=\"images/groupicons/moder.gif\" />";
                    break;
            }

            switch (info.Groupid)
            {
                case 10:
                    info.Olimg = "<img src=\"images/groupicons/member.gif\" />";
                    break;
                case 7:
                    info.Olimg = "<img src=\"images/groupicons/guest.gif\" />";
                    break;
            }

            if (info.Olimg == null || info.Olimg == "")
            {
                info.Olimg = "<img src=\"images/groupicons/member.gif\" />";
            }

            info.Invisible = Int16.Parse(reader["invisible"].ToString());
            info.Action = Int16.Parse(reader["action"].ToString());
            info.Lastactivity = Int16.Parse(reader["lastactivity"].ToString());
            info.Lastposttime = reader["lastposttime"].ToString();
            info.Lastpostpmtime = reader["lastpostpmtime"].ToString();
            info.Lastsearchtime = reader["lastsearchtime"].ToString();
            info.Lastupdatetime = reader["lastupdatetime"].ToString();
            info.Forumid = Int32.Parse(reader["forumid"].ToString());
            if (reader["forumname"] != DBNull.Value)
            {
                info.Forumname = reader["forumname"].ToString();
            }
            info.Titleid = Int32.Parse(reader["titleid"].ToString());
            if (reader["title"] != DBNull.Value)
            {
                info.Title = reader["title"].ToString();
            }
            info.Verifycode = reader["verifycode"].ToString();
            return info;
        }
Exemple #8
0
        /// <summary>
        /// 增加一个会员信息到在线列表中。用户login.aspx或在线用户信息超时,但用户仍在线的情况下重新生成用户在线列表
        /// </summary>
        /// <param name="uid"></param>
        private static OnlineUserInfo CreateUser(int uid, int timeout)
        {
            OnlineUserInfo onlineuserinfo = new OnlineUserInfo();
            if (uid > 0)
            {
                ShortUserInfo ui = Users.GetShortUserInfo(uid);
                if (ui != null)
                {
                    onlineuserinfo.Userid = uid;
                    onlineuserinfo.Username = ui.Username.Trim();
                    onlineuserinfo.Nickname = ui.Nickname.Trim();
                    onlineuserinfo.Password = ui.Password.Trim();
                    onlineuserinfo.Groupid = short.Parse(ui.Groupid.ToString());
                    onlineuserinfo.Olimg = GetGroupImg(short.Parse(ui.Groupid.ToString()));
                    onlineuserinfo.Adminid = short.Parse(ui.Adminid.ToString());
                    onlineuserinfo.Invisible = short.Parse(ui.Invisible.ToString());


                    onlineuserinfo.Ip = DNTRequest.GetIP();
                    onlineuserinfo.Lastposttime = "1900-1-1 00:00:00";
                    onlineuserinfo.Lastpostpmtime = "1900-1-1 00:00:00";
                    onlineuserinfo.Lastsearchtime = "1900-1-1 00:00:00";
                    onlineuserinfo.Lastupdatetime = Utils.GetDateTime();
                    onlineuserinfo.Action = 0;
                    onlineuserinfo.Lastactivity = 0;
                    onlineuserinfo.Verifycode = ForumUtils.CreateAuthStr(5, false);


                    int olid = Add(onlineuserinfo, timeout);
                    DatabaseProvider.GetInstance().SetUserOnlineState(uid, 1);
                    onlineuserinfo.Olid = olid;

                    HttpCookie cookie = HttpContext.Current.Request.Cookies["dnt"];
                    if (cookie != null)
                    {
                        cookie.Values["tpp"] = ui.Tpp.ToString();
                        cookie.Values["ppp"] = ui.Ppp.ToString();
                        if (HttpContext.Current.Request.Cookies["dnt"]["expires"] != null)
                        {
                            int expires = Utils.StrToInt(HttpContext.Current.Request.Cookies["dnt"]["expires"].ToString(), 0);
                            if (expires > 0)
                            {
                                cookie.Expires = DateTime.Now.AddMinutes(Utils.StrToInt(HttpContext.Current.Request.Cookies["dnt"]["expires"].ToString(), 0));
                            }
                        }
                    }

                    try
                    {
                        string cookieDomain = GeneralConfigs.GetConfig().CookieDomain.Trim();
                        if (cookieDomain != string.Empty && HttpContext.Current.Request.Url.Host.IndexOf(cookieDomain) > -1 && ForumUtils.IsValidDomain(HttpContext.Current.Request.Url.Host))
                            cookie.Domain = cookieDomain;
                        HttpContext.Current.Response.AppendCookie(cookie);
                    }
                    catch { }
                    //catch(Exception ex)
                    //{
                    //    Discuz.Forum.ScheduledEvents.EventLogs.WriteFailedLog("OnlineUsers.cs(440)," + ex.Message);
                    //}
                }
            }
            else
            {
                onlineuserinfo = CreateGuestUser(timeout);
            }
            return onlineuserinfo;

        }
		/// <summary>
		/// Gets the index in the collection of the specified <see cref="OnlineUserInfoCollection">OnlineUserInfoCollection</see>, if it exists in the collection.
		/// </summary>
		/// <param name="value">The <see cref="OnlineUserInfoCollection">OnlineUserInfoCollection</see> to locate in the collection.</param>
		/// <returns>The index in the collection of the specified object, if found; otherwise, -1.</returns>
		public int IndexOf(OnlineUserInfo value) 
		{
			return this.List.IndexOf(value);
		}
		/// <summary>
		/// Gets a value indicating whether the collection contains the specified <see cref="OnlineUserInfoCollection">OnlineUserInfoCollection</see>.
		/// </summary>
		/// <param name="value">The <see cref="OnlineUserInfoCollection">OnlineUserInfoCollection</see> to search for in the collection.</param>
		/// <returns><b>true</b> if the collection contains the specified object; otherwise, <b>false</b>.</returns>
		public bool Contains(OnlineUserInfo value) 
		{
			return this.List.Contains(value);
		}
		public int Add(OnlineUserInfo value) 
		{
			return this.List.Add(value);
		}
		/// <summary>
		/// Initializes a new instance of the <see cref="OnlineUserInfoCollection">OnlineUserInfoCollection</see> class containing the specified array of <see cref="OnlineUserInfo">OnlineUserInfo</see> Components.
		/// </summary>
		/// <param name="value">An array of <see cref="OnlineUserInfo">OnlineUserInfo</see> Components with which to initialize the collection. </param>
		public OnlineUserInfoCollection(OnlineUserInfo[] value)
		{
			this.AddRange(value);
		}
		public void Remove(OnlineUserInfo value) 
		{
			List.Remove(value);
		}
		public void Insert(int index, OnlineUserInfo value)	
		{
			List.Insert(index, value);
		}
Exemple #15
0
        public static bool CheckPostTimeSpan(UserGroupInfo userGroupInfo, AdminGroupInfo admininfo, OnlineUserInfo olUserInfo, ShortUserInfo shortUserInfo, ref string msg)
        {
            // 如果当前用户非管理员并且论坛设定了禁止发帖时间段,当前时间如果在其中的一个时间段内,不允许用户发帖
            if (olUserInfo.Adminid != 1 && userGroupInfo.Disableperiodctrl != 1)
            {
                string visittime = "";
                if (Scoresets.BetweenTime(GeneralConfigs.GetConfig().Postbanperiods, out visittime))
                {
                    msg = "在此时间段( " + visittime + " )内用户不可以发帖";
                    return false;
                }
            }

            if (admininfo == null || admininfo.Disablepostctrl != 1)
            {
                int Interval = Utils.StrDateDiffSeconds(olUserInfo.Lastposttime, GeneralConfigs.GetConfig().Postinterval);
                if (Interval < 0)
                {
                    msg = "系统规定发帖间隔为" + GeneralConfigs.GetConfig().Postinterval.ToString() + "秒, 您还需要等待 " + (Interval * -1).ToString() + " 秒";
                    return false;
                }
                else if (olUserInfo.Userid != -1)
                {
                    //ShortUserInfo shortUserInfo = Discuz.Data.Users.GetShortUserInfo(olUserInfo.Userid);
                    string joindate = (shortUserInfo != null) ? shortUserInfo.Joindate : "";
                    if (joindate == "")
                    {
                        msg = "您的用户资料出现错误";
                        return false;
                    }
                    Interval = Utils.StrDateDiffMinutes(joindate, GeneralConfigs.GetConfig().Newbiespan);
                    if (Interval < 0)
                    {
                        msg = "系统规定新注册用户必须要在" + GeneralConfigs.GetConfig().Newbiespan.ToString() + "分钟后才可以发帖, 您还需要等待 " + (Interval * -1).ToString() + " 分钟";
                        return false;
                    }
                }
            }
            return true;
        }
Exemple #16
0
        /// <summary>
        /// 执行在线用户向表及缓存中添加的操作。
        /// </summary>
        /// <param name="onlineuserinfo">在组用户信息内容</param>
        /// <param name="timeout">系统设置用户多少时间即算做离线</param>
        /// <param name="deletingfrequency">删除过期用户频率(单位:分钟)</param>
        /// <returns>添加成功则返回刚刚添加的olid,失败则返回0</returns>
        public int AddOnlineUser(OnlineUserInfo onlineUserInfo, int timeOut, int deletingFrequency)
        {
            //标识需要更新用户在线状态,0表示需要更新
            int onlinestate = 1;

            // 如果timeout为负数则代表不需要精确更新用户是否在线的状态
            if (timeOut > 0)
            {
                if (onlineUserInfo.Userid > 0)
                    onlinestate = 0;
            }
            else
                timeOut = timeOut * -1;

            if (timeOut > 9999)
                timeOut = 9999;

            DbParameter[] parms = {
									   DbHelper.MakeInParam("@onlinestate",(DbType)SqlDbType.Int,4,onlinestate),
									   DbHelper.MakeInParam("@userid",(DbType)SqlDbType.Int,4,onlineUserInfo.Userid),
									   DbHelper.MakeInParam("@ip",(DbType)SqlDbType.VarChar,15,onlineUserInfo.Ip),
									   DbHelper.MakeInParam("@username",(DbType)SqlDbType.NVarChar,40,onlineUserInfo.Username),
									   DbHelper.MakeInParam("@nickname",(DbType)SqlDbType.NVarChar,40,onlineUserInfo.Nickname),
									   DbHelper.MakeInParam("@password",(DbType)SqlDbType.Char,32,onlineUserInfo.Password),
									   DbHelper.MakeInParam("@groupid",(DbType)SqlDbType.SmallInt,2,onlineUserInfo.Groupid),
									   DbHelper.MakeInParam("@olimg",(DbType)SqlDbType.VarChar,80,onlineUserInfo.Olimg),
									   DbHelper.MakeInParam("@adminid",(DbType)SqlDbType.SmallInt,2,onlineUserInfo.Adminid),
									   DbHelper.MakeInParam("@invisible",(DbType)SqlDbType.SmallInt,2,onlineUserInfo.Invisible),
									   DbHelper.MakeInParam("@action",(DbType)SqlDbType.SmallInt,2,onlineUserInfo.Action),
									   DbHelper.MakeInParam("@lastactivity",(DbType)SqlDbType.SmallInt,2,onlineUserInfo.Lastactivity),
									   DbHelper.MakeInParam("@lastposttime",(DbType)SqlDbType.DateTime,8,DateTime.Parse(onlineUserInfo.Lastposttime)),
									   DbHelper.MakeInParam("@lastpostpmtime",(DbType)SqlDbType.DateTime,8,DateTime.Parse(onlineUserInfo.Lastpostpmtime)),
									   DbHelper.MakeInParam("@lastsearchtime",(DbType)SqlDbType.DateTime,8,DateTime.Parse(onlineUserInfo.Lastsearchtime)),
									   DbHelper.MakeInParam("@lastupdatetime",(DbType)SqlDbType.DateTime,8,DateTime.Parse(onlineUserInfo.Lastupdatetime)),
									   DbHelper.MakeInParam("@forumid",(DbType)SqlDbType.Int,4,onlineUserInfo.Forumid),
									   DbHelper.MakeInParam("@forumname",(DbType)SqlDbType.NVarChar,50,""),
									   DbHelper.MakeInParam("@titleid",(DbType)SqlDbType.Int,4,onlineUserInfo.Titleid),
									   DbHelper.MakeInParam("@title",(DbType)SqlDbType.NVarChar,80,""),
									   DbHelper.MakeInParam("@verifycode",(DbType)SqlDbType.VarChar,10,onlineUserInfo.Verifycode),
									   DbHelper.MakeInParam("@newpms",(DbType)SqlDbType.SmallInt,2,onlineUserInfo.Newpms),
									   DbHelper.MakeInParam("@newnotices",(DbType)SqlDbType.SmallInt,2,onlineUserInfo.Newnotices)
								   };
            int olid = TypeConverter.ObjectToInt(DbHelper.ExecuteScalar(CommandType.StoredProcedure, 
                                                                        string.Format("{0}createonlineuser", BaseConfigs.GetTablePrefix), 
                                                                        parms));

            //按照系统设置频率(默认5分钟)清除过期用户
            if (_lastRemoveTimeout == 0 || (System.Environment.TickCount - _lastRemoveTimeout) > 60000 * deletingFrequency)
            {
                DeleteExpiredOnlineUsers(timeOut);
                _lastRemoveTimeout = System.Environment.TickCount;
            }
            // 如果id值太大则重建在线表
            if (olid > 2147483000)
            {
                CreateOnlineTable();
                DbHelper.ExecuteNonQuery(CommandType.StoredProcedure, string.Format("{0}createonlineuser", BaseConfigs.GetTablePrefix), parms);
                return 1;
            }
            return 0;
        }
		/// <summary>
		/// Copies the collection Components to a one-dimensional <see cref="T:System.Array">Array</see> instance beginning at the specified index.
		/// </summary>
		/// <param name="array">The one-dimensional <see cref="T:System.Array">Array</see> that is the destination of the values copied from the collection.</param>
		/// <param name="index">The index of the array at which to begin inserting.</param>
		public void CopyTo(OnlineUserInfo[] array, int index) 
		{
			this.List.CopyTo(array, index);
		}
Exemple #18
0
 /// <summary>
 /// 执行在线用户向表及缓存中添加的操作。
 /// </summary>
 /// <param name="onlineuserinfo">在组用户信息内容</param>
 /// <returns>添加成功则返回刚刚添加的olid,失败则返回0</returns>
 private static int Add(OnlineUserInfo onlineuserinfo, int timeout)
 {
     return DatabaseProvider.GetInstance().AddOnlineUser(onlineuserinfo, timeout);
 }
Exemple #19
0
 /// <summary>
 /// Gets the index in the collection of the specified <see cref="OnlineUserInfoCollection">OnlineUserInfoCollection</see>, if it exists in the collection.
 /// </summary>
 /// <param name="value">The <see cref="OnlineUserInfoCollection">OnlineUserInfoCollection</see> to locate in the collection.</param>
 /// <returns>The index in the collection of the specified object, if found; otherwise, -1.</returns>
 public int IndexOf(OnlineUserInfo value)
 {
     return(this.List.IndexOf(value));
 }
Exemple #20
0
        /// <summary>
        /// 用户在线信息维护。判断当前用户的身份(会员还是游客),是否在在线列表中存在,如果存在则更新会员的当前动,不存在则建立.
        /// </summary>
        /// <param name="passwordkey">论坛passwordkey</param>
        /// <param name="timeout">在线超时时间</param>
        /// <param name="passwd">用户密码</param>
        public static OnlineUserInfo UpdateInfo(string passwordkey, int timeout, int uid, string passwd)
        {

            lock (SynObject)
            {
                OnlineUserInfo onlineuser = new OnlineUserInfo();


                string ip = DNTRequest.GetIP();
                int userid = Discuz.Forum.Users.GetUserIDFromCookie();

                if (userid != -1)
                {
                    
                    onlineuser = GetOnlineUser(userid, Users.GetUserInfo(userid).Password);

                    //更新流量统计
                    if (!DNTRequest.GetPageName().EndsWith("ajax.aspx") && GeneralConfigs.GetConfig().Statstatus == 1)
                    {
                        Stats.UpdateStatCount(false, onlineuser != null);
                    }

                    if (onlineuser != null)
                    {

                        if (onlineuser.Ip != ip)
                        {
                            UpdateIP(onlineuser.Olid, ip);

                            onlineuser.Ip = ip;

                            return onlineuser;
                        }
                    }
                    else
                    {

                        // 判断密码是否正确
                        userid = Users.CheckPassword(userid, Users.GetUserInfo(userid).Password, false);
                        if (userid != -1)
                        {
                            DeleteRowsByIP(ip);
                            return CreateUser(userid, timeout);
                        }
                        else
                        {
                            // 如密码错误则在在线表中创建游客
                            onlineuser = GetOnlineUserByIP(-1, ip);
                            if (onlineuser == null)
                            {
                                return CreateGuestUser(timeout);
                            }
                        }
                    }

                }
                else
                {
                    onlineuser = GetOnlineUserByIP(-1, ip);
                    //更新流量统计
                    if (!DNTRequest.GetPageName().EndsWith("ajax.aspx") && GeneralConfigs.GetConfig().Statstatus == 1)
                    {
                        Stats.UpdateStatCount(true, onlineuser != null);
                    }

                    if (onlineuser == null)
                    {
                        return CreateGuestUser(timeout);
                    }

                }

                //UpdateLastTime(onlineuser.Olid);

                onlineuser.Lastupdatetime = Utils.GetDateTime();
                return onlineuser;

            }

        }
Exemple #21
0
 public void Insert(int index, OnlineUserInfo value)
 {
     List.Insert(index, value);
 }
Exemple #22
0
 private static OnlineUserInfo LoadSingleOnlineUser(DataRow dr)
 {
     OnlineUserInfo info = new OnlineUserInfo();
     info.Olid = Int32.Parse(dr["olid"].ToString());
     info.Userid = Int32.Parse(dr["userid"].ToString());
     info.Ip = dr["ip"].ToString();
     info.Username = dr["username"].ToString();
     //info.Tickcount = Int32.Parse(reader["tickcount"].ToString());
     info.Nickname = dr["nickname"].ToString();
     info.Password = dr["password"].ToString();
     info.Groupid = Int16.Parse(dr["groupid"].ToString());
     info.Olimg = dr["olimg"].ToString();
     info.Adminid = Int16.Parse(dr["adminid"].ToString());
     info.Invisible = Int16.Parse(dr["invisible"].ToString());
     info.Action = Int16.Parse(dr["action"].ToString());
     info.Lastactivity = Int16.Parse(dr["lastactivity"].ToString());
     info.Lastposttime = dr["lastposttime"].ToString();
     info.Lastpostpmtime = dr["lastpostpmtime"].ToString();
     info.Lastsearchtime = dr["lastsearchtime"].ToString();
     info.Lastupdatetime = dr["lastupdatetime"].ToString();
     info.Forumid = Int32.Parse(dr["forumid"].ToString());
     if (dr["forumname"] != DBNull.Value)
     {
         info.Forumname = dr["forumname"].ToString();
     }
     info.Titleid = Int32.Parse(dr["titleid"].ToString());
     if (dr["title"] != DBNull.Value)
     {
         info.Title = dr["title"].ToString();
     }
     info.Verifycode = dr["verifycode"].ToString();
     return info;
 }
Exemple #23
0
 public void Remove(OnlineUserInfo value)
 {
     List.Remove(value);
 }
Exemple #24
0
        /// <summary>
        /// Cookie中没有用户ID或则存的的用户ID无效时在在线表中增加一个游客.
        /// </summary>
        public static OnlineUserInfo CreateGuestUser(int timeout)
        {
            OnlineUserInfo onlineuserinfo = new OnlineUserInfo();

            onlineuserinfo.Userid = -1;
            onlineuserinfo.Username = "******";
            onlineuserinfo.Nickname = "游客";
            onlineuserinfo.Password = "";
            onlineuserinfo.Groupid = 7;
            onlineuserinfo.Olimg = GetGroupImg(7);
            onlineuserinfo.Adminid = 0;
            onlineuserinfo.Invisible = 0;
            onlineuserinfo.Ip = DNTRequest.GetIP();
            onlineuserinfo.Lastposttime = "1900-1-1 00:00:00";
            onlineuserinfo.Lastpostpmtime = "1900-1-1 00:00:00";
            onlineuserinfo.Lastsearchtime = "1900-1-1 00:00:00";
            onlineuserinfo.Lastupdatetime = Utils.GetDateTime();
            onlineuserinfo.Action = 0;
            onlineuserinfo.Lastactivity = 0;
            onlineuserinfo.Verifycode = ForumUtils.CreateAuthStr(5, false);
            onlineuserinfo.Olid = Discuz.Data.OnlineUsers.CreateOnlineUserInfo(onlineuserinfo, timeout);

            return onlineuserinfo;
        }
Exemple #25
0
 public int Add(OnlineUserInfo value)
 {
     return(this.List.Add(value));
 }
Exemple #26
0
        /// <summary>
        /// 用户在线信息维护。判断当前用户的身份(会员还是游客),是否在在线列表中存在,如果存在则更新会员的当前动,不存在则建立.
        /// </summary>
        /// <param name="passwordkey">论坛passwordkey</param>
        /// <param name="timeout">在线超时时间</param>
        /// <param name="passwd">用户密码</param>
        public static OnlineUserInfo UpdateInfo(string passwordkey, int timeout, int uid, string passwd)
        {
            lock (SynObject)
            {
                OnlineUserInfo onlineuser = new OnlineUserInfo();
                string ip = DNTRequest.GetIP();
                int userid = TypeConverter.StrToInt(ForumUtils.GetCookie("userid"), uid);
                string password = (Utils.StrIsNullOrEmpty(passwd) ? ForumUtils.GetCookiePassword(passwordkey) : ForumUtils.GetCookiePassword(passwd, passwordkey));

                // 如果密码非Base64编码字符串则怀疑被非法篡改, 直接置身份为游客
                if (password.Length == 0 || !Utils.IsBase64String(password))
                    userid = -1;
                
                if (userid != -1)
                {
                    onlineuser = GetOnlineUser(userid, password);

                    //更新流量统计
                    if (!DNTRequest.GetPageName().EndsWith("ajax.aspx") && GeneralConfigs.GetConfig().Statstatus == 1)
                        Stats.UpdateStatCount(false, onlineuser != null);

                    if (onlineuser != null)
                    {
                        if (onlineuser.Ip != ip)
                        {
                            UpdateIP(onlineuser.Olid, ip);
                            onlineuser.Ip = ip;
                            return onlineuser;
                        }
                    }
                    else
                    {
                        // 判断密码是否正确
                        userid = Users.CheckPassword(userid, password, false);
                        if (userid != -1)
                        {
                            Discuz.Data.OnlineUsers.DeleteRowsByIP(ip);
                            CheckIp(ip);
                            return CreateUser(userid, timeout);
                        }
                        else
                        {
                            CheckIp(ip);
                            // 如密码错误则在在线表中创建游客
                            onlineuser = GetOnlineUserByIP(-1, ip);
                            if (onlineuser == null)
                                return CreateGuestUser(timeout);
                        }
                    }
                }
                else
                {
                    onlineuser = GetOnlineUserByIP(-1, ip);
                    //更新流量统计
                    if (!DNTRequest.GetPageName().EndsWith("ajax.aspx") && GeneralConfigs.GetConfig().Statstatus == 1)
                        Stats.UpdateStatCount(true, onlineuser != null);

                    if (onlineuser == null)
                        return CreateGuestUser(timeout);
                }
                
                //onlineuser.Lastupdatetime = Utils.GetDateTime();  为了客户端能够登录注释此句,如有问题再修改。
                return onlineuser;
            }
        }
Exemple #27
0
 /// <summary>
 /// Gets a value indicating whether the collection contains the specified <see cref="OnlineUserInfoCollection">OnlineUserInfoCollection</see>.
 /// </summary>
 /// <param name="value">The <see cref="OnlineUserInfoCollection">OnlineUserInfoCollection</see> to search for in the collection.</param>
 /// <returns><b>true</b> if the collection contains the specified object; otherwise, <b>false</b>.</returns>
 public bool Contains(OnlineUserInfo value)
 {
     return(this.List.Contains(value));
 }
Exemple #28
0
        private static OnlineUserInfo LoadSingleOnlineUser(DataRow dr)
        {
            OnlineUserInfo info = new OnlineUserInfo();
            info.Olid = TypeConverter.ObjectToInt(dr["olid"]);
            info.Userid = TypeConverter.ObjectToInt(dr["userid"]);
            info.Ip = dr["ip"].ToString();
            info.Username = dr["username"].ToString();
            info.Nickname = dr["nickname"].ToString();
            info.Password = dr["password"].ToString();
            info.Groupid = Int16.Parse(dr["groupid"].ToString());
            info.Olimg = dr["olimg"].ToString();
            info.Adminid = Int16.Parse(dr["adminid"].ToString());
            info.Invisible = Int16.Parse(dr["invisible"].ToString());
            info.Action = Int16.Parse(dr["action"].ToString());
            info.Actionname = "";
            info.Lastactivity = Int16.Parse(dr["lastactivity"].ToString());
            info.Lastposttime = dr["lastposttime"].ToString();
            info.Lastpostpmtime = dr["lastpostpmtime"].ToString();
            info.Lastsearchtime = dr["lastsearchtime"].ToString();
            info.Lastupdatetime = dr["lastupdatetime"].ToString();
            info.Forumid = TypeConverter.ObjectToInt(dr["forumid"]);
            if (dr["forumname"] != DBNull.Value)
                info.Forumname = dr["forumname"].ToString();

            info.Titleid = TypeConverter.ObjectToInt(dr["titleid"]);
            if (dr["title"] != DBNull.Value)
                info.Title = dr["title"].ToString();

            info.Verifycode = dr["verifycode"].ToString();
            if (dr["newpms"] != DBNull.Value)
                info.Newpms = Int16.Parse(dr["newpms"].ToString());

            if (dr["newnotices"] != DBNull.Value)
                info.Newnotices = Int16.Parse(dr["newnotices"].ToString());

            return info;
        }
Exemple #29
0
        /// <summary>
        /// BasePage类构造函数
        /// </summary>
        public PageBase()
        {
            if (recordPageView)
                PageViewStatistic(pagename);

            config = GeneralConfigs.GetConfig();
            if (SpacePluginProvider.GetInstance() == null)
                config.Enablespace = 0;
            if (AlbumPluginProvider.GetInstance() == null)
                config.Enablealbum = 0;
            if (MallPluginProvider.GetInstance() == null)
                config.Enablemall = 0;

            LoadUrlConfig();
            userid = Utils.StrToInt(ForumUtils.GetCookie("userid"), -1);

            

            #region == 联合登录 ==
            loginUrl = System.Configuration.ConfigurationManager.AppSettings["LoginUrl"];
            registerUrl = System.Configuration.ConfigurationManager.AppSettings["RegisterUrl"];
            PlantEng.Login.ILoginAdapter la = new PlantEng.Login.LoginAdapter();
            if (la.IsClientLogin())
            {
                PlantEng.Login.LoginUserInfo loginUserInfo = la.GetLoginedUserInfo();
                int _loginUserId = loginUserInfo.UserId;
                var _shortInfo = Users.GetShortUserInfo(_loginUserId);
                if (_shortInfo != null)
                {
                    userid = _shortInfo.Uid;
                }
                //ShowMessage(string.Format("{0}",userid),0);
                //return;
                if (userid <= 0)
                {
                    //论坛中不存在此用户
                    //插入用户表
                    UserInfo newUserInfo = new UserInfo();
                    newUserInfo.Uid = loginUserInfo.UserId;
                    newUserInfo.Username = loginUserInfo.UserName;
                    newUserInfo.Nickname = loginUserInfo.UserName;
                    newUserInfo.Password = Utils.MD5("123123");
                    newUserInfo.Secques = string.Empty;
                    newUserInfo.Gender = 0;
                    newUserInfo.Adminid = 0;
                    newUserInfo.Groupexpiry = 0;
                    newUserInfo.Extgroupids = "";
                    newUserInfo.Regip = DNTRequest.GetIP();
                    newUserInfo.Joindate = Utils.GetDateTime();
                    newUserInfo.Lastip = DNTRequest.GetIP();
                    newUserInfo.Lastvisit = Utils.GetDateTime();
                    newUserInfo.Lastactivity = Utils.GetDateTime();
                    newUserInfo.Lastpost = Utils.GetDateTime();
                    newUserInfo.Lastpostid = 0;
                    newUserInfo.Lastposttitle = "";
                    newUserInfo.Posts = 0;
                    newUserInfo.Digestposts = 0;
                    newUserInfo.Oltime = 0;
                    newUserInfo.Pageviews = 0;
                    newUserInfo.Credits = 0;
                    newUserInfo.Extcredits1 = Scoresets.GetScoreSet(1).Init;
                    newUserInfo.Extcredits2 = Scoresets.GetScoreSet(2).Init;
                    newUserInfo.Extcredits3 = Scoresets.GetScoreSet(3).Init;
                    newUserInfo.Extcredits4 = Scoresets.GetScoreSet(4).Init;
                    newUserInfo.Extcredits5 = Scoresets.GetScoreSet(5).Init;
                    newUserInfo.Extcredits6 = Scoresets.GetScoreSet(6).Init;
                    newUserInfo.Extcredits7 = Scoresets.GetScoreSet(7).Init;
                    newUserInfo.Extcredits8 = Scoresets.GetScoreSet(8).Init;
                    newUserInfo.Email = loginUserInfo.Email;
                    newUserInfo.Bday = string.Empty;
                    newUserInfo.Sigstatus = 0;

                    newUserInfo.Tpp = 0;
                    newUserInfo.Ppp = 0;
                    newUserInfo.Templateid = 0;
                    newUserInfo.Pmsound = 0;
                    newUserInfo.Showemail = 0;
                    newUserInfo.Salt = "0";
                    newUserInfo.Invisible = 0;
                    newUserInfo.Newpm = 0;
                    newUserInfo.Medals = "";
                    newUserInfo.Accessmasks = 0;
                    newUserInfo.Website = string.Empty;
                    newUserInfo.Icq = string.Empty;
                    newUserInfo.Qq = string.Empty;
                    newUserInfo.Yahoo = string.Empty;
                    newUserInfo.Msn = string.Empty;
                    newUserInfo.Skype = string.Empty;
                    newUserInfo.Location = string.Empty;
                    newUserInfo.Customstatus = string.Empty;
                    newUserInfo.Bio = string.Empty;
                    newUserInfo.Signature = string.Empty;
                    newUserInfo.Sightml = string.Empty;
                    newUserInfo.Authtime = Utils.GetDateTime();
                    newUserInfo.Authstr = "";
                    newUserInfo.Authflag = 0;
                    newUserInfo.Groupid = UserCredits.GetCreditsUserGroupId(0).Groupid;
                    newUserInfo.Realname = string.Empty;
                    newUserInfo.Idcard = string.Empty;
                    newUserInfo.Mobile = string.Empty;
                    newUserInfo.Phone = string.Empty;


                    userid = Discuz.Forum.Users.CreateUser(newUserInfo);

                }
                //ShowMessage(string.Format("{0}|{1}", userid,useradminid), 0);
                //return;
                ShortUserInfo userInfo = Users.GetShortUserInfo(userid);
                usergroupinfo = UserGroups.GetUserGroupInfo(userInfo.Groupid);
                useradminid = usergroupinfo.Radminid; // 根据用户组得到相关联的管理组id


                //更新论坛信息
                Users.UpdateTrendStat(TrendType.Login);
                OnlineUsers.UpdateAction(olid, UserAction.Login.ActionID, 0);
                LoginLogs.DeleteLoginLog(DNTRequest.GetIP());
                Users.UpdateUserCreditsAndVisit(userInfo.Uid, DNTRequest.GetIP());

                //写Cookie信息
                ForumUtils.WriteUserCookie(userid, 30, config.Passwordkey, 0, -1);
                ForumUtils.WriteUserCreditsCookie(userInfo, usergroupinfo.Grouptitle);

            }
            #endregion

            //清空当前页面查询统计
#if DEBUG
            Discuz.Data.DbHelper.QueryCount = 0;
            Discuz.Data.DbHelper.QueryDetail = "";
#endif
           
            // 如果启用游客页面缓存,则对游客输出缓存页
            if (userid == -1 && config.Guestcachepagetimeout > 0 && GetUserCachePage(pagename))
                return;

            AddMetaInfo(config.Seokeywords, config.Seodescription, config.Seohead);

            if (config.Nocacheheaders == 1)
            {
                System.Web.HttpContext.Current.Response.BufferOutput = false;
                System.Web.HttpContext.Current.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
                System.Web.HttpContext.Current.Response.Cache.SetExpires(DateTime.Now.AddDays(-1));
                System.Web.HttpContext.Current.Response.Expires = 0;
                System.Web.HttpContext.Current.Response.CacheControl = "no-cache";
                System.Web.HttpContext.Current.Response.Cache.SetNoStore();
            } 

            //当为forumlist.aspx或forumindex.aspx,可能出现在线并发问题,这时系统会延时2秒
            if ((pagename != "forumlist.aspx") && (pagename != "forumindex.aspx")){
                oluserinfo = OnlineUsers.UpdateInfo(config.Passwordkey, config.Onlinetimeout);
            }
            else
            {
                try
                {
                   oluserinfo = OnlineUsers.UpdateInfo(config.Passwordkey, config.Onlinetimeout);
                }
                catch
                {
                    System.Threading.Thread.Sleep(2000);
                    oluserinfo = OnlineUsers.UpdateInfo(config.Passwordkey, config.Onlinetimeout);
                }
            }
            userid = oluserinfo.Userid;
            usergroupid = oluserinfo.Groupid;
            username = oluserinfo.Username;
            password = oluserinfo.Password;
            userkey = password.Length > 16 ? password.Substring(4, 8).Trim() : "";
            lastposttime = oluserinfo.Lastposttime;
            lastpostpmtime = oluserinfo.Lastpostpmtime;
            lastsearchtime = oluserinfo.Lastsearchtime;
            olid = oluserinfo.Olid;
           
            if (config.PostTimeStorageMedia == 1 && Utils.GetCookie("lastposttime") != "")//如果最后发帖时间cookie不为空,则在此修改用户的该属性
                oluserinfo.Lastposttime = Utils.GetCookie("lastposttime");
            //确保头像可以取到
            if (userid > 0)
                useravatar = Avatars.GetAvatarUrl(userid, AvatarSize.Small);

            if (Utils.InArray(DNTRequest.GetString("selectedtemplateid"), Templates.GetValidTemplateIDList()))
                templateid = DNTRequest.GetInt("selectedtemplateid", 0);
            else if (Utils.InArray(Utils.GetCookie(Utils.GetTemplateCookieName()), Templates.GetValidTemplateIDList()))
                templateid = Utils.StrToInt(Utils.GetCookie(Utils.GetTemplateCookieName()), config.Templateid);

            if (templateid == 0)
                templateid = config.Templateid;

            pmsound = Utils.StrToInt(ForumUtils.GetCookie("pmsound"), 0);

            //已登录用户检测用户组状态,如果是禁言或禁止访问状态时间到期,则自动解禁
            if (usergroupid == 4 || usergroupid == 5)
            {

                //int groupExpiry = Users.GetShortUserInfo(userid).Groupexpiry;
                //if (groupExpiry != 0 && groupExpiry <= Utils.StrToInt(DateTime.Now.ToString("yyyyMMdd"), 0))
                //{
                //    //先改为第一个积分组
                //    usergroupid = 11;
                //    //usergroupinfo = UserGroups.GetUserGroupInfo(usergroupid);
                //    Users.UpdateUserGroup(userid, 11);
                //}

                ShortUserInfo userInfo = Users.GetShortUserInfo(userid);
                if (userInfo.Groupexpiry != 0 && userInfo.Groupexpiry <= Utils.StrToInt(DateTime.Now.ToString("yyyyMMdd"), 0))
                {
                    UserGroupInfo groupInfo = UserCredits.GetCreditsUserGroupId(userInfo.Credits);
                    usergroupid = groupInfo.Groupid != 0 ? groupInfo.Groupid : usergroupid;
                    Users.UpdateUserGroup(userid, usergroupid);
                }
            }

            usergroupinfo = UserGroups.GetUserGroupInfo(usergroupid);

            // 取得用户权限id,1管理员,2超版,3版主,0普通组,-1特殊组
            useradminid = usergroupinfo.Radminid;
            string tips = ForumUtils.GetUserCreditsCookie(userid, usergroupinfo.Grouptitle);
            if (tips != "")
            {
                string[] userinfotipsList = tips.Split(',');//因为考虑到应用程序做单点登录时获取不到userinfotips,封装了此方法
                userinfotips = "<p><a class=\"drop\" onmouseover=\"showMenu(this.id);\" href=\"" + BaseConfigs.GetForumPath + "usercpcreditspay.aspx\" id=\"extcreditmenu\">" + userinfotipsList[0] + "</a> ";
                userinfotips += "<span class=\"pipe\">|</span>用户组: <a class=\"xi2\" id=\"g_upmine\" href=\"" + BaseConfigs.GetForumPath + "usercp.aspx\">" + userinfotipsList[1].Split(':')[1] + "</a></p>";
                userinfotips += "<ul id=\"extcreditmenu_menu\" class=\"p_pop\" style=\"display:none;\">";
                for (int i = 2; i < userinfotipsList.Length; i++)
                {
                    userinfotips += string.Format("<li><a> {0}</a></li>", userinfotipsList[i]);
                }
                userinfotips += "</ul>";
            }

            mainnavigation = Navs.GetNavigationString(userid, useradminid);
            subnavigation = Navs.GetSubNavigation();
            mainnavigationhassub = Navs.GetMainNavigationHasSub();
            // 如果论坛关闭且当前用户请求页面不是登录页面且用户非管理员, 则跳转至论坛关闭信息页
            if (config.Closed == 1 && pagename != "login.aspx" && pagename != "logout.aspx" && pagename != "register.aspx" && useradminid != 1)
            {
                ShowMessage(1);
                return;
            }

            if (!Utils.InArray(pagename, "attachment.aspx"))//加入附件页面判断减少性能消耗
                onlineusercount = (userid != -1) ? OnlineUsers.GetOnlineAllUserCount() : OnlineUsers.GetCacheOnlineAllUserCount();

            //校验用户是否可以访问论坛
            if (!ValidateUserPermission())
                return;

            //更新用户在线时长
            if (userid != -1 && !Utils.InArray(pagename, "attachment.aspx"))//加入附件页面判断减少性能消耗
                OnlineUsers.UpdateOnlineTime(config.Oltimespan, userid);
            TemplateInfo templateInfo = Templates.GetTemplateItem(templateid);
            templatepath = templateInfo.Directory;
            if (templateInfo.Templateurl.ToLower().StartsWith("http://"))
            {
                imagedir = templateInfo.Templateurl.TrimEnd('/') + "/images";
                cssdir = templateInfo.Templateurl.TrimEnd('/');
            }
            else
            {
                imagedir = forumpath + "templates/" + templateInfo.Directory + "/images";
                cssdir = forumpath + "templates/" + templateInfo.Directory;
            }
            if (EntLibConfigs.GetConfig() != null && !Utils.StrIsNullOrEmpty(EntLibConfigs.GetConfig().Topicidentifydir))
                topicidentifydir = EntLibConfigs.GetConfig().Topicidentifydir.TrimEnd('/');
            else
                topicidentifydir = forumpath + "images/identify";

            if (EntLibConfigs.GetConfig() != null && !Utils.StrIsNullOrEmpty(EntLibConfigs.GetConfig().Posticondir))
                posticondir = EntLibConfigs.GetConfig().Posticondir.TrimEnd('/');
            else
                posticondir = forumpath + "images/posticons";



            if (EntLibConfigs.GetConfig() != null && !Utils.StrIsNullOrEmpty(EntLibConfigs.GetConfig().Jsdir))
                jsdir = EntLibConfigs.GetConfig().Jsdir.TrimEnd('/');
            else
                jsdir = rooturl + "javascript";

            nowdate = Utils.GetDate();
            nowtime = Utils.GetTime();
            nowdatetime = Utils.GetDateTime();
            ispost = DNTRequest.IsPost();
            isget = DNTRequest.IsGet();
            link = "";
            script = "";

            templatelistboxoptions = Caches.GetTemplateListBoxOptionsCache();

            string originalTemplate = string.Format("<li><a href=\"###\" onclick=\"window.location.href='{0}showtemplate.aspx?templateid={1}'\">",
                                   "", BaseConfigs.GetForumPath, templateid);
            string newTemplate = string.Format("<li class=\"current\"><a href=\"###\" onclick=\"window.location.href='{0}showtemplate.aspx?templateid={1}'\">",
                                     BaseConfigs.GetForumPath, templateid);
            templatelistboxoptions = templatelistboxoptions.Replace(originalTemplate, newTemplate);

            isLoginCode = config.Seccodestatus.Contains("login.aspx");
            //当该页面设置了验证码检验,并且当前用户的用户组没有给予忽略验证码的权限,则isseccode=true;
            isseccode = Utils.InArray(pagename, config.Seccodestatus) && usergroupinfo.Ignoreseccode == 0;


            headerad = Advertisements.GetOneHeaderAd("", 0);
            footerad = Advertisements.GetOneFooterAd("", 0);

            //设定当前页面的显示样式
            if (config.Allowchangewidth == 0)
                Utils.WriteCookie("allowchangewidth", "");

            if (pagename != "website.aspx")
            {
                if (Utils.GetCookie("allowchangewidth") == "0" || (string.IsNullOrEmpty(Utils.GetCookie("allowchangewidth")) && config.Showwidthmode == 1))
                    isnarrowpage = true;
            }

            //校验验证码
            if (isseccode && ispost && !ValidateVerifyCode())
                return;

            newtopicminute = config.Viewnewtopicminute;
            m_starttick = DateTime.Now;

            ShowPage();

            m_processtime = DateTime.Now.Subtract(m_starttick).TotalMilliseconds / 1000;

            querycount = Discuz.Data.DbHelper.QueryCount;
            Discuz.Data.DbHelper.QueryCount = 0;

#if DEBUG
            querydetail = Discuz.Data.DbHelper.QueryDetail;
            Discuz.Data.DbHelper.QueryDetail = "";
#endif
        }
Exemple #30
0
        /// <summary>
        /// 执行在线用户向表及缓存中添加的操作。
        /// </summary>
        /// <param name="onlineuserinfo">在组用户信息内容</param>
        /// <param name="timeout">系统设置用户多少时间即算做离线</param>
        /// <param name="deletingfrequency">删除过期用户频率(单位:分钟)</param>
        /// <returns>添加成功则返回刚刚添加的olid,失败则返回0</returns>
        public int AddOnlineUser(OnlineUserInfo onlineUserInfo, int timeOut, int deletingFrequency)
        {
            //标识需要更新用户在线状态,0表示需要更新
            int onlinestate = 1;

            // 如果timeout为负数则代表不需要精确更新用户是否在线的状态
            if (timeOut > 0)
            {
                if (onlineUserInfo.Userid > 0)
                    onlinestate = 0;
            }
            else
                timeOut = timeOut * -1;

            if (timeOut > 9999)
                timeOut = 9999;

            DbParameter[] parms = {
									   DbHelper.MakeInParam("@onlinestate",(DbType)SqlDbType.Int,4,onlinestate),
									   DbHelper.MakeInParam("@userid",(DbType)SqlDbType.Int,4,onlineUserInfo.Userid),
									   DbHelper.MakeInParam("@ip",(DbType)SqlDbType.VarChar,15,onlineUserInfo.Ip),
									   DbHelper.MakeInParam("@username",(DbType)SqlDbType.NVarChar,40,onlineUserInfo.Username),
									   DbHelper.MakeInParam("@nickname",(DbType)SqlDbType.NVarChar,40,onlineUserInfo.Nickname),
									   DbHelper.MakeInParam("@password",(DbType)SqlDbType.Char,32,onlineUserInfo.Password),
									   DbHelper.MakeInParam("@groupid",(DbType)SqlDbType.SmallInt,2,onlineUserInfo.Groupid),
									   DbHelper.MakeInParam("@olimg",(DbType)SqlDbType.VarChar,80,onlineUserInfo.Olimg),
									   DbHelper.MakeInParam("@adminid",(DbType)SqlDbType.SmallInt,2,onlineUserInfo.Adminid),
									   DbHelper.MakeInParam("@invisible",(DbType)SqlDbType.SmallInt,2,onlineUserInfo.Invisible),
									   DbHelper.MakeInParam("@action",(DbType)SqlDbType.SmallInt,2,onlineUserInfo.Action),
									   DbHelper.MakeInParam("@lastactivity",(DbType)SqlDbType.SmallInt,2,onlineUserInfo.Lastactivity),
									   DbHelper.MakeInParam("@lastposttime",(DbType)SqlDbType.DateTime,8,TypeConverter.StrToDateTime(onlineUserInfo.Lastposttime)),
									   DbHelper.MakeInParam("@lastpostpmtime",(DbType)SqlDbType.DateTime,8,TypeConverter.StrToDateTime(onlineUserInfo.Lastpostpmtime)),
									   DbHelper.MakeInParam("@lastsearchtime",(DbType)SqlDbType.DateTime,8,TypeConverter.StrToDateTime(onlineUserInfo.Lastsearchtime)),
									   DbHelper.MakeInParam("@lastupdatetime",(DbType)SqlDbType.DateTime,8,TypeConverter.StrToDateTime(onlineUserInfo.Lastupdatetime)),
									   DbHelper.MakeInParam("@forumid",(DbType)SqlDbType.Int,4,onlineUserInfo.Forumid),
									   DbHelper.MakeInParam("@forumname",(DbType)SqlDbType.NVarChar,50,""),
									   DbHelper.MakeInParam("@titleid",(DbType)SqlDbType.Int,4,onlineUserInfo.Titleid),
									   DbHelper.MakeInParam("@title",(DbType)SqlDbType.NVarChar,80,""),
									   DbHelper.MakeInParam("@verifycode",(DbType)SqlDbType.VarChar,10,onlineUserInfo.Verifycode),
									   DbHelper.MakeInParam("@newpms",(DbType)SqlDbType.SmallInt,2,onlineUserInfo.Newpms),
									   DbHelper.MakeInParam("@newnotices",(DbType)SqlDbType.SmallInt,2,onlineUserInfo.Newnotices)
                                       //DbHelper.MakeInParam("@newfriendrequest",(DbType)SqlDbType.SmallInt,2,onlineUserInfo.Newfriendrequest),
                                       //DbHelper.MakeInParam("@newapprequest",(DbType)SqlDbType.SmallInt,2,onlineUserInfo.Newapprequest)
								   };

            //当在线表被布署到别的数据库时
            if (EntLibConfigs.GetConfig() != null)
            {
                OnlineTableConnect onlineTableConnect = EntLibConfigs.GetConfig().Onlinetableconnect;
                if (onlineTableConnect.Enable && !string.IsNullOrEmpty(onlineTableConnect.SqlServerConn))
                {
                    if (onlinestate == 0)
                        DbHelper.ExecuteNonQuery(CommandType.Text, string.Format("UPDATE [{0}users] SET [onlinestate]=1 WHERE [uid]=@userid", BaseConfigs.GetTablePrefix), parms);

                    parms[0].Value = 1;//HACK:这个就不会在存储过程中运行更新users表信息的语句了,因为可能在分离的dnt_online表所在数据库中没有USER表。 
                }
            }

            int olid = TypeConverter.ObjectToInt(DbHelper.ExecuteScalar(CommandType.StoredProcedure,
                                                                        string.Format("{0}createonlineuser", BaseConfigs.GetTablePrefix),
                                                                        parms));

            //按照系统设置频率(默认5分钟)清除过期用户
            if (_lastRemoveTimeout == 0 || (System.Environment.TickCount - _lastRemoveTimeout) > 60000 * deletingFrequency)
            {
                DeleteExpiredOnlineUsers(timeOut);
                _lastRemoveTimeout = System.Environment.TickCount;
            }
            // 如果id值太大则重建在线表
            if (olid > 2147483000)
            {
                CreateOnlineTable();

                olid = TypeConverter.ObjectToInt(DbHelper.ExecuteScalar(CommandType.StoredProcedure,
                                                                        string.Format("{0}createonlineuser", BaseConfigs.GetTablePrefix),
                                                                        parms));

                //DbHelper.ExecuteNonQuery(CommandType.StoredProcedure, string.Format("{0}createonlineuser", BaseConfigs.GetTablePrefix), parms);
                //  return olid;
            }
            return olid;
        }
Exemple #31
0
        /// <summary>
        /// BasePage类构造函数
        /// </summary>
        public PageBase()
        {
            config = GeneralConfigs.GetConfig();
            if (SpacePluginProvider.GetInstance() == null)
                config.Enablespace = 0;
            if (AlbumPluginProvider.GetInstance() == null)
                config.Enablealbum = 0;
            if (MallPluginProvider.GetInstance() == null)
                config.Enablemall = 0;

            LoadUrlConfig();
            userid = Utils.StrToInt(ForumUtils.GetCookie("userid"), -1);

            //清空当前页面查询统计
#if DEBUG
            Discuz.Data.DbHelper.QueryCount = 0;
            Discuz.Data.DbHelper.QueryDetail = "";
#endif
            // 如果启用游客页面缓存,则对游客输出缓存页
            if (userid == -1 && config.Guestcachepagetimeout > 0 && GetUserCachePage(pagename))
                return;

            AddMetaInfo(config.Seokeywords, config.Seodescription, config.Seohead);

            if (config.Nocacheheaders == 1)
            {
                System.Web.HttpContext.Current.Response.BufferOutput = false;
                System.Web.HttpContext.Current.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
                System.Web.HttpContext.Current.Response.Cache.SetExpires(DateTime.Now.AddDays(-1));
                System.Web.HttpContext.Current.Response.Expires = 0;
                System.Web.HttpContext.Current.Response.CacheControl = "no-cache";
                System.Web.HttpContext.Current.Response.Cache.SetNoStore();
            }

            //当为forumlist.aspx或forumindex.aspx,可能出现在线并发问题,这时系统会延时2秒
            if ((pagename != "forumlist.aspx") && (pagename != "forumindex.aspx"))
                oluserinfo = OnlineUsers.UpdateInfo(config.Passwordkey, config.Onlinetimeout);
            else
            {
                try
                {
                    oluserinfo = OnlineUsers.UpdateInfo(config.Passwordkey, config.Onlinetimeout);
                }
                catch
                {
                    System.Threading.Thread.Sleep(2000);
                    oluserinfo = OnlineUsers.UpdateInfo(config.Passwordkey, config.Onlinetimeout);
                }
            }

            userid = oluserinfo.Userid;
            usergroupid = oluserinfo.Groupid;
            username = oluserinfo.Username;
            password = oluserinfo.Password;
            userkey = password.Length > 16 ? password.Substring(4, 8).Trim() : "";     
            lastposttime = oluserinfo.Lastposttime;
            lastpostpmtime = oluserinfo.Lastpostpmtime;
            lastsearchtime = oluserinfo.Lastsearchtime;
            olid = oluserinfo.Olid;

            //确保头像可以取到
            if (userid > 0)
                useravatar = Avatars.GetAvatarUrl(userid, AvatarSize.Small);

            if (Utils.InArray(DNTRequest.GetString("selectedtemplateid"), Templates.GetValidTemplateIDList()))
                templateid = DNTRequest.GetInt("selectedtemplateid", 0);
            else if (Utils.InArray(Utils.GetCookie(Utils.GetTemplateCookieName()), Templates.GetValidTemplateIDList()))
                templateid = Utils.StrToInt(Utils.GetCookie(Utils.GetTemplateCookieName()), config.Templateid);

            if (templateid == 0)
                templateid = config.Templateid;

            pmsound = Utils.StrToInt(ForumUtils.GetCookie("pmsound"), 0);

            usergroupinfo = UserGroups.GetUserGroupInfo(usergroupid);

            // 取得用户权限id,1管理员,2超版,3版主,0普通组,-1特殊组
            useradminid = usergroupinfo.Radminid;

            mainnavigation = Navs.GetNavigationString(userid, useradminid);
            subnavigation = Navs.GetSubNavigation();
            mainnavigationhassub = Navs.GetMainNavigationHasSub();
            // 如果论坛关闭且当前用户请求页面不是登录页面且用户非管理员, 则跳转至论坛关闭信息页
            if (config.Closed == 1 && pagename != "login.aspx" && pagename != "logout.aspx" && pagename != "register.aspx" && useradminid != 1)
            {
                ShowMessage(1);
                return;
            }

            onlineusercount = (userid != -1) ? OnlineUsers.GetOnlineAllUserCount() : OnlineUsers.GetCacheOnlineAllUserCount();
         
            //校验用户是否可以访问论坛
            if (!ValidateUserPermission())
                return;

            //更新用户在线时长
            if (userid != -1)
                OnlineUsers.UpdateOnlineTime(config.Oltimespan, userid);

            templatepath = Templates.GetTemplateItem(templateid).Directory;
            nowdate = Utils.GetDate();
            nowtime = Utils.GetTime();
            nowdatetime = Utils.GetDateTime();
            ispost = DNTRequest.IsPost();
            isget = DNTRequest.IsGet();
            link = "";
            script = "";

            templatelistboxoptions = Caches.GetTemplateListBoxOptionsCache();

            string originalTemplate = string.Format("<li><a href=\"###\" onclick=\"window.location.href='{0}showtemplate.aspx?templateid={1}'\">",
                                   "", BaseConfigs.GetForumPath, templateid);
            string newTemplate = string.Format("<li class=\"current\"><a href=\"###\" onclick=\"window.location.href='{0}showtemplate.aspx?templateid={1}'\">",
                                     BaseConfigs.GetForumPath, templateid);
            templatelistboxoptions = templatelistboxoptions.Replace(originalTemplate, newTemplate);

            isseccode = Utils.InArray(pagename, config.Seccodestatus);
            headerad = Advertisements.GetOneHeaderAd("", 0);
            footerad = Advertisements.GetOneFooterAd("", 0);

            //校验验证码
            if (isseccode && ispost && !ValidateVerifyCode())
                return;

            newtopicminute = config.Viewnewtopicminute;
            m_starttick = DateTime.Now;

            ShowPage();

            m_processtime = DateTime.Now.Subtract(m_starttick).TotalMilliseconds / 1000;

            querycount = Discuz.Data.DbHelper.QueryCount;
            Discuz.Data.DbHelper.QueryCount = 0;

#if DEBUG
            querydetail = Discuz.Data.DbHelper.QueryDetail;
            Discuz.Data.DbHelper.QueryDetail = "";
#endif
        }
Exemple #32
0
        /// <summary>
        /// ִ�������û�������������ӵIJ�����
        /// </summary>
        /// <param name="onlineuserinfo">�����û���Ϣ����</param>
        /// <param name="timeout">ϵͳ�����û�����ʱ�伴��������</param>
        /// <param name="deletingfrequency">ɾ�������û�Ƶ��(��λ:����)</param>
        /// <returns>��ӳɹ��򷵻ظո���ӵ�olid,ʧ���򷵻�0</returns>
        public int AddOnlineUser(OnlineUserInfo onlineUserInfo, int timeOut, int deletingFrequency)
        {
            //��ʶ��Ҫ�����û�����״̬��0��ʾ��Ҫ����
            int onlinestate = 1;

            // ���timeoutΪ������������Ҫ��ȷ�����û��Ƿ����ߵ�״̬
            if (timeOut > 0)
            {
                if (onlineUserInfo.Userid > 0)
                    onlinestate = 0;
            }
            else
                timeOut = timeOut * -1;

            if (timeOut > 9999)
                timeOut = 9999;

            DbParameter[] parms = {
                                       DbHelper.MakeInParam("@onlinestate",(DbType)SqlDbType.Int,4,onlinestate),
                                       DbHelper.MakeInParam("@userid",(DbType)SqlDbType.Int,4,onlineUserInfo.Userid),
                                       DbHelper.MakeInParam("@ip",(DbType)SqlDbType.VarChar,15,onlineUserInfo.Ip),
                                       DbHelper.MakeInParam("@username",(DbType)SqlDbType.NVarChar,40,onlineUserInfo.Username),
                                       DbHelper.MakeInParam("@nickname",(DbType)SqlDbType.NVarChar,40,onlineUserInfo.Nickname),
                                       DbHelper.MakeInParam("@password",(DbType)SqlDbType.Char,32,onlineUserInfo.Password),
                                       DbHelper.MakeInParam("@groupid",(DbType)SqlDbType.SmallInt,2,onlineUserInfo.Groupid),
                                       DbHelper.MakeInParam("@olimg",(DbType)SqlDbType.VarChar,80,onlineUserInfo.Olimg),
                                       DbHelper.MakeInParam("@adminid",(DbType)SqlDbType.SmallInt,2,onlineUserInfo.Adminid),
                                       DbHelper.MakeInParam("@invisible",(DbType)SqlDbType.SmallInt,2,onlineUserInfo.Invisible),
                                       DbHelper.MakeInParam("@action",(DbType)SqlDbType.SmallInt,2,onlineUserInfo.Action),
                                       DbHelper.MakeInParam("@lastactivity",(DbType)SqlDbType.SmallInt,2,onlineUserInfo.Lastactivity),
                                       DbHelper.MakeInParam("@lastposttime",(DbType)SqlDbType.DateTime,8,TypeConverter.StrToDateTime(onlineUserInfo.Lastposttime)),
                                       DbHelper.MakeInParam("@lastpostpmtime",(DbType)SqlDbType.DateTime,8,TypeConverter.StrToDateTime(onlineUserInfo.Lastpostpmtime)),
                                       DbHelper.MakeInParam("@lastsearchtime",(DbType)SqlDbType.DateTime,8,TypeConverter.StrToDateTime(onlineUserInfo.Lastsearchtime)),
                                       DbHelper.MakeInParam("@lastupdatetime",(DbType)SqlDbType.DateTime,8,TypeConverter.StrToDateTime(onlineUserInfo.Lastupdatetime)),
                                       DbHelper.MakeInParam("@forumid",(DbType)SqlDbType.Int,4,onlineUserInfo.Forumid),
                                       DbHelper.MakeInParam("@forumname",(DbType)SqlDbType.NVarChar,50,""),
                                       DbHelper.MakeInParam("@titleid",(DbType)SqlDbType.Int,4,onlineUserInfo.Titleid),
                                       DbHelper.MakeInParam("@title",(DbType)SqlDbType.NVarChar,80,""),
                                       DbHelper.MakeInParam("@verifycode",(DbType)SqlDbType.VarChar,10,onlineUserInfo.Verifycode),
                                       DbHelper.MakeInParam("@newpms",(DbType)SqlDbType.SmallInt,2,onlineUserInfo.Newpms),
                                       DbHelper.MakeInParam("@newnotices",(DbType)SqlDbType.SmallInt,2,onlineUserInfo.Newnotices)
                                       //DbHelper.MakeInParam("@newfriendrequest",(DbType)SqlDbType.SmallInt,2,onlineUserInfo.Newfriendrequest),
                                       //DbHelper.MakeInParam("@newapprequest",(DbType)SqlDbType.SmallInt,2,onlineUserInfo.Newapprequest)
                                   };

            //�����߱�����𵽱�����ݿ�ʱ
            if (EntLibConfigs.GetConfig() != null)
            {
                OnlineTableConnect onlineTableConnect = EntLibConfigs.GetConfig().Onlinetableconnect;
                if (onlineTableConnect.Enable && !string.IsNullOrEmpty(onlineTableConnect.SqlServerConn))
                {
                    if (onlinestate == 0)
                        DbHelper.ExecuteNonQuery(CommandType.Text, string.Format("UPDATE [{0}users] SET [onlinestate]=1 WHERE [uid]=@userid", BaseConfigs.GetTablePrefix), parms);

                    parms[0].Value = 1;//HACK������Ͳ����ڴ洢���������и���users����Ϣ������ˣ���Ϊ�����ڷ����dnt_online���������ݿ���û��USER���
                }
            }

            int olid = TypeConverter.ObjectToInt(DbHelper.ExecuteScalar(CommandType.StoredProcedure,
                                                                        string.Format("{0}createonlineuser", BaseConfigs.GetTablePrefix),
                                                                        parms));

            //����ϵͳ����Ƶ��(Ĭ��5����)��������û�
            if (_lastRemoveTimeout == 0 || (System.Environment.TickCount - _lastRemoveTimeout) > 60000 * deletingFrequency)
            {
                DeleteExpiredOnlineUsers(timeOut);
                _lastRemoveTimeout = System.Environment.TickCount;
            }
            // ���idֵ̫�����ؽ����߱�
            if (olid > 2147483000)
            {
                CreateOnlineTable();

                olid = TypeConverter.ObjectToInt(DbHelper.ExecuteScalar(CommandType.StoredProcedure,
                                                                        string.Format("{0}createonlineuser", BaseConfigs.GetTablePrefix),
                                                                        parms));

                //DbHelper.ExecuteNonQuery(CommandType.StoredProcedure, string.Format("{0}createonlineuser", BaseConfigs.GetTablePrefix), parms);
                //  return olid;
            }
            return olid;
        }
Exemple #33
0
        /// <summary>
        /// BasePage类构造函数
        /// </summary>
        public void PageBaseStart()
        {
            config = GeneralConfigs.GetConfig();

            LoadUrlConfig();
            Issmileyinsert = config.Smileyinsert;
            userid = Discuz.Forum.Users.GetUserIDFromCookie();

            if (userid <= 0)
            {
                userid = -1;
            }

            #region 为 CPS 商家保存第一次访问的二级域名

            new FirstUrl().Save();

            #endregion


            //清空当前页面查询统计
            Discuz.Data.DbHelper.QueryCount = 0;

#if DEBUG
            Discuz.Data.DbHelper.QueryDetail = "";
#endif



            // 如果启用游客页面缓存,则对游客输出缓存页
            if (userid == -1 && config.Guestcachepagetimeout > 0)
            {
                if (GetUserCachePage(pagename))
                    return;
            }


            AddMetaInfo(config.Seokeywords, config.Seodescription, config.Seohead);


            if (config.Nocacheheaders == 1)
            {
                System.Web.HttpContext.Current.Response.BufferOutput = false;
                System.Web.HttpContext.Current.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
                System.Web.HttpContext.Current.Response.Cache.SetExpires(DateTime.Now.AddDays(-1));
                System.Web.HttpContext.Current.Response.Expires = 0;
                System.Web.HttpContext.Current.Response.CacheControl = "no-cache";
                System.Web.HttpContext.Current.Response.Cache.SetNoStore();
            }



            //当为forumlist.aspx或focuslist_aspx,可能出现在线并发问题,这时系统会延时2秒
            if ((pagename != "forumlist.aspx") && (pagename != "focuslist.aspx"))
            {
                oluserinfo = OnlineUsers.UpdateInfo(config.Passwordkey, config.Onlinetimeout);
            }
            else
            {
                try
                {
                    oluserinfo = OnlineUsers.UpdateInfo(config.Passwordkey, config.Onlinetimeout);
                }
                catch
                {
                    System.Threading.Thread.Sleep(2000);
                    oluserinfo = OnlineUsers.UpdateInfo(config.Passwordkey, config.Onlinetimeout);
                }
            }

            userid = oluserinfo.Userid;
            usergroupid = oluserinfo.Groupid;
            username = oluserinfo.Username;
            password = oluserinfo.Password;
            if (password.Length > 16)
            {
                userkey = password.Substring(4, 8).Trim();
            }
            else
            {
                userkey = "";
            }
            lastposttime = oluserinfo.Lastposttime;
            lastpostpmtime = oluserinfo.Lastpostpmtime;
            lastsearchtime = oluserinfo.Lastsearchtime;
            olid = oluserinfo.Olid;

            //确保头像可以取到
            if (userid > 0)
            {
                useravatar = Utils.UrlDecode(ForumUtils.GetCookie("avatar"));
                if (useravatar == string.Empty)
                {
                    useravatar = Users.GetUserInfo(userid).Avatar;

                    //ForumUtils.WriteCookie("avatar", Utils.UrlEncode(useravatar));
                }
            }

            if (Utils.InArray(DNTRequest.GetString("selectedtemplateid"), Templates.GetValidTemplateIDList()))
            {
                templateid = DNTRequest.GetInt("selectedtemplateid", 0);
            }
            else if (Utils.InArray(Utils.GetCookie(Utils.GetTemplateCookieName()), Templates.GetValidTemplateIDList()))
            {
                templateid = Utils.StrToInt(Utils.GetCookie(Utils.GetTemplateCookieName()), config.Templateid);
            }

            if (templateid == 0)
            {
                templateid = config.Templateid;
            }



            pmsound = Utils.StrToInt(ForumUtils.GetCookie("pmsound"), 0);

            usergroupinfo = UserGroups.GetUserGroupInfo(usergroupid);

            // 根据用户组得到相关联的管理组id
            useradminid = usergroupinfo.Radminid;

            // 如果论坛关闭且当前用户请求页面不是登录页面且用户非管理员, 则跳转至论坛关闭信息页
            if (config.Closed == 1 && pagename != "login.aspx" && pagename != "logout.aspx" && pagename != "register.aspx" && useradminid != 1)
            {
                ShowMessage(1);
                return;
            }
            if (config.Onlinetimeout > 0 && userid != -1)
            {
                onlineusercount = OnlineUsers.GetOnlineAllUserCount();
            }
            else
            {
                onlineusercount = OnlineUsers.GetCacheOnlineAllUserCount();
            }

            //校验用户是否可以访问论坛
            if (!ValidateUserPermission())
                return;

            if (userid != -1)
            {
                //更新用户在线时长
                OnlineUsers.UpdateOnlineTime(config.Oltimespan, userid);


                string ignore = DNTRequest.GetString("ignore");
                newpmcount = Users.GetUserNewPMCount(userid);
                realnewpmcount = Math.Abs(newpmcount);
                if (ignore.ToLower().Equals("yes"))
                {
                    newpmcount = newpmcount * -1;
                    Users.SetUserNewPMCount(userid, newpmcount);
                }
            }

            templatepath = Templates.GetTemplateItem(templateid).Directory;
            nowdate = Utils.GetDate();
            nowtime = Utils.GetTime();
            nowdatetime = Utils.GetDateTime();


            ispost = DNTRequest.IsPost();
            isget = DNTRequest.IsGet();

            link = "";

            script = "";

            templatelistboxoptions = Caches.GetTemplateListBoxOptionsCache();

            isseccode = Utils.InArray(pagename, config.Seccodestatus);
            headerad = Advertisements.GetOneHeaderAd("", 0);
            footerad = Advertisements.GetOneFooterAd("", 0);

            //校验验证码
            if ((isseccode) && (ispost))
            {
                if (!ValidateVerifyCode())
                    return;
            }


            newtopicminute = config.Viewnewtopicminute;

            m_starttick = DateTime.Now;


            ShowPage();


            //m_processtime = //(System.Environment.TickCount - m_starttick) / 1000;
            m_processtime = DateTime.Now.Subtract(m_starttick).TotalMilliseconds / 1000;

            querycount = Discuz.Data.DbHelper.QueryCount;
            Discuz.Data.DbHelper.QueryCount = 0;
#if NET1
#else
#if DEBUG

            querydetail = Discuz.Data.DbHelper.QueryDetail;
            Discuz.Data.DbHelper.QueryDetail = "";
#endif
#endif

        }
Exemple #34
0
		/// <summary>
		/// 执行在线用户向表及缓存中添加的操作。
		/// </summary>
		/// <param name="__onlineuserinfo">在组用户信息内容</param>
		/// <returns>添加成功则返回刚刚添加的olid,失败则返回0</returns>
		public int AddOnlineUser(OnlineUserInfo __onlineuserinfo, int timeout)
		{

			string strDelTimeOutSql = "";
			// 如果timeout为负数则代表不需要精确更新用户是否在线的状态
			if (timeout > 0)
			{
				if (__onlineuserinfo.Userid > 0)
				{
					strDelTimeOutSql = string.Format("{0}UPDATE [{1}users] SET [onlinestate]=1 WHERE [uid]={2};", strDelTimeOutSql, BaseConfigs.GetTablePrefix, __onlineuserinfo.Userid.ToString());
				}
			}
			else
			{
				timeout = timeout * -1;
			}

			if (timeout > 9999)
			{
				timeout = 9999;
			}

			System.Text.StringBuilder sb = new System.Text.StringBuilder();
			System.Text.StringBuilder sb2 = new System.Text.StringBuilder();

			IDataReader dr = DbHelper.ExecuteReader(CommandType.Text, string.Format("SELECT [userid] FROM [{0}online] WHERE [lastupdatetime]<'{1}'", BaseConfigs.GetTablePrefix, DateTime.Parse(DateTime.Now.AddMinutes(timeout * -1).ToString("yyyy-MM-dd HH:mm:ss"))));
			try
			{
				while (dr.Read())
				{
					sb.Append(",");
					sb.Append(dr[0].ToString());
					if (dr[0].ToString() != "-1")
					{
						sb2.Append(",");
						sb2.Append(dr[0].ToString());
					}
				}
			}
			finally
			{
				dr.Close();
			}

			if (sb.Length > 0)
			{
				sb.Remove(0, 1);
				strDelTimeOutSql = string.Format("{0}DELETE FROM [{1}online] WHERE [userid] IN ({2});", strDelTimeOutSql, BaseConfigs.GetTablePrefix, sb.ToString());
			}
			if (sb2.Length > 0)
			{
				sb2.Remove(0, 1);
				strDelTimeOutSql = string.Format("{0}UPDATE [{1}users] SET [onlinestate]=0,[lastactivity]=GETDATE() WHERE [uid] IN ({2});", strDelTimeOutSql, BaseConfigs.GetTablePrefix, sb2.ToString());
			}




			IDataParameter[] prams = {
									  DbHelper.MakeInParam("@userid",(DbType)SqlDbType.Int,4,__onlineuserinfo.Userid),
									  DbHelper.MakeInParam("@ip",(DbType)SqlDbType.VarChar,15,__onlineuserinfo.Ip),
									  DbHelper.MakeInParam("@username",(DbType)SqlDbType.NVarChar,40,__onlineuserinfo.Username),
									  //DbHelper.MakeInParam("@tickcount",(DbType)SqlDbType.Int,4,System.Environment.TickCount),
									  DbHelper.MakeInParam("@nickname",(DbType)SqlDbType.NVarChar,40,__onlineuserinfo.Nickname),
									  DbHelper.MakeInParam("@password",(DbType)SqlDbType.Char,32,__onlineuserinfo.Password),
									  DbHelper.MakeInParam("@groupid",(DbType)SqlDbType.SmallInt,2,__onlineuserinfo.Groupid),
									  DbHelper.MakeInParam("@olimg",(DbType)SqlDbType.VarChar,80,__onlineuserinfo.Olimg),
									  DbHelper.MakeInParam("@adminid",(DbType)SqlDbType.SmallInt,2,__onlineuserinfo.Adminid),
									  DbHelper.MakeInParam("@invisible",(DbType)SqlDbType.SmallInt,2,__onlineuserinfo.Invisible),
									  DbHelper.MakeInParam("@action",(DbType)SqlDbType.SmallInt,2,__onlineuserinfo.Action),
									  DbHelper.MakeInParam("@lastactivity",(DbType)SqlDbType.SmallInt,2,__onlineuserinfo.Lastactivity),
									  DbHelper.MakeInParam("@lastposttime",(DbType)SqlDbType.DateTime,8,DateTime.Parse(__onlineuserinfo.Lastposttime)),
									  DbHelper.MakeInParam("@lastpostpmtime",(DbType)SqlDbType.DateTime,8,DateTime.Parse(__onlineuserinfo.Lastpostpmtime)),
									  DbHelper.MakeInParam("@lastsearchtime",(DbType)SqlDbType.DateTime,8,DateTime.Parse(__onlineuserinfo.Lastsearchtime)),
									  DbHelper.MakeInParam("@lastupdatetime",(DbType)SqlDbType.DateTime,8,DateTime.Parse(__onlineuserinfo.Lastupdatetime)),
									  DbHelper.MakeInParam("@forumid",(DbType)SqlDbType.Int,4,__onlineuserinfo.Forumid),
									  DbHelper.MakeInParam("@forumname",(DbType)SqlDbType.NVarChar,50,""),
									  DbHelper.MakeInParam("@titleid",(DbType)SqlDbType.Int,4,__onlineuserinfo.Titleid),
									  DbHelper.MakeInParam("@title",(DbType)SqlDbType.NVarChar,80,""),
									  DbHelper.MakeInParam("@verifycode",(DbType)SqlDbType.VarChar,10,__onlineuserinfo.Verifycode)
								  };
			int olid = Utils.StrToInt(DbHelper.ExecuteScalar(CommandType.Text, strDelTimeOutSql + "INSERT INTO [" + BaseConfigs.GetTablePrefix + "online] ([userid],[ip],[username],[nickname],[password],[groupid],[olimg],[adminid],[invisible],[action],[lastactivity],[lastposttime],[lastpostpmtime],[lastsearchtime],[lastupdatetime],[forumid],[forumname],[titleid],[title], [verifycode])VALUES(@userid,@ip,@username,@nickname,@password,@groupid,@olimg,@adminid,@invisible,@action,@lastactivity,@lastposttime,@lastpostpmtime,@lastsearchtime,@lastupdatetime,@forumid,@forumname,@titleid,@title,@verifycode);SELECT SCOPE_IDENTITY()", prams).ToString(), 0);

			// 如果id值太大则重建在线表
			if (olid > 2147483000)
			{
				CreateOnlineTable();
				DbHelper.ExecuteNonQuery(CommandType.Text, strDelTimeOutSql + "INSERT INTO [" + BaseConfigs.GetTablePrefix + "online] ([userid],[ip],[username],[nickname],[password],[groupid],[olimg],[adminid],[invisible],[action],[lastactivity],[lastposttime],[lastpostpmtime],[lastsearchtime],[lastupdatetime],[forumid],[titleid],[verifycode])VALUES(@userid,@ip,@username,@nickname,@password,@groupid,@olimg,@adminid,@invisible,@action,@lastactivity,@lastposttime,@lastpostpmtime,@lastsearchtime,@lastupdatetime,@forumid,@forumname,@titleid,@title,@verifycode);SELECT SCOPE_IDENTITY()", prams);
				return 1;
			}


			return 0;
			//return (int)DbHelper.ExecuteDataset(CommandType.Text, "SELECT [olid] FROM ["+BaseConfigFactory.GetTablePrefix+"online] WHERE [userid]=" + __onlineuserinfo.Userid.ToString()).Tables[0].Rows[0][0];

		}
 /// <summary>
 /// 执行在线用户向表及缓存中添加的操作。
 /// </summary>
 /// <param name="onlineuserinfo">在组用户信息内容</param>
 /// <returns>添加成功则返回刚刚添加的olid,失败则返回0</returns>
 public static int CreateOnlineUserInfo(OnlineUserInfo onlineuserinfo, int timeout)
 {
     //如果启用用户缓存则进行更新
     if (Users.appDBCache && Users.IUserService != null)
     {
         UserInfo userInfo = Users.IUserService.GetUserInfo(onlineuserinfo.Userid);
         if (userInfo != null)
         {
             userInfo.Onlinestate = 1;
             Users.IUserService.UpdateUser(userInfo);
         }
     }
     //如果启用在线用户表缓存
     if (appDBCache)
         return IOnlineUserService.CreateOnlineUserInfo(onlineuserinfo, timeout);
     else
         return DatabaseProvider.GetInstance().AddOnlineUser(onlineuserinfo, timeout, GeneralConfigs.GetConfig().Deletingexpireduserfrequency);
 }