Пример #1
0
        protected override string OnAttachCreated(Discuz.Entity.AttachmentInfo[] attachs, int usergroupid, int userid, string username)
        {
            if (attachs == null)
            {
                return("");
            }
            string[] albumsid = DNTRequest.GetString("albums") == "" ? null : DNTRequest.GetString("albums").Split(',');
            if (albumsid == null)
            {
                return("");
            }
            int maxphotosize     = UserGroups.GetUserGroupInfo(usergroupid).Maxspacephotosize;
            int currentphotisize = DbProvider.GetInstance().GetPhotoSizeByUserid(userid);

            if (attachs.Length + 2 == albumsid.Length)//验证提交上来的albums数据是否是合法可用数据,因为albums数据提交逗号数组头尾各有一个0,则合法数据位附件list长度加2==albums元素个数
            {
                for (int i = 0; i < attachs.Length; i++)
                {
                    if (attachs[i].Filename != "" && (attachs[i].Filetype == "image/pjpeg") || (attachs[i].Filetype == "image/gif") || (attachs[i].Filetype == "image/x-png"))
                    {
                        //由于提交上来的albums数据是头尾各含有一个值为0的元素的数组,则和第一个附件对应的相册ID其实是第二个值
                        string aid = albumsid[i + 1];
                        if (aid != "0")
                        {
                            if ((maxphotosize - currentphotisize - (int)attachs[i].Filesize) > 0)
                            {
                                string filename  = Utils.GetMapPath(BaseConfigs.GetForumPath + "upload/" + attachs[i].Filename.Replace('\\', '/'));
                                string extension = Path.GetExtension(filename);
                                Common.Thumbnail.MakeThumbnailImage(filename, filename.Replace(extension, "_thumbnail" + extension), 150, 150);
                                Common.Thumbnail.MakeSquareImage(filename, filename.Replace(extension, "_square" + extension), 100);
                                PhotoInfo photoinfo = new PhotoInfo();
                                photoinfo.Filename      = "upload/" + attachs[i].Filename.Replace('\\', '/');
                                photoinfo.Attachment    = attachs[i].Attachment;
                                photoinfo.Filesize      = (int)attachs[i].Filesize;
                                photoinfo.Title         = attachs[i].Attachment.Remove(attachs[i].Attachment.IndexOf("."));
                                photoinfo.Description   = attachs[i].Description;
                                photoinfo.Albumid       = int.Parse(aid);
                                photoinfo.Userid        = userid;
                                photoinfo.Username      = username;
                                photoinfo.Views         = 0;
                                photoinfo.Commentstatus = 0;
                                photoinfo.Tagstatus     = 0;
                                photoinfo.Comments      = 0;
                                photoinfo.IsAttachment  = 1;
                                DbProvider.GetInstance().AddSpacePhoto(photoinfo);
                                AlbumInfo albumInfo = DTOProvider.GetAlbumInfo(Convert.ToInt32(aid));
                                albumInfo.Imgcount = DbProvider.GetInstance().GetSpacePhotoCountByAlbumId(int.Parse(aid));
                                DbProvider.GetInstance().SaveSpaceAlbum(albumInfo);
                                currentphotisize += (int)attachs[i].Filesize;
                            }
                            else
                            {
                                return("相册空间不足,可能有图片未能加入相册");
                            }
                        }
                    }
                }
            }
            return("");
        }
Пример #2
0
        /// <summary>
        /// 解析帖子列表附加信息及内容
        /// </summary>
        /// <param name="postpramsInfo">参数对象</param>
        /// <param name="attachList">附件列表</param>
        /// <param name="isModer">是否为版主</param>
        /// <param name="postList">帖子列表</param>
        public static void ParsePostListExtraInfo(PostpramsInfo postpramsInfo, List <ShowtopicPageAttachmentInfo> attachList, bool isModer, List <ShowtopicPagePostInfo> postList)
        {
            int originalHideStatus = postpramsInfo.Hide;
            // 计算是否允许查看附件
            int allowGetAttach = GetAllowGetAttachValue(postpramsInfo);

            #region 计算辩论帖是否被顶过
            string    diggedPidList = string.Empty;
            TopicInfo topicInfo     = postpramsInfo.Topicinfo == null?Topics.GetTopicInfo(postpramsInfo.Tid) : postpramsInfo.Topicinfo;

            if (topicInfo.Special == 4 && UserGroups.GetUserGroupInfo(7).Allowdiggs != 1)
            {
                diggedPidList = Discuz.Data.Debates.GetUesrDiggs(postpramsInfo.Tid, postpramsInfo.CurrentUserid);
            }
            #endregion

            foreach (ShowtopicPagePostInfo postInfo in postList)
            {
                LoadPostMessage(postpramsInfo, attachList, isModer, allowGetAttach, originalHideStatus, postInfo);

                if (topicInfo.Special == 4)
                {
                    if (UserGroups.GetUserGroupInfo(7).Allowdiggs == 1)
                    {
                        postInfo.Digged = Debates.IsDigged(postInfo.Pid, postpramsInfo.CurrentUserid);
                    }
                    else
                    {
                        postInfo.Digged = Utils.InArray(postInfo.Pid.ToString(), diggedPidList); //diggslist.Contains(reader["pid"].ToString());
                    }
                }
            }
        }
Пример #3
0
        protected override void ShowPage()
        {
            pagetitle = "查看用户信息";

            if (usergroupinfo.Allowviewpro != 1 && userid != id)
            {
                AddErrLine(string.Format("您当前的身份 \"{0}\" 没有查看用户资料的权限", usergroupinfo.Grouptitle));
                if (userid < 1)
                {
                    needlogin = true;
                }

                return;
            }

            if (Utils.StrIsNullOrEmpty(DNTRequest.GetString("username")) && Utils.StrIsNullOrEmpty(DNTRequest.GetString("userid")))
            {
                AddErrLine("错误的URL链接");
                return;
            }



            if (id == -1)
            {
                id = Users.GetUserId(Utils.UrlDecode(DNTRequest.GetString("username")));
            }

            if (id == -1)
            {
                AddErrLine("该用户不存在");
                return;
            }

            user = Users.GetUserInfo(id);
            if (user == null)
            {
                AddErrLine("该用户不存在");
                return;
            }

            //用户设定Email保密时,清空用户的Email属性以避免被显示
            if (user.Showemail != 1 && id != userid)
            {
                user.Email = "";
            }

            //获取积分机制和用户组信息,底层有缓存
            score     = Scoresets.GetValidScoreName();
            group     = UserGroups.GetUserGroupInfo(user.Groupid);
            admininfo = AdminUserGroups.AdminGetAdminGroupInfo(usergroupid);
            score1    = ((decimal)user.Extcredits1).ToString();
            score2    = ((decimal)user.Extcredits2).ToString();
            score3    = ((decimal)user.Extcredits3).ToString();
            score4    = ((decimal)user.Extcredits4).ToString();
            score5    = ((decimal)user.Extcredits5).ToString();
            score6    = ((decimal)user.Extcredits6).ToString();
            score7    = ((decimal)user.Extcredits7).ToString();
            score8    = ((decimal)user.Extcredits8).ToString();
        }
 protected void EditUserGroup_Click(object sender, EventArgs e)
 {
     #region 编辑用户组
     try
     {
         int       row = 0;
         ArrayList creditshigherArray = new ArrayList();
         ArrayList creditslowerArray  = new ArrayList();
         ArrayList updateArray        = new ArrayList();
         foreach (object o in DataGrid1.GetKeyIDArray())
         {
             int    groupid    = int.Parse(o.ToString());
             string grouptitle = DataGrid1.GetControlValue(row, "grouptitle");
             if (grouptitle.Trim() == "")
             {
                 base.RegisterStartupScript("", "<script>alert('组标题未输入,请检查!');window.location.href='global_usergroupgrid.aspx';</script>");
                 return;
             }
             int creditshigher = int.Parse(DataGrid1.GetControlValue(row, "creditshigher"));
             int creditslower  = int.Parse(DataGrid1.GetControlValue(row, "creditslower"));
             if (creditshigher >= creditslower)
             {
                 base.RegisterStartupScript("", "<script>alert('" + grouptitle + "组的积分下限超过上限,请检查!');window.location.href='global_usergroupgrid.aspx';</script>");
                 return;
             }
             creditshigherArray.Add(creditshigher);
             creditslowerArray.Add(creditslower);
             updateArray.Add(new UserGroup(groupid, grouptitle, creditshigher, creditslower));
             row++;
         }
         creditshigherArray.Sort();
         creditslowerArray.Sort();
         for (int i = 1; i < creditshigherArray.Count; i++)
         {
             if (creditshigherArray[i].ToString() != creditslowerArray[i - 1].ToString())
             {
                 base.RegisterStartupScript("", "<script>alert('积分下限与上限取值不连续,请检查!');window.location.href='global_usergroupgrid.aspx';</script>");
                 return;
             }
         }
         for (int i = 0; i < updateArray.Count; i++)
         {
             UserGroup     ug            = (UserGroup)updateArray[i];
             UserGroupInfo userGroupInfo = UserGroups.GetUserGroupInfo(ug.id);
             userGroupInfo.Grouptitle    = ug.grouptitle;
             userGroupInfo.Creditslower  = ug.creditslower;
             userGroupInfo.Creditshigher = ug.creditshigher;
             UserGroups.UpdateUserGroup(userGroupInfo);
         }
         Caches.ReSetUserGroupList();
         base.RegisterStartupScript("", "<script>window.location.href='global_usergroupgrid.aspx';</script>");
     }
     catch
     {
         base.RegisterStartupScript("", "<script>alert('积分下限或是上限输入的数值不合法,请检查!');window.location.href='global_usergroupgrid.aspx';</script>");
     }
     #endregion
 }
Пример #5
0
        public string GroupName(string groupid)
        {
            #region 通过组ID获取组的名称

            UserGroupInfo userGroupInfo = UserGroups.GetUserGroupInfo(TypeConverter.StrToInt(groupid));
            return(userGroupInfo != null ? userGroupInfo.Grouptitle : "");

            #endregion
        }
        public ajaxuserspacecommentlist()
        {
            postid = DNTRequest.GetInt("postid", 0);

            if (postid > 0)
            {
                if (Discuz.Common.DNTRequest.GetString("load") == "true")
                {
                    //当前用户是否是日志的作者
                    SpacePostInfo __spacepostinfo = BlogProvider.GetSpacepostsInfo(Space.Data.DbProvider.GetInstance().GetSpacePost(postid));
                    if (__spacepostinfo.Uid == userid)
                    {
                        ispostauthor = true;
                    }

                    if (Forum.AdminGroups.GetAdminGroupInfo(_userinfo.Groupid) != null)
                    {
                        isadmin = true;
                    }

                    //当是发布状态或当前作者的日志时
                    if (__spacepostinfo.PostStatus == 0)
                    {
                        errorinfo = "当前请求的内容无效!";
                        return;
                    }

                    //当有要删除的记录时
                    int delcommentid = DNTRequest.GetInt("delcommentid", 0);
                    if (delcommentid > 0)
                    {
                        //判断该用户是否为本人或管理组内
                        if ((UserGroups.GetUserGroupInfo(_userinfo.Groupid).Radminid == 1 && this.isadmin) || (this.spaceconfiginfo.UserID == this.userid))
                        {
                            Space.Data.DbProvider.GetInstance().DeleteSpaceComment(delcommentid);
                        }

                        //更新相关评论数
                        Space.Data.DbProvider.GetInstance().CountUserSpaceCommentCountByUserID(__spacepostinfo.Uid, -1);
                        Space.Data.DbProvider.GetInstance().CountSpaceCommentCountByPostID(postid, -1);
                    }

                    //得到当前评论列表
                    __spacecommentinfos = GetSpaceCommentInfoList(currentpage, postid);
                    //得到页码链接
                    pagelink = AjaxPagination(Space.Data.DbProvider.GetInstance().GetSpaceCommentsCountByPostid(postid), 16, currentpage);
                }
            }
            else
            {
                errorinfo = "当前请求日志回复信息无效!";
            }
        }
Пример #7
0
        private void radminid_SelectedIndexChanged(object sender, EventArgs e)
        {
            #region 绑定关联组
            //DataTable usergrouprightstable = Discuz.Data.DatabaseProvider.GetInstance().GetUserGroupInfoByGroupid(int.Parse(radminid.SelectedValue));
            UserGroupInfo radminUserGroupInfo = UserGroups.GetUserGroupInfo(int.Parse(radminid.SelectedValue));
            if (radminUserGroupInfo != null)
            {
                //设置管理组初始化信息
                //DataRow usergrouprights = usergrouprightstable.Rows[0];
                creditshigher.Text = radminUserGroupInfo.Creditslower.ToString();
                creditslower.Text  = radminUserGroupInfo.Creditslower.ToString();
                stars.Text         = radminUserGroupInfo.Stars.ToString();
                color.Text         = radminUserGroupInfo.Color;
                groupavatar.Text   = radminUserGroupInfo.Groupavatar;
                readaccess.Text    = radminUserGroupInfo.Readaccess.ToString();
                maxprice.Text      = radminUserGroupInfo.Maxprice.ToString();
                maxpmnum.Text      = radminUserGroupInfo.Maxpmnum.ToString();
                maxsigsize.Text    = radminUserGroupInfo.Maxsigsize.ToString();
                maxattachsize.Text = radminUserGroupInfo.Maxattachsize.ToString();
                maxsizeperday.Text = radminUserGroupInfo.Maxsizeperday.ToString();
                DataTable dt = Attachments.GetAttachmentType();
                attachextensions.AddTableData(dt, radminUserGroupInfo.Attachextensions);
            }

            AdminGroupInfo radminUserGroup = AdminGroups.GetAdminGroupInfo(int.Parse(radminid.SelectedValue));
            if (radminUserGroup != null)
            {
                //设置管理权限组初始化信息
                //DataRow dr = admingrouprights.Rows[0];
                admingroupright.SelectedIndex     = -1;
                admingroupright.Items[0].Selected = radminUserGroup.Alloweditpost == 1;
                admingroupright.Items[1].Selected = radminUserGroup.Alloweditpoll == 1;
                admingroupright.Items[2].Selected = radminUserGroup.Allowdelpost == 1;
                admingroupright.Items[3].Selected = radminUserGroup.Allowmassprune == 1;
                admingroupright.Items[4].Selected = radminUserGroup.Allowviewip == 1;
                admingroupright.Items[5].Selected = radminUserGroup.Allowedituser == 1;
                admingroupright.Items[6].Selected = radminUserGroup.Allowviewlog == 1;
                admingroupright.Items[7].Selected = radminUserGroup.Disablepostctrl == 1;
                admingroupright.Items[8].Selected = radminUserGroup.Allowviewrealname == 1;
            }

            if (radminid.SelectedValue == "1")
            {
                allowstickthread.Enabled       = false;
                allowstickthread.SelectedValue = "3";
            }
            else
            {
                allowstickthread.Enabled = true;
            }
            #endregion
        }
