Пример #1
0
        protected override void ShowPage()
        {
            pagetitle = "用户控制面板";

            if (!IsLogin())
            {
                return;
            }

            if (DNTRequest.IsPost())
            {
                if (ForumUtils.IsCrossSitePost())
                {
                    AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。");
                    return;
                }

                ValidateInfo();

                if (IsErr())
                {
                    return;
                }

                if (page_err == 0)
                {
                    UserInfo oldUserInfo = Users.GetUserInfo(userid);
                    UserInfo userInfo    = oldUserInfo.Clone();
                    //需要判断签名是否修改过
                    sig               = oldUserInfo.Sightml;
                    userInfo.Uid      = userid;
                    userInfo.Username = username;
                    userInfo.Nickname = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("nickname")));
                    userInfo.Gender   = DNTRequest.GetInt("gender", 0);
                    userInfo.Realname = DNTRequest.GetString("realname");
                    userInfo.Idcard   = DNTRequest.GetString("idcard");
                    userInfo.Mobile   = DNTRequest.GetString("mobile");
                    userInfo.Phone    = DNTRequest.GetString("phone");
                    userInfo.Email    = DNTRequest.GetString("email").Trim().ToLower();
                    if (userInfo.Email != oldUserInfo.Email && !Users.ValidateEmail(userInfo.Email, userid))
                    {
                        AddErrLine("Email: \"" + userInfo.Email + "\" 已经被其它用户注册使用");
                        return;
                    }

                    userInfo.Bday      = Utils.HtmlEncode(DNTRequest.GetString("bday"));
                    userInfo.Showemail = DNTRequest.GetInt("showemail", 1);

                    if (DNTRequest.GetString("website").IndexOf(".") > -1 && !DNTRequest.GetString("website").ToLower().StartsWith("http"))
                    {
                        userInfo.Website = Utils.HtmlEncode("http://" + DNTRequest.GetString("website"));
                    }
                    else
                    {
                        userInfo.Website = Utils.HtmlEncode(DNTRequest.GetString("website"));
                    }

                    userInfo.Icq      = Utils.HtmlEncode(DNTRequest.GetString("icq"));
                    userInfo.Qq       = Utils.HtmlEncode(DNTRequest.GetString("qq"));
                    userInfo.Yahoo    = Utils.HtmlEncode(DNTRequest.GetString("yahoo"));
                    userInfo.Msn      = Utils.HtmlEncode(DNTRequest.GetString("msn"));
                    userInfo.Skype    = Utils.HtmlEncode(DNTRequest.GetString("skype"));
                    userInfo.Location = Utils.HtmlEncode(DNTRequest.GetString("location"));
                    userInfo.Bio      = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("bio")));

                    PostpramsInfo postPramsInfo = new PostpramsInfo();
                    postPramsInfo.Usergroupid        = usergroupid;
                    postPramsInfo.Attachimgpost      = config.Attachimgpost;
                    postPramsInfo.Showattachmentpath = config.Showattachmentpath;
                    postPramsInfo.Hide  = 0;
                    postPramsInfo.Price = 0;
                    //获取提交的内容并进行脏字和Html处理
                    postPramsInfo.Sdetail                = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("signature")));;
                    postPramsInfo.Smileyoff              = 1;
                    postPramsInfo.Bbcodeoff              = 1 - usergroupinfo.Allowsigbbcode;
                    postPramsInfo.Parseurloff            = 1;
                    postPramsInfo.Showimages             = usergroupinfo.Allowsigimgcode;
                    postPramsInfo.Allowhtml              = 0;
                    postPramsInfo.Signature              = 1;
                    postPramsInfo.Smiliesinfo            = Smilies.GetSmiliesListWithInfo();
                    postPramsInfo.Customeditorbuttoninfo = null;
                    postPramsInfo.Smiliesmax             = config.Smiliesmax;
                    postPramsInfo.Signature              = 1;

                    userInfo.Sightml = UBB.UBBToHTML(postPramsInfo);
                    if (sig != userInfo.Sightml)
                    {
                        Sync.UpdateSignature(userid, userInfo.Username, userInfo.Sightml, "");
                    }
                    if (userInfo.Sightml.Length >= 1000)
                    {
                        AddErrLine("您的签名转换后超出系统最大长度, 请返回修改");
                        return;
                    }

                    userInfo.Signature = postPramsInfo.Sdetail;
                    userInfo.Sigstatus = DNTRequest.GetInt("sigstatus", 0) != 0 ? 1 : 0;


                    if (CheckModified(oldUserInfo, userInfo))
                    {
                        Users.UpdateUserProfile(userInfo);
                        Sync.UpdateProfile(userInfo.Uid, userInfo.Username, "");
                    }
                    OnlineUsers.DeleteUserByUid(userid);    //删除在线表中的信息,使之重建该用户在线表信息
                    //ManyouApplications.AddUserLog(userid, UserLogActionEnum.Update);

                    ForumUtils.WriteCookie("sigstatus", userInfo.Sigstatus.ToString());

                    SetUrl("usercpprofile.aspx");
                    SetMetaRefresh();
                    SetShowBackLink(true);
                    AddMsgLine("修改个人档案完毕");
                }
            }
            else
            {
                pagename += action == "" ? "" : "?action=" + action;

                UserInfo userInfo = Users.GetUserInfo(userid);//olid
                avatarFlashParam = Utils.GetRootUrl(BaseConfigs.GetForumPath) + "images/common/camera.swf?nt=1&inajax=1&appid=" +
                                   Utils.MD5(userInfo.Username + userInfo.Password + userInfo.Uid + olid) + "&input=" +
                                   DES.Encode(userid + "," + olid, config.Passwordkey) + "&ucapi=" + Utils.UrlEncode(Utils.GetRootUrl(BaseConfigs.GetForumPath) +
                                                                                                                     "tools/ajax.aspx");
                avatarImage = Avatars.GetAvatarUrl(userid);
            }
        }
