Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!DiscuzCloud.GetCloudServiceEnableStatus("connect"))
            {
                ResponseScript("<script>alert('站点 " + (config.Cloudenabled == 1 ? "QQ 登录服务" : "云平台") +
                               "未开启');window.location.href='" + (config.Cloudenabled == 1 ? " global_cloudindex.aspx" : "global_cloudset.aspx") + "';</script>");
            }

            if (DNTRequest.GetInt("save", 0) > 0)
            {
                config.Allowconnectregister = DNTRequest.GetInt("enablereg", 0);
                config.Allowuseqzavater     = DNTRequest.GetInt("enablecatchqzavatar", 0);
                int bindCount = DNTRequest.GetInt("maxbindcount", -1);

                if (bindCount < 0)
                {
                    ResponseScript("<script>alert('允许QQ号注册数量填写错误');window.location.href='global_connectset.aspx';</script>");
                    return;
                }
                config.Maxuserbindcount = bindCount;
                DiscuzCloudConfigs.SaveConfig(config);
                DiscuzCloudConfigs.ResetConfig();
                ResponseScript("<script>alert('操作成功');window.location.href='global_connectset.aspx';</script>");
            }

            uploadLogoUrl = DiscuzCloud.GetCloudUploadLogoIFrame(userid);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取主题信息
        /// </summary>
        /// <returns></returns>
        public TopicInfo GetTopicInfo()
        {
            string go = DNTRequest.GetString("go").Trim().ToLower();

            if (go == "")
            {
                forumid = 0;
            }
            else if (forumid == 0)
            {
                go = "";
            }

            TopicInfo topicInfo;

            // 获取该主题的信息
            switch (go)
            {
            case "prev": topicInfo = Topics.GetTopicInfo(topicid, forumid, 1); break;

            case "next": topicInfo = Topics.GetTopicInfo(topicid, forumid, 2); break;

            default: topicInfo = Topics.GetTopicInfo(topicid); break;
            }

            if (topicInfo == null)
            {
                if (go == "prev")
                {
                    msg = "没有更旧的主题, 请返回";
                }
                else if (go == "next")
                {
                    msg = "没有更新的主题, 请返回";
                }
                else
                {
                    msg = "该主题不存在";
                }

                //如果站点开启了QQ Connect
                if (DiscuzCloud.GetCloudServiceEnableStatus("connect"))
                {
                    DeleteFeed df = new DeleteFeed();
                    df.DeleteTopicPushedFeed(topicid);
                }

                AddErrLine(msg);
                GetForumAds(0);
            }
            return(topicInfo);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 绑定当前在线用户
        /// </summary>
        private void BindLoginedUser()
        {
            userconnectinfo = DiscuzCloud.GetUserConnectInfo(openid);
            if (userconnectinfo == null || userconnectinfo.Uid > 0)
            {
                AddErrLine("Connect信息异常,登录失败,请尝试再次登录");
                return;
            }
            if (DiscuzCloud.IsBindConnect(userid))
            {
                AddErrLine("该用户已经绑定了QQ,无法再次绑定");
                return;
            }
            userconnectinfo.Uid           = userid;
            userconnectinfo.IsSetPassword = 1;
            DiscuzCloud.UpdateUserConnectInfo(userconnectinfo);
            UserBindConnectLog bindLog = DiscuzCloud.GetUserConnectBindLog(userconnectinfo.OpenId);

            if (bindLog == null)
            {
                bindLog           = new UserBindConnectLog();
                bindLog.OpenId    = userconnectinfo.OpenId;
                bindLog.Uid       = userconnectinfo.Uid;
                bindLog.Type      = 1;
                bindLog.BindCount = 1;
                DiscuzCloud.CreateUserConnectBindLog(bindLog);
            }
            else
            {
                bindLog.Uid  = userconnectinfo.Uid;
                bindLog.Type = 1;
                DiscuzCloud.UpdateUserConnectBindLog(bindLog);
            }

            SetUrl("index.aspx");
            SetMetaRefresh();
            SetShowBackLink(false);
            AddMsgLine("QQ绑定成功,继续浏览");
            Utils.WriteCookie("bindconnect", "true");//将当前登录用户是否绑定QQ互联的状态设置为true
            ShortUserInfo userInfo = Users.GetShortUserInfo(userid);

            notifyscript = GetNotifyScript(userconnectinfo, userInfo.Username, userInfo.Bday, userInfo.Gender,
                                           userInfo.Email, userInfo.Showemail, DNTRequest.GetInt("useqqavatar", 2), "loginbind");
        }
Exemplo n.º 4
0
        private void BindLoginedUser()
        {
            this.userconnectinfo = DiscuzCloud.GetUserConnectInfo(this.openid);
            if (this.userconnectinfo == null || this.userconnectinfo.Uid > 0)
            {
                base.AddErrLine("Connect信息异常,登录失败,请尝试再次登录");
                return;
            }
            if (DiscuzCloud.IsBindConnect(this.userid))
            {
                base.AddErrLine("该用户已经绑定了QQ,无法再次绑定");
                return;
            }
            this.userconnectinfo.Uid           = this.userid;
            this.userconnectinfo.IsSetPassword = true;
            DiscuzCloud.UpdateUserConnectInfo(this.userconnectinfo);
            ConnectbindLog userConnectBindLog = DiscuzCloud.GetUserConnectBindLog(this.userconnectinfo.OpenId);

            if (userConnectBindLog == null)
            {
                DiscuzCloud.CreateUserConnectBindLog(new ConnectbindLog
                {
                    OpenID    = this.userconnectinfo.OpenId,
                    Uid       = this.userconnectinfo.Uid,
                    Type      = 1,
                    BindCount = 1
                });
            }
            else
            {
                userConnectBindLog.Uid  = this.userconnectinfo.Uid;
                userConnectBindLog.Type = 1;
                DiscuzCloud.UpdateUserConnectBindLog(userConnectBindLog);
            }
            base.SetUrl("index.aspx");
            base.SetMetaRefresh();
            base.SetShowBackLink(false);
            base.AddMsgLine("QQ绑定成功,继续浏览");
            Utils.WriteCookie("bindconnect", "1");
            IUser shortUserInfo = Discuz.Entity.User.FindByID(this.userid);

            this.notifyscript = this.GetNotifyScript(this.userconnectinfo, shortUserInfo.Name, shortUserInfo.Bday, shortUserInfo.Gender, shortUserInfo.Email, shortUserInfo.ShowEmail, DNTRequest.GetInt("useqqavatar", 2), "loginbind");
        }
Exemplo n.º 5
0
        protected override void ShowPage()
        {
            pagetitle = "QQ绑定";

            if (!IsLogin())
            {
                return;
            }

            if (!isbindconnect)
            {
                AddErrLine("您未绑定QQ");
                return;
            }

            UserConnectInfo userConnectInfo = DiscuzCloud.GetUserConnectInfo(userid);

            if (userConnectInfo == null)
            {
                //修正Cookie值状态
                Utils.WriteCookie("bindconnect", "false");
                AddErrLine("您未绑定QQ");
                return;
            }

            if (ispost)
            {
                userConnectInfo.AllowPushFeed = DNTRequest.GetInt("ispublishfeed", 0) + DNTRequest.GetInt("ispublisht", 0);
                DiscuzCloud.UpdateUserConnectInfo(userConnectInfo);
                Utils.WriteCookie("cloud_feed_status", string.Format("{0}|{1}", userid, userConnectInfo.AllowPushFeed));
                SetUrl("usercpqqbind.aspx");
                SetMetaRefresh();
                SetShowBackLink(true);
                AddMsgLine("绑定设置修改完毕");
                return;
            }
            else
            {
                ispublishfeed = (userConnectInfo.AllowPushFeed & 1) == 1;
                ispublisht    = (userConnectInfo.AllowPushFeed & 2) == 2;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            switch (DNTRequest.GetString("action"))
            {
            case "reg":
                AjaxResponse(DiscuzCloud.RegisterSite());
                break;

            case "bind":
                AjaxResponse(string.Format("{{url:\"{0}\"}}", DiscuzCloud.GetCloudBindUrl(userid)));
                break;

            case "sync":
                AjaxResponse(DiscuzCloud.SyncSite());
                break;

            case "resetkey":
                AjaxResponse(DiscuzCloud.ResetSiteKey());
                break;
            }
        }
        protected override void ShowPage()
        {
            pagetitle = "用户控制面板";

            if (!IsLogin())
            {
                return;
            }

            UserConnectInfo connectInfo = new UserConnectInfo();

            if (isbindconnect)
            {
                connectInfo          = DiscuzCloud.GetUserConnectInfo(userid);
                isconnectsetpassword = connectInfo != null && connectInfo.IsSetPassword == 0;
            }

            if (DNTRequest.IsPost())
            {
                UserInfo userInfo = Users.GetUserInfo(userid);

                string newpassword = DNTRequest.GetString("newpassword");

                if (!isconnectsetpassword)
                {
                    //第三方加密验证模式
                    if (config.Passwordmode > 1 && PasswordModeProvider.GetInstance() != null)
                    {
                        if (!PasswordModeProvider.GetInstance().CheckPassword(userInfo, DNTRequest.GetString("oldpassword")))
                        {
                            AddErrLine("您的原密码错误");
                            return;
                        }
                    }
                    else if (Users.CheckPassword(userid, DNTRequest.GetString("oldpassword"), true) == -1)
                    {
                        AddErrLine("您的原密码错误");
                        return;
                    }
                }

                if (newpassword != DNTRequest.GetString("newpassword2"))
                {
                    AddErrLine("新密码两次输入不一致");
                    return;
                }
                if (Utils.StrIsNullOrEmpty(newpassword))
                {
                    newpassword = DNTRequest.GetString("oldpassword");
                }
                if (newpassword.Length < 6)
                {
                    AddErrLine("密码不得少于6个字符");
                    return;
                }

                userInfo.Password = newpassword;
                Users.ResetPassword(userInfo);

                //同步其他应用密码
                Sync.UpdatePassword(userInfo.Username, userInfo.Password, "");

                if (!Utils.StrIsNullOrEmpty(DNTRequest.GetString("changesecques")))
                {
                    Users.UpdateUserSecques(userid, DNTRequest.GetInt("question", 0), DNTRequest.GetString("answer"));
                }

                ForumUtils.WriteCookie("password", ForumUtils.SetCookiePassword(userInfo.Password, config.Passwordkey));
                OnlineUsers.UpdatePassword(olid, userInfo.Password);

                if (isconnectsetpassword && connectInfo.Uid == userid)
                {
                    connectInfo.IsSetPassword = 1;
                    DiscuzCloud.UpdateUserConnectInfo(connectInfo);
                }

                SetUrl("usercpnewpassword.aspx");
                SetMetaRefresh();
                SetShowBackLink(true);
                AddMsgLine("修改密码完毕, 同时已经更新了您的登录信息");
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     iFrameUrl = config.Cloudenabled == 1 ? DiscuzCloud.GetCloudAppListIFrame(userid) : string.Empty;
 }
Exemplo n.º 9
0
        protected override void ShowPage()
        {
            if (!DiscuzCloud.GetCloudServiceEnableStatus("connect"))
            {
                AddErrLine("QQ登录功能已关闭");
                return;
            }

            switch (action)
            {
            case "access":
                if (!CheckCallbackSignature(DNTRequest.GetString("con_sig")))
                {
                    AddErrLine("非法请求");
                    return;
                }

                OAuthAccessTokenInfo tokenInfo = DiscuzCloud.GetConnectAccessTokenInfo();
                if (tokenInfo == null)
                {
                    AddErrLine("QQ登录过程中出现异常,请尝试再次登录");
                    return;
                }

                userconnectinfo = DiscuzCloud.GetUserConnectInfo(tokenInfo.Openid);
                if (userconnectinfo == null)
                {
                    userconnectinfo        = new UserConnectInfo();
                    userconnectinfo.OpenId = tokenInfo.Openid;
                    userconnectinfo.Token  = tokenInfo.Token;
                    userconnectinfo.Secret = tokenInfo.Secret;
                    userconnectinfo.AllowVisitQQUserInfo = DNTRequest.GetInt("con_is_user_info", 0);
                    userconnectinfo.AllowPushFeed        = DNTRequest.GetInt("con_is_feed", 0) == 1 ? 3 : 0;
                    userconnectinfo.CallbackInfo         = usedusernames + "&" + birthday + "&" + gender + "&" + email;
                    DiscuzCloud.CreateUserConnectInfo(userconnectinfo);
                }
                else if (userconnectinfo.Uid > 0)
                {
                    if (userid > 0)
                    {
                        SetBackLink("index.aspx");
                        AddErrLine(userconnectinfo.Uid != userid ? "该QQ已经绑定了其他帐号" : "该QQ用户已登录");
                        return;
                    }

                    ShortUserInfo userInfo    = Users.GetShortUserInfo(userconnectinfo.Uid);
                    string        redirectUrl = "";
                    //如果userInfo==null,可能是管理员后台删除了这个帐号,则用户的ConnnectInfo也需要被解绑重置
                    if (userInfo == null)
                    {
                        DiscuzCloud.UnbindUserConnectInfo(userconnectinfo.OpenId);
                        redirectUrl = HttpContext.Current.Request.RawUrl;
                    }
                    else
                    {
                        redirectUrl = forumpath + "index.aspx";
                        //如果云端的token和Secret发生改变,则更新本地保存的token和Secret
                        if (tokenInfo.Token != userconnectinfo.Token || tokenInfo.Secret != userconnectinfo.Secret)
                        {
                            userconnectinfo.Token  = tokenInfo.Token;
                            userconnectinfo.Secret = tokenInfo.Secret;
                            DiscuzCloud.UpdateUserConnectInfo(userconnectinfo);
                        }
                        LoginUser(userInfo);
                    }
                    HttpContext.Current.Response.Redirect(redirectUrl);
                    HttpContext.Current.ApplicationInstance.CompleteRequest();
                }
                else
                {
                    string[] callbackInfo = userconnectinfo.CallbackInfo.Split('&');
                    if (callbackInfo.Length == 4)
                    {
                        usedusernames = string.IsNullOrEmpty(usedusernames) ? callbackInfo[0] : usedusernames;
                        birthday      = string.IsNullOrEmpty(birthday) ? callbackInfo[1] : birthday;
                        gender        = gender == 0 ? Utils.StrToInt(callbackInfo[2], 0) : gender;
                        email         = string.IsNullOrEmpty(email) ? callbackInfo[3] : email;
                    }
                }
                UserBindConnectLog userBindLog = DiscuzCloud.GetUserConnectBindLog(userconnectinfo.OpenId);
                isbindoverflow = userBindLog != null && cloudconfig.Maxuserbindcount > 0 && userBindLog.BindCount >= cloudconfig.Maxuserbindcount;

                allowreg      = config.Regstatus != 0 && cloudconfig.Allowconnectregister == 1 && !isbindoverflow;
                connectswitch = allowreg && userid < 0 ? 1 : 2;

                #region convert used username list
                byte[] bt = Convert.FromBase64String(usedusernames);
                usedusernames = System.Text.Encoding.Default.GetString(bt);

                #endregion
                avatarurl = string.Format("http://avatar.connect.discuz.qq.com/{0}/{1}", DiscuzCloudConfigs.GetConfig().Connectappid, userconnectinfo.OpenId);
                openid    = userconnectinfo.OpenId;
                break;

            case "bind":
                if (ispost)
                {
                    if (DNTRequest.GetString("bind_type") == "new")
                    {
                        RegisterAndBind();
                    }
                    else
                    {
                        if (userid < 0)
                        {
                            BindForumExistedUser();
                        }
                        else
                        {
                            BindLoginedUser();
                        }
                    }
                }
                break;

            case "unbind":
                if (userid < 1)
                {
                    AddErrLine("未登录用户无法进行该操作");
                    return;
                }
                userconnectinfo = DiscuzCloud.GetUserConnectInfo(userid);
                if (userconnectinfo == null)
                {
                    AddErrLine("您并没有绑定过QQ,不需要执行该操作");
                    return;
                }
                if (ispost)
                {
                    if (userconnectinfo.IsSetPassword == 0)
                    {
                        string passwd = DNTRequest.GetString("newpasswd");
                        if (string.IsNullOrEmpty(passwd))
                        {
                            AddErrLine("您必须为帐号设置新密码才能解除绑定");
                            return;
                        }
                        if (passwd.Length < 6)
                        {
                            AddErrLine("密码不得少于6个字符");
                            return;
                        }

                        if (passwd != DNTRequest.GetString("confirmpasswd"))
                        {
                            AddErrLine("两次输入的新密码不一致");
                            return;
                        }
                        UserInfo userInfo = Users.GetUserInfo(userid);
                        userInfo.Password = passwd;
                        Users.ResetPassword(userInfo);
                        //同步其他应用密码
                        Sync.UpdatePassword(userInfo.Username, userInfo.Password, "");

                        if (!Utils.StrIsNullOrEmpty(DNTRequest.GetString("changesecques")))
                        {
                            Users.UpdateUserSecques(userid, DNTRequest.GetInt("question", 0), DNTRequest.GetString("answer"));
                        }

                        ForumUtils.WriteCookie("password", ForumUtils.SetCookiePassword(userInfo.Password, config.Passwordkey));
                        OnlineUsers.UpdatePassword(olid, userInfo.Password);
                    }

                    DiscuzCloud.UnbindUserConnectInfo(userconnectinfo.OpenId);
                    UserBindConnectLog bindLog = DiscuzCloud.GetUserConnectBindLog(userconnectinfo.OpenId);
                    if (bindLog != null)
                    {
                        bindLog.Type = 2;
                        DiscuzCloud.UpdateUserConnectBindLog(bindLog);
                    }

                    AddMsgLine("解绑成功");
                    string reurl = Utils.UrlDecode(ForumUtils.GetReUrl());
                    SetUrl(reurl.IndexOf("register.aspx") < 0 ? reurl : forumpath + "index.aspx");
                    SetMetaRefresh();
                }
                break;

            default:
                if (isbindconnect)
                {
                    AddErrLine("用户已登录");
                    return;
                }
                HttpContext.Current.Response.Redirect(DiscuzCloud.GetConnectLoginPageUrl(userid));
                HttpContext.Current.ApplicationInstance.CompleteRequest();
                break;
            }
        }
Exemplo n.º 10
0
 /// <summary>
 /// 生成通知云平台的js脚本
 /// </summary>
 /// <param name="connectInfo"></param>
 /// <param name="userName"></param>
 /// <param name="birthday"></param>
 /// <param name="gender"></param>
 /// <param name="email"></param>
 /// <param name="isPublicEmail"></param>
 /// <param name="isUsedQQAvatar"></param>
 /// <param name="type"></param>
 /// <returns></returns>
 private string GetNotifyScript(UserConnectInfo connectInfo, string userName, string birthday, int gender,
                                string email, int isPublicEmail, int isUsedQQAvatar, string type)
 {
     return(string.Format("<script type=\"text/javascript\" src=\"{0}\" ></script>", DiscuzCloud.GetBindUserNotifyUrl(connectInfo, userName, birthday
                                                                                                                      , gender, email, isPublicEmail == 1 ? 1 : 2, isUsedQQAvatar, type)));
 }
Exemplo n.º 11
0
        /// <summary>
        /// 在论坛注册一个新用户并绑定
        /// </summary>
        private void RegisterAndBind()
        {
            if (userid > 0)
            {
                AddErrLine("当前已有用户登录,无法注册");
                return;
            }

            if (config.Regstatus < 1 || cloudconfig.Allowconnectregister == 0)
            {
                AddErrLine("论坛当前禁止新的QQ会员登录");
                return;
            }

            string tmpUserName = DNTRequest.GetString(config.Antispamregisterusername);
            string email       = DNTRequest.GetString(config.Antispamregisteremail).Trim().ToLower();
            string tmpBday     = DNTRequest.GetString("bday").Trim();

            string errorMessage = "";

            if (!Users.PageValidateUserName(tmpUserName, out errorMessage) || !Users.PageValidateEmail(email, false, out errorMessage))
            {
                AddErrLine(errorMessage);
                return;
            }

            //用户注册模板中,生日可以单独用一个名为bday的文本框, 也可以分别用bday_y bday_m bday_d三个文本框, 用户可不填写
            if (!Utils.IsDateString(tmpBday) && !string.IsNullOrEmpty(tmpBday))
            {
                AddErrLine("生日格式错误, 如果不想填写生日请置空");
                return;
            }

            //如果用户名符合注册规则, 则判断是否已存在
            if (Users.GetUserId(tmpUserName) > 0)
            {
                AddErrLine("请不要重复提交!");
                return;
            }

            //读取当前用户的OPENID信息
            userconnectinfo = DiscuzCloud.GetUserConnectInfo(openid);
            if (userconnectinfo == null || userconnectinfo.Uid > 0)
            {
                AddErrLine("Connect信息异常,登录失败,请尝试再次登录");
                return;
            }

            UserBindConnectLog bindLog = DiscuzCloud.GetUserConnectBindLog(userconnectinfo.OpenId);

            if (cloudconfig.Maxuserbindcount != 0 && bindLog != null && (bindLog.Type != 1 && bindLog.BindCount >= cloudconfig.Maxuserbindcount))
            {
                AddErrLine("当前QQ用户解绑次数过多,无法绑定新注册的用户");
                return;
            }

            UserInfo userInfo = CreateUser(tmpUserName, email, tmpBday);

            userconnectinfo.Uid = userInfo.Uid;
            DiscuzCloud.UpdateUserConnectInfo(userconnectinfo);

            if (bindLog == null)
            {
                bindLog           = new UserBindConnectLog();
                bindLog.OpenId    = userconnectinfo.OpenId;
                bindLog.Uid       = userconnectinfo.Uid;
                bindLog.Type      = 1;
                bindLog.BindCount = 1;
                DiscuzCloud.CreateUserConnectBindLog(bindLog);
            }
            else
            {
                bindLog.BindCount++;
                bindLog.Uid  = userconnectinfo.Uid;
                bindLog.Type = 1;
                DiscuzCloud.UpdateUserConnectBindLog(bindLog);
            }

            #region 发送欢迎信息
            if (config.Welcomemsg == 1)
            {
                // 收件箱
                PrivateMessageInfo privatemessageinfo = new PrivateMessageInfo();
                privatemessageinfo.Message      = config.Welcomemsgtxt;
                privatemessageinfo.Subject      = "欢迎您的加入! (请勿回复本信息)";
                privatemessageinfo.Msgto        = userInfo.Username;
                privatemessageinfo.Msgtoid      = userInfo.Uid;
                privatemessageinfo.Msgfrom      = PrivateMessages.SystemUserName;
                privatemessageinfo.Msgfromid    = 0;
                privatemessageinfo.New          = 1;
                privatemessageinfo.Postdatetime = Utils.GetDateTime();
                privatemessageinfo.Folder       = 0;
                PrivateMessages.CreatePrivateMessage(privatemessageinfo, 0);
            }
            #endregion

            //发送同步数据给应用程序
            Sync.UserRegister(userInfo.Uid, userInfo.Username, userInfo.Password, "");

            //如果用户选择使用QZone头像
            if (cloudconfig.Allowuseqzavater == 1 && DNTRequest.GetString("use_qzone_avatar") == "1")
            {
                QZoneAvatar qz = new QZoneAvatar();
                qz.AsyncGetAvatar(userconnectinfo);
            }

            SetUrl("index.aspx");
            SetShowBackLink(false);
            //如果不是需要管理员审核的注册,页面延时刷新为2秒,否则是5秒
            SetMetaRefresh(config.Regverify != 2 ? 2 : 5);
            Statistics.ReSetStatisticsCache();

            if (config.Regverify != 2)
            {
                CreditsFacade.UpdateUserCredits(userInfo.Uid);
                ForumUtils.WriteUserCookie(userInfo, -1, config.Passwordkey);
                Utils.WriteCookie("bindconnect", "true");//将当前登录用户是否绑定QQ互联的状态设置为true
                OnlineUsers.UpdateAction(olid, UserAction.Register.ActionID, 0, config.Onlinetimeout);
                AddMsgLine("QQ登录成功,继续浏览");
            }
            else
            {
                AddMsgLine("QQ数据绑定完成, 但需要系统管理员审核您的帐户后才可登录使用");
            }
            notifyscript = GetNotifyScript(userconnectinfo, userInfo.Username, userInfo.Bday, userInfo.Gender,
                                           userInfo.Email, userInfo.Showemail, DNTRequest.GetInt("useqqavatar", 2), "register");
        }
Exemplo n.º 12
0
        /// <summary>
        /// 绑定论坛已存在的用户
        /// </summary>
        private void BindForumExistedUser()
        {
            if (LoginLogs.UpdateLoginLog(DNTRequest.GetIP(), false) >= 5)
            {
                AddErrLine("您已经多次输入密码错误, 请15分钟后再登录");
                return;
            }

            if (config.Emaillogin == 1 && Utils.IsValidEmail(postusername))
            {
                DataTable dt = Users.GetUserInfoByEmail(postusername);
                if (dt.Rows.Count == 0)
                {
                    AddErrLine("用户不存在");
                    return;
                }
                if (dt.Rows.Count > 1)
                {
                    AddErrLine("您所使用Email不唯一,请使用用户名登陆");
                    return;
                }
                if (dt.Rows.Count == 1)
                {
                    postusername = dt.Rows[0]["username"].ToString();
                }
            }

            if (config.Emaillogin == 0)
            {
                if ((Users.GetUserId(postusername) == 0))
                {
                    AddErrLine("用户不存在");
                }
            }

            if (string.IsNullOrEmpty(postpassword))
            {
                AddErrLine("密码不能为空");
            }

            if (IsErr())
            {
                return;
            }

            ShortUserInfo userInfo = GetShortUserInfo();

            if (userInfo != null)
            {
                #region 当前用户所在用户组为"禁止访问"或"等待激活"时
                if ((userInfo.Groupid == 4 || userInfo.Groupid == 5) && 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;
                    userInfo.Groupid = usergroupid;
                    Users.UpdateUserGroup(userInfo.Uid, usergroupid);
                }

                if (userInfo.Groupid == 5)// 5-禁止访问
                {
                    AddErrLine("该用户已经被禁止访问,无法绑定");
                    return;
                }
                #endregion


                //读取当前用户的OPENID信息
                userconnectinfo = DiscuzCloud.GetUserConnectInfo(openid);
                if (userconnectinfo == null || userconnectinfo.Uid > 0)
                {
                    AddErrLine("Connect信息异常,登录失败,请尝试再次登录");
                    return;
                }
                if (DiscuzCloud.IsBindConnect(userInfo.Uid))
                {
                    AddErrLine("该用户已经绑定了QQ,无法再次绑定");
                    return;
                }
                userconnectinfo.Uid           = userInfo.Uid;
                userconnectinfo.IsSetPassword = 1;
                DiscuzCloud.UpdateUserConnectInfo(userconnectinfo);

                UserBindConnectLog bindLog = DiscuzCloud.GetUserConnectBindLog(userconnectinfo.OpenId);
                if (bindLog == null)
                {
                    bindLog           = new UserBindConnectLog();
                    bindLog.OpenId    = userconnectinfo.OpenId;
                    bindLog.Uid       = userconnectinfo.Uid;
                    bindLog.Type      = 1;
                    bindLog.BindCount = 1;
                    DiscuzCloud.CreateUserConnectBindLog(bindLog);
                }
                else
                {
                    bindLog.Uid  = userconnectinfo.Uid;
                    bindLog.Type = 1;
                    DiscuzCloud.UpdateUserConnectBindLog(bindLog);
                }

                if (userInfo.Groupid != 8)
                {
                    LoginUser(userInfo);
                    AddMsgLine("QQ登录成功,继续浏览");
                }
                else
                {
                    AddMsgLine("帐号绑定成功,但需要管理员审核通过才能登录");
                }
                SetUrl("index.aspx");
                SetMetaRefresh();
                SetShowBackLink(false);
                notifyscript = GetNotifyScript(userconnectinfo, userInfo.Username, userInfo.Bday, userInfo.Gender,
                                               userInfo.Email, userInfo.Showemail, DNTRequest.GetInt("useqqavatar", 2), "registerbind");
                return;
            }
            else
            {
                int errcount = LoginLogs.UpdateLoginLog(DNTRequest.GetIP(), true);
                if (errcount > 5)
                {
                    AddErrLine("您已经输入密码5次错误, 请15分钟后再试");
                }
                else
                {
                    AddErrLine(string.Format("密码或安全提问第{0}次错误, 您最多有5次机会重试", errcount));
                }
            }
            if (IsErr())
            {
                return;
            }
        }
Exemplo n.º 13
0
        private void RegisterAndBind()
        {
            if (this.userid > 0)
            {
                base.AddErrLine("当前已有用户登录,无法注册");
                return;
            }
            if (this.config.Regstatus < 1 || this.cloudconfig.Allowconnectregister == 0)
            {
                base.AddErrLine("论坛当前禁止新的QQ会员登录");
                return;
            }
            string @string = DNTRequest.GetString(this.config.Antispamregisterusername);
            string text    = DNTRequest.GetString(this.config.Antispamregisteremail).Trim().ToLower();
            string text2   = DNTRequest.GetString("bday").Trim();
            string errinfo = "";

            if (!Users.PageValidateUserName(@string, out errinfo) || !Users.PageValidateEmail(text, false, out errinfo))
            {
                base.AddErrLine(errinfo);
                return;
            }
            if (!Utils.IsDateString(text2) && !string.IsNullOrEmpty(text2))
            {
                base.AddErrLine("生日格式错误, 如果不想填写生日请置空");
                return;
            }
            if (Users.GetUserId(@string) > 0)
            {
                base.AddErrLine("请不要重复提交!");
                return;
            }
            this.userconnectinfo = DiscuzCloud.GetUserConnectInfo(this.openid);
            if (this.userconnectinfo == null || this.userconnectinfo.Uid > 0)
            {
                base.AddErrLine("Connect信息异常,登录失败,请尝试再次登录");
                return;
            }
            ConnectbindLog userConnectBindLog = DiscuzCloud.GetUserConnectBindLog(this.userconnectinfo.OpenId);

            if (this.cloudconfig.Maxuserbindcount != 0 && userConnectBindLog != null && userConnectBindLog.Type != 1 && userConnectBindLog.BindCount >= this.cloudconfig.Maxuserbindcount)
            {
                base.AddErrLine("当前QQ用户解绑次数过多,无法绑定新注册的用户");
                return;
            }
            User userInfo = this.CreateUser(@string, text, text2);

            this.userconnectinfo.Uid = userInfo.ID;
            DiscuzCloud.UpdateUserConnectInfo(this.userconnectinfo);
            if (userConnectBindLog == null)
            {
                DiscuzCloud.CreateUserConnectBindLog(new ConnectbindLog
                {
                    OpenID    = this.userconnectinfo.OpenId,
                    Uid       = this.userconnectinfo.Uid,
                    Type      = 1,
                    BindCount = 1
                });
            }
            else
            {
                userConnectBindLog.BindCount++;
                userConnectBindLog.Uid  = this.userconnectinfo.Uid;
                userConnectBindLog.Type = 1;
                DiscuzCloud.UpdateUserConnectBindLog(userConnectBindLog);
            }
            if (this.config.Welcomemsg == 1)
            {
                PrivateMessages.CreatePrivateMessage(new PrivateMessageInfo
                {
                    Message      = this.config.Welcomemsgtxt,
                    Subject      = "欢迎您的加入! (请勿回复本信息)",
                    Msgto        = userInfo.Name,
                    Msgtoid      = userInfo.ID,
                    Msgfrom      = "系统",
                    Msgfromid    = 0,
                    New          = 1,
                    Postdatetime = Utils.GetDateTime(),
                    Folder       = 0
                }, 0);
            }
            Sync.UserRegister(userInfo.ID, userInfo.Name, userInfo.Password, "");
            if (this.cloudconfig.Allowuseqzavater == 1 && DNTRequest.GetString("use_qzone_avatar") == "1")
            {
                QZoneAvatar qZoneAvatar = new QZoneAvatar();
                qZoneAvatar.AsyncGetAvatar(this.userconnectinfo);
            }
            base.SetUrl("index.aspx");
            base.SetShowBackLink(false);
            base.SetMetaRefresh((this.config.Regverify != 2) ? 2 : 5);
            Statistics.ReSetStatisticsCache();
            if (this.config.Regverify != 2)
            {
                CreditsFacade.UpdateUserCredits(userInfo.ID);
                ForumUtils.WriteUserCookie(userInfo, -1, this.config.Passwordkey);
                Utils.WriteCookie("bindconnect", "1");
                OnlineUsers.UpdateAction(this.olid, UserAction.Register.ActionID, 0, this.config.Onlinetimeout);
                base.AddMsgLine("QQ登录成功,继续浏览");
            }
            else
            {
                base.AddMsgLine("QQ数据绑定完成, 但需要系统管理员审核您的帐户后才可登录使用");
            }
            this.notifyscript = this.GetNotifyScript(this.userconnectinfo, userInfo.Name, userInfo.Bday, userInfo.Gender, userInfo.Email, userInfo.ShowEmail, DNTRequest.GetInt("useqqavatar", 2), "register");
        }
Exemplo n.º 14
0
        protected override void OnInit(EventArgs e)
        {
            if (!DiscuzCloud.GetCloudServiceEnableStatus("connect"))
            {
                base.AddErrLine("QQ登录功能已关闭");
                return;
            }
            string a;

            if ((a = this.action) != null)
            {
                if (!(a == "access"))
                {
                    if (!(a == "bind"))
                    {
                        if (a == "unbind")
                        {
                            if (this.userid < 1)
                            {
                                base.AddErrLine("未登录用户无法进行该操作");
                                return;
                            }
                            this.userconnectinfo = DiscuzCloud.GetUserConnectInfo(this.userid);
                            if (this.userconnectinfo == null)
                            {
                                base.AddErrLine("您并没有绑定过QQ,不需要执行该操作");
                                return;
                            }
                            if (this.ispost)
                            {
                                if (!this.userconnectinfo.IsSetPassword)
                                {
                                    string @string = DNTRequest.GetString("newpasswd");
                                    if (string.IsNullOrEmpty(@string))
                                    {
                                        base.AddErrLine("您必须为帐号设置新密码才能解除绑定");
                                        return;
                                    }
                                    if (@string.Length < 6)
                                    {
                                        base.AddErrLine("密码不得少于6个字符");
                                        return;
                                    }
                                    if (@string != DNTRequest.GetString("confirmpasswd"))
                                    {
                                        base.AddErrLine("两次输入的新密码不一致");
                                        return;
                                    }
                                    var userInfo = Users.GetUserInfo(this.userid);
                                    userInfo.Password = @string;
                                    Users.ResetPassword(userInfo);
                                    Sync.UpdatePassword(userInfo.Name, userInfo.Password, "");
                                    if (!Utils.StrIsNullOrEmpty(DNTRequest.GetString("changesecques")))
                                    {
                                        Users.UpdateUserSecques(this.userid, DNTRequest.GetInt("question", 0), DNTRequest.GetString("answer"));
                                    }
                                    ForumUtils.WriteCookie("password", ForumUtils.SetCookiePassword(userInfo.Password, this.config.Passwordkey));
                                    OnlineUsers.UpdatePassword(this.olid, userInfo.Password);
                                }
                                DiscuzCloud.UnbindUserConnectInfo(this.userconnectinfo.OpenId);
                                ConnectbindLog userConnectBindLog = DiscuzCloud.GetUserConnectBindLog(this.userconnectinfo.OpenId);
                                if (userConnectBindLog != null)
                                {
                                    userConnectBindLog.Type = 2;
                                    DiscuzCloud.UpdateUserConnectBindLog(userConnectBindLog);
                                }
                                base.AddMsgLine("解绑成功");
                                string text = Utils.UrlDecode(ForumUtils.GetReUrl());
                                base.SetUrl((text.IndexOf("register.aspx") < 0) ? text : (this.forumpath + "index.aspx"));
                                base.SetMetaRefresh();
                                return;
                            }
                            return;
                        }
                    }
                    else
                    {
                        if (!this.ispost)
                        {
                            return;
                        }
                        if (DNTRequest.GetString("bind_type") == "new")
                        {
                            this.RegisterAndBind();
                            return;
                        }
                        if (this.userid < 0)
                        {
                            this.BindForumExistedUser();
                            return;
                        }
                        this.BindLoginedUser();
                        return;
                    }
                }
                else
                {
                    if (!this.CheckCallbackSignature(DNTRequest.GetString("con_sig")))
                    {
                        base.AddErrLine("非法请求");
                        return;
                    }
                    OAuthAccessTokenInfo connectAccessTokenInfo = DiscuzCloud.GetConnectAccessTokenInfo();
                    if (connectAccessTokenInfo == null)
                    {
                        base.AddErrLine("QQ登录过程中出现异常,请尝试再次登录");
                        return;
                    }
                    userconnectinfo = DiscuzCloud.GetUserConnectInfo(connectAccessTokenInfo.Openid);
                    if (userconnectinfo == null)
                    {
                        userconnectinfo        = new UserConnect();
                        userconnectinfo.OpenId = connectAccessTokenInfo.Openid;
                        userconnectinfo.Token  = connectAccessTokenInfo.Token;
                        userconnectinfo.Secret = connectAccessTokenInfo.Secret;
                        userconnectinfo.AllowVisitQQUserInfo = DNTRequest.GetInt("con_is_user_info", 0) != 0;
                        userconnectinfo.AllowPushFeed        = DNTRequest.GetInt("con_is_feed", 0) != 0;
                        userconnectinfo.CallbackInfo         = usedusernames + "&" + birthday + "&" + gender + "&" + email;
                        //DiscuzCloud.CreateUserConnectInfo(this.userconnectinfo);
                        userconnectinfo.Insert();
                    }
                    else
                    {
                        if (this.userconnectinfo.Uid > 0)
                        {
                            if (this.userid > 0)
                            {
                                base.SetBackLink("index.aspx");
                                base.AddErrLine((this.userconnectinfo.Uid != this.userid) ? "该QQ已经绑定了其他帐号" : "该QQ用户已登录");
                                return;
                            }
                            IUser  shortUserInfo = Discuz.Entity.User.FindByID(this.userconnectinfo.Uid);
                            string url;
                            if (shortUserInfo == null)
                            {
                                DiscuzCloud.UnbindUserConnectInfo(this.userconnectinfo.OpenId);
                                url = HttpContext.Current.Request.RawUrl;
                            }
                            else
                            {
                                url = HttpContext.Current.Request.QueryString["url"];
                                if (string.IsNullOrEmpty(url))
                                {
                                    url = this.forumpath + "index.aspx";
                                }
                                if (connectAccessTokenInfo.Token != this.userconnectinfo.Token || connectAccessTokenInfo.Secret != this.userconnectinfo.Secret)
                                {
                                    this.userconnectinfo.Token  = connectAccessTokenInfo.Token;
                                    this.userconnectinfo.Secret = connectAccessTokenInfo.Secret;
                                    DiscuzCloud.UpdateUserConnectInfo(this.userconnectinfo);
                                }
                                this.LoginUser(shortUserInfo);
                            }
                            HttpContext.Current.Response.Redirect(url);
                            HttpContext.Current.ApplicationInstance.CompleteRequest();
                        }
                        else
                        {
                            string[] array = this.userconnectinfo.CallbackInfo.Split('&');
                            if (array.Length == 4)
                            {
                                this.usedusernames = (string.IsNullOrEmpty(this.usedusernames) ? array[0] : this.usedusernames);
                                this.birthday      = (string.IsNullOrEmpty(this.birthday) ? array[1] : this.birthday);
                                this.gender        = ((this.gender == 0) ? Utils.StrToInt(array[2], 0) : this.gender);
                                this.email         = (string.IsNullOrEmpty(this.email) ? array[3] : this.email);
                            }
                        }
                    }
                    ConnectbindLog userConnectBindLog2 = DiscuzCloud.GetUserConnectBindLog(this.userconnectinfo.OpenId);
                    this.isbindoverflow = (userConnectBindLog2 != null && this.cloudconfig.Maxuserbindcount > 0 && userConnectBindLog2.BindCount >= this.cloudconfig.Maxuserbindcount);
                    this.allowreg       = (this.config.Regstatus != 0 && this.cloudconfig.Allowconnectregister == 1 && !this.isbindoverflow);
                    this.connectswitch  = ((this.allowreg && this.userid < 0) ? 1 : 2);
                    byte[] bytes = Convert.FromBase64String(this.usedusernames);
                    this.usedusernames = Encoding.Default.GetString(bytes);
                    this.avatarurl     = string.Format("http://avatar.connect.discuz.qq.com/{0}/{1}", DiscuzCloudConfigInfo.Current.Connectappid, this.userconnectinfo.OpenId);
                    this.openid        = this.userconnectinfo.OpenId;
                    return;
                }
            }
            if (this.isbindconnect)
            {
                base.AddErrLine("用户已登录");
                return;
            }
            HttpContext.Current.Response.Redirect(DiscuzCloud.GetConnectLoginPageUrl(this.userid));
            HttpContext.Current.ApplicationInstance.CompleteRequest();
        }
Exemplo n.º 15
0
        private void BindForumExistedUser()
        {
            if (LoginLogs.UpdateLoginLog(DNTRequest.GetIP(), false) >= 5)
            {
                base.AddErrLine("您已经多次输入密码错误, 请15分钟后再登录");
                return;
            }
            if (this.config.Emaillogin == 1 && Utils.IsValidEmail(this.postusername))
            {
                var list = Discuz.Entity.User.FindAllByEmail(postusername);
                if (list.Count == 0)
                {
                    base.AddErrLine("用户不存在");
                    return;
                }
                if (list.Count > 1)
                {
                    base.AddErrLine("您所使用Email不唯一,请使用用户名登陆");
                    return;
                }
                if (list.Count == 1)
                {
                    this.postusername = list[0].Name;
                }
            }
            if (this.config.Emaillogin == 0 && Users.GetUserId(this.postusername) == 0)
            {
                base.AddErrLine("用户不存在");
            }
            if (string.IsNullOrEmpty(this.postpassword))
            {
                base.AddErrLine("密码不能为空");
            }
            if (base.IsErr())
            {
                return;
            }
            IUser shortUserInfo = this.GetShortUserInfo();

            if (shortUserInfo == null)
            {
                int num = LoginLogs.UpdateLoginLog(DNTRequest.GetIP(), true);
                if (num > 5)
                {
                    base.AddErrLine("您已经输入密码5次错误, 请15分钟后再试");
                }
                else
                {
                    base.AddErrLine(string.Format("密码或安全提问第{0}次错误, 您最多有5次机会重试", num));
                }
                base.IsErr();
                return;
            }
            if ((shortUserInfo.GroupID == 4 || shortUserInfo.GroupID == 5) && shortUserInfo.GroupExpiry != 0 && shortUserInfo.GroupExpiry <= Utils.StrToInt(DateTime.Now.ToString("yyyyMMdd"), 0))
            {
                var creditsUserGroupId = CreditsFacade.GetCreditsUserGroupId((float)shortUserInfo.Credits);
                this.usergroupid      = ((creditsUserGroupId.ID != 0) ? creditsUserGroupId.ID : this.usergroupid);
                shortUserInfo.GroupID = this.usergroupid;
                Users.UpdateUserGroup(shortUserInfo.ID, this.usergroupid);
            }
            if (shortUserInfo.GroupID == 5)
            {
                base.AddErrLine("该用户已经被禁止访问,无法绑定");
                return;
            }
            this.userconnectinfo = DiscuzCloud.GetUserConnectInfo(this.openid);
            if (this.userconnectinfo == null || this.userconnectinfo.Uid > 0)
            {
                base.AddErrLine("Connect信息异常,登录失败,请尝试再次登录");
                return;
            }
            if (DiscuzCloud.IsBindConnect(shortUserInfo.ID))
            {
                base.AddErrLine("该用户已经绑定了QQ,无法再次绑定");
                return;
            }
            this.userconnectinfo.Uid           = shortUserInfo.ID;
            this.userconnectinfo.IsSetPassword = true;
            DiscuzCloud.UpdateUserConnectInfo(this.userconnectinfo);
            ConnectbindLog userConnectBindLog = DiscuzCloud.GetUserConnectBindLog(this.userconnectinfo.OpenId);

            if (userConnectBindLog == null)
            {
                DiscuzCloud.CreateUserConnectBindLog(new ConnectbindLog
                {
                    OpenID    = this.userconnectinfo.OpenId,
                    Uid       = this.userconnectinfo.Uid,
                    Type      = 1,
                    BindCount = 1
                });
            }
            else
            {
                userConnectBindLog.Uid  = this.userconnectinfo.Uid;
                userConnectBindLog.Type = 1;
                DiscuzCloud.UpdateUserConnectBindLog(userConnectBindLog);
            }
            if (shortUserInfo.GroupID != 8)
            {
                this.LoginUser(shortUserInfo);
                base.AddMsgLine("QQ登录成功,继续浏览");
            }
            else
            {
                base.AddMsgLine("帐号绑定成功,但需要管理员审核通过才能登录");
            }
            base.SetUrl("index.aspx");
            base.SetMetaRefresh();
            base.SetShowBackLink(false);
            this.notifyscript = this.GetNotifyScript(this.userconnectinfo, shortUserInfo.Name, shortUserInfo.Bday, shortUserInfo.Gender, shortUserInfo.Email, shortUserInfo.ShowEmail, DNTRequest.GetInt("useqqavatar", 2), "registerbind");
        }
Exemplo n.º 16
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;
        }