Пример #8
0
        protected override void ShowPage()
        {
            pagetitle = "查看用户信息";

            if (usergroupinfo.Allowviewpro != 1)
            {
                AddErrLine(string.Format("您当前的身份 \"{0}\" 没有查看用户资料的权限", usergroupinfo.Grouptitle));
                if (userid < 1)
                {
                    needlogin = true;
                }
                return;
            }

            if (DNTRequest.GetString("username").Trim() == "" && DNTRequest.GetString("userid").Trim() == "")
            {
                AddErrLine("错误的URL链接");
                return;
            }

            int id = DNTRequest.GetInt("userid", -1);

            if (id == -1)
            {
                id = Discuz.Forum.Users.GetUserID(Utils.UrlDecode(DNTRequest.GetString("username")));
            }

            if (id == -1)
            {
                AddErrLine("该用户不存在");
                return;
            }

            user = Discuz.Forum.Users.GetUserInfo(id);
            if (user == null)
            {
                AddErrLine("该用户不存在");
                return;
            }

            //用户设定Email保密时,清空用户的Email属性以避免被显示
            if (user.Showemail != 1)
            {
                user.Email = "";
            }
            //获取金币机制和用户组信息,底层有缓存
            score     = Scoresets.GetValidScoreName();
            group     = UserGroups.GetUserGroupInfo(user.Groupid);
            admininfo = AdminUserGroups.AdminGetAdminGroupInfo(usergroupid);
        }
Пример #9
0
        /// <summary>
        /// 获得允许的附件后缀
        /// </summary>
        /// <param name="groupid"></param>
        /// <returns></returns>
        private static string GetAllowedExtensions(int groupid)
        {
            UserGroupInfo usergroupinfo          = UserGroups.GetUserGroupInfo(groupid);
            StringBuilder sbAttachmentTypeSelect = new StringBuilder();

            if (!usergroupinfo.Attachextensions.Trim().Equals(""))
            {
                sbAttachmentTypeSelect.Append("[id] in (");
                sbAttachmentTypeSelect.Append(usergroupinfo.Attachextensions);
                sbAttachmentTypeSelect.Append(")");
            }

            return(Attachments.GetAttachmentTypeArray(sbAttachmentTypeSelect.ToString()));
        }
Пример #10
0
 public void SetGroupRights(int groupid)
 {
     #region 设置组权限相关信息
     UserGroupInfo userGroupInfo = UserGroups.GetUserGroupInfo(groupid);
     stars.Text         = userGroupInfo.Stars.ToString();
     color.Text         = userGroupInfo.Color;
     groupavatar.Text   = userGroupInfo.Groupavatar;
     readaccess.Text    = userGroupInfo.Readaccess.ToString();
     maxprice.Text      = userGroupInfo.Maxprice.ToString();
     maxpmnum.Text      = userGroupInfo.Maxpmnum.ToString();
     maxsigsize.Text    = userGroupInfo.Maxsigsize.ToString();
     maxattachsize.Text = userGroupInfo.Maxattachsize.ToString();
     maxsizeperday.Text = userGroupInfo.Maxsizeperday.ToString();
     //maxfriendscount.Text = userGroupInfo.MaxFriendsCount.ToString();
     #endregion
 }
Пример #11
0
 /// <summary>
 /// 登录操作
 /// </summary>
 /// <param name="userInfo"></param>
 private void LoginUser(ShortUserInfo userInfo)
 {
     #region 无延迟更新在线信息和相关用户信息
     ForumUtils.WriteUserCookie(userInfo.Uid, TypeConverter.StrToInt(DNTRequest.GetString("expires"), -1),
                                config.Passwordkey, DNTRequest.GetInt("templateid", 0), DNTRequest.GetInt("loginmode", -1));
     oluserinfo    = OnlineUsers.UpdateInfo(config.Passwordkey, config.Onlinetimeout, userInfo.Uid, "");
     olid          = oluserinfo.Olid;
     username      = userInfo.Username;
     userid        = userInfo.Uid;
     usergroupinfo = UserGroups.GetUserGroupInfo(userInfo.Groupid);
     useradminid   = usergroupinfo.Radminid;   // 根据用户组得到相关联的管理组id
     Utils.WriteCookie("bindconnect", "true"); //将当前登录用户是否绑定QQ互联的状态设置为true
     OnlineUsers.UpdateAction(olid, UserAction.Login.ActionID, 0);
     LoginLogs.DeleteLoginLog(DNTRequest.GetIP());
     Users.UpdateUserCreditsAndVisit(userInfo.Uid, DNTRequest.GetIP());
     #endregion
 }
Пример #12
0
        private void InitializeComponent()
        {
            this.StopTalk.Click                += new EventHandler(this.StopTalk_Click);
            this.DelPosts.Click                += new EventHandler(this.DelPosts_Click);
            this.SaveUserInfo.Click            += new EventHandler(this.SaveUserInfo_Click);
            this.ResetPassWord.Click           += new EventHandler(this.ResetPassWord_Click);
            this.IsEditUserName.CheckedChanged += new EventHandler(this.IsEditUserName_CheckedChanged);

            this.DelUserInfo.Click         += new EventHandler(this.DelUserInfo_Click);
            this.ReSendEmail.Click         += new EventHandler(this.ReSendEmail_Click);
            this.CalculatorScore.Click     += new EventHandler(this.CalculatorScore_Click);
            this.ResetUserDigestPost.Click += new EventHandler(this.ResetUserDigestPost_Click);
            this.ResetUserPost.Click       += new EventHandler(this.ResetUserPost_Click);

            this.GivenMedal.Click += new EventHandler(this.GivenMedal_Click);
            //UserCredits.UpdateUserCredits(DNTRequest.GetInt("uid", -1));
            userInfo = AdminUsers.GetUserInfo(DNTRequest.GetInt("uid", -1));

            UserGroupInfo tmpUserGroupInfo = CreditsFacade.GetCreditsUserGroupId(userInfo.Credits);

            groupid.Items.Add(new ListItem(UserGroups.GetUserGroupInfo(tmpUserGroupInfo.Groupid).Grouptitle, tmpUserGroupInfo.Groupid.ToString()));
            foreach (UserGroupInfo userGroupInfo in UserGroups.GetUserGroupList())
            {
                //if (userGroupInfo.System == 0 && userInfo.Groupid != userGroupInfo.Groupid || userGroupInfo.Groupid == 7)
                //    continue;

                if ((userGroupInfo.System == 0 && userGroupInfo.Radminid == 0) || userGroupInfo.Groupid == 7)
                {
                    continue;
                }
                groupid.Items.Add(new ListItem(userGroupInfo.Grouptitle, userGroupInfo.Groupid.ToString()));
                extgroupids.Items.Add(new ListItem(userGroupInfo.Grouptitle, userGroupInfo.Groupid.ToString()));
            }

            templateid.AddTableData(Templates.GetValidTemplateList(), "name", "templateid");
            templateid.Items[0].Text = "默认";
            TabControl1.InitTabPage();

            if (DNTRequest.GetString("uid") == "")
            {
                Response.Redirect("global_usergrid.aspx");
                return;
            }
            LoadCurrentUserInfo(DNTRequest.GetInt("uid", -1));
            LoadScoreInf(DNTRequest.GetString("uid"), DNTRequest.GetString("fieldname"));
        }
Пример #13
0
        public List <ShowtopicPageAttachmentInfo> GetAttachList(int topicid, int forumid, string onlyauthor, int posterid, CredentialInfo creinfo)
        {
            TopicInfo     topic         = Topics.GetTopicInfo(topicid);
            ForumInfo     forum         = Forums.GetForumInfo(forumid);
            UserInfo      userinfo      = new UserInfo();
            UserGroupInfo usergroupinfo = UserGroups.GetUserGroupInfo(7);//默认为游客

            if (AuthenticateUser(creinfo))
            {
                userinfo      = Users.GetUserInfo(creinfo.UserID);
                usergroupinfo = UserGroups.GetUserGroupInfo(userinfo.Groupid);
            }
            // 取得用户权限id,1管理员,2超版,3版主,0普通组,-1特殊组
            int ismoder = Moderators.IsModer(usergroupinfo.Radminid, userinfo.Uid, forumid) ? 1 : 0;
            int price   = GetTopicPrice(topic, creinfo, ismoder);

            return(GetAttachList(price, onlyauthor, ismoder, posterid, userinfo, usergroupinfo, topic, forum));
        }
        private void ComUsergroup_Click(object sender, EventArgs e)
        {
            #region 合并用户组
            if (this.CheckCookie())
            {
                if ((sourceusergroup.SelectedIndex == 0) || (targetusergroup.SelectedIndex == 0))
                {
                    base.RegisterStartupScript("", "<script>alert('操作失败,请您选择有效的用户组!');</script>");
                    return;
                }

                if (sourceusergroup.SelectedValue == targetusergroup.SelectedValue)
                {
                    base.RegisterStartupScript("", "<script>alert('操作失败,同一个用户组不能够合并!');</script>");
                    return;
                }

                if (UserGroups.GetUserGroupInfo(int.Parse(sourceusergroup.SelectedValue)).Creditslower !=
                    UserGroups.GetUserGroupInfo(int.Parse(targetusergroup.SelectedValue)).Creditshigher)
                {
                    base.RegisterStartupScript("", "<script>alert('操作失败,要合并的用户组必须是积分相连的两个用户组!');</script>");
                    return;
                }

                //合并用户积分上下限
                UserGroupInfo userGroupInfo = UserGroups.GetUserGroupInfo(int.Parse(targetusergroup.SelectedValue));
                userGroupInfo.Creditshigher = UserGroups.GetUserGroupInfo(int.Parse(sourceusergroup.SelectedValue)).Creditshigher;
                UserGroups.UpdateUserGroup(userGroupInfo);
                //UserGroups.CombinationUserGroupScore(int.Parse(sourceusergroup.SelectedValue), int.Parse(targetusergroup.SelectedValue));
                //删除被合并的源用户组
                //DatabaseProvider.GetInstance().DeleteUserGroupInfo(int.Parse(sourceusergroup.SelectedValue));
                UserGroups.DeleteUserGroupInfo(int.Parse(sourceusergroup.SelectedValue));

                //更新用户组中的信息
                //Data.DatabaseProvider.GetInstance().ChangeUsergroup(int.Parse(sourceusergroup.SelectedValue), int.Parse(targetusergroup.SelectedValue));
                UserGroups.ChangeAllUserGroupId(int.Parse(sourceusergroup.SelectedValue), int.Parse(targetusergroup.SelectedValue));

                DNTCache.GetCacheService().RemoveObject("/Forum/UserGroupList");
                AdminVistLogs.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "合并用户组", "把组ID:" + sourceusergroup.SelectedIndex + " 合并到组ID:" + targetusergroup.SelectedIndex);
                base.RegisterStartupScript("PAGE", "window.location.href='global_usergroupgrid.aspx';");
            }

            #endregion
        }
Пример #15
0
        /// <summary>
        /// 创建短消息
        /// </summary>
        /// <param name="folder">所属文件夹(0:收件箱,1:发件箱,2:草稿箱)</param>
        /// <param name="saveToSendBox">是否保存到发件箱</param>
        /// <param name="url">跳转链接</param>
        /// <param name="msg">提示信息</param>
        private void CreatePM(int folder, int saveToSendBox, string url, string msg)
        {
            if (folder != 2)
            {
                UserInfo touser = Users.GetUserInfo(msgtoid);
                // 检查接收人的短消息是否已超过接收人用户组的上限,管理组不受接收人短消息上限限制
                int radminId = UserGroups.GetUserGroupInfo(usergroupid).Radminid;
                if (!(radminId > 0 && radminId <= 3) && PrivateMessages.GetPrivateMessageCount(msgtoid, -1) >= UserGroups.GetUserGroupInfo(touser.Groupid).Maxpmnum)
                {
                    AddErrLine("抱歉,接收人的短消息已达到上限,无法接收");
                    return;
                }
                if (!Utils.InArray(Convert.ToInt32(touser.Newsletter).ToString(), "2,3,6,7"))
                {
                    AddErrLine("抱歉,接收人拒绝接收短消息");
                    return;
                }
            }

            // 检查发送人的短消息是否已超过发送人用户组的上限
            if (url != "usercpinbox.aspx" && PrivateMessages.GetPrivateMessageCount(userid, -1) >= usergroupinfo.Maxpmnum)
            {
                AddErrLine("抱歉,您的短消息已达到上限,无法保存到发件箱");
                return;
            }
            pm.Folder = folder;
            if (CreditsFacade.SendPM(userid) == -1)
            {
                AddErrLine("您的积分不足, 不能发送短消息");
                return;
            }
            pm.Pmid = PrivateMessages.CreatePrivateMessage(pm, saveToSendBox);
            //发送邮件通知
            if (DNTRequest.GetString("emailnotify") == "on")
            {
                SendNotifyEmail(Users.GetUserInfo(msgtoid).Email.Trim(), pm);
            }

            SetUrl(url);
            SetMetaRefresh();
            SetShowBackLink(true);
            MsgForward("usercppostpm_succeed");
            AddMsgLine(msg);
        }
Пример #16
0
        private void EditUserGroup_Click(object sender, EventArgs e)
        {
            #region 重定向到指定的用户组编辑页面

            if (Usergroupid.SelectedValue != "0")
            {
                int groupid = Convert.ToInt32(Usergroupid.SelectedValue);
                if (groupid >= 1 && groupid <= 3)
                {
                    Response.Redirect("../global/global_editadminusergroup.aspx?groupid=" + Usergroupid.SelectedValue);
                    return;
                }
                if (groupid >= 4 && groupid <= 8)
                {
                    Response.Redirect("../global/global_editsysadminusergroup.aspx?groupid=" + Usergroupid.SelectedValue);
                    return;
                }

                int radminid = UserGroups.GetUserGroupInfo(Utils.StrToInt(Usergroupid.SelectedValue, 0)).Radminid;
                if (radminid == 0)
                {
                    Response.Redirect("../global/global_editusergroup.aspx?groupid=" + Usergroupid.SelectedValue);
                    return;
                }
                if (radminid > 0)
                {
                    Response.Redirect("../global/global_editadminusergroup.aspx?groupid=" + Usergroupid.SelectedValue);
                    return;
                }
                if (radminid < 0)
                {
                    Response.Redirect("../global/global_editusergroupspecial.aspx?groupid=" + Usergroupid.SelectedValue);
                    return;
                }
            }
            else
            {
                base.RegisterStartupScript("", "<script>alert('请您选择有效的用户组!');</script>");
            }

            #endregion
        }