Пример #2
0
 public string GetAvatarUrl(string uid)
 {
     return(Avatars.GetAvatarUrl(uid, AvatarSize.Small));
 }
Пример #3
0
        protected override void ShowPage()
        {
            this.pagetitle = "用户控制面板";
            if (!base.IsLogin())
            {
                return;
            }

            var uid = userid;

            if (DNTRequest.IsPost())
            {
                if (ForumUtils.IsCrossSitePost())
                {
                    base.AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。");
                    return;
                }
                this.ValidateInfo();
                if (base.IsErr())
                {
                    return;
                }

                if (this.page_err == 0)
                {
                    var userInfo = Users.GetUserInfo(uid);
                    //var userInfo2 = (User)userInfo.Clone();
                    var uf = userInfo.Field;
                    this.sig = userInfo.Field.Sightml;
                    //userInfo.ID = uid;
                    userInfo.Name     = this.username;
                    userInfo.NickName = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("nickname")));
                    userInfo.Gender   = DNTRequest.GetInt("gender", 0);

                    uf.RealName = DNTRequest.GetHtmlEncodeString("realname");
                    uf.Idcard   = DNTRequest.GetHtmlEncodeString("idcard");
                    uf.Mobile   = DNTRequest.GetHtmlEncodeString("mobile");
                    uf.Phone    = DNTRequest.GetHtmlEncodeString("phone");

                    var email = DNTRequest.GetHtmlEncodeString("email").Trim().ToLower();
                    if (email != userInfo.Email && !Users.ValidateEmail(email, userInfo.ID))
                    {
                        base.AddErrLine("Email: \"" + userInfo.Email + "\" 已经被其它用户注册使用");
                        return;
                    }
                    userInfo.Email = email;

                    userInfo.Bday      = DNTRequest.GetHtmlEncodeString("bday");
                    userInfo.ShowEmail = DNTRequest.GetInt("showemail", 1) != 0;

                    if (DNTRequest.GetString("website").IndexOf(".") > -1 && !DNTRequest.GetString("website").ToLower().StartsWith("http"))
                    {
                        uf.Website = Utils.HtmlEncode("http://" + DNTRequest.GetString("website"));
                    }
                    else
                    {
                        uf.Website = DNTRequest.GetHtmlEncodeString("website");
                    }
                    uf.Icq      = DNTRequest.GetHtmlEncodeString("icq");
                    uf.qq       = DNTRequest.GetHtmlEncodeString("qq");
                    uf.Yahoo    = DNTRequest.GetHtmlEncodeString("yahoo");
                    uf.Msn      = DNTRequest.GetHtmlEncodeString("msn");
                    uf.Skype    = DNTRequest.GetHtmlEncodeString("skype");
                    uf.Location = DNTRequest.GetHtmlEncodeString("location");
                    uf.Bio      = ForumUtils.BanWordFilter(DNTRequest.GetHtmlEncodeString("bio"));

                    var postpramsInfo = new PostpramsInfo();
                    postpramsInfo.Usergroupid        = this.usergroupid;
                    postpramsInfo.Attachimgpost      = this.config.Attachimgpost;
                    postpramsInfo.Showattachmentpath = this.config.Showattachmentpath;
                    postpramsInfo.Hide                   = 0;
                    postpramsInfo.Price                  = 0;
                    postpramsInfo.Sdetail                = ForumUtils.BanWordFilter(DNTRequest.GetHtmlEncodeString("signature"));
                    postpramsInfo.Smileyoff              = 1;
                    postpramsInfo.BBCode                 = this.usergroupinfo.AllowSigbbCode;
                    postpramsInfo.Parseurloff            = 1;
                    postpramsInfo.Showimages             = this.usergroupinfo.AllowSigimgCode ? 1 : 0;
                    postpramsInfo.Allowhtml              = 0;
                    postpramsInfo.Signature              = 1;
                    postpramsInfo.Smiliesinfo            = Smilies.GetSmiliesListWithInfo();
                    postpramsInfo.Customeditorbuttoninfo = null;
                    postpramsInfo.Smiliesmax             = this.config.Smiliesmax;
                    postpramsInfo.Signature              = 1;

                    uf.Sightml = UBB.UBBToHTML(postpramsInfo);
                    if (this.sig != uf.Sightml)
                    {
                        Sync.UpdateSignature(userInfo.ID, userInfo.Name, uf.Sightml, "");
                    }
                    if (uf.Sightml.Length >= 1000)
                    {
                        base.AddErrLine("您的签名转换后超出系统最大长度, 请返回修改");
                        return;
                    }
                    uf.Signature       = postpramsInfo.Sdetail;
                    userInfo.Sigstatus = ((DNTRequest.GetInt("sigstatus", 0) != 0) ? 1 : 0);
                    //throw new NotImplementedException("CheckModified");
                    ////if (this.CheckModified(userInfo, userInfo2))
                    //{
                    //    //Users.UpdateUserProfile(userInfo2);
                    //    Sync.UpdateProfile(userInfo.ID, userInfo.Name, "");
                    //}
                    userInfo.Save();
                    Sync.UpdateProfile(userInfo.ID, userInfo.Name, "");

                    Online.DeleteUserByUid(userInfo.ID);
                    ForumUtils.WriteCookie("sigstatus", userInfo.Sigstatus.ToString());

                    base.SetUrl("usercpprofile.aspx");
                    base.SetMetaRefresh();
                    base.SetShowBackLink(true);
                    base.AddMsgLine("修改个人档案完毕");
                    return;
                }
            }
            else
            {
                this.pagename += ((String.IsNullOrEmpty(this.action)) ? "" : ("?action=" + this.action));
                var userInfo3 = Users.GetUserInfo(uid);
                this.avatarFlashParam = Utils.GetRootUrl(BaseConfigs.GetForumPath) + "images/common/camera.swf?nt=1&inajax=1&appid=" + (Utils.MD5(userInfo3.Name + userInfo3.Password + userInfo3.ID + this.olid)) + "&input=" + (DES.Encode(uid + "," + this.olid, this.config.Passwordkey)) + "&ucapi=" + (Utils.UrlEncode(Utils.GetRootUrl(BaseConfigs.GetForumPath) + "tools/ajax.ashx"));
                this.avatarImage      = Avatars.GetAvatarUrl(uid);
            }
        }