Пример #17
0
        protected override void ShowPage()
        {
            //pagetitle = "编辑帖子";
            #region 判断是否是灌水
            AdminGroupInfo admininfo = AdminGroups.GetAdminGroupInfo(usergroupid);
            this.disablepostctrl = 0;
            if (admininfo != null)
            {
                disablepostctrl = admininfo.Disablepostctrl;
            }
            #endregion

            if (userid == -1)
            {
                forum    = new ForumInfo();
                topic    = new TopicInfo();
                postinfo = new PostInfo();
                AddErrLine("您尚未登录");
                return;
            }

            #region 获取帖子和主题相关信息
            // 如果帖子ID非数字
            if (postid == -1)
            {
                AddErrLine("无效的帖子ID");
                return;
            }

            postinfo = Posts.GetPostInfo(topicid, postid);
            // 如果帖子不存在
            if (postinfo == null)
            {
                AddErrLine("不存在的帖子ID");
                return;
            }
            pagetitle   = (postinfo.Title == "") ? "编辑帖子" : postinfo.Title;
            htmlon      = postinfo.Htmlon;
            message     = postinfo.Message;
            isfirstpost = postinfo.Layer == 0;

            // 获取主题ID
            if (topicid != postinfo.Tid || postinfo.Tid == -1)
            {
                AddErrLine("无效的主题ID");
                return;
            }

            // 获取该主题的信息
            topic = Topics.GetTopicInfo(postinfo.Tid);
            // 如果该主题不存在
            if (topic == null)
            {
                AddErrLine("不存在的主题ID");
                return;
            }

            if (topic.Special == 1 && postinfo.Layer == 0)
            {
                pollinfo       = Polls.GetPollInfo(topic.Tid);
                polloptionlist = Polls.GetPollOptionList(topic.Tid);
            }

            if (topic.Special == 4 && postinfo.Layer == 0)
            {
                debateinfo = Debates.GetDebateTopic(topic.Tid);
            }

            #endregion

            #region 获取并检查版块信息
            ///得到所在版块信息
            forumid   = topic.Fid;
            forum     = Forums.GetForumInfo(forumid);
            needaudit = UserAuthority.NeedAudit(forum, useradminid, topic, userid, disablepostctrl, usergroupinfo);
            // 如果该版块不存在
            if (forum == null || forum.Layer == 0)
            {
                AddErrLine("版块已不存在");
                forum = new ForumInfo();
                return;
            }

            if (!Utils.StrIsNullOrEmpty(forum.Password) && Utils.MD5(forum.Password) != ForumUtils.GetCookie("forum" + forumid + "password"))
            {
                AddErrLine("本版块被管理员设置了密码");
                SetBackLink(base.ShowForumAspxRewrite(forumid, 0));
                return;
            }

            if (forum.Applytopictype == 1)  //启用主题分类
            {
                topictypeselectoptions = Forums.GetCurrentTopicTypesOption(forum.Fid, forum.Topictypes);
            }
            customeditbuttons = Caches.GetCustomEditButtonList();
            #endregion

            //是否有编辑帖子的权限
            if (!UserAuthority.CanEditPost(postinfo, userid, useradminid, ref msg))
            {
                AddErrLine(msg);
                return;
            }
            #region  附件信息绑定
            //得到用户可以上传的文件类型
            string attachmentTypeSelect = Attachments.GetAllowAttachmentType(usergroupinfo, forum);
            attachextensions       = Attachments.GetAttachmentTypeArray(attachmentTypeSelect);
            attachextensionsnosize = Attachments.GetAttachmentTypeString(attachmentTypeSelect);
            //得到今天允许用户上传的附件总大小(字节)
            int MaxTodaySize = (userid > 0 ? MaxTodaySize = Attachments.GetUploadFileSizeByuserid(userid) : 0);
            attachsize = usergroupinfo.Maxsizeperday - MaxTodaySize;//今天可上传得大小
            //是否有上传附件的权限
            canpostattach = UserAuthority.PostAttachAuthority(forum, usergroupinfo, userid, ref msg);

            userinfo = Users.GetShortUserInfo(userid);
            if (canpostattach && (config.Enablealbum == 1) && apb != null &&
                (UserGroups.GetUserGroupInfo(userinfo.Groupid).Maxspacephotosize - apb.GetPhotoSizeByUserid(userid) > 0))
            {
                caninsertalbum = true;
                albumlist      = apb.GetSpaceAlbumByUserId(userid);
            }
            else
            {
                caninsertalbum = false;
            }

            attachmentlist  = Attachments.GetAttachmentListByPid(postinfo.Pid);
            attachmentcount = attachmentlist.Rows.Count;
            //当前用户是否有允许下载附件权限
            allowviewattach = UserAuthority.DownloadAttachment(forum, userid, usergroupinfo);

            #endregion

            smileyoff          = (!DNTRequest.IsPost()) ? postinfo.Smileyoff : 1 - forum.Allowsmilies;
            allowimg           = forum.Allowimgcode;
            parseurloff        = postinfo.Parseurloff;
            bbcodeoff          = (usergroupinfo.Allowcusbbcode == 1) ? postinfo.Bbcodeoff : 1;
            usesig             = postinfo.Usesig;
            userextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetTopicAttachCreditsTrans());
            if (bonusCreditsTrans > 0 && bonusCreditsTrans < 9)
            {
                bonusextcreditsinfo = Scoresets.GetScoreSet(bonusCreditsTrans);
                mybonustranscredits = Users.GetUserExtCredits(userid, bonusCreditsTrans);
            }

            //是否有访问当前版块的权限
            if (!UserAuthority.VisitAuthority(forum, usergroupinfo, userid, ref msg))
            {
                AddErrLine(msg);
                return;
            }

            // 判断当前用户是否有修改权限, 检查是否具有版主的身份
            if (!Moderators.IsModer(useradminid, userid, forumid))
            {
                if (postinfo.Posterid != userid)
                {
                    AddErrLine("你并非作者, 且你当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有修改该帖的权限");
                    return;
                }
                else if (config.Edittimelimit > 0 && Utils.StrDateDiffMinutes(postinfo.Postdatetime, config.Edittimelimit) > 0)
                {
                    AddErrLine("抱歉, 系统规定只能在帖子发表" + config.Edittimelimit + "分钟内才可以修改");
                    return;
                }
                else if (config.Edittimelimit == -1)
                {
                    AddErrLine("抱歉,系统不允许修改帖子");
                    return;
                }
            }

            #region htmltitle标题
            if (postinfo.Layer == 0)
            {
                canhtmltitle = usergroupinfo.Allowhtmltitle == 1;
            }

            if (Topics.GetMagicValue(topic.Magic, MagicType.HtmlTitle) == 1)
            {
                htmltitle = Topics.GetHtmlTitle(topic.Tid).Replace("\"", "\\\"").Replace("'", "\\'");
            }
            #endregion

            #region tag信息
            enabletag = (config.Enabletag & forum.Allowtag) == 1;
            if (enabletag && Topics.GetMagicValue(topic.Magic, MagicType.TopicTag) == 1)
            {
                foreach (TagInfo tag in ForumTags.GetTagsListByTopic(topic.Tid))
                {
                    if (tag.Orderid > -1)
                    {
                        topictags += string.Format(" {0}", tag.Tagname);
                    }
                }
                topictags = topictags.Trim();
            }
            #endregion
            userGroupInfoList.Sort(delegate(UserGroupInfo x, UserGroupInfo y) { return((x.Readaccess - y.Readaccess) + (y.Groupid - x.Groupid)); });
            //如果是提交...
            if (ispost)
            {
                SetBackLink("editpost.aspx?topicid=" + postinfo.Tid + "&postid=" + postinfo.Pid);

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

                //设置相关帖子信息
                SetPostInfo(admininfo, userinfo, Utils.StrToInt(DNTRequest.GetString("htmlon"), 0) == 1);

                if (IsErr())
                {
                    return;
                }

                //通过验证的用户可以编辑帖子
                Posts.UpdatePost(postinfo);

                //设置附件相关信息
                System.Text.StringBuilder sb = SetAttachmentInfo();

                if (IsErr())
                {
                    return;
                }

                UserCredits.UpdateUserCredits(userid);

                #region 设置提示信息和跳转链接
                //辩论地址
                if (topic.Special == 4)
                {
                    SetUrl(Urls.ShowDebateAspxRewrite(topic.Tid));
                }
                else if (DNTRequest.GetQueryString("referer") != "")//ajax快速回复将传递referer参数
                {
                    SetUrl(string.Format("showtopic.aspx?page=end&forumpage={2}&topicid={0}#{1}", topic.Tid, postinfo.Pid, forumpageid));
                }
                else if (pageid != "")//如果不是ajax,则应该是带pageid的参数
                {
                    if (config.Aspxrewrite == 1)
                    {
                        SetUrl(string.Format("showtopic-{0}-{2}{1}#{3}", topic.Tid, config.Extname, DNTRequest.GetString("pageid"), postinfo.Pid));
                    }
                    else
                    {
                        SetUrl(string.Format("showtopic.aspx?topicid={0}&forumpage={3}&page={2}#{1}", topic.Tid, postinfo.Pid, DNTRequest.GetString("pageid"), forumpageid));
                    }
                }
                else//如果都为空.就跳转到第一页(以免意外情况)
                {
                    if (config.Aspxrewrite == 1)
                    {
                        SetUrl(string.Format("showtopic-{0}{1}", topic.Tid, config.Extname));
                    }
                    else
                    {
                        SetUrl(string.Format("showtopic.aspx?topicid={0}&forumpage={1}", topic.Tid, forumpageid));
                    }
                }

                if (sb.Length > 0)
                {
                    SetMetaRefresh(5);
                    SetShowBackLink(true);
                    if (infloat == 1)
                    {
                        AddErrLine(sb.ToString());
                        return;
                    }
                    else
                    {
                        sb.Insert(0, "<table cellspacing=\"0\" cellpadding=\"4\" border=\"0\"><tr><td colspan=2 align=\"left\"><span class=\"bold\"><nobr>编辑帖子成功,但图片/附件上传出现问题:</nobr></span><br /></td></tr>");
                        sb.Append("</table>");
                        AddMsgLine(sb.ToString());
                    }
                }
                else
                {
                    //编辑主题和回复需要审核
                    if (postinfo.Layer == 0)
                    {
                        SetMetaRefresh(2, base.ShowForumAspxRewrite(forumid, forumpageid));
                    }
                    else
                    {
                        SetMetaRefresh();
                    }
                    SetShowBackLink(false);

                    if (useradminid != 1 && (needaudit || topic.Displayorder == -2 || postinfo.Invisible == 1))
                    {
                        if (postinfo.Layer == 0)
                        {
                            SetUrl(base.ShowForumAspxRewrite(forumid, forumpageid));
                        }
                        else
                        {
                            SetUrl(base.ShowTopicAspxRewrite(topic.Tid, forumpageid));
                        }
                        AddMsgLine("编辑成功, 但需要经过审核才可以显示");
                    }
                    else
                    {
                        MsgForward("editpost_succeed");
                        AddMsgLine("编辑帖子成功, 返回该主题");
                    }
                }
                #endregion

                // 删除主题游客缓存
                if (postinfo.Layer == 0)
                {
                    ForumUtils.DeleteTopicCacheFile(topic.Tid);
                }
            }
            else
            {
                AddLinkCss(BaseConfigs.GetForumPath + "templates/" + templatepath + "/editor.css", "css");
            }
        }
Пример #18
0
//实现文件上传

        public MediaObjectUrl newMediaObject(string blogid, string username, string password, MediaObject mediaObject)
        {
            int uid = ValidateUser(username, password);

            if (uid < 1)
            {
                throw new XmlRpcFaultException(0, "用户不存在");
            }

            string[] currentdate  = DateTime.Now.ToString("yyyy-MM-dd").Split('-');
            string   fileDatePath = currentdate[0] + "/" + currentdate[1] + "/" + currentdate[2] + "/";
            string   sSavePath    = Utils.GetMapPath(BaseConfigs.GetForumPath + "space/upload/" + ((FTPs.GetSpaceAttachInfo.Allowupload == 1 && FTPs.GetSpaceAttachInfo.Reservelocalattach == 0) ? "temp/" : fileDatePath));

            if (!Directory.Exists(sSavePath))
            {
                Utils.CreateDir(sSavePath);
            }

            Random random    = new Random(unchecked ((int)DateTime.Now.Ticks));
            string sFilename = (Environment.TickCount & int.MaxValue).ToString() + random.Next(1000, 9999).ToString() + System.IO.Path.GetExtension(mediaObject.name).ToLower();
            //判断sFilename的文件名称是否已存在于服务器上. 如存在, 则添加文件递增标识
            int file_append = 0;

            while (File.Exists(sSavePath + sFilename))
            {
                file_append++;
                sFilename = Path.GetFileNameWithoutExtension(mediaObject.name) + file_append.ToString() + Path.GetExtension(mediaObject.name).ToLower();
            }
            string fileExtName = Path.GetExtension(mediaObject.name).ToLower();

            fileExtName = fileExtName != "" ? fileExtName: ".invalidExtName";
            int    groupid          = Users.GetShortUserInfo(uid).Groupid;
            string attachextensions = GetAllowedExtensions(groupid);

            if ((attachextensions == null) || (attachextensions.ToLower().IndexOf(fileExtName.Remove(0, 1)) >= 0))
            {
                //上传图片文件
                if ((fileExtName == ".jpg") || (fileExtName == ".gif") || (fileExtName == ".png") || (fileExtName == ".jpeg"))
                {
                    try
                    {
                        int maxspacesize = UserGroups.GetUserGroupInfo(groupid).Maxspaceattachsize;
                        int currentspaceattachmentsize = DbProvider.GetInstance().GetSpaceAttachmentSizeByUserid(uid);
                        if ((maxspacesize - currentspaceattachmentsize - mediaObject.bits.Length) <= 0)  //个人空间的存储空间不足
                        {
                            throw new XmlRpcFaultException(101, "存储空间不足, 上传失败!");
                        }
                        else
                        {
                            FileStream newFile = new FileStream(sSavePath + sFilename, FileMode.Create);
                            newFile.Write(mediaObject.bits, 0, mediaObject.bits.Length);
                            newFile.Close();
                        }

                        string filename = "";
                        filename = GetAttachRootPath(fileDatePath);

                        //当支持FTP上传附件时,使用FTP上传远程附件,并在上传完成之后删除本地tempfilename文件
                        if (FTPs.GetSpaceAttachInfo.Allowupload == 1)
                        {
                            FTPs ftps = new FTPs();
                            ftps.UpLoadFile(filename.Replace(FTPs.GetSpaceAttachInfo.Remoteurl, ""), sSavePath + sFilename, FTPs.FTPUploadEnum.SpaceAttach);
                        }


                        filename = filename + sFilename;
                        //保存文件信息
                        SaveSpaceAttachment(mediaObject, uid, filename);

                        string permalink = filename;
                        if (!(FTPs.GetSpaceAttachInfo.Allowupload == 1))
                        {
                            permalink = "http://" + DNTRequest.GetCurrentFullHost() + filename;
                        }

                        MediaObjectUrl mediaObjectUrl = new MediaObjectUrl();
                        mediaObjectUrl.url = permalink;
                        return(mediaObjectUrl);
                    }
                    catch
                    {
                        File.Delete(sSavePath + sFilename);
                        throw new XmlRpcFaultException(102, "上传文件发生异常");
                    }
                }
                else //其它类型文件
                {
                    int maxspacesize = UserGroups.GetUserGroupInfo(groupid).Maxspaceattachsize;
                    int currentspaceattachmentsize = DbProvider.GetInstance().GetSpaceAttachmentSizeByUserid(uid);
                    if ((maxspacesize - currentspaceattachmentsize - mediaObject.bits.Length) <= 0)  //个人空间的存储空间不足
                    {
                        throw new XmlRpcFaultException(101, "存储空间不足, 上传失败!");
                    }
                    else
                    {
                        try
                        {
                            FileStream newFile = new FileStream(sSavePath + sFilename, FileMode.Create);
                            newFile.Write(mediaObject.bits, 0, mediaObject.bits.Length);
                            newFile.Close();

                            string filename = "";

                            filename = GetAttachRootPath(fileDatePath);
                            filename = filename + sFilename;
                            //保存文件信息
                            SaveSpaceAttachment(mediaObject, uid, filename);

                            //当支持FTP上传附件时,使用FTP上传远程附件,并在上传完成之后删除本地tempfilename文件
                            if (FTPs.GetSpaceAttachInfo.Allowupload == 1)
                            {
                                FTPs ftps = new FTPs();
                                ftps.UpLoadFile(GetAttachRootPath(fileDatePath).Replace(FTPs.GetSpaceAttachInfo.Remoteurl, ""), sSavePath + sFilename, FTPs.FTPUploadEnum.SpaceAttach);
                            }

                            string permalink = filename;
                            if (!(FTPs.GetSpaceAttachInfo.Allowupload == 1))
                            {
                                permalink = "http://" + DNTRequest.GetCurrentFullHost() + filename;
                            }
                            MediaObjectUrl mediaObjectUrl = new MediaObjectUrl();
                            mediaObjectUrl.url = permalink;
                            return(mediaObjectUrl);
                        }
                        catch
                        {
                            File.Delete(sSavePath + sFilename);
                            throw new XmlRpcFaultException(102, "上传文件发生异常");
                        }
                    }
                }
            }
            return(new MediaObjectUrl());
        }
Пример #19
0
        private void Page_Load(object sender, EventArgs e)
        {
            //当用户在线信息不正确时,则重新返回登陆页
            if (userid <= 0 || Utils.StrToInt(ForumUtils.GetCookie("userid"), -1) != userid)
            {
                Context.Response.Redirect("../../login.aspx");
                return;
            }

            //已登录
            ShortUserInfo _user = Users.GetShortUserInfo(userid);

            if (_user == null || _user.Spaceid <= 0) //用户还未开通个人空间
            {
                Context.Response.Write("<script type='text/javascript'>alert('您还未开通" + config.Spacename + "!');window.location='../../';</script>");
                Context.Response.End();
                return;
            }

            string[] currentdate = DateTime.Now.ToString("yyyy-MM-dd").Split('-');
            if (config.Forumurl == "")
            {
                Response.Write("请正确配置论坛URL地址");
                Response.End();
                return;
            }

            string uploaddir    = "";
            string fileDatePath = currentdate[0] + "/" + currentdate[1] + "/" + currentdate[2] + "/";

            //当支持FTP上传附件
            if (FTPs.GetSpaceAttachInfo.Allowupload == 1)
            {
                //不保留本地附件模式时
                if (FTPs.GetSpaceAttachInfo.Reservelocalattach == 0)
                {
                    uploaddir = Utils.GetMapPath(BaseConfigs.GetForumPath + "space/upload/temp/");
                }
                else
                {
                    uploaddir = Utils.GetMapPath(BaseConfigs.GetForumPath + "space/upload/" + fileDatePath);
                }

                httplink = FTPs.GetSpaceAttachInfo.Remoteurl + "/" + fileDatePath;
                ViewState["RelativeFilePath"] = FTPs.GetSpaceAttachInfo.Remoteurl + "/" + fileDatePath;
            }
            else
            {
                httplink  = BaseConfigs.GetForumPath + "space/upload/" + fileDatePath;
                uploaddir = Utils.GetMapPath(BaseConfigs.GetForumPath + "space/upload/" + fileDatePath);
                ViewState["RelativeFilePath"] = BaseConfigs.GetForumPath + "space/upload/" + fileDatePath;
            }

            if (!Directory.Exists(uploaddir))
            {
                Utils.CreateDir(uploaddir);
            }

            ViewState["UploadDir"] = uploaddir;
            ViewState["postid"]    = DNTRequest.GetInt("postid", 0);

            //载入相册列表
            if (this.spaceconfiginfo.Status == SpaceStatusType.Natural)
            {
                UserGroupInfo usergroupinfo = UserGroups.GetUserGroupInfo(userid);
                //得到用户可以上传的文件类型
                StringBuilder sbAttachmentTypeSelect = new StringBuilder();
                if (!usergroupinfo.Attachextensions.Trim().Equals(""))
                {
                    sbAttachmentTypeSelect.Append("[id] in (");
                    sbAttachmentTypeSelect.Append(usergroupinfo.Attachextensions);
                    sbAttachmentTypeSelect.Append(")");
                }
                attachextensions = Attachments.GetAttachmentTypeArray(sbAttachmentTypeSelect.ToString());
            }
            else
            {
                albums.Visible = false;
            }
        }
Пример #20
0
        private string StartUploadFile()
        {
            string sSavePath = "";

            if (ViewState["UploadDir"] != null)
            {
                sSavePath = ViewState["UploadDir"].ToString();
            }
            else
            {
                sSavePath = Server.MapPath(BaseConfigs.GetForumPath + "space/upload/");
            }

            if (filefield1.PostedFile != null)
            {
                HttpPostedFile myFile   = filefield1.PostedFile;
                int            nFileLen = myFile.ContentLength;
                if (nFileLen == 0)
                {
                    return("");
                }

                byte[] myData = new Byte[nFileLen];
                myFile.InputStream.Read(myData, 0, nFileLen);
                Random random    = new Random(unchecked ((int)DateTime.Now.Ticks));
                string sFilename = (Environment.TickCount & int.MaxValue).ToString() + random.Next(1000, 9999).ToString() + System.IO.Path.GetExtension(myFile.FileName).ToLower();

                //判断sFilename的文件名称是否已存在于服务器上. 如存在, 则添加文件递增标识
                int file_append = 0;
                while (File.Exists(sSavePath + sFilename))
                {
                    file_append++;
                    sFilename = Path.GetFileNameWithoutExtension(myFile.FileName) + file_append.ToString() + Path.GetExtension(myFile.FileName).ToLower();
                }

                string fileExtName      = Path.GetExtension(myFile.FileName).ToLower();
                string relativeFilePath = ViewState["RelativeFilePath"].ToString().Trim();

                fileExtName = fileExtName != "" ? fileExtName: ".invalidExtName";

                if ((attachextensions == null) || (attachextensions.ToLower().IndexOf(fileExtName.Remove(0, 1)) >= 0))
                {
                    //上传图片文件
                    if ((fileExtName == ".jpg") || (fileExtName == ".gif") || (fileExtName == ".png") || (fileExtName == ".jpeg"))
                    {
                        try
                        {
                            AlbumPluginBase apb = AlbumPluginProvider.GetInstance();
                            //上传附件同时加入相册
                            if (albums.SelectedValue != "" && apb != null)
                            {
                                int maxphotosize     = UserGroups.GetUserGroupInfo(_userinfo.Groupid).Maxspacephotosize;
                                int currentphotisize = apb.GetPhotoSizeByUserid(userid);
                                if ((maxphotosize - currentphotisize - nFileLen) <= 0)  //相册的存储空间不足
                                {
                                    HttpContext.Current.Response.Write("<script>alert('" + config.Albumname + "空间不足, 上传至相册失败!');</script>");
                                    HttpContext.Current.Response.End();
                                    return("");
                                }
                                else
                                {
                                    FileStream newFile = new FileStream(sSavePath + sFilename, FileMode.Create);
                                    newFile.Write(myData, 0, myData.Length);
                                    newFile.Close();

                                    string extension = Path.GetExtension(sSavePath + sFilename);
                                    Common.Thumbnail.MakeThumbnailImage(sSavePath + sFilename, (sSavePath + sFilename).Replace(extension, "_thumbnail" + extension), 150, 150);
                                    Common.Thumbnail.MakeSquareImage(sSavePath + sFilename, (sSavePath + sFilename).Replace(extension, "_square" + extension), 100);
                                    string sPath = relativeFilePath;
                                    if (sPath.StartsWith("/"))
                                    {
                                        sPath = sPath.Substring(1, sPath.Length - 1);
                                    }

                                    PhotoInfo photoinfo = new PhotoInfo();
                                    photoinfo.Filename      = sPath + sFilename;
                                    photoinfo.Attachment    = Path.GetFileName(filefield1.PostedFile.FileName);
                                    photoinfo.Filesize      = nFileLen;
                                    photoinfo.Title         = sFilename.Remove(sFilename.IndexOf("."), 1);
                                    photoinfo.Description   = "";
                                    photoinfo.Albumid       = Utils.StrToInt(albums.SelectedValue, 0);
                                    photoinfo.Userid        = userid;
                                    photoinfo.Username      = username;
                                    photoinfo.Views         = 0;
                                    photoinfo.Commentstatus = 0;
                                    photoinfo.Tagstatus     = 0;
                                    photoinfo.Comments      = 0;
                                    photoinfo.IsAttachment  = 1;
                                    Space.Data.DbProvider.GetInstance().AddSpacePhoto(photoinfo);
                                    AlbumInfo albumInfo = apb.GetAlbumInfo(Utils.StrToInt((albums.SelectedValue), 0));
                                    albumInfo.Imgcount = Space.Data.DbProvider.GetInstance().GetSpacePhotoCountByAlbumId(Utils.StrToInt(albums.SelectedValue, 0));
                                    Space.Data.DbProvider.GetInstance().SaveSpaceAlbum(albumInfo);

                                    //当支持FTP上传附件时,使用FTP上传远程附件,并在上传完成之后删除本地tempfilename文件
                                    if (FTPs.GetSpaceAttachInfo.Allowupload == 1)
                                    {
                                        FTPs ftps = new FTPs();
                                        relativeFilePath = relativeFilePath.Replace(FTPs.GetSpaceAttachInfo.Remoteurl, "");
                                        ftps.UpLoadFile(relativeFilePath, sSavePath + sFilename, FTPs.FTPUploadEnum.SpaceAttach);
                                        ftps = new FTPs();
                                        ftps.UpLoadFile(relativeFilePath, (sSavePath + sFilename).Replace(extension, "_thumbnail" + extension), FTPs.FTPUploadEnum.SpaceAttach);
                                        ftps = new FTPs();
                                        ftps.UpLoadFile(relativeFilePath, (sSavePath + sFilename).Replace(extension, "_square" + extension), FTPs.FTPUploadEnum.SpaceAttach);
                                    }
                                }
                            }
                            else
                            {
                                int maxspacesize = UserGroups.GetUserGroupInfo(_userinfo.Groupid).Maxspaceattachsize;
                                int currentspaceattachmentsize = Space.Data.DbProvider.GetInstance().GetSpaceAttachmentSizeByUserid(userid);
                                if ((maxspacesize - currentspaceattachmentsize - nFileLen) <= 0)  //个人空间的存储空间不足
                                {
                                    HttpContext.Current.Response.Write("<script>alert('" + config.Spacename + "存储空间不足, 上传失败!');</script>");
                                    HttpContext.Current.Response.End();
                                    return("");
                                }
                                else
                                {
                                    FileStream newFile = new FileStream(sSavePath + sFilename, FileMode.Create);
                                    newFile.Write(myData, 0, myData.Length);
                                    newFile.Close();
                                }

                                //当支持FTP上传附件时,使用FTP上传远程附件,并在上传完成之后删除本地tempfilename文件
                                if (FTPs.GetSpaceAttachInfo.Allowupload == 1)
                                {
                                    FTPs ftps = new FTPs();
                                    ftps.UpLoadFile(relativeFilePath.Replace(FTPs.GetSpaceAttachInfo.Remoteurl, ""), sSavePath + sFilename, FTPs.FTPUploadEnum.SpaceAttach);
                                }
                            }

                            InsertSapceAttachment(relativeFilePath + sFilename, myFile.ContentType, myData.Length, Path.GetFileName(myFile.FileName).ToLower());

                            return(sFilename);
                        }
                        catch (ArgumentException errArgument)
                        {
                            File.Delete(sSavePath + sFilename);
                            HttpContext.Current.Response.Write("<script>alert('" + errArgument.Message + "!');</script>");
                            HttpContext.Current.Response.End();
                            return("");
                        }
                    }
                    else //其它类型文件
                    {
                        int maxspacesize = UserGroups.GetUserGroupInfo(_userinfo.Groupid).Maxspaceattachsize;
                        int currentspaceattachmentsize = Space.Data.DbProvider.GetInstance().GetSpaceAttachmentSizeByUserid(userid);
                        if ((maxspacesize - currentspaceattachmentsize - nFileLen) <= 0)  //个人空间的存储空间不足
                        {
                            HttpContext.Current.Response.Write("<script>alert('" + config.Spacename + "存储空间不足, 上传失败!');</script>");
                            HttpContext.Current.Response.End();
                            return("");
                        }
                        else
                        {
                            try
                            {
                                myFile.SaveAs(sSavePath + sFilename);
                                InsertSapceAttachment(relativeFilePath + sFilename, myFile.ContentType, myData.Length, Path.GetFileName(myFile.FileName).ToLower());

                                //当支持FTP上传附件时,使用FTP上传远程附件,并在上传完成之后删除本地tempfilename文件
                                if (FTPs.GetSpaceAttachInfo.Allowupload == 1)
                                {
                                    FTPs ftps = new FTPs();
                                    ftps.UpLoadFile(relativeFilePath.Replace(FTPs.GetSpaceAttachInfo.Remoteurl, ""), sSavePath + sFilename, FTPs.FTPUploadEnum.SpaceAttach);
                                }
                                return(sFilename);
                            }
                            catch (ArgumentException errArgument)
                            {
                                File.Delete(sSavePath + sFilename);
                                HttpContext.Current.Response.Write("<script>alert('" + errArgument.Message + "!');</script>");
                                HttpContext.Current.Response.End();
                                return("");
                            }
                        }
                    }
                }
                else //当上传的附件类型无效时
                {
                    return("invalid_file");
                }
            }
            return("");
        }