Пример #4
0
        protected void gvClubMemberList_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                var uc = e.Row.DataItem as UserClub;
                if (uc != null)
                {
                    var userInfo = Users.GetUserInfo(uc.Userid.Value);
                    if (userInfo != null)
                    {
                        #region set avatar

                        var imgAvatar = e.Row.FindControl("imgAvatar") as Image;

                        if (imgAvatar != null)
                        {
                            //if (userInfo.Avatar == string.Empty)
                            //{
                            //    imgAvatar.ImageUrl = "/avatars/common/0.gif";
                            //}
                            //else if (userInfo.Avatar.ToLower().IndexOf(@"/") == 0)
                            //{
                            //    imgAvatar.ImageUrl = userInfo.Avatar;
                            //}
                            //else if (userInfo.Avatar.ToLower().IndexOf("http") >= 0)
                            //{
                            //    imgAvatar.ImageUrl = userInfo.Avatar;
                            //}
                            //else
                            //{
                            //    imgAvatar.ImageUrl = string.Format("/{0}", userInfo.Avatar);
                            //}

                            var myAvatar = Avatars.GetAvatarUrl(uc.Userid.Value, AvatarSize.Small);
                            imgAvatar.ImageUrl = myAvatar;

                            imgAvatar.AlternateText = userInfo.Username.Trim();
                        }

                        #endregion

                        #region set responsibility

                        var ltrlResponsibility = e.Row.FindControl("ltrlResponsibility") as Literal;
                        if (ltrlResponsibility != null)
                        {
                            if (uc.Responsibility.Value == (int)Responsibility.Member)
                            {
                                ltrlResponsibility.Text = string.Empty;
                            }
                            else
                            {
                                ltrlResponsibility.Text =
                                    $"<em>({ClubLogic.TranslateResponsibility(uc.Responsibility.Value)})</em>";
                            }
                        }

                        #endregion

                        #region set user group

                        var ltrlUserGroup = e.Row.FindControl("ltrlUserGroup") as Literal;
                        if (ltrlUserGroup != null)
                        {
                            var groupInfo = UserGroups.GetUserGroupInfo(userInfo.Groupid);

                            if (groupInfo != null)
                            {
                                ltrlUserGroup.Text =
                                    $"<span title=\"积分:{userInfo.Credits.ToString("N0")}\">{groupInfo.Grouptitle}</span>";
                            }
                        }

                        #endregion

                        #region set user fortune

                        var ltrlUserFortune = e.Row.FindControl("ltrlUserFortune") as Literal;
                        if (ltrlUserFortune != null)
                        {
                            ltrlUserFortune.Text = userInfo.Extcredits2.ToString("N2");
                        }

                        #endregion

                        #region set user posts

                        var ltrlUserPosts = e.Row.FindControl("ltrlUserPosts") as Literal;
                        if (ltrlUserPosts != null)
                        {
                            ltrlUserPosts.Text = userInfo.Posts.ToString("N0");
                        }

                        #endregion

                        #region set user days

                        var ltrlDays = e.Row.FindControl("ltrlDays") as Literal;
                        if (ltrlDays != null)
                        {
                            ltrlDays.Text = ((int)((DateTime.Now - uc.JoinClubDate.Value).TotalDays)).ToString();
                        }

                        #endregion

                        #region contribute value

                        var ltrlContributeValue = e.Row.FindControl("ltrlContributeValue") as Literal;

                        try
                        {
                            var contribution = FortuneContributeAlgorithm.CalcContributeFortune(userInfo, false);

                            var bonusRate = PlayerStrip.CalcPlayerContributionBonusRate(uc.Userid.Value);

                            if (bonusRate != 0)
                            {
                                ltrlContributeValue.Text = $"<em>{contribution}(*{1 + bonusRate}) 枪手币</em>";
                            }
                            else
                            {
                                ltrlContributeValue.Text = $"<em>{contribution} 枪手币</em>";
                            }

                            _totalContribution += (int)(contribution * (1 + bonusRate));
                        }
                        catch
                        {
                        }

                        #endregion
                    }
                }
            }
        }