Пример #21
0
        protected override void ShowPage()
        {
            pagetitle = "用户登录";

            postusername = Utils.UrlDecode(DNTRequest.GetString("postusername")).Trim();

            if (this.userid != -1)
            {
                //SetUrl("/Forum/");
                SetMetaRefresh();
                SetShowBackLink(false);
                AddMsgLine("您已经登录,无须重复登录");
                ispost = true;
                SetLeftMenuRefresh();

                APIConfigInfo apiInfo = APIConfigs.GetConfig();
                if (apiInfo.Enable)
                {
                    APILogin(apiInfo);
                }
            }

            /*
             * if (LoginLogs.UpdateLoginLog(DNTRequest.GetIP(), false) >= 5)
             * {
             *  AddMsgLine("您已经多次输入密码错误, 请15分钟后再登录");
             *  loginsubmit = false;
             *  return;
             * }
             */

            //未提交或跨页提交时
            if (!DNTRequest.IsPost() || referer != "")
            {
                string r = "";
                if (referer != "")
                {
                    r = referer;
                }
                else
                {
                    if ((DNTRequest.GetUrlReferrer() == "") || (DNTRequest.GetUrlReferrer().IndexOf("login") > -1) ||
                        DNTRequest.GetUrlReferrer().IndexOf("logout") > -1)
                    {
                        r = "index.aspx";
                    }
                    else
                    {
                        r = DNTRequest.GetUrlReferrer();
                    }
                }
                Utils.WriteCookie("reurl", (DNTRequest.GetQueryString("reurl") == "" || DNTRequest.GetQueryString("reurl").IndexOf("login.aspx") > -1) ? r : DNTRequest.GetQueryString("reurl"));
            }

            //如果提交...
            if (DNTRequest.IsPost())
            {
                StringBuilder builder = new StringBuilder();
                foreach (string key in System.Web.HttpContext.Current.Request.QueryString.AllKeys)
                {
                    if (key != "postusername")
                    {
                        builder.Append("&");
                        builder.Append(key);
                        builder.Append("=");
                        builder.Append(DNTRequest.GetQueryString(key));
                    }
                }
                base.SetBackLink("login.aspx?postusername="******"username")) + builder.ToString());


                //如果没输入验证码就要求用户填写
                if (isseccode && DNTRequest.GetString("vcode") == "")
                {
                    postusername = DNTRequest.GetString("username");
                    loginauth    = DES.Encode(DNTRequest.GetString("password"), config.Passwordkey).Replace("+", "[");
                    loginsubmit  = true;
                    return;
                }

                bool isExistsUserByName = Discuz.Forum.Users.Exists(DNTRequest.GetString("username"));
                if (!isExistsUserByName)
                {
                    Discuz.Data.DatabaseProvider.GetInstance().ClubLoginLog(1, -1, System.Web.HttpContext.Current.Request.UserHostAddress, 7);
                    AddErrLine("用户不存在");
                }

                if (DNTRequest.GetString("password").Equals("") && DNTRequest.GetString("loginauth") == "")
                {
                    AddErrLine("密码不能为空");
                }

                if (IsErr())
                {
                    return;
                }

                if (!Utils.StrIsNullOrEmpty(loginauth))
                {
                    postpassword = DES.Decode(loginauth.Replace("[", "+"), config.Passwordkey);
                }
                else
                {
                    postpassword = DNTRequest.GetString("password");
                }

                if (postusername == "")
                {
                    postusername = DNTRequest.GetString("username");
                }

                int uid = -1;
                if (config.Passwordmode == 1)
                {
                    if (config.Secques == 1 && (!Utils.StrIsNullOrEmpty(loginauth) || !loginsubmit))
                    {
                        uid = Discuz.Forum.Users.CheckDvBbsPasswordAndSecques(postusername,
                                                                              postpassword,
                                                                              DNTRequest.GetInt("question", 0),
                                                                              DNTRequest.GetString("answer"));
                    }
                    else
                    {
                        uid = Discuz.Forum.Users.CheckDvBbsPassword(postusername, postpassword);
                    }
                }
                else
                {
                    if (config.Secques == 1 && (!Utils.StrIsNullOrEmpty(loginauth) || !loginsubmit))
                    {
                        uid = Discuz.Forum.Users.CheckPasswordAndSecques(postusername,
                                                                         postpassword,
                                                                         true,
                                                                         DNTRequest.GetInt("question", 0),
                                                                         DNTRequest.GetString("answer"));
                    }
                    else
                    {
                        uid = Discuz.Forum.Users.CheckPassword(postusername, postpassword, true);
                    }
                }


                if (uid != -1)
                {
                    ShortUserInfo userinfo = Discuz.Forum.Users.GetShortUserInfo(uid);
                    if (userinfo.Groupid == 8)
                    {
                        AddErrLine("抱歉, 您的用户身份尚未得到验证");
                        if (config.Regverify == 1)
                        {
                            AddMsgLine("请您到您的邮箱中点击激活链接来激活您的帐号");
                        }

                        if (config.Regverify == 2)
                        {
                            AddMsgLine("您需要等待一些时间, 待系统管理员审核您的帐户后才可登录使用");
                        }
                        loginsubmit = false;
                    }
                    else
                    {
                        if (!Utils.StrIsNullOrEmpty(userinfo.Secques) && loginsubmit && Utils.StrIsNullOrEmpty(DNTRequest.GetString("loginauth")))
                        {
                            loginauth = DES.Encode(DNTRequest.GetString("password"), config.Passwordkey).Replace("+", "[");
                        }
                        else
                        {
                            LoginLogs.DeleteLoginLog(DNTRequest.GetIP());
                            UserCredits.UpdateUserCredits(uid);
                            ForumUtils.WriteUserCookie(
                                uid,
                                Utils.StrToInt(DNTRequest.GetString("expires"), -1),
                                config.Passwordkey,
                                DNTRequest.GetInt("templateid", 0),
                                DNTRequest.GetInt("loginmode", -1));
                            OnlineUsers.UpdateAction(olid, UserAction.Login.ActionID, 0);
                            //无延迟更新在线信息
                            oluserinfo = OnlineUsers.UpdateInfo(config.Passwordkey, config.Onlinetimeout);
                            olid       = oluserinfo.Olid;
                            Discuz.Forum.Users.UpdateUserLastvisit(uid, DNTRequest.GetIP());

                            string reurl = Utils.UrlDecode(ForumUtils.GetReUrl());
                            if (reurl.IndexOf("register.aspx") < 0)
                            {
                                SetUrl(reurl);
                            }
                            else
                            {
                                SetUrl("index.aspx");
                            }

                            APIConfigInfo apiInfo = APIConfigs.GetConfig();
                            if (apiInfo.Enable)
                            {
                                APILogin(apiInfo);
                            }

                            Discuz.Forum.Users.SaveUserIDToCookie(uid);

                            Discuz.Data.DatabaseProvider.GetInstance().ClubLoginLog(1, uid, System.Web.HttpContext.Current.Request.UserHostAddress, 5);
                            AddMsgLine("登录成功, 返回登录前页面");

                            userid        = uid;
                            usergroupinfo = UserGroups.GetUserGroupInfo(userinfo.Groupid);
                            // 根据用户组得到相关联的管理组id
                            useradminid = usergroupinfo.Radminid;

                            SetMetaRefresh();
                            SetShowBackLink(false);

                            SetLeftMenuRefresh();

                            loginsubmit = false;
                        }
                    }
                }
                else
                {
                    int errcount = LoginLogs.UpdateLoginLog(DNTRequest.GetIP(), true);
                    if (errcount > 5)
                    {
                        AddErrLine("您已经输入密码5次错误, 请15分钟后再试");
                    }
                    else
                    {
                        if (isExistsUserByName)
                        {
                            uid = Discuz.Data.DatabaseProvider.GetInstance().GetuidByusername(postusername);
                        }
                        Discuz.Data.DatabaseProvider.GetInstance().ClubLoginLog(1, uid, System.Web.HttpContext.Current.Request.UserHostAddress, 6);
                        AddErrLine(string.Format("密码或安全提问第{0}次错误, 您最多有5次机会重试", errcount.ToString()));
                    }
                }
            }
        }
Пример #22
0
        protected void gvClubMemberList_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                var ah = e.Row.DataItem as ApplyHistory;
                if (ah != null)
                {
                    var userInfo = Users.GetUserInfo(ah.Userid);
                    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(ah.Userid, AvatarSize.Small);
                            imgAvatar.ImageUrl = myAvatar;

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

                        #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 = groupInfo.Grouptitle;
                            }
                        }

                        #endregion

                        #region set user credits

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

                        #endregion

                        #region set user fortune

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

                        #endregion

                        #region set user posts

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

                        #endregion
                    }
                }
            }
        }
Пример #23
0
        protected override void ShowPage()
        {
            pagetitle = "撰写短消息";

            if (userid == -1)
            {
                AddErrLine("你尚未登录");

                return;
            }
            user = Discuz.Forum.Users.GetUserInfo(userid);

            if (!CheckPermission())
            {
                return;
            }

            if (DNTRequest.IsPost())
            {
                if (!CheckPermissionAfterPost())
                {
                    return;
                }

                #region 创建并发送短消息

                PrivateMessageInfo pm = new PrivateMessageInfo();

                string curdatetime = Utils.GetDateTime();
                // 收件箱
                if (useradminid == 1)
                {
                    pm.Message = Utils.HtmlEncode(DNTRequest.GetString("message"));
                    pm.Subject = Utils.HtmlEncode(DNTRequest.GetString("subject"));
                }
                else
                {
                    pm.Message =
                        Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("message")));
                    pm.Subject =
                        Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("subject")));
                }

                if (ForumUtils.HasBannedWord(pm.Message) || ForumUtils.HasBannedWord(pm.Subject))
                {
                    //HasBannedWord 指定的字符串中是否含有禁止词汇

                    AddErrLine("对不起, 您提交的内容包含不良信息, 因此无法提交, 请返回修改!");
                    return;
                }


                if (ForumUtils.HasAuditWord(pm.Message) || ForumUtils.HasAuditWord(pm.Subject))
                {
                    AddErrLine("对不起, 您提交的内容包含不良信息, 因此无法提交, 请返回修改!");
                    return;
                }

                pm.Message = ForumUtils.BanWordFilter(pm.Message);
                pm.Subject = ForumUtils.BanWordFilter(pm.Subject);

                pm.Msgto        = DNTRequest.GetString("msgto");
                pm.Msgtoid      = msgtoid;
                pm.Msgfrom      = username;
                pm.Msgfromid    = userid;
                pm.New          = 1;
                pm.Postdatetime = curdatetime;


                if (!DNTRequest.GetString("savetousercpdraftbox").Equals(""))
                {
                    // 检查发送人的短消息是否已超过发送人用户组的上限
                    if (PrivateMessages.GetPrivateMessageCount(userid, -1) >= usergroupinfo.Maxpmnum)
                    {
                        AddErrLine("抱歉,您的短消息已达到上限,无法保存到草稿箱");
                        return;
                    }
                    // 只将消息保存到草稿箱
                    pm.Folder = 2;
                    if (UserCredits.UpdateUserCreditsBySendpms(base.userid) == -1)
                    {
                        AddErrLine("您的金币不足, 不能发送短消息");
                        return;
                    }
                    pm.Pmid = PrivateMessages.CreatePrivateMessage(pm, 0);

                    //发送邮件通知
                    if (DNTRequest.GetString("emailnotify") == "on")
                    {
                        SendNotifyEmail(Discuz.Forum.Users.GetUserInfo(msgtoid).Email.Trim(), pm);
                    }

                    SetUrl("usercpdraftbox.aspx");
                    SetMetaRefresh();
                    SetShowBackLink(true);
                    AddMsgLine("已将消息保存到草稿箱");
                }
                else if (!DNTRequest.GetString("savetosentbox").Equals(""))
                {
                    // 检查接收人的短消息是否已超过接收人用户组的上限
                    UserInfo touser = Discuz.Forum.Users.GetUserInfo(msgtoid);
                    //管理组不受接收人短消息上限限制
                    int radminId = UserGroups.GetUserGroupInfo(usergroupid).Radminid;
                    if (!(radminId > 0 && radminId <= 3) && PrivateMessages.GetPrivateMessageCount(msgtoid, -1) >=
                        UserGroups.GetUserGroupInfo(touser.Groupid).Maxpmnum)
                    {
                        AddErrLine("抱歉,接收人的短消息已达到上限,无法接收");
                        return;
                    }

                    if (!Utils.InArray(Convert.ToInt32(touser.Newsletter).ToString(), "2,3,6,7"))
                    {
                        AddErrLine("抱歉,接收人拒绝接收短消息");
                        return;
                    }
                    // 检查发送人的短消息是否已超过发送人用户组的上限
                    if (PrivateMessages.GetPrivateMessageCount(userid, -1) >= usergroupinfo.Maxpmnum)
                    {
                        AddErrLine("抱歉,您的短消息已达到上限,无法保存到发件箱");
                        return;
                    }
                    // 发送消息且保存到发件箱
                    pm.Folder = 0;
                    if (UserCredits.UpdateUserCreditsBySendpms(base.userid) == -1)
                    {
                        AddErrLine("您的金币不足, 不能发送短消息");
                        return;
                    }
                    pm.Pmid = PrivateMessages.CreatePrivateMessage(pm, 1);

                    //发送邮件通知
                    if (DNTRequest.GetString("emailnotify") == "on")
                    {
                        SendNotifyEmail(touser.Email.Trim(), pm);
                    }

                    // 更新在线表中的用户最后发帖时间
                    OnlineUsers.UpdatePostPMTime(olid);

                    SetUrl("usercpsentbox.aspx");
                    SetMetaRefresh();
                    SetShowBackLink(true);
                    AddMsgLine("发送完毕, 且已将消息保存到发件箱");
                }
                else
                {
                    UserInfo touser = Discuz.Forum.Users.GetUserInfo(msgtoid);
                    // 检查接收人的短消息是否已超过接收人用户组的上限,管理组不受接收人短消息上限限制
                    int radminId = UserGroups.GetUserGroupInfo(usergroupid).Radminid;
                    if (!(radminId > 0 && radminId <= 3) && PrivateMessages.GetPrivateMessageCount(msgtoid, -1) >=
                        UserGroups.GetUserGroupInfo(touser.Groupid).Maxpmnum)
                    {
                        AddErrLine("抱歉,接收人的短消息已达到上限,无法接收");
                        return;
                    }
                    if (!Utils.InArray(Convert.ToInt32(touser.Newsletter).ToString(), "2,3,6,7"))
                    {
                        AddErrLine("抱歉,接收人拒绝接收短消息");
                        return;
                    }

                    // 发送消息但不保存到发件箱
                    pm.Folder = 0;
                    if (UserCredits.UpdateUserCreditsBySendpms(base.userid) == -1)
                    {
                        AddErrLine("您的金币不足, 不能发送短消息");
                        return;
                    }
                    pm.Pmid = PrivateMessages.CreatePrivateMessage(pm, 0);

                    //发送邮件通知
                    if (DNTRequest.GetString("emailnotify") == "on")
                    {
                        SendNotifyEmail(touser.Email.Trim(), pm);
                    }

                    SetUrl("usercpinbox.aspx");
                    SetMetaRefresh();
                    SetShowBackLink(true);
                    AddMsgLine("发送完毕");
                }

                #endregion
            }

            msgto = Utils.HtmlEncode(DNTRequest.GetString("msgto"));

            msgtoid = DNTRequest.GetInt("msgtoid", 0);
            if (msgtoid > 0)
            {
                msgto = Discuz.Forum.Users.GetUserName(msgtoid).Trim();
            }

            subject = Utils.HtmlEncode(DNTRequest.GetString("subject"));
            message = Utils.HtmlEncode(DNTRequest.GetString("message"));

            string action = DNTRequest.GetQueryString("action").ToLower();
            if (action.CompareTo("re") == 0 || action.CompareTo("fw") == 0) //回复或者转发
            {
                int pmid = DNTRequest.GetQueryInt("pmid", -1);
                if (pmid != -1)
                {
                    PrivateMessageInfo pm = PrivateMessages.GetPrivateMessageInfo(pmid);
                    if (pm != null)
                    {
                        if (pm.Msgtoid == userid || pm.Msgfromid == userid)
                        {
                            if (action.CompareTo("re") == 0)
                            {
                                msgto = Utils.HtmlEncode(pm.Msgfrom);
                            }
                            else
                            {
                                msgto = "";
                            }
                            subject = Utils.HtmlEncode(action) + ":" + pm.Subject;
                            message = Utils.HtmlEncode("> ") + pm.Message.Replace("\n", "\n> ") + "\r\n\r\n";
                        }
                    }
                }
            }
        }
Пример #24
0
        /// <summary>
        /// 根据附件加载帖子内容
        /// </summary>
        /// <param name="postpramsInfo">参数对象</param>
        /// <param name="attachList">附件列表</param>
        /// <param name="isModer">是否是管理人员</param>
        /// <param name="allowGetAttach">是否允许获取附件</param>
        /// <param name="originalHideStatus">帖子原始Hide属性</param>
        /// <param name="postInfo">帖子信息 </param>
        private static void LoadPostMessage(PostpramsInfo postpramsInfo, List <ShowtopicPageAttachmentInfo> attachList, bool isModer, int allowGetAttach, int originalHideStatus, ShowtopicPagePostInfo postInfo)
        {
            UserGroupInfo tmpGroupInfo;

            if (!Utils.InArray(postInfo.Groupid.ToString(), "4,5,6"))
            {
                //处理帖子内容
                postpramsInfo.Smileyoff   = postInfo.Smileyoff;
                postpramsInfo.Bbcodeoff   = postInfo.Bbcodeoff;
                postpramsInfo.Parseurloff = postInfo.Parseurloff;
                postpramsInfo.Allowhtml   = postInfo.Htmlon;
                postpramsInfo.Sdetail     = postInfo.Message;
                postpramsInfo.Pid         = postInfo.Pid;
                //校正hide处理
                tmpGroupInfo = UserGroups.GetUserGroupInfo(postInfo.Groupid);
                if (tmpGroupInfo.Allowhidecode == 0)
                {
                    postpramsInfo.Hide = 0;
                }

                //先简单判断是否是动网兼容模式
                if (!postpramsInfo.Ubbmode)
                {
                    postInfo.Message = UBB.UBBToHTML(postpramsInfo);
                }
                else
                {
                    postInfo.Message = Utils.HtmlEncode(postInfo.Message);
                }

                if (postpramsInfo.Jammer == 1)
                {
                    postInfo.Message = ForumUtils.AddJammer(postInfo.Message);
                }

                string message = postInfo.Message;
                if (postInfo.Attachment > 0 || regexAttach.IsMatch(message) || regexAttachImg.IsMatch(message))
                {
                    //获取在[hide]标签中的附件id
                    string[] attHidArray = Posts.GetHiddenAttachIdList(postpramsInfo.Sdetail, postpramsInfo.Hide);
                    List <ShowtopicPageAttachmentInfo> attachDeleteList = new List <ShowtopicPageAttachmentInfo>();
                    foreach (ShowtopicPageAttachmentInfo attach in attachList)
                    {
                        message = Attachments.GetMessageWithAttachInfo(postpramsInfo, allowGetAttach, attHidArray, postInfo, attach, message);
                        if ((postpramsInfo.CurrentUserGroup.Radminid == 1 || attach.Uid == postpramsInfo.CurrentUserid || attach.Attachprice <= 0 || attach.Isbought == 1) ||//当为发帖人或不为收费附件或已购买该收费附件时
                            Utils.InArray(attach.Aid.ToString(), attHidArray))
                        {
                            ;
                        }
                        else
                        {
                            attachDeleteList.Add(attach);
                        }
                    }

                    foreach (ShowtopicPageAttachmentInfo attach in attachDeleteList)
                    {
                        attachList.Remove(attach);
                    }
                    postInfo.Message = message;
                }

                //恢复hide初值
                postpramsInfo.Hide = originalHideStatus;
            }
            else//发帖人已经被禁止发言
            {
                if (isModer)
                {
                    postInfo.Message = "<div class='hintinfo'>该用户帖子内容已被屏蔽, 您拥有管理权限, 以下是帖子内容</div>" + postInfo.Message;
                }
                else
                {
                    postInfo.Message = "该用户帖子内容已被屏蔽";
                    List <ShowtopicPageAttachmentInfo> delattlist = new List <ShowtopicPageAttachmentInfo>();
                    foreach (ShowtopicPageAttachmentInfo attach in attachList)
                    {
                        if (attach.Pid == postInfo.Pid)
                        {
                            delattlist.Add(attach);
                        }
                    }

                    foreach (ShowtopicPageAttachmentInfo attach in delattlist)
                    {
                        attachList.Remove(attach);
                    }
                }
            }
        }
Пример #25
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
                    }
                }
            }
        }
Пример #26
0
        public AttachUploadPage()
        {
            if (!DNTRequest.GetRawUrl().Contains("action=swfupload") && ForumUtils.IsCrossSitePost(DNTRequest.GetUrlReferrer(), DNTRequest.GetHost())) //如果是跨站提交...
            {
                return;
            }

            //处理flash批量上传无法获取userid的问题
            bool canpostattach = true;

            if (DNTRequest.GetString("operation") == "upload")
            {
                string uploadUserid = DNTRequest.GetString("uid");
                int    olid         = Discuz.Forum.OnlineUsers.GetOlidByUid(TypeConverter.StrToInt(uploadUserid));
                if (olid > 0)
                {
                    OnlineUserInfo oluserinfo = Discuz.Forum.OnlineUsers.GetOnlineUser(olid);
                    string         hash       = Discuz.Common.DES.Encode(oluserinfo.Olid.ToString() + "," + oluserinfo.Username.ToString(), oluserinfo.Password.Substring(0, 10)).Replace("+", "[");
                    if (DNTRequest.GetString("hash") == hash)
                    {
                        userid        = oluserinfo.Userid;
                        usergroupinfo = UserGroups.GetUserGroupInfo(oluserinfo.Groupid);
                    }
                    else
                    {
                        canpostattach = false;
                    }
                }
                else
                {
                    canpostattach = false;
                }
            }

            UserInfo  userinfo     = Users.GetUserInfo(userid);
            ForumInfo forum        = Forums.GetForumInfo(forumid);
            int       MaxTodaySize = (userid > 0 ? Attachments.GetUploadFileSizeByuserid(userid) : 0);
            //今天可上传得大小
            int attachsize = usergroupinfo.Maxsizeperday - MaxTodaySize;
            //得到用户可以上传的文件类型
            string attachmentTypeSelect   = Attachments.GetAllowAttachmentType(usergroupinfo, forum);
            string attachextensions       = Attachments.GetAttachmentTypeArray(attachmentTypeSelect);
            string attachextensionsnosize = Attachments.GetAttachmentTypeString(attachmentTypeSelect);

            if (DNTRequest.GetString("action") == "swfupload" && DNTRequest.GetString("operation") == "config")
            {
                GetConfig(userid, attachextensionsnosize, attachsize, DNTRequest.GetString("type").Trim() == "image");
            }
            else
            {
                //处理附件
                string        msg = "";
                StringBuilder sb  = new StringBuilder();
                canpostattach &= UserAuthority.PostAttachAuthority(forum, usergroupinfo, userid, ref msg);
                if (!canpostattach)
                {
                    ResponseXML(sb.Append("DISCUZUPLOAD|11|0|-1").ToString());//11,上传权限
                    return;
                }
                if (attachsize <= 0)
                {
                    ResponseXML(sb.Append("DISCUZUPLOAD|3|0|-1").ToString());//3,附件大小超限
                    return;
                }

                //得到今天允许用户上传的附件总大小(字节)
                AttachmentInfo[] attachmentinfoarray = ForumUtils.SaveRequestFiles(forumid, config.Maxattachments, usergroupinfo.Maxsizeperday, usergroupinfo.Maxattachsize, MaxTodaySize,
                                                                                   attachextensions, forum.Disablewatermark == 1 ? 0 : config.Watermarkstatus, config, "Filedata", DNTRequest.GetString("type") == "image");
                if (attachmentinfoarray.Length > 0)//已有上传文件
                {
                    int    aId      = DNTRequest.GetInt("aid", 0);
                    string noUpload = "";

                    foreach (AttachmentInfo attachmentinfo in attachmentinfoarray)
                    {
                        noUpload           = string.IsNullOrEmpty(attachmentinfo.Sys_noupload) ? noUpload : attachmentinfo.Sys_noupload;
                        attachmentinfo.Uid = userid;
                    }

                    if (aId <= 0)
                    {
                        Attachments.CreateAttachments(attachmentinfoarray);
                    }
                    else if (string.IsNullOrEmpty(noUpload))
                    {
                        AttachmentInfo attchmentInfo = Attachments.GetAttachmentInfo(aId);
                        //判断当前用户是否为附件所有者
                        if (attchmentInfo == null || (userinfo.Adminid <= 0 && attchmentInfo.Uid != userid))
                        {
                            return;
                        }
                        attchmentInfo.Postdatetime = attachmentinfoarray[0].Postdatetime;
                        attchmentInfo.Filename     = attachmentinfoarray[0].Filename;
                        attchmentInfo.Description  = attachmentinfoarray[0].Description;
                        attchmentInfo.Filetype     = attachmentinfoarray[0].Filetype;
                        attchmentInfo.Filesize     = attachmentinfoarray[0].Filesize;
                        attchmentInfo.Attachment   = attachmentinfoarray[0].Attachment;
                        attchmentInfo.Width        = attachmentinfoarray[0].Width;
                        attchmentInfo.Height       = attachmentinfoarray[0].Height;
                        attchmentInfo.Isimage      = attachmentinfoarray[0].Isimage;
                        Attachments.UpdateAttachment(attchmentInfo);
                    }
                    StringBuilder text = new StringBuilder();
                    int           type = attachmentinfoarray[0].Filetype.StartsWith("image") ? 0 : -1;

                    int resultCode = GetNoUploadCode(noUpload);

                    if (aId <= 0)
                    {
                        if (DNTRequest.GetString("action") != "swfupload")
                        {
                            text.AppendFormat("DISCUZUPLOAD|{0}|{1}|{2}", resultCode, attachmentinfoarray[0].Aid, type);
                        }
                        else
                        {
                            text.AppendFormat(resultCode != 0 ? "error" : attachmentinfoarray[0].Aid.ToString());
                        }
                    }
                    else
                    {
                        text.AppendFormat("DISCUZUPDATE|{0}|{1}|{2}|{3}", resultCode, attachmentinfoarray[0].Attachment, aId, type);
                    }
                    ResponseXML(text.ToString());
                }
            }
        }