Пример #5
0
        protected void gvClubMemberList_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                var uc = e.Row.DataItem as UserClub;
                if (uc != null)
                {
                    var userInfo = Users.GetUserInfo(uc.Userid.Value);
                    if (userInfo != null)
                    {
                        #region set avatar

                        var imgAvatar = e.Row.FindControl("imgAvatar") as Image;

                        if (imgAvatar != null)
                        {
                            //if (userInfo.Avatar == string.Empty)
                            //{
                            //    imgAvatar.ImageUrl = "/avatars/common/0.gif";
                            //}
                            //else if (userInfo.Avatar.ToLower().IndexOf(@"/") == 0)
                            //{
                            //    imgAvatar.ImageUrl = userInfo.Avatar;
                            //}
                            //else if (userInfo.Avatar.ToLower().IndexOf("http") >= 0)
                            //{
                            //    imgAvatar.ImageUrl = userInfo.Avatar;
                            //}
                            //else
                            //{
                            //    imgAvatar.ImageUrl = string.Format("/{0}", userInfo.Avatar);
                            //}

                            var myAvatar = Avatars.GetAvatarUrl(uc.Userid.Value, AvatarSize.Small);
                            imgAvatar.ImageUrl = myAvatar;

                            imgAvatar.AlternateText = userInfo.Username.Trim();
                        }

                        #endregion

                        #region set User Info & Responsibility

                        var ltrlUserInfoResponsibility = e.Row.FindControl("ltrlUserInfoResponsibility") as Literal;
                        var _strUserInfo =
                            $"<a href=\"MyPlayerProfile.aspx?userID={uc.Userid}\" target=\"_blank\">{uc.UserName.Trim()}</a>";

                        if (ltrlUserInfoResponsibility != null)
                        {
                            if (uc.Responsibility.HasValue &&
                                !uc.Responsibility.Value.Equals((int)Responsibility.Member))
                            {
                                ltrlUserInfoResponsibility.Text =
                                    $"{_strUserInfo}<em>{ClubLogic.TranslateResponsibility(uc.Responsibility.Value)}</em>";
                            }
                            else
                            {
                                ltrlUserInfoResponsibility.Text = _strUserInfo;
                            }
                        }

                        #endregion

                        #region set user group

                        var ltrlUserGroup = e.Row.FindControl("ltrlUserGroup") as Literal;
                        if (ltrlUserGroup != null)
                        {
                            var groupInfo = UserGroups.GetUserGroupInfo(userInfo.Groupid);

                            if (groupInfo != null)
                            {
                                ltrlUserGroup.Text =
                                    $"<span title=\"积分:{userInfo.Credits.ToString("N0")}\">{groupInfo.Grouptitle}</span>";
                            }
                        }

                        #endregion

                        #region set user fortune

                        var ltrlUserFortune = e.Row.FindControl("ltrlUserFortune") as Literal;
                        if (ltrlUserFortune != null)
                        {
                            ltrlUserFortune.Text = userInfo.Extcredits2.ToString("N2");
                        }

                        #endregion

                        #region set user posts

                        var ltrlUserPosts = e.Row.FindControl("ltrlUserPosts") as Literal;
                        if (ltrlUserPosts != null)
                        {
                            ltrlUserPosts.Text = userInfo.Posts.ToString("N0");
                        }

                        #endregion

                        #region set user days

                        var ltrlDays = e.Row.FindControl("ltrlDays") as Literal;
                        var _days    = (int)((DateTime.Now - uc.JoinClubDate.Value).TotalDays);

                        if (ltrlDays != null)
                        {
                            ltrlDays.Text =
                                $"<em title=\"自{uc.FromDate.ToString("yyyy-MM-dd")}入会以来\">{_days}天</em>";
                        }

                        #endregion

                        #region contribute value

                        var ltrlContributeValue = e.Row.FindControl("ltrlContributeValue") as Literal;

                        try
                        {
                            ltrlContributeValue.Text =
                                $"<em>{FortuneContributeAlgorithm.CalcContributeFortune(userInfo, true).ToString("N2")}</em>";
                        }
                        catch
                        {
                        }

                        #endregion

                        //Literal ltrlButtonDisplay = e.Row.FindControl("ltrlButtonDisplay") as Literal;
                        //if (ltrlButtonDisplay != null && uc.Responsibility.Value == (int)Responsibility.Manager)
                        //{
                        //    ltrlButtonDisplay.Text = "none";
                        //}

                        var btnKick = e.Row.FindControl("btnKick") as LinkButton;

                        if (btnKick != null && ClubID > 0)
                        {
                            if (uc.Responsibility.Value != (int)Responsibility.Manager &&
                                CurrUserManagedClubs.Exists(delegate(Club c) { return(c.ID.Equals(ClubID)); }))
                            {
                                btnKick.CommandArgument = uc.Userid.ToString();
                            }
                            else
                            {
                                btnKick.Visible = false;
                            }
                        }

                        var hlTransfer = e.Row.FindControl("hlTransfer") as HyperLink;

                        if (hlTransfer != null)
                        {
                            if (uc.Userid.Value != userid)
                            {
                                hlTransfer.NavigateUrl =
                                    $"ManageExtcredit.aspx?clubID={ClubID}&ToUID={uc.Userid.Value}";
                            }
                            else
                            {
                                hlTransfer.Visible = false;
                            }
                        }
                    }
                }
            }
        }