Пример #27
0
        private void SaveUserInfo_Click(object sender, EventArgs e)
        {
            #region 保存用户信息

            if (this.CheckCookie())
            {
                int    uid       = DNTRequest.GetInt("uid", -1);
                string errorInfo = "";

                if (!AllowEditUserInfo(uid, true))
                {
                    return;
                }

                if (userName.Text != ViewState["username"].ToString())
                {
                    if (AdminUsers.GetUserId(userName.Text) > 0)
                    {
                        base.RegisterStartupScript("", "<script>alert('您所输入的用户名已被使用过, 请输入其他的用户名!');</script>");
                        return;
                    }
                }

                if (userName.Text == "")
                {
                    base.RegisterStartupScript("", "<script>alert('用户名不能为空!');</script>");
                    return;
                }

                if (groupid.SelectedValue == "0")
                {
                    base.RegisterStartupScript("", "<script>alert('您未选中任何用户组!');</script>");
                    return;
                }

                userInfo             = AdminUsers.GetUserInfo(uid);
                userInfo.Username    = userName.Text;
                userInfo.Nickname    = nickname.Text;
                userInfo.Accessmasks = Convert.ToInt32(accessmasks.SelectedValue);

                //当用户组发生变化时则相应更新用户的管理组字段
                if (userInfo.Groupid.ToString() != groupid.SelectedValue)
                {
                    userInfo.Adminid = UserGroups.GetUserGroupInfo(int.Parse(groupid.SelectedValue)).Radminid;
                }

                //userInfo.Avatarshowid = 0;

                if ((bday.Text == "0000-00-00") || (bday.Text == "0000-0-0") | (bday.Text.Trim() == ""))
                {
                    userInfo.Bday = "";
                }
                else
                {
                    if (!Utils.IsDateString(bday.Text.Trim()))
                    {
                        base.RegisterStartupScript("", "<script>alert('用户生日不是有效的日期型数据!');</script>");
                        return;
                    }
                    else
                    {
                        userInfo.Bday = bday.Text;
                    }
                }


                if (!Users.ValidateEmail(email.Text, uid))
                {
                    base.RegisterStartupScript("", "<script>alert('当前用户的邮箱地址已被使用过, 请输入其他的邮箱!');</script>");
                    return;
                }

                userInfo.Email  = email.Text;
                userInfo.Gender = Convert.ToInt32(gender.SelectedValue);
                //userInfo.Groupexpiry = Convert.ToInt32(groupexpiry.Text);后台操作为永久禁言和永久禁访

                userInfo.Groupexpiry = 0;
                userInfo.Extgroupids = extgroupids.GetSelectString(",");

                if ((groupid.SelectedValue != "1") && (userInfo.Uid == BaseConfigs.GetFounderUid))
                {
                    base.RegisterStartupScript("", "<script>alert('创始人的所属用户组不能被修改为其它组!');window.location.href='global_edituser.aspx?uid=" + DNTRequest.GetString("uid") + "';</script>");
                    return;
                }

                userInfo.Groupid      = Convert.ToInt32(groupid.SelectedValue);
                userInfo.Invisible    = Convert.ToInt32(invisible.SelectedValue);
                userInfo.Joindate     = joindate.Text;
                userInfo.Lastactivity = lastactivity.Text;
                userInfo.Lastip       = lastip.Text;
                userInfo.Lastpost     = lastpost.Text;
                userInfo.Lastvisit    = lastvisit.Text;
                userInfo.Newpm        = Convert.ToInt32(newpm.SelectedValue);
                userInfo.Newsletter   = (ReceivePMSettingType)GetNewsLetter();
                userInfo.Oltime       = Convert.ToInt32(oltime.Text);
                userInfo.Pageviews    = Convert.ToInt32(pageviews.Text);
                userInfo.Pmsound      = Convert.ToInt32(pmsound.Text);
                userInfo.Posts        = Convert.ToInt32(posts.Text);
                userInfo.Ppp          = Convert.ToInt32(ppp.Text);
                userInfo.Regip        = regip.Text;
                userInfo.Digestposts  = Convert.ToInt32(digestposts.Text);

                if (secques.SelectedValue == "1")
                {
                    userInfo.Secques = "";                               //清空安全码
                }
                userInfo.Showemail  = Convert.ToInt32(showemail.SelectedValue);
                userInfo.Sigstatus  = Convert.ToInt32(sigstatus.SelectedValue);
                userInfo.Templateid = Convert.ToInt32(templateid.SelectedValue);
                userInfo.Tpp        = Convert.ToInt32(tpp.Text);


                if (Utils.IsNumeric(extcredits1.Text.Replace("-", "")))
                {
                    userInfo.Extcredits1 = float.Parse(extcredits1.Text);
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>");
                    return;
                }

                if (Utils.IsNumeric(extcredits2.Text.Replace("-", "")))
                {
                    userInfo.Extcredits2 = float.Parse(extcredits2.Text);
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>");
                    return;
                }

                if (Utils.IsNumeric(extcredits3.Text.Replace("-", "")))
                {
                    userInfo.Extcredits3 = float.Parse(extcredits3.Text);
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>");
                    return;
                }

                if (Utils.IsNumeric(extcredits4.Text.Replace("-", "")))
                {
                    userInfo.Extcredits4 = float.Parse(extcredits4.Text);
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>");
                    return;
                }

                if (Utils.IsNumeric(extcredits5.Text.Replace("-", "")))
                {
                    userInfo.Extcredits5 = float.Parse(extcredits5.Text);
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>");
                    return;
                }

                if (Utils.IsNumeric(extcredits6.Text.Replace("-", "")))
                {
                    userInfo.Extcredits6 = float.Parse(extcredits6.Text);
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>");
                    return;
                }

                if (Utils.IsNumeric(extcredits7.Text.Replace("-", "")))
                {
                    userInfo.Extcredits7 = float.Parse(extcredits7.Text);
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>");
                    return;
                }

                if (Utils.IsNumeric(extcredits8.Text.Replace("-", "")))
                {
                    userInfo.Extcredits8 = float.Parse(extcredits8.Text);
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('用户扩展积分不能为空或大于7位 !');</script>");
                    return;
                }


                //根据公式计算用户的总积分,并更新
                userInfo.Credits = CreditsFacade.GetUserCreditsByUserInfo(userInfo);
                //判断用户组是否为积分用户组。如果是的话,就用当前积分更新。
                if (UserGroups.IsCreditUserGroup(userInfo.Groupid))
                {
                    userInfo.Groupid = CreditsFacade.GetCreditsUserGroupId(userInfo.Credits).Groupid;
                }
                //用户扩展信息
                userInfo.Website      = website.Text;
                userInfo.Icq          = icq.Text;
                userInfo.Qq           = qq.Text;
                userInfo.Yahoo        = yahoo.Text;
                userInfo.Msn          = msn.Text;
                userInfo.Skype        = skype.Text;
                userInfo.Location     = location.Text;
                userInfo.Customstatus = customstatus.Text;
                //userInfo.Avatar = avatar.Text;
                //userInfo.Avatarheight = Convert.ToInt32(avatarheight.Text);
                //userInfo.Avatarwidth = Convert.ToInt32(avatarwidth.Text);
                userInfo.Bio = bio.Text;
                if (signature.Text.Length > UserGroups.GetUserGroupInfo(userInfo.Groupid).Maxsigsize)
                {
                    errorInfo = "更新的签名长度超过 " + UserGroups.GetUserGroupInfo(userInfo.Groupid).Maxsigsize + " 字符的限制,未能更新。";
                }
                else
                {
                    userInfo.Signature = signature.Text;
                    //签名UBB转换HTML
                    PostpramsInfo _postpramsinfo = new PostpramsInfo();
                    _postpramsinfo.Showimages = UserGroups.GetUserGroupInfo(userInfo.Groupid).Allowsigimgcode;
                    _postpramsinfo.Sdetail    = signature.Text;
                    userInfo.Sightml          = UBB.UBBToHTML(_postpramsinfo);
                }

                userInfo.Realname = realname.Text;
                userInfo.Idcard   = idcard.Text;
                userInfo.Mobile   = mobile.Text;
                userInfo.Phone    = phone.Text;
                userInfo.Medals   = DNTRequest.GetString("medalid");

                if (IsEditUserName.Checked && userName.Text != ViewState["username"].ToString())
                {
                    AdminUsers.UserNameChange(userInfo, ViewState["username"].ToString());
                    //用户重命名同步
                    Discuz.Forum.Sync.RenameUser(userInfo.Uid, ViewState["username"].ToString(), userInfo.Username, "");
                }

                if (AdminUsers.UpdateUserAllInfo(userInfo))
                {
                    OnlineUsers.DeleteUserByUid(userInfo.Uid);    //移除该用户的在线信息,使之重建在线表信息
                    if (ViewState["Groupid"].ToString() != userInfo.Groupid.ToString())
                    {
                        if (userInfo.Groupid == 4)
                        {
                            if (AlbumPluginProvider.GetInstance() != null)
                            {
                                AlbumPluginProvider.GetInstance().Ban(userInfo.Uid);
                            }
                            if (SpacePluginProvider.GetInstance() != null)
                            {
                                SpacePluginProvider.GetInstance().Ban(userInfo.Uid);
                            }
                        }
                        else
                        {
                            if (AlbumPluginProvider.GetInstance() != null)
                            {
                                AlbumPluginProvider.GetInstance().UnBan(userInfo.Uid);
                            }
                            if (SpacePluginProvider.GetInstance() != null)
                            {
                                SpacePluginProvider.GetInstance().UnBan(userInfo.Uid);
                            }
                        }
                    }
                    //if (userName.Text != ViewState["username"].ToString())
                    //{
                    //    AdminUsers.UserNameChange(userInfo, ViewState["username"].ToString());
                    //}
                    //删除头像
                    if (delavart.Checked)
                    {
                        Avatars.DeleteAvatar(userInfo.Uid.ToString());
                    }
                    AdminVistLogs.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "后台编辑用户", "用户名:" + userName.Text);
                    if (errorInfo == "")
                    {
                        base.RegisterStartupScript("PAGE", "window.location.href='global_usergrid.aspx?condition=" + DNTRequest.GetString("condition") + "';");
                    }
                    else
                    {
                        base.RegisterStartupScript("PAGE", "alert('" + errorInfo + "');window.location.href='global_usergrid.aspx?condition=" + DNTRequest.GetString("condition") + "';");
                    }
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('操作失败');window.location.href='global_usergrid.aspx?condition=" + DNTRequest.GetString("condition") + "';</script>");
                }
            }

            #endregion
        }