Пример #6
0
 protected override void ShowPage()
 {
     this.pagetitle = "邀请注册";
     if (!Utils.InArray(this.config.Regstatus.ToString(), "2,3"))
     {
         base.AddErrLine("当前站点没有开启邀请功能!");
         return;
     }
     if (this.userid > 0)
     {
         if (this.action == "floatwinemail")
         {
             return;
         }
         this.avatarSmall  = Avatars.GetAvatarUrl(this.userid, AvatarSize.Small);
         this.avatarMedium = Avatars.GetAvatarUrl(this.userid, AvatarSize.Medium);
         this.avatarLarge  = Avatars.GetAvatarUrl(this.userid, AvatarSize.Large);
         this.userinfo     = Users.GetUserInfo(this.userid);
         if (this.config.Regstatus == 2)
         {
             this.invitecodeinfo = Invitation.GetInviteCodeByUid(this.userid);
             if (this.invitecodeinfo != null)
             {
                 this.inviteurl = this.GetUserInviteUrl(this.invitecodeinfo.Code, false);
                 this.userscore = this.GetUserInviteScore(this.invitecodeinfo.SuccessCount);
                 this.usersaid  = string.Format("邀请附言:<div id=\"usersaidinemail\">{0}</div>", this.usersaid);
                 if (!this.ispost)
                 {
                     this.CreateEmailPreview();
                 }
             }
         }
         else
         {
             this.invitecodecount = Invitation.GetUserInviteCodeCount(this.userid);
             this.invitecodelist  = Invitation.GetUserInviteCodeList(this.userid, this.pageindex);
             this.invitecodeprice = this.GetInviteCodePrice();
             this.pagecount       = (this.invitecodecount - 1) / 10 + 1;
             this.pagenumber      = Utils.GetPageNumbers(this.pageindex, this.pagecount, "invite.aspx", 8);
         }
         if (this.ispost)
         {
             string a;
             if ((a = this.action) == null)
             {
                 return;
             }
             if (!(a == "createcode"))
             {
                 if (!(a == "convertcode"))
                 {
                     if (!(a == "buycode"))
                     {
                         if (!(a == "floatwinemailsend"))
                         {
                             return;
                         }
                         this.SendEmail();
                     }
                     else
                     {
                         this.BuyInviteCode();
                     }
                 }
                 else
                 {
                     this.ConvertInviteCode();
                 }
             }
             else
             {
                 this.CreateInviteCode();
             }
         }
     }
     if (userid == -1 && !String.IsNullOrEmpty(invitecode))
     {
         //this.invitecodeinfo = Invitation.GetInviteCodeByCode(this.Code);
         invitecodeinfo = Invitation.FindByCode(invitecode);
     }
 }
Пример #7
0
        /// <summary>
        /// 从UserInfo对象中将属性值导入API接口专用User对象
        /// </summary>
        /// <param name="userInfo">UserInfo对象</param>
        /// <param name="fields">应用程序设置读取的字段</param>
        /// <param name="loadAuthAttribute">是否读取需要权限范围的字段</param>
        /// <returns></returns>
        public static User LoadSingleUser(UserInfo userInfo, string fields, bool loadAuthAttribute)
        {
            List <string> fieldlist = new List <string>(fields.Split(','));
            User          user      = new User();

            #region normal security

            user.Uid           = fieldlist.Contains("uid") ? (int?)userInfo.Uid : null;
            user.UserName      = fieldlist.Contains("user_name") ? userInfo.Username : null;
            user.Avatar        = fieldlist.Contains("avatar") ? Avatars.GetAvatarUrl(userInfo.Uid).TrimStart('/') : null;
            user.Credits       = fieldlist.Contains("credits") ? (int?)userInfo.Credits : null;
            user.Birthday      = fieldlist.Contains("birthday") ? userInfo.Bday.Trim() : null;
            user.DigestPosts   = fieldlist.Contains("digest_post_count") ? (int?)userInfo.Digestposts : null;
            user.ExtCredits1   = fieldlist.Contains("ext_credits_1") ? (int?)userInfo.Extcredits1 : null;
            user.ExtCredits2   = fieldlist.Contains("ext_credits_2") ? (int?)userInfo.Extcredits2 : null;
            user.ExtCredits3   = fieldlist.Contains("ext_credits_3") ? (int?)userInfo.Extcredits3 : null;
            user.ExtCredits4   = fieldlist.Contains("ext_credits_4") ? (int?)userInfo.Extcredits4 : null;
            user.ExtCredits5   = fieldlist.Contains("ext_credits_5") ? (int?)userInfo.Extcredits5 : null;
            user.ExtCredits6   = fieldlist.Contains("ext_credits_6") ? (int?)userInfo.Extcredits6 : null;
            user.ExtCredits7   = fieldlist.Contains("ext_credits_7") ? (int?)userInfo.Extcredits7 : null;
            user.ExtCredits8   = fieldlist.Contains("ext_credits_8") ? (int?)userInfo.Extcredits8 : null;
            user.ExtGroupids   = fieldlist.Contains("ext_groupids") ? userInfo.Extgroupids.Trim() : null;
            user.Gender        = fieldlist.Contains("gender") ? (int?)userInfo.Gender : null;
            user.AdminId       = fieldlist.Contains("admin_id") ? (int?)userInfo.Adminid : null;
            user.GroupExpiry   = fieldlist.Contains("group_expiry") ? (int?)userInfo.Groupexpiry : null;
            user.GroupId       = fieldlist.Contains("group_id") ? (int?)userInfo.Groupid : null;
            user.JoinDate      = fieldlist.Contains("join_date") ? userInfo.Joindate : null;
            user.LastActivity  = fieldlist.Contains("last_activity") ? userInfo.Lastactivity : null;
            user.LastIp        = fieldlist.Contains("last_ip") ? userInfo.Lastip.Trim() : null;
            user.LastPost      = fieldlist.Contains("last_post") ? userInfo.Lastpost : null;
            user.LastPostid    = fieldlist.Contains("last_post_id") ? (int?)userInfo.Lastpostid : null;
            user.LastPostTitle = fieldlist.Contains("last_post_title") ? userInfo.Lastposttitle : null;
            user.LastVisit     = fieldlist.Contains("last_visit") ? userInfo.Lastvisit : null;
            user.NickName      = fieldlist.Contains("nick_name") ? userInfo.Nickname : null;
            user.OnlineState   = fieldlist.Contains("online_state") ? (int?)userInfo.Onlinestate : null;
            user.OnlineTime    = fieldlist.Contains("online_time") ? (int?)userInfo.Oltime : null;
            user.PageViews     = fieldlist.Contains("page_view_count") ? (int?)userInfo.Pageviews : null;
            user.Posts         = fieldlist.Contains("post_count") ? (int?)userInfo.Posts : null;
            user.SpaceId       = fieldlist.Contains("space_id") ? (int?)userInfo.Spaceid : null;
            user.CustomStatus  = fieldlist.Contains("custom_status") ? userInfo.Customstatus : null; //自定义头衔
            user.Medals        = fieldlist.Contains("medals") ? userInfo.Medals : null;              //勋章列表
            user.WebSite       = fieldlist.Contains("web_site") ? userInfo.Website : null;           //网站
            user.Icq           = fieldlist.Contains("icq") ? userInfo.Icq : null;                    //icq号码
            user.Qq            = fieldlist.Contains("qq") ? userInfo.Qq : null;                      //qq号码
            user.Yahoo         = fieldlist.Contains("yahoo") ? userInfo.Yahoo : null;                //yahoo messenger帐号
            user.Msn           = fieldlist.Contains("msn") ? userInfo.Msn : null;                    //msn messenger帐号
            user.Skype         = fieldlist.Contains("skype") ? userInfo.Skype : null;                //skype帐号
            user.Location      = fieldlist.Contains("location") ? userInfo.Location : null;          //来自
            user.Bio           = fieldlist.Contains("about_me") ? userInfo.Bio : null;               //自我介绍
            user.Sightml       = fieldlist.Contains("signhtml") ? userInfo.Sightml : null;           //签名Html(自动转换得到)
            user.RealName      = fieldlist.Contains("real_name") ? userInfo.Realname : null;         //用户实名
            user.IdCard        = fieldlist.Contains("id_card") ? userInfo.Idcard : null;             //用户身份证件号
            user.Mobile        = fieldlist.Contains("mobile") ? userInfo.Mobile : null;              //用户移动电话
            user.Phone         = fieldlist.Contains("telephone") ? userInfo.Phone : null;            //用户固定电话

            #endregion

            if (loadAuthAttribute)
            {
                #region high security

                user.Password    = fieldlist.Contains("password") ? userInfo.Password : null;
                user.ShowEmail   = fieldlist.Contains("show_email") ? (int?)userInfo.Showemail : null;
                user.Email       = fieldlist.Contains("email") ? userInfo.Email.Trim() : null;
                user.NewPm       = fieldlist.Contains("has_new_pm") ? (int?)userInfo.Newpm : null;
                user.NewPmCount  = fieldlist.Contains("new_pm_count") ? (int?)userInfo.Newpmcount : null;
                user.AccessMasks = fieldlist.Contains("access_masks") ? (int?)userInfo.Accessmasks : null;
                user.Invisible   = fieldlist.Contains("invisible") ? (int?)userInfo.Invisible : null;
                user.PmSound     = fieldlist.Contains("pm_sound") ? (int?)userInfo.Pmsound : null;
                user.Ppp         = fieldlist.Contains("ppp") ? (int?)userInfo.Ppp : null;
                user.RegIp       = fieldlist.Contains("reg_ip") ? userInfo.Regip : null;
                user.Secques     = fieldlist.Contains("secques") ? userInfo.Secques : null;
                user.Templateid  = fieldlist.Contains("template_id") ? (int?)userInfo.Templateid : null;
                user.Tpp         = fieldlist.Contains("tpp") ? (int?)userInfo.Tpp : null;

                #endregion
            }
            return(user);
        }