Пример #28
0
        private void SaveUserInfo_Click(object sender, EventArgs e)
        {
            #region 保存用户信息

            if (this.CheckCookie())
            {
                int    uid       = DNTRequest.GetInt("uid", -1);
                string errorInfo = "";

                if (!AllowEditUserInfo(uid, true))
                {
                    return;
                }

                if (userName.Text != ViewState["username"].ToString())
                {
                    if (AdminUsers.GetUserID(userName.Text) != -1)
                    {
                        base.RegisterStartupScript("", "<script>alert('您所输入的用户名已被使用过, 请输入其他的用户名!');</script>");
                        return;
                    }
                }

                if (userName.Text == "")
                {
                    base.RegisterStartupScript("", "<script>alert('用户名不能为空!');</script>");
                    return;
                }

                if (groupid.SelectedValue == "0")
                {
                    base.RegisterStartupScript("", "<script>alert('您未选中任何用户组!');</script>");
                    return;
                }

                __userinfo             = AdminUsers.GetUserInfo(uid);
                __userinfo.Username    = userName.Text;
                __userinfo.Nickname    = nickname.Text;
                __userinfo.Accessmasks = Convert.ToInt32(accessmasks.SelectedValue);

                //当用户组发生变化时则相应更新用户的管理组字段
                if (__userinfo.Groupid.ToString() != groupid.SelectedValue)
                {
                    __userinfo.Adminid = DatabaseProvider.GetInstance().GetRadminidByGroupid(int.Parse(groupid.SelectedValue));
                }

                __userinfo.Avatarshowid = 0;

                if ((bday.Text == "0000-00-00") || (bday.Text == "0000-0-0") | (bday.Text.Trim() == ""))
                {
                    __userinfo.Bday = "";
                }
                else
                {
                    if (!Utils.IsDateString(bday.Text.Trim()))
                    {
                        base.RegisterStartupScript("", "<script>alert('用户生日不是有效的日期型数据!');</script>");
                        return;
                    }
                    else
                    {
                        __userinfo.Bday = bday.Text;
                    }
                }

                if (Utils.IsNumeric(credits.Text.Replace("-", "")))
                {
                    __userinfo.Credits = Convert.ToInt32(credits.Text);
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('用户的金币不能为空或大于9位 !');</script>");
                    return;
                }

                GeneralConfigInfo __configinfo = GeneralConfigs.Deserialize(Server.MapPath("../../config/general.config"));
                if (__configinfo.Doublee == 0)
                {
                    int currentuid = AdminUsers.FindUserEmail(email.Text);
                    if ((currentuid != -1) && (currentuid != uid))
                    {
                        base.RegisterStartupScript("", "<script>alert('当前用户的邮箱地址已被使用过, 请输入其他的邮箱!');</script>");
                        return;
                    }
                }

                __userinfo.Email       = email.Text;
                __userinfo.Gender      = Convert.ToInt32(gender.SelectedValue);
                __userinfo.Groupexpiry = Convert.ToInt32(groupexpiry.Text);
                __userinfo.Extgroupids = extgroupids.GetSelectString(",");

                if ((groupid.SelectedValue != "1") && (__userinfo.Uid == 1))
                {
                    base.RegisterStartupScript("", "<script>alert('初始化系统管理员的所属用户组设置不能修改为其它组!');window.location.href='global_edituser.aspx?uid=" + DNTRequest.GetString("uid") + "';</script>");
                    return;
                }

                __userinfo.Groupid      = Convert.ToInt32(groupid.SelectedValue);
                __userinfo.Invisible    = Convert.ToInt32(invisible.SelectedValue);
                __userinfo.Joindate     = joindate.Text;
                __userinfo.Lastactivity = lastactivity.Text;
                __userinfo.Lastip       = lastip.Text;
                __userinfo.Lastpost     = lastpost.Text;
                __userinfo.Lastvisit    = lastvisit.Text;
                __userinfo.Newpm        = Convert.ToInt32(newpm.SelectedValue);
                __userinfo.Newsletter   = (ReceivePMSettingType)GetNewsLetter();
                __userinfo.Oltime       = Convert.ToInt32(oltime.Text);
                __userinfo.Pageviews    = Convert.ToInt32(pageviews.Text);
                __userinfo.Pmsound      = Convert.ToInt32(pmsound.Text);
                __userinfo.Posts        = Convert.ToInt32(posts.Text);
                __userinfo.Ppp          = Convert.ToInt32(ppp.Text);
                __userinfo.Regip        = regip.Text;
                __userinfo.Digestposts  = Convert.ToInt32(digestposts.Text);

                if (secques.SelectedValue == "1")
                {
                    __userinfo.Secques = "";                               //清空安全码
                }
                __userinfo.Showemail  = Convert.ToInt32(showemail.SelectedValue);
                __userinfo.Sigstatus  = Convert.ToInt32(sigstatus.SelectedValue);
                __userinfo.Templateid = Convert.ToInt32(templateid.SelectedValue);
                __userinfo.Tpp        = Convert.ToInt32(tpp.Text);


                if (Utils.IsNumeric(extcredits1.Text.Replace("-", "")))
                {
                    __userinfo.Extcredits1 = float.Parse(extcredits1.Text);
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('用户扩展金币不能为空或大于7位 !');</script>");
                    return;
                }

                if (Utils.IsNumeric(extcredits2.Text.Replace("-", "")))
                {
                    __userinfo.Extcredits2 = float.Parse(extcredits2.Text);
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('用户扩展金币不能为空或大于7位 !');</script>");
                    return;
                }

                if (Utils.IsNumeric(extcredits3.Text.Replace("-", "")))
                {
                    __userinfo.Extcredits3 = float.Parse(extcredits3.Text);
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('用户扩展金币不能为空或大于7位 !');</script>");
                    return;
                }

                if (Utils.IsNumeric(extcredits4.Text.Replace("-", "")))
                {
                    __userinfo.Extcredits4 = float.Parse(extcredits4.Text);
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('用户扩展金币不能为空或大于7位 !');</script>");
                    return;
                }

                if (Utils.IsNumeric(extcredits5.Text.Replace("-", "")))
                {
                    __userinfo.Extcredits5 = float.Parse(extcredits5.Text);
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('用户扩展金币不能为空或大于7位 !');</script>");
                    return;
                }

                if (Utils.IsNumeric(extcredits6.Text.Replace("-", "")))
                {
                    __userinfo.Extcredits6 = float.Parse(extcredits6.Text);
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('用户扩展金币不能为空或大于7位 !');</script>");
                    return;
                }

                if (Utils.IsNumeric(extcredits7.Text.Replace("-", "")))
                {
                    __userinfo.Extcredits7 = float.Parse(extcredits7.Text);
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('用户扩展金币不能为空或大于7位 !');</script>");
                    return;
                }

                if (Utils.IsNumeric(extcredits8.Text.Replace("-", "")))
                {
                    __userinfo.Extcredits8 = float.Parse(extcredits8.Text);
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('用户扩展金币不能为空或大于7位 !');</script>");
                    return;
                }


                //用户扩展信息
                __userinfo.Website      = website.Text;
                __userinfo.Icq          = icq.Text;
                __userinfo.Qq           = qq.Text;
                __userinfo.Yahoo        = yahoo.Text;
                __userinfo.Msn          = msn.Text;
                __userinfo.Skype        = skype.Text;
                __userinfo.Location     = location.Text;
                __userinfo.Customstatus = customstatus.Text;
                __userinfo.Avatar       = avatar.Text;
                __userinfo.Avatarheight = Convert.ToInt32(avatarheight.Text);
                __userinfo.Avatarwidth  = Convert.ToInt32(avatarwidth.Text);
                __userinfo.Bio          = bio.Text;
                if (signature.Text.Length > UserGroups.GetUserGroupInfo(__userinfo.Groupid).Maxsigsize)
                {
                    errorInfo = "更新的签名长度超过 " + UserGroups.GetUserGroupInfo(__userinfo.Groupid).Maxsigsize + " 字符的限制,未能更新。";
                }
                else
                {
                    __userinfo.Signature = signature.Text;
                    //签名UBB转换HTML
                    PostpramsInfo _postpramsinfo = new PostpramsInfo();
                    _postpramsinfo.Showimages = UserGroups.GetUserGroupInfo(__userinfo.Groupid).Allowsigimgcode;
                    _postpramsinfo.Sdetail    = signature.Text;
                    __userinfo.Sightml        = UBB.UBBToHTML(_postpramsinfo);
                }

                __userinfo.Realname = realname.Text;
                __userinfo.Idcard   = idcard.Text;
                __userinfo.Mobile   = mobile.Text;
                __userinfo.Phone    = phone.Text;
                __userinfo.Medals   = DNTRequest.GetString("medalid");

                if (IsEditUserName.Checked)
                {
                    AdminUsers.UserNameChange(__userinfo, ViewState["username"].ToString());
                }

                if (AdminUsers.UpdateUserAllInfo(__userinfo))
                {
                    if (userName.Text != ViewState["username"].ToString())
                    {
                        AdminUsers.UserNameChange(__userinfo, ViewState["username"].ToString());
                    }
                    AdminVistLogs.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "后台编辑用户", "用户名:" + userName.Text);
                    if (errorInfo == "")
                    {
                        base.RegisterStartupScript("PAGE", "window.location.href='global_usergrid.aspx?condition=" + DNTRequest.GetString("condition") + "';");
                    }
                    else
                    {
                        base.RegisterStartupScript("PAGE", "alert('" + errorInfo + "');window.location.href='global_usergrid.aspx?condition=" + DNTRequest.GetString("condition") + "';");
                    }
                }
                else
                {
                    base.RegisterStartupScript("", "<script>alert('操作失败');window.location.href='global_usergrid.aspx?condition=" + DNTRequest.GetString("condition") + "';</script>");
                }
            }

            #endregion
        }
Пример #29
0
        /// <summary>
        /// 构造函数
        /// </summary>
        public ArchiverPage()
        {
            config = GeneralConfigs.GetConfig();

            if (config.Archiverstatus == 2 && DNTRequest.IsSearchEnginesGet())//启用,但当用户从搜索引擎点击时自动转向动态页面
            {
                string url = OrganizeURL(HttpContext.Current.Request.Url);
                HttpContext.Current.Response.Redirect(url);
            }

            if (config.Archiverstatus == 3 && DNTRequest.IsBrowserGet())            //启用,但当用户使用浏览器访问时自动转向动态页面
            {
                string url = OrganizeURL(HttpContext.Current.Request.Url);
                HttpContext.Current.Response.Redirect(url);
            }

            int onlineusercount = OnlineUsers.GetOnlineAllUserCount();

            if (onlineusercount >= config.Maxonlines)
            {
                ShowError("抱歉,目前访问人数太多,你暂时无法访问论坛.", 0);
            }

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

            OnlineUserInfo oluserinfo = OnlineUsers.UpdateInfo(config.Passwordkey, config.Onlinetimeout);

            userid      = oluserinfo.Userid;
            useradminid = oluserinfo.Adminid;


            // 如果论坛关闭且当前用户请求页面不是登录页面且用户非管理员, 则跳转至论坛关闭信息页
            if (config.Closed == 1 && oluserinfo.Adminid != 1)
            {
                ShowError("", 1);
            }

            usergroupinfo = UserGroups.GetUserGroupInfo(oluserinfo.Groupid);

            // 如果不允许访问论坛则转向到tools/ban.htm
            if (usergroupinfo.Allowvisit != 1)
            {
                ShowError("抱歉, 您所在的用户组不允许访问论坛", 2);
            }
            // 如果IP访问列表有设置则进行判断
            if (config.Ipaccess.Trim() != "")
            {
                string[] regctrl = Utils.SplitString(config.Ipaccess, "\n");
                if (!Utils.InIPArray(DNTRequest.GetIP(), regctrl))
                {
                    ShowError("抱歉, 系统设置了IP访问列表限制, 您无法访问本论坛", 0);
                    return;
                }
            }


            // 如果IP访问列表有设置则进行判断
            if (config.Ipdenyaccess.Trim() != "")
            {
                string[] regctrl = Utils.SplitString(config.Ipdenyaccess, "\n");
                if (Utils.InIPArray(DNTRequest.GetIP(), regctrl))
                {
                    ShowError("由于您严重违反了论坛的相关规定, 已被禁止访问.", 2);
                    return;
                }
            }

            // 如果当前用户请求页面不是登录页面并且当前用户非管理员并且论坛设定了时间段,当时间在其中的一个时间段内,则跳转到论坛登录页面
            if (oluserinfo.Adminid != 1 && DNTRequest.GetPageName() != "login.aspx")
            {
                if (Scoresets.BetweenTime(config.Visitbanperiods))
                {
                    ShowError("在此时间段内不允许访问本论坛", 2);
                    return;
                }
            }

            HttpContext.Current.Response.Write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\r\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n<head>\r\n");

            if (config.Seokeywords != "")
            {
                HttpContext.Current.Response.Write("<meta name=\"keywords\" content=\"" + config.Seokeywords + "\" />\r\n");
            }
            if (config.Seodescription != "")
            {
                HttpContext.Current.Response.Write("<meta name=\"description\" content=\"" + config.Seodescription + "\" />\r\n");
            }
            HttpContext.Current.Response.Write(config.Seohead.Trim());
            HttpContext.Current.Response.Write("\r\n<link href=\"dntarchiver.css\" rel=\"stylesheet\" type=\"text/css\" />");

            if (config.Archiverstatus == 0)
            {
                ShowError("系统禁止使用Archiver", 3);
                HttpContext.Current.Response.End();
                return;
            }
        }
Пример #30
0
        protected override void ShowPage()
        {
            pagetitle = "用户登录";
            inapi     = DNTRequest.GetInt("inapi", 0);
            if (userid != -1)
            {
                SetUrl(BaseConfigs.GetForumPath);
                AddMsgLine("您已经登录,无须重复登录");
                ispost = true;
                SetLeftMenuRefresh();

                if (APIConfigs.GetConfig().Enable)
                {
                    APILogin(APIConfigs.GetConfig());
                }
            }

            if (LoginLogs.UpdateLoginLog(DNTRequest.GetIP(), false) >= 5)
            {
                AddErrLine("您已经多次输入密码错误, 请15分钟后再登录");
                loginsubmit = false;
                return;
            }

            SetReUrl();

            //如果提交...
            if (DNTRequest.IsPost())
            {
                SetBackLink();

                //如果没输入验证码就要求用户填写
                if (isseccode && DNTRequest.GetString("vcode") == "")
                {
                    postusername = DNTRequest.GetString("username");
                    loginauth    = DES.Encode(DNTRequest.GetString("password"), config.Passwordkey).Replace("+", "[");
                    loginsubmit  = true;
                    return;
                }

                if (config.Emaillogin == 1 && Utils.IsValidEmail(DNTRequest.GetString("username")))
                {
                    DataTable dt = Users.GetUserInfoByEmail(DNTRequest.GetString("username"));
                    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(DNTRequest.GetString("username")) == 0))
                    {
                        AddErrLine("用户不存在");
                    }
                }

                if (Utils.StrIsNullOrEmpty(DNTRequest.GetString("password")) && Utils.StrIsNullOrEmpty(DNTRequest.GetString("loginauth")))
                {
                    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 = UserCredits.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;
                    }

                    if (userInfo.Groupid == 8)
                    {
                        if (config.Regverify == 1)
                        {
                            needactiveuid = userInfo.Uid;
                            email         = userInfo.Email;
                            timestamp     = DateTime.Now.Ticks.ToString();
                            authstr       = Utils.MD5(string.Concat(userInfo.Password, config.Passwordkey, timestamp));
                            AddMsgLine("请您到您的邮箱中点击激活链接来激活您的帐号");
                        }
                        else if (config.Regverify == 2)
                        {
                            AddMsgLine("您需要等待一些时间, 待系统管理员审核您的帐户后才可登录使用");
                        }
                        else
                        {
                            AddErrLine("抱歉, 您的用户身份尚未得到验证");
                        }

                        loginsubmit = false;
                        return;
                    }
                    #endregion

                    if (!Utils.StrIsNullOrEmpty(userInfo.Secques) && loginsubmit && Utils.StrIsNullOrEmpty(DNTRequest.GetString("loginauth")))
                    {
                        loginauth = DES.Encode(DNTRequest.GetString("password"), config.Passwordkey).Replace("+", "[");
                    }
                    else
                    {
                        //通过api整合的程序登录
                        if (APIConfigs.GetConfig().Enable)
                        {
                            APILogin(APIConfigs.GetConfig());
                        }


                        AddMsgLine("登录成功, 返回登录前页面");

                        #region 无延迟更新在线信息和相关用户信息
                        ForumUtils.WriteUserCookie(userInfo.Uid, TypeConverter.StrToInt(DNTRequest.GetString("expires"), -1),
                                                   config.Passwordkey, DNTRequest.GetInt("templateid", 0), DNTRequest.GetInt("loginmode", -1));
                        //oluserinfo = OnlineUsers.UpdateInfo(config.Passwordkey, config.Onlinetimeout);
                        oluserinfo    = OnlineUsers.UpdateInfo(config.Passwordkey, config.Onlinetimeout, userInfo.Uid, "");
                        olid          = oluserinfo.Olid;
                        username      = DNTRequest.GetString("username");
                        userid        = userInfo.Uid;
                        usergroupinfo = UserGroups.GetUserGroupInfo(userInfo.Groupid);
                        useradminid   = usergroupinfo.Radminid; // 根据用户组得到相关联的管理组id


                        OnlineUsers.UpdateAction(olid, UserAction.Login.ActionID, 0);
                        LoginLogs.DeleteLoginLog(DNTRequest.GetIP());
                        Users.UpdateUserCreditsAndVisit(userInfo.Uid, DNTRequest.GetIP());
                        #endregion

                        loginsubmit = false;
                        string reurl = Utils.UrlDecode(ForumUtils.GetReUrl());
                        SetUrl(reurl.IndexOf("register.aspx") < 0 ? reurl : forumpath + "index.aspx");

                        SetLeftMenuRefresh();

                        //同步登录到第三方应用
                        if (APIConfigs.GetConfig().Enable)
                        {
                            AddMsgLine(Sync.GetLoginScript(userid, username));
                        }

                        if (!APIConfigs.GetConfig().Enable || !Sync.NeedAsyncLogin())
                        {
                            MsgForward("login_succeed", true);
                        }
                    }
                }
                else
                {
                    int errcount = LoginLogs.UpdateLoginLog(DNTRequest.GetIP(), true);
                    if (errcount > 5)
                    {
                        AddErrLine("您已经输入密码5次错误, 请15分钟后再试");
                    }
                    else
                    {
                        AddErrLine(string.Format("密码或安全提问第{0}次错误, 您最多有5次机会重试", errcount));
                    }
                }
                if (IsErr())
                {
                    return;
                }

                ForumUtils.WriteUserCreditsCookie(userInfo, usergroupinfo.Grouptitle);
            }
        }