Пример #8
0
        protected override void ShowPage()
        {
            pagetitle = "邀请注册";
            if (!Utils.InArray(config.Regstatus.ToString(), "2,3"))
            {
                AddErrLine("当前站点没有开启邀请功能!");
                return;
            }
            if (userid > 0)
            {
                if (action == "floatwinemail")
                {
                    return;
                }
                //提取预览头像
                avatarSmall  = Avatars.GetAvatarUrl(userid, AvatarSize.Small);
                avatarMedium = Avatars.GetAvatarUrl(userid, AvatarSize.Medium);
                avatarLarge  = Avatars.GetAvatarUrl(userid, AvatarSize.Large);

                userinfo = Users.GetUserInfo(userid);
                if (config.Regstatus == 2)
                {
                    invitecodeinfo = Invitation.GetInviteCodeByUid(userid);
                    if (invitecodeinfo != null)
                    {
                        inviteurl = GetUserInviteUrl(invitecodeinfo.Code, false);
                        userscore = GetUserInviteScore(invitecodeinfo.SuccessCount);
                        usersaid  = string.Format("邀请附言:<div id=\"usersaidinemail\">{0}</div>", usersaid);
                        if (!ispost)
                        {
                            CreateEmailPreview();
                        }
                    }
                }
                else
                {
                    invitecodecount = Invitation.GetUserInviteCodeCount(userid);
                    invitecodelist  = Invitation.GetUserInviteCodeList(userid, pageindex);
                    invitecodeprice = GetInviteCodePrice();
                    pagecount       = ((invitecodecount - 1) / 10) + 1;
                    pagenumber      = Utils.GetPageNumbers(pageindex, pagecount, "invite.aspx", 8);
                }
                if (ispost)
                {
                    switch (action)
                    {
                    case "createcode":
                        CreateInviteCode();    //创建开放式邀请码
                        break;

                    case "convertcode":
                        ConvertInviteCode();    //将开放邀请码兑换为用户积分
                        break;

                    case "buycode":
                        BuyInviteCode();    //购买封闭式邀请码
                        break;

                    case "floatwinemailsend":
                        SendEmail();    //弹窗邮件发送邀请码
                        break;

                    default:
                        return;
                    }
                }
            }
            if (userid == -1 && invitecode != "")
            {
                invitecodeinfo = Invitation.GetInviteCodeByCode(invitecode);
            }
        }
Пример #9
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;
        }