示例#1
0
        protected override void ShowPage()
        {
            pagetitle = "版块列表";

            if (config.Rssstatus == 1)
            {
                AddLinkRss("tools/rss.aspx", config.Forumtitle + "最新主题");
            }
            userinfo = new ShortUserInfo();
            if (userid != -1)
            {
                userinfo = Discuz.Forum.Users.GetShortUserInfo(userid);
                if (userinfo.Newpm == 0)
                {
                    base.newpmcount = 0;
                }
            }

            OnlineUsers.UpdateAction(olid, UserAction.IndexShow.ActionID, 0, config.Onlinetimeout);
            // 获得统计信息
            totalonline = onlineusercount;
            totalonlineuser = OnlineUsers.GetOnlineUserCount();

            score = Scoresets.GetValidScoreName();
        }
示例#2
0
 /// <summary>
 /// 返回指定扩展积分
 /// </summary>
 /// <param name="userInfo">用户信息</param>
 /// <param name="extCreditsId">扩展积分ID</param>
 /// <returns></returns>
 private static float GetUserExtCredits(ShortUserInfo userInfo, int extCreditsId)
 {
     switch (extCreditsId)
     {
         case 1: return userInfo.Extcredits1;
         case 2: return userInfo.Extcredits2;
         case 3: return userInfo.Extcredits3;
         case 4: return userInfo.Extcredits4;
         case 5: return userInfo.Extcredits5;
         case 6: return userInfo.Extcredits6;
         case 7: return userInfo.Extcredits7;
         case 8: return userInfo.Extcredits8;
         default: return 0;
     }
 }
示例#3
0
        protected override void ShowPage()
        {
            pagetitle = "版块列表";

            if (config.Rssstatus == 1)
                AddLinkRss("tools/rss.aspx", config.Forumtitle + "最新主题");

            if (userid != -1)
            {
                userinfo = Users.GetShortUserInfo(userid);
                newpmcount = userinfo.Newpm == 0 ? 0 :newpmcount;
            }

            OnlineUsers.UpdateAction(olid, UserAction.IndexShow.ActionID, 0, config.Onlinetimeout);
            // 获得统计信息
            totalonline = onlineusercount;
        }
示例#4
0
        /// <summary>
        ///  根据得到给定主题的用户列表(posterid)
        /// </summary>
        /// <param name="topicList">主题列表</param>
        /// <param name="op">操作源(0:精华,1:删除)</param>      
        /// <param name="losslessdel">删帖不减积分时间期限(天)</param>
        /// <returns></returns>
        public static List<ShortUserInfo> GetUserListWithTopicList(string topicList, int op, int losslessdel)
        {
            IDataReader reader = null;
            if (op == 1 && losslessdel != 0)
                reader = DatabaseProvider.GetInstance().GetUserListWithTopicList(topicList, losslessdel);
            else
                reader = DatabaseProvider.GetInstance().GetUserListWithTopicList(topicList);

            List<ShortUserInfo> users = new List<ShortUserInfo>();
            while (reader.Read())
            {
                ShortUserInfo userInfo = new ShortUserInfo();
                userInfo.Uid = TypeConverter.ObjectToInt(reader["posterid"], -1);
                users.Add(userInfo);
            }
            reader.Close();
            return users;
        }
示例#5
0
        /// <summary>
        /// 根据积分公式更新用户积分,并且受分数变动影响有可能会更改用户所属的用户组
        /// <param name="userInfo">用户信息</param>
        /// </summary
        public static int UpdateUserCredits(ShortUserInfo userInfo)
        {
            if (userInfo == null || userInfo.Uid < 1)
                return 0;

            Discuz.Data.UserCredits.UpdateUserCredits(userInfo.Uid);
            UserGroupInfo tmpUserGroupInfo = UserGroups.GetUserGroupInfo(userInfo.Groupid);

            if (tmpUserGroupInfo != null && ((tmpUserGroupInfo.System == 0 && tmpUserGroupInfo.Radminid == 0)
                || (tmpUserGroupInfo.Groupid == 7 && userInfo.Adminid == -1)))//当用户是已删除的特殊组成员时,则运算相应积分,并更新该用户所属组信息
            {
                tmpUserGroupInfo = GetCreditsUserGroupId(userInfo.Credits);
                if (tmpUserGroupInfo.Groupid != userInfo.Groupid)//当用户所属组发生变化时
                {
                    Discuz.Data.Users.UpdateUserGroup(userInfo.Uid.ToString(), tmpUserGroupInfo.Groupid);
                    Discuz.Data.OnlineUsers.UpdateGroupid(userInfo.Uid, tmpUserGroupInfo.Groupid);
                }
            }
            return 1;
        }
示例#6
0
        /// <summary>
        /// 创建邀请码信息
        /// </summary>
        /// <param name="userInfo">创建用户信息</param>
        /// <returns></returns>
        public static int CreateInviteCode(ShortUserInfo userInfo)
        {
            InvitationConfigInfo configInfo = InvitationConfigs.GetConfig();
            InviteCodeInfo inviteCode = new InviteCodeInfo();
            inviteCode.CreatorId = userInfo.Uid;
            inviteCode.Creator = userInfo.Username;

            inviteCode.Code = BuildInviteCode();
            while (IsInviteCodeExist(inviteCode.Code))//生成的邀请码code是否存在于数据库中
            {
                inviteCode.Code = BuildInviteCode();
            }

            inviteCode.CreateTime = Utils.GetDateTime();
            inviteCode.InviteType = GeneralConfigs.GetConfig().Regstatus;
            inviteCode.ExpireTime = Utils.GetDateTime(configInfo.InviteCodeExpireTime);
            if (inviteCode.InviteType == 3)
                inviteCode.MaxCount = configInfo.InviteCodeMaxCount > 1 ? configInfo.InviteCodeMaxCount : 1;
            else
                inviteCode.MaxCount = configInfo.InviteCodeMaxCount;
            return Data.Invitation.CreateInviteCode(inviteCode);
        }
示例#7
0
        /// <summary>
        /// 验证帖子信息
        /// </summary>
        /// <param name="admininfo"></param>
        /// <param name="user"></param>
        /// <param name="ishtmlon"></param>
        private void SetPostInfo(AdminGroupInfo admininfo, ShortUserInfo user, bool ishtmlon)
        {
            if (postinfo.Layer == 0 && forum.Applytopictype == 1 && forum.Postbytopictype == 1 && topictypeselectoptions != string.Empty)
            {
                if (Utils.StrIsNullOrEmpty(DNTRequest.GetString("typeid")) || DNTRequest.GetString("typeid").Trim() == "0")
                {
                    AddErrLine("主题类型不能为空");
                    return;
                }

                if (!Forums.IsCurrentForumTopicType(DNTRequest.GetString("typeid").Trim(), forum.Topictypes))
                {
                    AddErrLine("错误的主题类型");
                    return;
                }
            }

            //这段代码有什么作用,和下面的SetAttachmentInfo方法做的事情是否有重复?能否拿掉?
            ///删除附件
            if (DNTRequest.GetInt("isdeleteatt", 0) == 1)
            {
                if (DNTRequest.GetFormInt("aid", 0) > 0 && Attachments.DeleteAttachment(DNTRequest.GetFormInt("aid", 0)) > 0)
                {
                    attachmentlist = Attachments.GetAttachmentListByPid(postinfo.Pid);
                    attachmentcount = Attachments.GetAttachmentCountByPid(postinfo.Pid);
                }
                AddLinkCss(BaseConfigs.GetForumPath + "templates/" + templatepath + "/editor.css", "css");
                // 帖子内容
                message = postinfo.Message;
                ispost = false;

                return;
            }
            //
            #region 检查标题和内容信息
            if (string.IsNullOrEmpty(postTitle.Trim().Replace(" ", "")) && postinfo.Layer == 0)
                AddErrLine("标题不能为空");
            else if (postTitle.Length > 60)
                AddErrLine("标题最大长度为60个字符,当前为 " + postTitle.Length.ToString() + " 个字符");

            //string postmessage = DNTRequest.GetString("message");
            if (postMessage.Equals("") || postMessage.Replace(" ", "").Equals(""))
                AddErrLine("内容不能为空");

            if (admininfo != null && disablepostctrl != 1)
            {
                if (postMessage.Length < config.Minpostsize)
                    AddErrLine("您发表的内容过少, 系统设置要求帖子内容不得少于 " + config.Minpostsize.ToString() + " 字多于 " + config.Maxpostsize.ToString() + " 字");
                else if (postMessage.Length > config.Maxpostsize)
                    AddErrLine("您发表的内容过多, 系统设置要求帖子内容不得少于 " + config.Minpostsize.ToString() + " 字多于 " + config.Maxpostsize.ToString() + " 字");
            }

            //新用户广告强力屏蔽检查
            if ((config.Disablepostad == 1) && useradminid < 1)  //如果开启新用户广告强力屏蔽检查或是游客
            {
                if ((config.Disablepostadpostcount != 0 && user.Posts <= config.Disablepostadpostcount) ||
                    (config.Disablepostadregminute != 0 && DateTime.Now.AddMinutes(-config.Disablepostadregminute) <= Convert.ToDateTime(user.Joindate)))
                {
                    foreach (string regular in config.Disablepostadregular.Replace("\r", "").Split('\n'))
                    {
                        if (Posts.IsAD(regular, postTitle, postMessage))
                        {
                            AddErrLine("发帖失败,内容中有不符合新用户强力广告屏蔽规则的字符,请检查标题和内容,如有疑问请与管理员联系");
                            return;
                        }
                    }
                }
            }

            #endregion
            string[] pollitem = Utils.SplitString(DNTRequest.GetString("PollItemname"), "\r\n");
            int topicprice = 0;
            string tmpprice = DNTRequest.GetString("topicprice");

            if (postinfo.Layer == 0)
            {

                #region 投票信息
                //string[] pollitem = Utils.SplitString(DNTRequest.GetString("PollItemname"), "\r\n");

                if (!Utils.StrIsNullOrEmpty(DNTRequest.GetString("updatepoll")) && topic.Special == 1)
                {
                    pollinfo.Multiple = DNTRequest.GetInt("multiple", 0);

                    // 验证用户是否有发布投票的权限
                    if (usergroupinfo.Allowpostpoll != 1)
                    {
                        AddErrLine("您当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有发布投票的权限");
                        return;
                    }

                    if (pollitem.Length < 2)
                        AddErrLine("投票项不得少于2个");
                    else if (pollitem.Length > config.Maxpolloptions)
                        AddErrLine("系统设置为投票项不得多于" + config.Maxpolloptions + "个");
                    else
                    {
                        for (int i = 0; i < pollitem.Length; i++)
                            if (Utils.StrIsNullOrEmpty(pollitem[i]))
                                AddErrLine("投票项不能为空");
                    }
                }
                #endregion

                #region 悬赏信息
                //int topicprice = 0;
                //string tmpprice = DNTRequest.GetString("topicprice");

                if (Regex.IsMatch(tmpprice, "^[0-9]*[0-9][0-9]*$") || tmpprice == string.Empty)
                {
                    topicprice = Utils.StrToInt(tmpprice, 0) > 32767 ? 32767 : Utils.StrToInt(tmpprice, 0);
                    //当不是正在进行的悬赏...
                    if (topic.Special != 2)
                    {
                        if (topicprice > usergroupinfo.Maxprice && usergroupinfo.Maxprice > 0)
                        {
                            if (userextcreditsinfo.Unit.Equals(""))
                                AddErrLine(string.Format("主题售价不能高于 {0} {1}", usergroupinfo.Maxprice, userextcreditsinfo.Name));
                            else
                                AddErrLine(string.Format("主题售价不能高于 {0} {1}({2})", usergroupinfo.Maxprice, userextcreditsinfo.Name, userextcreditsinfo.Unit));
                        }
                        else if (topicprice > 0 && usergroupinfo.Maxprice <= 0)
                            AddErrLine(string.Format("您当前的身份 \"{0}\" 未被允许出售主题", usergroupinfo.Grouptitle));
                        else if (topicprice < 0)
                            AddErrLine("主题售价不能为负数");
                    }
                    else
                    {
                        if (usergroupinfo.Radminid != 1)
                        {
                            if (usergroupinfo.Allowbonus == 0)
                                AddErrLine(string.Format("您当前的身份 \"{0}\" 未被允许进行悬赏", usergroupinfo.Grouptitle));

                            if (topicprice < usergroupinfo.Minbonusprice || topicprice > usergroupinfo.Maxbonusprice)
                                AddErrLine(string.Format("悬赏价格超出范围, 您应在 {0} - {1} {2}{3} 范围内进行悬赏", usergroupinfo.Minbonusprice, usergroupinfo.Maxbonusprice,
                                    userextcreditsinfo.Unit, userextcreditsinfo.Name));
                        }
                    }
                }
                else
                {
                    if (topic.Special != 2)
                        AddErrLine("主题售价只能为整数");
                    else
                        AddErrLine("悬赏价格只能为整数");
                }
                #endregion

                #region 辩论信息
                if (!Utils.StrIsNullOrEmpty(DNTRequest.GetString("updatedebate")) && topic.Special == 4)
                {
                    if (usergroupinfo.Allowdebate != 1)
                    {
                        AddErrLine("您当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有发布辩论的权限");
                        return;
                    }
                    if (Utils.StrIsNullOrEmpty(DNTRequest.GetString("positiveopinion")))
                    {
                        AddErrLine("正方观点不能为空");
                        return;
                    }
                    if (Utils.StrIsNullOrEmpty(DNTRequest.GetString("negativeopinion")))
                    {
                        AddErrLine("反方观点不能为空");
                        return;
                    }
                    if (Utils.StrIsNullOrEmpty(DNTRequest.GetString("terminaltime")))
                    {
                        AddErrLine("辩论的结束日期不能为空");
                        return;
                    }
                    if (!Utils.IsDateString(DNTRequest.GetString("terminaltime")))
                    {
                        AddErrLine("结束日期格式不正确");
                        return;
                    }
                }
                #endregion

            }

            #region 绑定并检查主题和帖子信息
            if (useradminid == 1)
            {
                postinfo.Title = Utils.HtmlEncode(postTitle);

                if (usergroupinfo.Allowhtml == 0)
                    postinfo.Message = Utils.HtmlEncode(postMessage);
                else
                    postinfo.Message = ishtmlon ? postMessage :
                            Utils.HtmlEncode(postMessage);
            }
            else
            {
                postinfo.Title = Utils.HtmlEncode(ForumUtils.BanWordFilter(postTitle));
                    
                if (usergroupinfo.Allowhtml == 0)
                    postinfo.Message = Utils.HtmlEncode(ForumUtils.BanWordFilter(postMessage));
                else
                    postinfo.Message = ishtmlon ? ForumUtils.BanWordFilter(postMessage) :
                            Utils.HtmlEncode(ForumUtils.BanWordFilter(postMessage));
            }
            postinfo.Title = postinfo.Title.Length > 60 ? postinfo.Title.Substring(0, 60) : postinfo.Title;

            if (useradminid != 1 && (ForumUtils.HasBannedWord(postTitle) || ForumUtils.HasBannedWord(postMessage)))
            {
                string bannedWord = ForumUtils.GetBannedWord(postTitle) == string.Empty ? ForumUtils.GetBannedWord(postMessage) : ForumUtils.GetBannedWord(postTitle);
                AddErrLine(string.Format("对不起, 您提交的内容包含不良信息  <font color=\"red\">{0}</font>, 请返回修改!", bannedWord));
                return;
            }

            //if (useradminid != 1 && (ForumUtils.HasAuditWord(postinfo.Title) || ForumUtils.HasAuditWord(postinfo.Message)))
            //{
            //    AddErrLine("对不起, 管理员设置了需要对发帖进行审核, 您没有权力编辑已通过审核的帖子, 请返回修改!");
            //    return;
            //}

            topic.Displayorder = Topics.GetTitleDisplayOrder(usergroupinfo, useradminid, forum, topic, message, disablepostctrl);

            #endregion
            // 检察上面验证是否有错误
            if (IsErr())
                return;
            //如果是不是管理员组,或者编辑间隔超过60秒,则附加编辑信息
            if (Utils.StrDateDiffSeconds(postinfo.Postdatetime, 60) > 0 && config.Editedby == 1 && useradminid != 1)
                postinfo.Lastedit = username + " 最后编辑于 " + Utils.GetDateTime();

            postinfo.Usesig = Utils.StrToInt(DNTRequest.GetString("usesig"), 0);
            postinfo.Htmlon = (usergroupinfo.Allowhtml == 1 && ishtmlon ? 1 : 0);
            postinfo.Smileyoff = smileyoff == 0 ? TypeConverter.StrToInt(DNTRequest.GetString("smileyoff")) : smileyoff;
            postinfo.Bbcodeoff = (usergroupinfo.Allowcusbbcode == 1 ? TypeConverter.StrToInt(DNTRequest.GetString("bbcodeoff")) : 1);
            postinfo.Parseurloff = TypeConverter.StrToInt(DNTRequest.GetString("parseurloff"));
            postinfo.Invisible = needaudit ? 1 : 0;

            //如果当前用户就是作者或所在管理组有编辑的权限
            if (userid == postinfo.Posterid || (admininfo != null && admininfo.Alloweditpost == 1 && Moderators.IsModer(useradminid, userid, forumid)))
                alloweditpost = true;
            else
            {
                AddErrLine("您当前的身份不是作者");
                return;
            }

            if (!alloweditpost)
            {
                AddErrLine("您当前的身份没有编辑帖子的权限");
                return;
            }

            if (alloweditpost)
                SetTopicInfo(pollitem, topicprice, postMessage);
        }
示例#8
0
        /// <summary>
        /// 常规项验证
        /// </summary>
        /// <param name="admininfo"></param>
        /// <param name="postmessage"></param>
        private void NormalValidate(AdminGroupInfo admininfo, string postmessage, ShortUserInfo user)
        {
            if (ForumUtils.IsCrossSitePost())
            {
                AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。");
                return;
            }

            if (forum.Applytopictype == 1 && forum.Postbytopictype == 1 && !Utils.StrIsNullOrEmpty(topictypeselectoptions))
            {
                if (DNTRequest.GetString("typeid").Trim().Equals(""))
                    AddErrLine("主题类型不能为空");
                //检测所选主题分类是否有效
                if (!Forums.IsCurrentForumTopicType(DNTRequest.GetString("typeid").Trim(), forum.Topictypes))
                    AddErrLine("错误的主题类型");
            }
            if (Utils.StrIsNullOrEmpty(DNTRequest.GetString("title")))
                AddErrLine("标题不能为空");
            else if (DNTRequest.GetString("title").IndexOf(" ") != -1)
                AddErrLine("标题不能包含全角空格符");
            else if (DNTRequest.GetString("title").Length > 60)
                AddErrLine("标题最大长度为60个字符,当前为 " + DNTRequest.GetString("title").Length + " 个字符");

            if (Utils.StrIsNullOrEmpty(postmessage.Replace(" ", "")))
                AddErrLine("内容不能为空");

            if (admininfo != null && admininfo.Disablepostctrl != 1)
            {
                if (postmessage.Length < config.Minpostsize)
                    AddErrLine("您发表的内容过少, 系统设置要求帖子内容不得少于 " + config.Minpostsize.ToString() + " 字多于 " + config.Maxpostsize.ToString() + " 字");
                else if (postmessage.Length > config.Maxpostsize)
                    AddErrLine("您发表的内容过多, 系统设置要求帖子内容不得少于 " + config.Minpostsize.ToString() + " 字多于 " + config.Maxpostsize.ToString() + " 字");
            }

            //新用户广告强力屏蔽检查
            if ((config.Disablepostad == 1) && useradminid < 1)  //如果开启新用户广告强力屏蔽检查或是游客
            {
                if ((config.Disablepostadpostcount != 0 && user.Posts <= config.Disablepostadpostcount) ||
                    (config.Disablepostadregminute != 0 && DateTime.Now.AddMinutes(-config.Disablepostadregminute) <= Convert.ToDateTime(user.Joindate)))
                {
                    foreach (string regular in config.Disablepostadregular.Replace("\r", "").Split('\n'))
                    {
                        if (Posts.IsAD(regular, DNTRequest.GetString("title"), postmessage))
                            AddErrLine("发帖失败,内容中似乎有广告信息,请检查标题和内容,如有疑问请与管理员联系");
                    }
                }
            }
        }
示例#9
0
        protected override void ShowPage()
        {
            //获取主题信息
            topic = GetTopicInfo();
            if (topic == null)
                return;
            topicid = topic.Tid;
            forumid = topic.Fid;
            forum = Forums.GetForumInfo(forumid);
            if (forum == null)
            {
                AddErrLine("不存在的版块ID"); return;
            }

            //验证不通过则返回
            if (!ValidateInfo() || IsErr())
                return;

            int price = GetTopicPrice(topic);
            if (topic.Special == 0 && price > 0)
            {
                HttpContext.Current.Response.Redirect(forumpath + "buytopic.aspx?topicid=" + topic.Tid);
                return;
            }

            if (userid > 0)
            {
                userInfo = Users.GetShortUserInfo(userid);
            }

            if (topic.Identify > 0)
                topicidentify = Caches.GetTopicIdentify(topic.Identify);

            pagetitle = string.Format("{0} - {1}", topic.Title, forum.Name);

            ///得到广告列表              
            GetForumAds(forum.Fid);

            IsModer();

            //获取主题类型
            Caches.GetTopicTypeArray().TryGetValue(topic.Typeid, out topictypes);
            topictypes = Utils.StrIsNullOrEmpty(topictypes) ? "" : "[" + topictypes + "]";

            userextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetTopicAttachCreditsTrans());
            score = Scoresets.GetValidScoreName();
            scoreunit = Scoresets.GetValidScoreUnit();
            navhomemenu = Caches.GetForumListMenuDivCache(usergroupid, userid, config.Extname);
            //编辑器状态
            EditorState();

            string[] customauthorinfo = GeneralConfigs.GetConfig().Customauthorinfo.Split('|');
            postleftshow = customauthorinfo[0].Split(',');//帖子左边要显示的用户信息项目
            userfaceshow = customauthorinfo[1].Split(',');//头像上方要显示的项目
            //if (newpmcount > 0)
            //    pmlist = PrivateMessages.GetPrivateMessageListForIndex(userid, 5, 1, 1);

            onlyauthor = (onlyauthor == "1" || onlyauthor == "2") ? onlyauthor : "0";
            // 获取分页相关信息
            BindPageCountAndId();

            GetPostAds(GetPostPramsInfo(price), postlist.Count);

            #region 获取特殊主题相关信息
            bonuslogs = Bonus.GetLogs(topic);

            if (topic.Special == 1)//获取投票信息
                GetPollInfo();

            if (topic.Special == 4) //获取辩论信息
                GetDebateInfo();
            #endregion

            if (postlist.Count <= 0)
            {
                AddErrLine("读取信息失败"); 
                return;
            }

            enabletag = (config.Enabletag & forum.Allowtag) == 1;
            //if (enabletag)
            //    relatedtopics = Topics.GetRelatedTopicList(topicid, 5);

            //更新页面Meta信息
            UpdateMetaInfo(Utils.RemoveHtml(postlist[0].Message));

            //判断是否需要生成游客缓存页面
            IsGuestCachePage();

            //更新主题查看次数和在线用户信息
            TopicStats.Track(topicid, 1);
            Topics.MarkOldTopic(topic);
            topicviews = topic.Views + 1 + (config.TopicQueueStats == 1 ? TopicStats.GetStoredTopicViewCount(topic.Tid) : 0);
            OnlineUsers.UpdateAction(olid, UserAction.ShowTopic.ActionID, forumid, forum.Name, topicid, topic.Title);

            //UserCredits.UpdateUserCredits(userInfo);此方法与后台积分设置中的条目不匹配,故注释
        }
示例#10
0
        public static List<ShortUserInfo> GetUserListWithDigestTopicList(string digestTopicList, int digestType)
        {
            IDataReader reader = DatabaseProvider.GetInstance().GetUserListWithDigestTopicList(digestTopicList, digestType);

            List<ShortUserInfo> users = new List<ShortUserInfo>();
            while (reader.Read())
            {
                ShortUserInfo userInfo = new ShortUserInfo();
                userInfo.Uid = TypeConverter.ObjectToInt(reader["posterid"], -1);
                users.Add(userInfo);
            }
            reader.Close();
            return users;
        }
示例#11
0
 public static ShortUserInfo LoadSingleShortUserInfo(IDataReader reader)
 {
     ShortUserInfo userInfo = null;
     if (reader.Read())
     {
         userInfo = new ShortUserInfo();
         userInfo.Uid = TypeConverter.ObjectToInt(reader["uid"]);
         userInfo.Username = reader["username"].ToString();
         userInfo.Nickname = reader["nickname"].ToString();
         userInfo.Password = reader["password"].ToString();
         userInfo.Spaceid = TypeConverter.ObjectToInt(reader["spaceid"]);
         userInfo.Secques = reader["secques"].ToString();
         userInfo.Gender = TypeConverter.ObjectToInt(reader["gender"]);
         userInfo.Adminid = TypeConverter.ObjectToInt(reader["adminid"]);
         userInfo.Groupid = TypeConverter.ObjectToInt(reader["groupid"]);
         userInfo.Groupexpiry = TypeConverter.ObjectToInt(reader["groupexpiry"]);
         userInfo.Extgroupids = reader["extgroupids"].ToString();
         userInfo.Regip = reader["regip"].ToString();
         userInfo.Joindate = reader["joindate"].ToString();
         userInfo.Lastip = reader["lastip"].ToString();
         userInfo.Lastvisit = reader["lastvisit"].ToString();
         userInfo.Lastactivity = reader["lastactivity"].ToString();
         userInfo.Lastpost = reader["lastpost"].ToString();
         userInfo.Lastpostid = TypeConverter.ObjectToInt(reader["lastpostid"]);
         userInfo.Lastposttitle = reader["lastposttitle"].ToString();
         userInfo.Posts = TypeConverter.ObjectToInt(reader["posts"]);
         userInfo.Digestposts = TypeConverter.StrToInt(reader["digestposts"].ToString());
         userInfo.Oltime = TypeConverter.ObjectToInt(reader["oltime"]);
         userInfo.Pageviews = TypeConverter.StrToInt(reader["pageviews"].ToString());
         userInfo.Credits = TypeConverter.ObjectToInt(reader["credits"]);
         userInfo.Extcredits1 = TypeConverter.StrToFloat(reader["extcredits1"].ToString());
         userInfo.Extcredits2 = TypeConverter.StrToFloat(reader["extcredits2"].ToString());
         userInfo.Extcredits3 = TypeConverter.StrToFloat(reader["extcredits3"].ToString());
         userInfo.Extcredits4 = TypeConverter.StrToFloat(reader["extcredits4"].ToString());
         userInfo.Extcredits5 = TypeConverter.StrToFloat(reader["extcredits5"].ToString());
         userInfo.Extcredits6 = TypeConverter.StrToFloat(reader["extcredits6"].ToString());
         userInfo.Extcredits7 = TypeConverter.StrToFloat(reader["extcredits7"].ToString());
         userInfo.Extcredits8 = TypeConverter.StrToFloat(reader["extcredits8"].ToString());
         userInfo.Email = reader["email"].ToString();
         userInfo.Bday = reader["bday"].ToString();
         userInfo.Sigstatus = TypeConverter.ObjectToInt(reader["sigstatus"]);
         userInfo.Tpp = TypeConverter.ObjectToInt(reader["tpp"]);
         userInfo.Ppp = TypeConverter.ObjectToInt(reader["ppp"]);
         userInfo.Templateid = TypeConverter.ObjectToInt(reader["templateid"]);
         userInfo.Pmsound = TypeConverter.ObjectToInt(reader["pmsound"]);
         userInfo.Showemail = TypeConverter.ObjectToInt(reader["showemail"]);
         userInfo.Newsletter = (ReceivePMSettingType)TypeConverter.ObjectToInt(reader["newsletter"]);
         userInfo.Invisible = TypeConverter.ObjectToInt(reader["invisible"]);
         userInfo.Newpm = TypeConverter.ObjectToInt(reader["newpm"]);
         userInfo.Newpmcount = TypeConverter.ObjectToInt(reader["newpmcount"]);
         userInfo.Accessmasks = TypeConverter.ObjectToInt(reader["accessmasks"]);
         userInfo.Onlinestate = TypeConverter.ObjectToInt(reader["onlinestate"]);
         userInfo.Salt = reader["salt"].ToString();//二次MD5所用的字段
     }
     reader.Close();
     return userInfo;
 }
 public static int CalcContributeFortune(ShortUserInfo info, bool playerBonus)
 {
     return CalcContributeFortune(info.Uid, info.Credits, info.Extcredits1, (int) info.Extcredits2, playerBonus);
 }
示例#13
0
        protected override void ShowPage()
		{
			pagetitle = "首页";
            if (userid > 0 && useradminid > 0)
            {
                AdminGroupInfo admingroupinfo = AdminGroups.GetAdminGroupInfo(usergroupid);
                if (admingroupinfo != null)
                    disablepostctrl = admingroupinfo.Disablepostctrl;
            }

            int toframe = DNTRequest.GetInt("f", 1);
            if (toframe == 0)
                ForumUtils.WriteCookie("isframe", "1");
            else
                toframe = Utils.StrToInt(ForumUtils.GetCookie("isframe"), -1) == -1 ? config.Isframeshow : Utils.StrToInt(ForumUtils.GetCookie("isframe"), -1);

			if (toframe == 2)
			{
				HttpContext.Current.Response.Redirect(BaseConfigs.GetForumPath + "frame.aspx");
				HttpContext.Current.Response.End();
                return;
			}

            if (config.Rssstatus == 1)
				AddLinkRss("tools/rss.aspx", "最新主题");

			OnlineUsers.UpdateAction(olid, UserAction.IndexShow.ActionID, 0, config.Onlinetimeout);

            //if (newpmcount > 0)
            //    pmlist = PrivateMessages.GetPrivateMessageListForIndex(userid,5,1,1);

			if (userid != -1)
			{
				userinfo = Users.GetShortUserInfo(userid);
                if (userinfo == null)
                {
                    userid = -1;
                    ForumUtils.ClearUserCookie("dnt");
                }
                else
                {
					newpmcount = userinfo.Newpm == 0 ? 0 : newpmcount;
				    lastvisit = userinfo.Lastvisit.ToString();
                    showpmhint = Convert.ToInt32(userinfo.Newsletter) > 4;
                }
			}

			navhomemenu = Caches.GetForumListMenuDivCache(usergroupid, userid, config.Extname);

			forumlist = Forums.GetForumIndexCollection(config.Hideprivate, usergroupid, config.Moddisplay, out totaltopic, out totalpost, out todayposts);
			forumlinkcount = forumlinklist.Rows.Count;

			//个人空间控制
            if (config.Enablespace == 1)
                GetSpacePerm();

			// 获得统计信息
			totalusers = TypeConverter.StrToInt(Statistics.GetStatisticsRowItem("totalusers"));
			lastusername = Statistics.GetStatisticsRowItem("lastusername").Trim();
            lastuserid = TypeConverter.StrToInt(Statistics.GetStatisticsRowItem("lastuserid"));
            yesterdayposts = TypeConverter.StrToInt(Statistics.GetStatisticsRowItem("yesterdayposts"));
            highestposts = TypeConverter.StrToInt(Statistics.GetStatisticsRowItem("highestposts"));
            highestpostsdate = Statistics.GetStatisticsRowItem("highestpostsdate").ToString().Trim();
            if (todayposts > highestposts)
            {
                highestposts = todayposts;
                highestpostsdate = DateTime.Now.ToString("yyyy-M-d");
            }
            totalonline = onlineusercount;
			showforumonline = false;
			onlineiconlist = Caches.GetOnlineGroupIconList();
			if (totalonline < config.Maxonlinelist || DNTRequest.GetString("showonline") == "yes")
			{
				showforumonline = true;
				//获得在线用户列表和图标
                onlineuserlist = OnlineUsers.GetOnlineUserCollection(out totalonline, out totalonlineguest, out totalonlineuser, out totalonlineinvisibleuser);
			}

			if (DNTRequest.GetString("showonline") == "no")
				showforumonline = false;

			highestonlineusercount = Statistics.GetStatisticsRowItem("highestonlineusercount");
			highestonlineusertime = DateTime.Parse(Statistics.GetStatisticsRowItem("highestonlineusertime")).ToString("yyyy-MM-dd HH:mm");
			// 得到公告
			announcementlist = Announcements.GetSimplifiedAnnouncementList(nowdatetime, "2999-01-01 00:00:00");
			announcementcount = announcementlist != null ? announcementlist.Rows.Count : 0;

            List<IndexPageForumInfo> topforum = new List<IndexPageForumInfo>();
            foreach (IndexPageForumInfo f in forumlist)
            {
                if (f.Layer == 0)
                    topforum.Add(f);
            }
        
            taglist = config.Enabletag == 1 ? ForumTags.GetCachedHotForumTags(config.Hottagcount) : new TagInfo[0];

            ///得到广告列表
            headerad = Advertisements.GetOneHeaderAd("indexad", 0);
            footerad = Advertisements.GetOneFooterAd("indexad", 0);
            inforumad = Advertisements.GetInForumAd("indexad", 0, topforum, templatepath);
			pagewordad = Advertisements.GetPageWordAd("indexad", 0);
			doublead = Advertisements.GetDoubleAd("indexad", 0);
			floatad = Advertisements.GetFloatAd("indexad", 0);
            mediaad = Advertisements.GetMediaAd(templatepath, "indexad", 0);

            if (userid > 0)
            {
                if (oluserinfo.Newpms < 0)
                    Users.UpdateUserNewPMCount(userid, olid);
                if (oluserinfo.Newnotices < 0)
                    OnlineUsers.UpdateNewNotices(olid, -1 * oluserinfo.Newnotices);
            }
		}
示例#14
0
        /// <summary>
        /// 获得百度论坛收录协议xml
        /// </summary>
        /// <param name="ttl">TTL数值</param>
        /// <returns></returns>
        public static string GetBaiduSitemap(string sbforumlist, ShortUserInfo master)
        {
            StringBuilder sitemapBuilder = new StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n");
            IDataReader reader = DatabaseProvider.GetInstance().GetSitemapNewTopics(sbforumlist.ToString());

            sitemapBuilder.Append("<document xmlns:bbs=\"http://www.baidu.com/search/bbs_sitemap.xsd\">\r\n");
            sitemapBuilder.AppendFormat("  <webSite>{0}</webSite>\r\n", forumurl);
            sitemapBuilder.AppendFormat("  <webMaster>{0}</webMaster>\r\n", master != null ? master.Email : "");
            sitemapBuilder.AppendFormat("  <updatePeri>{0}</updatePeri>\r\n", config.Sitemapttl);
            sitemapBuilder.AppendFormat("  <updatetime>{0}</updatetime>\r\n", DateTime.Now.ToString("r"));
            sitemapBuilder.AppendFormat("  <version>Discuz!NT {0}</version>\r\n", Utils.GetAssemblyVersion());

            if (reader != null)
            {
                while (reader.Read())
                {
                    sitemapBuilder.Append("    <item>\r\n");
                    sitemapBuilder.AppendFormat("      <link>{0}", Utils.HtmlEncode(forumurl));
                    if (config.Aspxrewrite == 1)
                        sitemapBuilder.AppendFormat("showtopic-{0}{1}", reader["tid"], config.Extname);
                    else
                        sitemapBuilder.AppendFormat("showtopic-{0}", reader["tid"]);

                    sitemapBuilder.Append("      </link>\r\n");
                    sitemapBuilder.AppendFormat("      <title>{0}</title>\r\n", Utils.HtmlEncode(reader["title"].ToString().Trim()));
                    sitemapBuilder.AppendFormat("      <pubDate>{0}</pubDate>\r\n", Utils.HtmlEncode(reader["postdatetime"].ToString().Trim()));
                    sitemapBuilder.AppendFormat("      <bbs:lastDate>{0}</bbs:lastDate>\r\n", reader["lastpost"]);
                    sitemapBuilder.AppendFormat("      <bbs:reply>{0}</bbs:reply>\r\n", reader["replies"]);
                    sitemapBuilder.AppendFormat("      <bbs:hit>{0}</bbs:hit>\r\n", reader["views"]);
                    sitemapBuilder.AppendFormat("      <bbs:boardid>{0}</bbs:boardid>\r\n", reader["fid"]);
                    sitemapBuilder.AppendFormat("      <bbs:pick>{0}</bbs:pick>\r\n", reader["digest"]);
                    sitemapBuilder.Append("    </item>\r\n");
                }
                reader.Close();
                sitemapBuilder.Append("</document>");
            }
            else
            {
                sitemapBuilder.Length = 0;
                sitemapBuilder.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n");
                sitemapBuilder.Append("<document>Error</document>\r\n");
            }
            return sitemapBuilder.ToString();
        }
示例#15
0
        protected override void ShowPage()
        {
            #region 临时帐号发帖
            int realuserid = -1;
            bool tempaccountspost = false;
            string tempusername = DNTRequest.GetString("tempusername");
            if (!Utils.StrIsNullOrEmpty(tempusername) && tempusername != username)
            {
                realuserid = Users.CheckTempUserInfo(tempusername, DNTRequest.GetString("temppassword"), DNTRequest.GetInt("question", 0), DNTRequest.GetString("answer"));
                if (realuserid == -1)
                {
                    AddErrLine("临时帐号登录失败,无法继续发帖。");
                    return;
                }
                else
                {
                    userid = realuserid;
                    username = tempusername;
                    tempaccountspost = true;
                }
            }
            #endregion

            if (userid > 0)
            {
                userinfo = Users.GetShortUserInfo(userid);
                if (userinfo != null)
                {
                    usergroupinfo = UserGroups.GetUserGroupInfo(userinfo.Groupid);
                    usergroupid = usergroupinfo.Groupid;
                    useradminid = userinfo.Adminid;
                }
            }

            #region 判断是否是灌水
            AdminGroupInfo admininfo = AdminGroups.GetAdminGroupInfo(usergroupid);
            if (admininfo != null)
                disablepost = admininfo.Disablepostctrl;

            if (!UserAuthority.CheckPostTimeSpan(usergroupinfo, admininfo, oluserinfo, ref msg))
            {
                AddErrLine(msg); return;
            }
            #endregion

            //获取主题帖信息 
            PostInfo postinfo = GetPostAndTopic(admininfo);
            if (IsErr())
                return;

            forum = Forums.GetForumInfo(forumid);
            smileyoff = 1 - forum.Allowsmilies;
            bbcodeoff = (forum.Allowbbcode == 1 && usergroupinfo.Allowcusbbcode == 1) ? 0 : 1;
            allowimg = forum.Allowimgcode;
            needaudit = UserAuthority.NeedAudit(forum, useradminid, userid);
            #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);

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

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

            #region 访问和发帖权限校验
            if (!UserAuthority.VisitAuthority(forum, usergroupinfo, userid, ref msg))
            {
                AddErrLine(msg);
                needlogin = true;
                return;
            }

            if (!UserAuthority.PostReply(forum, userid, usergroupinfo, topic))
            {
                AddErrLine(topic.Closed == 1 ? "主题已关闭无法回复" : "您没有发表回复的权限");
                needlogin = (topic.Closed == 1 ? false : true);
                return;
            }

            if (!UserAuthority.CheckPostTimeSpan(usergroupinfo, admininfo, oluserinfo, ref msg))
            {
                AddErrLine(msg);
                return;
            }
            #endregion

            // 如果是受灌水限制用户, 则判断是否是灌水
            if (admininfo != null)
                disablepost = admininfo.Disablepostctrl;

            if (forum.Templateid > 0)
                templatepath = Templates.GetTemplateItem(forum.Templateid).Directory;


            //判断是否为回复可见帖, hide=0为非回复可见(正常), hide > 0为回复可见, hide=-1为回复可见但当前用户已回复
            lastpostlist = GetLastPostDataTable();

            AddLinkCss(BaseConfigs.GetForumPath + "templates/" + templatepath + "/editor.css", "css");

            //如果是提交...
            if (ispost)
            {
                string backlink = (DNTRequest.GetInt("topicid", -1) > 0 ?
                        string.Format("postreply.aspx?topicid={0}&restore=1&forumpage=" + forumpageid, topicid) :
                        string.Format("postreply.aspx?postid={0}&restore=1&forumpage=" + forumpageid, postid));

                if (!DNTRequest.GetString("quote").Equals(""))
                    backlink = string.Format("{0}&quote={1}", backlink, DNTRequest.GetString("quote"));

                SetBackLink(backlink);

                #region 验证提交信息
                //常规项验证
                NormalValidate(admininfo, postmessage, Users.GetShortUserInfo(userid));

                if (IsErr())
                    return;
                #endregion

                //是否有上传附件的权限
                canpostattach = UserAuthority.PostAttachAuthority(forum, usergroupinfo, userid, ref msg);

                // 产生新帖子
                postinfo = CreatePostInfo(postmessage);
                postid = postinfo.Pid;
                if (IsErr())
                    return;

                #region 当回复成功后,发送通知
                if (postinfo.Pid > 0 && DNTRequest.GetString("postreplynotice") == "on")
                {
                    //postinfo.Pid = postid;
                    Notices.SendPostReplyNotice(postinfo, topic, postinfo.Posterid);
                }
                #endregion

                //更新主题相关信息
                UpdateTopicInfo(postmessage);

                #region 处理附件
                StringBuilder sb = new StringBuilder();
                AttachmentInfo[] attachmentinfo = ForumUtils.SaveRequestFiles(forumid, config.Maxattachments, usergroupinfo.Maxsizeperday, usergroupinfo.Maxattachsize, MaxTodaySize, attachextensions, forum.Disablewatermark == 1 ? 0 : config.Watermarkstatus, config, "postfile");
                Attachments.UpdateAttachment(attachmentinfo, topic.Tid, postinfo.Pid, postinfo, ref sb, userid, config, usergroupinfo);

                //加入相册
                if (!tempaccountspost && config.Enablealbum == 1 && apb != null)
                    sb.Append(apb.CreateAttachment(attachmentinfo, usergroupid, userid, username));
                #endregion

                OnlineUsers.UpdateAction(olid, UserAction.PostReply.ActionID, forumid, forum.Name, topicid, topictitle, config.Onlinetimeout);
                // 更新在线表中的用户最后发帖时间
                OnlineUsers.UpdatePostTime(olid);

                #region 设置提示信息和跳转链接
                //辩论地址
                if (topic.Special == 4)
                    SetUrl(Urls.ShowDebateAspxRewrite(topicid));
                else
                    SetUrl("showtopic.aspx?page=end&forumpage=" + forumpageid + "&topicid=" + topicid + "#" + postid);

                if (DNTRequest.GetFormString("continuereply") == "on")
                    SetUrl("postreply.aspx?topicid=" + topicid.ToString().Trim() + "&forumpage=" + forumpageid + "&continuereply=yes");

                if (sb.Length > 0)
                {
                    StringBuilder builder = new StringBuilder();
                    UpdateUserCredits(Forums.GetValues(forum.Replycredits));
                    SetMetaRefresh(5);
                    SetShowBackLink(true);
                    if (infloat == 1)
                    {
                        AddErrLine(sb.ToString());
                        return;
                    }
                    else
                    {
                        builder.Insert(0, "<table cellspacing=\"0\" cellpadding=\"4\" border=\"0\"><tr><td colspan=2 align=\"left\"><span class=\"bold\"><nobr>发表主题成功,但以下附件上传失败:</nobr></span><br /></td></tr>");
                        builder.Append("</table>");
                        AddMsgLine(builder.ToString());
                    }
                }
                else
                {
                    SetMetaRefresh();
                    SetShowBackLink(false);
                    //上面已经进行用户组判断
                    if (postinfo.Invisible == 1)
                        AddMsgLine(string.Format("发表回复成功, 但需要经过审核才可以显示. {0}<br /><br />(<a href=\"" + base.ShowForumAspxRewrite(forumid, 0) + "\">点击这里返回 {1}</a>)", (DNTRequest.GetFormString("continuereply") == "on" ? "继续回复" : "返回该主题"), forum.Name));
                    else
                    {
                        UpdateUserCredits(Forums.GetValues(forum.Replycredits));
                        AddMsgLine(string.Format("发表回复成功, {0}<br />(<a href=\"" + base.ShowForumAspxRewrite(forumid, 0) + "\">点击这里返回 {1}</a>)<br />", (DNTRequest.GetFormString("continuereply") == "on" ? "继续回复" : "返回该主题"), forum.Name));
                    }
                }
                #endregion

                // 删除主题游客缓存
                if (topic.Replies < (config.Ppp + 10))
                    ForumUtils.DeleteTopicCacheFile(topicid);

                //发送邮件通知
                if (DNTRequest.GetString("emailnotify") == "on" && topic.Posterid != -1)
                    SendNotifyEmail(Users.GetShortUserInfo(topic.Posterid).Email.Trim(), postinfo, "http://" + DNTRequest.GetCurrentFullHost() + "/showtopic.aspx?page=end&topicid=" + topicid + "#" + postid);
            }
        }
示例#16
0
        protected override void ShowPage()
        {
            pagetitle = "用户管理";

            if (userid == -1)
            {
                AddErrLine("请先登录");
                return;
            }
            if (ForumUtils.IsCrossSitePost(DNTRequest.GetUrlReferrer(), DNTRequest.GetHost()) || Utils.StrIsNullOrEmpty(action))
            {
                AddErrLine("非法提交");
                return;
            }
            if (action == "")
            {
                AddErrLine("操作类型参数为空");
                return;
            }
            // 如果拥有管理组身份
            admininfo = AdminGroups.GetAdminGroupInfo(usergroupid);
            // 如果所属管理组不存在
            if (admininfo == null)
            {
                AddErrLine("你没有管理权限");
                return;
            }
            if (operateduid == -1)
            {
                AddErrLine("没有选择要操作的用户");
                return;
            }
            operateduser = Users.GetShortUserInfo(operateduid);
            if (operateduser == null)
            {
                AddErrLine("选择的用户不存在");
                return;
            }
            if (operateduser.Adminid > 0)
            {
                AddErrLine("无法对拥有管理权限的用户进行操作, 请管理员登录后台进行操作");
                return;
            }
            operatedusername = operateduser.Username;
            

            if (!ispost)
            {
                Utils.WriteCookie("reurl", DNTRequest.GetUrlReferrer());
                if (action == "banuser")
                {
                    operationtitle = "禁止用户";
                    switch (operateduser.Groupid)
                    {
                        case 4:
                            bantype = 1;
                            groupexpiry = "(" + Utils.FormatDate(operateduser.Groupexpiry) + ")";
                            break;
                        case 5: 
                            bantype = 2;
                            groupexpiry = "(" + Utils.FormatDate(operateduser.Groupexpiry) + ")";
                            break;
                        case 6: 
                            bantype = 3;
                            groupexpiry = "(" + Utils.FormatDate(operateduser.Groupexpiry) + ")";
                            break;
                        default:
                            bantype = 0; 
                            break;
                    }
                    if (admininfo.Allowbanuser != 1)
                    {
                        AddErrLine("您没有禁止用户的权限");
                        return;
                    }
                }
            }
            else if (action == "banuser")
            {
                operationtitle = "禁止用户";
                DoBanUserOperation();
            }
        }
示例#17
0
文件: Auth.cs 项目: khaliyo/DiscuzNT
        /// <summary>
        /// 验证用户 // Edit By Cyrano
        /// </summary>
        /// <returns></returns>
        public string Validate()
        {
            string returnStr = string.Empty;

            if (Signature != GetParam("sig").ToString())
            {
                ErrorCode = (int)ErrorType.API_EC_SIGNATURE;
                return returnStr;
            }

            if (CallId <= LastCallId)
            {
                ErrorCode = (int)ErrorType.API_EC_CALLID;
                return returnStr;
            }

            if (!CheckRequiredParams("user_name,password"))
            {
                ErrorCode = (int)ErrorType.API_EC_PARAM;
                return returnStr;
            }

            if (this.App.ApplicationType == (int)ApplicationType.DESKTOP)//如果是桌面程序则不允许此方法
            {
                if (Uid < 1 || Discuz.Forum.UserGroups.GetUserGroupInfo(Discuz.Forum.Users.GetShortUserInfo(Uid).Groupid).Radminid != 1)
                {
                    ErrorCode = (int)ErrorType.API_EC_PERMISSION_DENIED;
                    return "";
                }
            }
            else if (Uid > 0)//已经登录的用户不能再验证
            {
                ErrorCode = (int)ErrorType.API_EC_USER_ONLINE;
                return returnStr;
            }

            string username = GetParam("user_name").ToString();
            string password = GetParam("password").ToString();

            bool isMD5Passwd = GetParam("password_format") != null && GetParam("password_format").ToString() == "md5" ? true : false;

            //用户名不符合规范
            //if (!CheckUsername(username))
            //{
            //    ErrorCode = (int)ErrorType.API_EC_USERNAME_ILLEGAL;
            //    return returnStr;
            //}

            if (Discuz.Forum.Users.GetUserId(username) == 0)//如果用户名符合注册规则, 则判断是否已存在
            {
                ErrorCode = (int)ErrorType.API_EC_USER_NONEXIST;
                return returnStr;
            }

            if (!isMD5Passwd && password.Length < 6)
            {
                ErrorCode = (int)ErrorType.API_EC_PARAM;
                return returnStr;
            }

            ShortUserInfo userInfo = new ShortUserInfo();
            var postpassword =  password;
            var postusername = username;
            int uid = -1;

            uid = Discuz.Forum.Users.CheckPassword(postusername, postpassword, !isMD5Passwd);
            userInfo = uid > 0 ? Discuz.Forum.Users.GetShortUserInfo(uid) : null;

            if (userInfo != null)
            {
                #region 当前用户所在用户组为"禁止访问"或"等待激活"时

                if (userInfo.Groupid == 5 || userInfo.Groupid == 8)// 5-禁止访问, 8-等待激活
                {
                    ErrorCode = (int)ErrorType.API_EC_USERNAME_ILLEGAL;
                    return returnStr;
                }

                #endregion
            }
            else
            {
                int errcount = LoginLogs.UpdateLoginLog(DNTRequest.GetIP(), true);

                if (errcount > 5)
                {
                    //AddErrLine("您已经输入密码5次错误, 请15分钟后再试");
                }
                else
                {
                    //AddErrLine(string.Format("密码或安全提问第{0}次错误, 您最多有5次机会重试", errcount));
                }
            }

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

            if (Format == FormatType.JSON)
                return string.Format("\"{0}\"", userInfo.Uid);

            ValidateResponse vr = new ValidateResponse();
            vr.Uid = userInfo.Uid;

            return SerializationHelper.Serialize(vr);
        }
示例#18
0
        /// <summary>
        /// 判断用户密码是否正确
        /// </summary>
        /// <param name="username">用户名</param>
        /// <param name="password">密码</param>
        /// <param name="originalpassword">是否为未MD5密码</param>
        /// <returns>如果正确则返回uid</returns>
        public static ShortUserInfo CheckPassword(string username, string password, bool originalpassword)
        {
            IDataReader reader = DatabaseProvider.GetInstance().CheckPassword(username, password, originalpassword);
            ShortUserInfo userInfo = null;

            if (reader.Read())
            {
                userInfo = new ShortUserInfo();
                userInfo.Uid = Utils.StrToInt(reader[0].ToString(), -1);
                userInfo.Groupid = Utils.StrToInt(reader[1].ToString(), -1);
                userInfo.Adminid  = Utils.StrToInt(reader[2].ToString(), -1);
            }
            reader.Close();
            return userInfo;
        }
示例#19
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
 }
示例#20
0
        protected override void ShowPage()
        {
            #region 临时帐号发帖
            //int realuserid = -1;
            //bool tempaccountspost = false;
            //string tempusername = DNTRequest.GetString("tempusername");
            //if (!Utils.StrIsNullOrEmpty(tempusername) && tempusername != username)
            //{
            //    realuserid = Users.CheckTempUserInfo(tempusername, DNTRequest.GetString("temppassword"), DNTRequest.GetInt("question", 0), DNTRequest.GetString("answer"));
            //    if (realuserid == -1)
            //    {
            //        AddErrLine("临时帐号登录失败,无法继续发帖。");
            //        return;
            //    }
            //    else
            //    {
            //        userid = realuserid;
            //        username = tempusername;
            //        tempaccountspost = true;
            //    }
            //}
            #endregion

            if (userid > 0)
                userinfo = Users.GetShortUserInfo(userid);

            #region 判断是否是灌水
            AdminGroupInfo admininfo = AdminGroups.GetAdminGroupInfo(usergroupid);
            if (admininfo != null)
                disablepost = admininfo.Disablepostctrl;

            if (!UserAuthority.CheckPostTimeSpan(usergroupinfo, admininfo, oluserinfo, userinfo, ref msg))
            {
                AddErrLine(msg); return;
            }
            #endregion

            //获取主题帖信息
            PostInfo postinfo = GetPostAndTopic(admininfo);
            if (IsErr())
                return;

            forum = Forums.GetForumInfo(forumid);
            smileyoff = 1 - forum.Allowsmilies;
            bbcodeoff = (forum.Allowbbcode == 1 && usergroupinfo.Allowcusbbcode == 1) ? 0 : 1;
            allowimg = forum.Allowimgcode;
            needaudit = UserAuthority.NeedAudit(forum, useradminid, topic, userid, disablepost, usergroupinfo);
            #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);

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

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

            #region 访问和发帖权限校验
            if (!UserAuthority.VisitAuthority(forum, usergroupinfo, userid, ref msg))
            {
                AddErrLine(msg);
                needlogin = true;
                return;
            }
            if (!UserAuthority.PostReply(forum, userid, usergroupinfo, topic))
            {
                AddErrLine(topic.Closed == 1 ? "主题已关闭无法回复" : "您没有发表回复的权限");
                needlogin = (topic.Closed == 1 ? false : true);
                return;
            }

            if (!UserAuthority.CheckPostTimeSpan(usergroupinfo, admininfo, oluserinfo, userinfo, ref msg))
            {
                AddErrLine(msg);
                return;
            }
            #endregion

            // 如果是受灌水限制用户, 则判断是否是灌水
            if (admininfo != null)
                disablepost = admininfo.Disablepostctrl;

            if (forum.Templateid > 0)
                templatepath = Templates.GetTemplateItem(forum.Templateid).Directory;

            AddLinkCss(BaseConfigs.GetForumPath + "templates/" + templatepath + "/editor.css", "css");
            //如果是提交...
            if (ispost)
            {
                string backlink = (DNTRequest.GetInt("topicid", -1) > 0 ?
                        string.Format("postreply.aspx?topicid={0}&restore=1&forumpage=" + forumpageid, topicid) :
                        string.Format("postreply.aspx?postid={0}&restore=1&forumpage=" + forumpageid, postid));

                if (!DNTRequest.GetString("quote").Equals(""))
                    backlink = string.Format("{0}&quote={1}", backlink, DNTRequest.GetString("quote"));

                SetBackLink(backlink);

                #region 验证提交信息
                //常规项验证
                NormalValidate(admininfo, postmessage, userinfo);

                if (IsErr())
                    return;
                #endregion

                //是否有上传附件的权限
                canpostattach = UserAuthority.PostAttachAuthority(forum, usergroupinfo, userid, ref msg);

                // 产生新帖子
                if (!string.IsNullOrEmpty(DNTRequest.GetFormString("toreplay_user").Trim()))
                    postmessage = DNTRequest.GetFormString("toreplay_user").Trim() + "\n\n" + postmessage;

                postinfo = CreatePostInfo(postmessage);

                //获取被回复帖子的作者uid
                int replyUserid = postid > 0 ? Posts.GetPostInfo(topicid, postid).Posterid : postinfo.Posterid;
                postid = postinfo.Pid;
                if (IsErr())
                    return;

                #region 当回复成功后,发送通知
                if (postinfo.Pid > 0 && DNTRequest.GetString("postreplynotice") == "on")
                    Notices.SendPostReplyNotice(postinfo, topic, replyUserid);
                #endregion

                //向第三方应用同步数据
                Sync.Reply(postid.ToString(), topic.Tid.ToString(), topic.Title, postinfo.Poster, postinfo.Posterid.ToString(), topic.Fid.ToString(), "");

                //更新主题相关信息
                //UpdateTopicInfo(postmessage);

                #region 处理附件
                //处理附件
                StringBuilder sb = new StringBuilder();
                AttachmentInfo[] attachmentinfo = null;
                string attachId = DNTRequest.GetFormString("attachid");
                if (!string.IsNullOrEmpty(attachId))
                {
                    attachmentinfo = Attachments.GetNoUsedAttachmentArray(userid, attachId);
                    Attachments.UpdateAttachment(attachmentinfo, topic.Tid, postinfo.Pid, postinfo, ref sb, userid, config, usergroupinfo);
                }

                //加入相册
                if (config.Enablealbum == 1 && apb != null)
                    sb.Append(apb.CreateAttachment(attachmentinfo, usergroupid, userid, username));
                #endregion

                OnlineUsers.UpdateAction(olid, UserAction.PostReply.ActionID, forumid, forum.Name, topicid, topictitle);

                #region 设置提示信息和跳转链接
                //辩论地址
                if (topic.Special == 4)
                    SetUrl(Urls.ShowDebateAspxRewrite(topicid));
                else if (infloat == 0)//此处加是否弹窗提交判断是因为在IE6下弹窗提交会造成gettopicinfo, getpostlist(位于showtopic页面)被提交了两次
                    SetUrl(string.Format("showtopic.aspx?forumpage={0}&topicid={1}&page=end&jump=pid#{2}", forumpageid, topicid, postid));

                if (DNTRequest.GetFormString("continuereply") == "on")
                    SetUrl("postreply.aspx?topicid=" + topicid + "&forumpage=" + forumpageid + "&continuereply=yes");

                if (sb.Length > 0)
                {
                    UpdateUserCredits(Forums.GetValues(forum.Replycredits));
                    SetMetaRefresh(5);
                    SetShowBackLink(true);
                    if (infloat == 1)
                    {
                        AddErrLine(sb.ToString());
                        return;
                    }
                    else
                        AddMsgLine("<table cellspacing=\"0\" cellpadding=\"4\" border=\"0\"><tr><td colspan=2 align=\"left\"><span class=\"bold\"><nobr>发表回复成功,但图片/附件上传出现问题:</nobr></span><br /></td></tr></table>");
                }
                else
                {
                    SetMetaRefresh();
                    SetShowBackLink(false);
                    //上面已经进行用户组判断
                    if (postinfo.Invisible == 1)
                        AddMsgLine(string.Format("发表回复成功, 但需要经过审核才可以显示. {0}<br /><br />(<a href=\"" + base.ShowForumAspxRewrite(forumid, 0) + "\">点击这里返回 {1}</a>)", (DNTRequest.GetFormString("continuereply") == "on" ? "继续回复" : "返回该主题"), forum.Name));
                    else
                    {
                        UpdateUserCredits(Forums.GetValues(forum.Replycredits));
                        MsgForward("postreply_succeed");
                        AddMsgLine(string.Format("发表回复成功, {0}<br />(<a href=\"" + base.ShowForumAspxRewrite(forumid, 0) + "\">点击这里返回 {1}</a>)<br />", (DNTRequest.GetFormString("continuereply") == "on" ? "继续回复" : "返回该主题"), forum.Name));
                    }
                }
                #endregion

                // 删除主题游客缓存
                if (topic.Replies < (config.Ppp + 10))
                    ForumUtils.DeleteTopicCacheFile(topicid);

                //发送邮件通知
                if (DNTRequest.GetString("emailnotify") == "on" && topic.Posterid != -1 && topic.Posterid != userid)
                    SendNotifyEmail(Users.GetShortUserInfo(topic.Posterid).Email.Trim(), postinfo, Utils.GetRootUrl(BaseConfigs.GetForumPath) + string.Format("showtopic.aspx?topicid={0}&page=end&jump=pid#{1}", topicid, postid));
            }
        }
示例#21
0
        /// <summary>
        /// 检测密码
        /// </summary>
        /// <param name="uid">用户id</param>
        /// <param name="password">密码</param>
        /// <param name="originalpassword">是否非MD5密码</param>
        /// <returns>如果用户密码正确则返回uid, 否则返回-1</returns>
        public static ShortUserInfo CheckPassword(int uid, string password, bool originalpassword)
        {
            ShortUserInfo userInfo = null;
            if (appDBCache)
            {
                userInfo = IUserService.CheckPassword(uid, password, originalpassword);
                if (userInfo != null)
                    return userInfo;
            }

            IDataReader reader = DatabaseProvider.GetInstance().CheckPassword(uid, password, originalpassword);

            if (reader.Read())
            {
                userInfo = new ShortUserInfo();
                userInfo.Uid = Utils.StrToInt(reader[0].ToString(), -1);
                userInfo.Groupid = Utils.StrToInt(reader[1].ToString(), -1);
                userInfo.Adminid = Utils.StrToInt(reader[2].ToString(), -1);
            }
            reader.Close();

            if (appDBCache && userInfo != null && userInfo.Uid > 0)
                GetUserInfo(userInfo.Uid);

            return userInfo;
        }
示例#22
0
        /// <summary>
        /// 常规项验证
        /// </summary>
        /// <param name="admininfo"></param>
        /// <param name="postmessage"></param>
        private void NormalValidate(AdminGroupInfo admininfo, string postmessage, ShortUserInfo user)
        {
            if (ForumUtils.IsCrossSitePost())
            {
                AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。");
                return;
            }
            else if (posttitle.Length > 60)
                AddErrLine("标题最大长度为60个字符,当前为 " + posttitle.Length + " 个字符");

            if (Utils.StrIsNullOrEmpty(postmessage.Replace(" ", "")))
                AddErrLine("内容不能为空");

            if (admininfo != null && admininfo.Disablepostctrl != 1)
            {
                if (postmessage.Length < config.Minpostsize)
                    AddErrLine("您发表的内容过少, 系统设置要求帖子内容不得少于 " + config.Minpostsize + " 字多于 " + config.Maxpostsize + " 字");
                else if (postmessage.Length > config.Maxpostsize)
                    AddErrLine("您发表的内容过多, 系统设置要求帖子内容不得少于 " + config.Minpostsize + " 字多于 " + config.Maxpostsize + " 字");
            }

            if (topic.Special == 4 && DNTRequest.GetInt("debateopinion", 0) == 0)
                AddErrLine("请选择您在辩论中的观点");

            if (topic.Special == 4)
            {
                DebateInfo debateexpand = Debates.GetDebateTopic(topic.Tid);
                if (debateexpand.Terminaltime < DateTime.Now)
                    AddErrLine("此辩论主题已经到期");
            }

            //新用户广告强力屏蔽检查
            if ((config.Disablepostad == 1) && useradminid < 1)  //如果开启新用户广告强力屏蔽检查或是游客
            {
                if ((config.Disablepostadpostcount != 0 && user.Posts <= config.Disablepostadpostcount) ||
                    (config.Disablepostadregminute != 0 && DateTime.Now.AddMinutes(-config.Disablepostadregminute) <= Convert.ToDateTime(user.Joindate)))
                {
                    foreach (string regular in config.Disablepostadregular.Replace("\r", "").Split('\n'))
                    {
                        if (Posts.IsAD(regular, posttitle, postmessage))
                        {
                            AddErrLine("发帖失败,内容中有不符合新用户强力广告屏蔽规则的字符,请检查标题和内容,如有疑问请与管理员联系");
                        }
                    }
                }
            }
        }
示例#23
0
        protected override void ShowPage()
        {
            pagetitle = "邀请注册";
            if (!Utils.InArray(config.Regstatus.ToString(), "2,3"))
            {
                AddErrLine("当前站点没有开启邀请功能!");
                return;
            }
            if (userid > 0)
            {
                if (action == "floatwinemail")
                {
                    return;
                }
                //提取预览头像
                avatarSmall = Avatars.GetAvatarUrl(userid, AvatarSize.Small);
                avatarMedium = Avatars.GetAvatarUrl(userid, AvatarSize.Medium);
                avatarLarge = Avatars.GetAvatarUrl(userid, AvatarSize.Large);

                userinfo = Users.GetUserInfo(userid);
                if (config.Regstatus == 2)
                {
                    invitecodeinfo = Invitation.GetInviteCodeByUid(userid);
                    if (invitecodeinfo != null)
                    {
                        inviteurl = GetUserInviteUrl(invitecodeinfo.Code, false);
                        userscore = GetUserInviteScore(invitecodeinfo.SuccessCount);
                        usersaid = string.Format("邀请附言:<div id=\"usersaidinemail\">{0}</div>", usersaid);
                        if (!ispost)
                            CreateEmailPreview();
                    }
                }
                else
                {
                    invitecodecount = Invitation.GetUserInviteCodeCount(userid);
                    invitecodelist = Invitation.GetUserInviteCodeList(userid, pageindex);
                    invitecodeprice = GetInviteCodePrice();
                    pagecount = ((invitecodecount - 1) / 10) + 1;
                    pagenumber = Utils.GetPageNumbers(pageindex, pagecount, "invite.aspx", 8);
                }
                if (ispost)
                {
                    switch (action)
                    {
                        case "createcode":
                            CreateInviteCode();//创建开放式邀请码
                            break;
                        case "convertcode":
                            ConvertInviteCode();//将开放邀请码兑换为用户积分
                            break;
                        case "buycode":
                            BuyInviteCode();//购买封闭式邀请码
                            break;
                        case "floatwinemailsend":
                            SendEmail();//弹窗邮件发送邀请码
                            break;
                        default:
                            return;
                    }
                }
            }
            if (userid == -1 && invitecode != "")
            {
                invitecodeinfo = Invitation.GetInviteCodeByCode(invitecode);
            }

        }
示例#24
0
文件: Stats.cs 项目: khaliyo/DiscuzNT
        /// <summary>
        /// 获得用户列表
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static ShortUserInfo[] GetUserArray(string type, string postTableId)
        {
            IDataReader reader = DatabaseProvider.GetInstance().GetUsersRank(20, postTableId, type);
            if (reader == null)
                return new ShortUserInfo[0];

            List<ShortUserInfo> list = new List<ShortUserInfo>();

            while (reader.Read())
            {
                ShortUserInfo u = new ShortUserInfo();
                u.Username = reader["username"].ToString();
                u.Uid = Utils.StrToInt(reader["uid"], 0);

                switch (type)
                {
                    case "digestposts":
                        u.Digestposts = TypeConverter.ObjectToInt(reader["digestposts"]);
                        break;
                    case "credits":
                        u.Credits = TypeConverter.ObjectToInt(reader["credits"]);
                        break;
                    case "extcredits1":
                        u.Extcredits1 = TypeConverter.ObjectToFloat(reader["extcredits1"]);
                        break;
                    case "extcredits2":
                        u.Extcredits2 = TypeConverter.ObjectToFloat(reader["extcredits2"]);
                        break;
                    case "extcredits3":
                        u.Extcredits3 = TypeConverter.ObjectToFloat(reader["extcredits3"]);
                        break;
                    case "extcredits4":
                        u.Extcredits4 = TypeConverter.ObjectToFloat(reader["extcredits4"]);
                        break;
                    case "extcredits5":
                        u.Extcredits5 = TypeConverter.ObjectToFloat(reader["extcredits5"]);
                        break;
                    case "extcredits6":
                        u.Extcredits6 = TypeConverter.ObjectToFloat(reader["extcredits6"]);
                        break;
                    case "extcredits7":
                        u.Extcredits7 = TypeConverter.ObjectToFloat(reader["extcredits7"]);
                        break;
                    case "extcredits8":
                        u.Extcredits8 = TypeConverter.ObjectToFloat(reader["extcredits8"]);
                        break;
                    case "oltime":
                        u.Oltime = TypeConverter.ObjectToInt(reader["oltime"]);
                        break;
                    default:
                        u.Posts = TypeConverter.ObjectToInt(reader["posts"]);
                        break;
                }

                u.Password = u.Secques = u.Nickname = u.Bday = string.Empty;

                list.Add(u);
            }
            reader.Close();

            return list.ToArray();
        }
示例#25
0
        public static bool CheckPostTimeSpan(UserGroupInfo userGroupInfo, AdminGroupInfo admininfo, OnlineUserInfo olUserInfo, ShortUserInfo shortUserInfo, ref string msg)
        {
            // 如果当前用户非管理员并且论坛设定了禁止发帖时间段,当前时间如果在其中的一个时间段内,不允许用户发帖
            if (olUserInfo.Adminid != 1 && userGroupInfo.Disableperiodctrl != 1)
            {
                string visittime = "";
                if (Scoresets.BetweenTime(GeneralConfigs.GetConfig().Postbanperiods, out visittime))
                {
                    msg = "在此时间段( " + visittime + " )内用户不可以发帖";
                    return false;
                }
            }

            if (admininfo == null || admininfo.Disablepostctrl != 1)
            {
                int Interval = Utils.StrDateDiffSeconds(olUserInfo.Lastposttime, GeneralConfigs.GetConfig().Postinterval);
                if (Interval < 0)
                {
                    msg = "系统规定发帖间隔为" + GeneralConfigs.GetConfig().Postinterval.ToString() + "秒, 您还需要等待 " + (Interval * -1).ToString() + " 秒";
                    return false;
                }
                else if (olUserInfo.Userid != -1)
                {
                    //ShortUserInfo shortUserInfo = Discuz.Data.Users.GetShortUserInfo(olUserInfo.Userid);
                    string joindate = (shortUserInfo != null) ? shortUserInfo.Joindate : "";
                    if (joindate == "")
                    {
                        msg = "您的用户资料出现错误";
                        return false;
                    }
                    Interval = Utils.StrDateDiffMinutes(joindate, GeneralConfigs.GetConfig().Newbiespan);
                    if (Interval < 0)
                    {
                        msg = "系统规定新注册用户必须要在" + GeneralConfigs.GetConfig().Newbiespan.ToString() + "分钟后才可以发帖, 您还需要等待 " + (Interval * -1).ToString() + " 分钟";
                        return false;
                    }
                }
            }
            return true;
        }
示例#26
0
        /// <summary>
        /// 根据用户信息重新计算用户积分
        /// </summary>
        /// <param name="shortUserInfo">用户信息</param>
        /// <returns>用户积分</returns>
        public static int GetUserCreditsByUserInfo(ShortUserInfo shortUserInfo)
        {
            string ArithmeticStr = Scoresets.GetScoreCalFormula();

            if (Utils.StrIsNullOrEmpty(ArithmeticStr))
                return 0;

            ArithmeticStr = ArithmeticStr.Replace("digestposts", shortUserInfo.Digestposts.ToString());
            ArithmeticStr = ArithmeticStr.Replace("posts", shortUserInfo.Posts.ToString());
            ArithmeticStr = ArithmeticStr.Replace("oltime", shortUserInfo.Oltime.ToString());
            ArithmeticStr = ArithmeticStr.Replace("pageviews", shortUserInfo.Pageviews.ToString());
            ArithmeticStr = ArithmeticStr.Replace("extcredits1", shortUserInfo.Extcredits1.ToString());
            ArithmeticStr = ArithmeticStr.Replace("extcredits2", shortUserInfo.Extcredits2.ToString());
            ArithmeticStr = ArithmeticStr.Replace("extcredits3", shortUserInfo.Extcredits3.ToString());
            ArithmeticStr = ArithmeticStr.Replace("extcredits4", shortUserInfo.Extcredits4.ToString());
            ArithmeticStr = ArithmeticStr.Replace("extcredits5", shortUserInfo.Extcredits5.ToString());
            ArithmeticStr = ArithmeticStr.Replace("extcredits6", shortUserInfo.Extcredits6.ToString());
            ArithmeticStr = ArithmeticStr.Replace("extcredits7", shortUserInfo.Extcredits7.ToString());
            ArithmeticStr = ArithmeticStr.Replace("extcredits8", shortUserInfo.Extcredits8.ToString());

            object expression = Arithmetic.ComputeExpression(ArithmeticStr);
            return Utils.StrToInt(Math.Floor(Utils.StrToFloat(expression, 0)), 0);
        }
示例#27
0
        protected override void ShowPage()
        {
            if (oluserinfo.Groupid == 4)
            {
                AddErrLine("你所在的用户组,为禁止发言"); return;
            }

            #region 临时帐号发帖
            int realuserid = -1;
            bool tempaccountspost = false;
            string tempusername = DNTRequest.GetString("tempusername");
            if (!Utils.StrIsNullOrEmpty(tempusername) && tempusername != username)
            {
                realuserid = Users.CheckTempUserInfo(tempusername, DNTRequest.GetString("temppassword"), DNTRequest.GetInt("question", 0), DNTRequest.GetString("answer"));
                if (realuserid == -1)
                {
                    AddErrLine("临时帐号登录失败,无法继续发帖。"); return;
                }
                else
                {
                    userid = realuserid;
                    username = tempusername;
                    tempaccountspost = true;
                }
            }
            #endregion

            if (userid > 0)
            {
                userinfo = Users.GetShortUserInfo(userid);
                if (userinfo != null)
                {
                    usergroupinfo = UserGroups.GetUserGroupInfo(userinfo.Groupid);
                    usergroupid = usergroupinfo.Groupid;
                    useradminid = userinfo.Adminid;
                }
            }

            #region 获取并检查版块信息
            forum = Forums.GetForumInfo(forumid);
            if (forum == null || forum.Layer == 0)
            {
                allowposttopic = false;
                AddErrLine("错误的论坛ID"); return;
            }

            pagetitle = Utils.RemoveHtml(forum.Name);
            enabletag = (config.Enabletag & forum.Allowtag) == 1;

            if (forum.Applytopictype == 1)  //启用主题分类
                topictypeselectoptions = Forums.GetCurrentTopicTypesOption(forum.Fid, forum.Topictypes);

            if (forum.Password != "" && Utils.MD5(forum.Password) != ForumUtils.GetCookie("forum" + forumid + "password"))
            {
                AddErrLine("本版块被管理员设置了密码");
                SetBackLink(base.ShowForumAspxRewrite(forumid, 0)); return;
            }
            needaudit = UserAuthority.NeedAudit(forum, useradminid, userid);
            smileyoff = 1 - forum.Allowsmilies;
            bbcodeoff = (forum.Allowbbcode == 1 && usergroupinfo.Allowcusbbcode == 1) ? 0 : 1;
            allowimg = forum.Allowimgcode;
            #endregion

            #region 访问和发帖权限校验
            if (!UserAuthority.VisitAuthority(forum, usergroupinfo, userid, ref msg))
            {
                AddErrLine(msg);
                needlogin = true; return;
            }

            if (!UserAuthority.PostAuthority(forum, usergroupinfo, userid, ref msg))
            {
                AddErrLine(msg);
                needlogin = true; return;
            }
            #endregion

            #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);

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

            #region 判断是否是灌水
            AdminGroupInfo admininfo = AdminGroups.GetAdminGroupInfo(usergroupid);
            if (admininfo != null)
                disablepost = admininfo.Disablepostctrl;

            if (!UserAuthority.CheckPostTimeSpan(usergroupinfo, admininfo, oluserinfo, ref msg))
            {
                AddErrLine(msg); return;
            }
            #endregion

            #region 积分信息
            creditstrans = Scoresets.GetTopicAttachCreditsTrans();
            userextcreditsinfo = Scoresets.GetScoreSet(creditstrans);
            bonusextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetBonusCreditsTrans());
            #endregion

            #region 特殊主题权限判断
            if (forum.Allowspecialonly > 0 && Utils.StrIsNullOrEmpty(type))
            {
                AddErrLine(string.Format("当前版块 \"{0}\" 不允许发表普通主题", forum.Name)); return;
            }
            if (!UserAuthority.PostSpecialAuthority(forum, type, ref msg))
            {
                AddErrLine(msg); return;
            }
            if (!UserAuthority.PostSpecialAuthority(usergroupinfo, type, ref msg))
            {
                AddErrLine(msg);
                needlogin = true; return;
            }
            if (type == "bonus")
            {
                int creditTrans = Scoresets.GetBonusCreditsTrans();
                //当“交易积分设置”有效时(1-8的整数):
                if (creditTrans <= 0)
                {
                    //AddErrLine(string.Format("系统未设置\"交易积分设置\", 无法判断当前要使用的(扩展)积分字段, 暂时无法发布悬赏", usergroupinfo.Grouptitle)); return;
                    AddErrLine("系统未设置\"交易积分设置\", 无法判断当前要使用的(扩展)积分字段, 暂时无法发布悬赏"); return;
                }
                mybonustranscredits = Users.GetUserExtCredits(userid, creditTrans);
            }
            #endregion

            //如果是提交...
            if (ispost)
            {
                SetBackLink(string.Format("posttopic.aspx?forumid={0}&restore=1&type={1}", forumid, type));

                ForumUtils.WriteCookie("postmessage", postmessage);

                #region 验证提交信息
                //常规项验证
                NormalValidate(admininfo, postmessage, userinfo);
                if (IsErr()) return;

                // 如果用户上传了附件,则检测用户是否有上传附件的权限
                if (ForumUtils.IsPostFile())
                {
                    if (Utils.StrIsNullOrEmpty(Attachments.GetAttachmentTypeArray(attachmentTypeSelect)))
                        AddErrLine("系统不允许上传附件");

                    if (!UserAuthority.PostAttachAuthority(forum, usergroupinfo, userid, ref msg))
                        AddErrLine(msg);
                }

                //发悬赏校验
                int topicprice = 0;
                bool isbonus = type == "bonus";
                ValidateBonus(ref topicprice, ref isbonus);

                //发特殊主题校验
                ValidatePollAndDebate();

                if (IsErr())
                    return;
                #endregion

                int hide = (ForumUtils.IsHidePost(postmessage) && usergroupinfo.Allowhidecode == 1) ? 1 : 0;

                TopicInfo topicinfo = CreateTopic(admininfo, postmessage, isbonus, topicprice);
                if (IsErr())
                    return;

                PostInfo postinfo = CreatePost(topicinfo);
                if (IsErr())
                    return;

                //处理附件
                StringBuilder sb = new StringBuilder();
                AttachmentInfo[] attachmentinfo = ForumUtils.SaveRequestFiles(forumid, config.Maxattachments, usergroupinfo.Maxsizeperday, usergroupinfo.Maxattachsize, MaxTodaySize, attachextensions, forum.Disablewatermark == 1 ? 0 : config.Watermarkstatus, config, "postfile");
                Attachments.UpdateAttachment(attachmentinfo, topicinfo.Tid, postinfo.Pid, postinfo, ref sb, userid, config, usergroupinfo);

                //加入相册
                if (!tempaccountspost && config.Enablealbum == 1 && apb != null)
                    sb.Append(apb.CreateAttachment(attachmentinfo, usergroupid, userid, username));

                #region 添加日志的操作
                SpacePluginBase spb = SpacePluginProvider.GetInstance();
                if (DNTRequest.GetFormString("addtoblog") == "on" && spb != null)
                {
                    if (userid != -1 && userinfo.Spaceid > 0)
                        spb.CreateTopic(topicinfo, postinfo, attachmentinfo);
                    else
                        AddMsgLine("您的个人空间尚未开通, 无法同时添加为日志");
                }
                #endregion

                OnlineUsers.UpdateAction(olid, UserAction.PostTopic.ActionID, forumid, forum.Name, -1, "", config.Onlinetimeout);
                // 更新在线表中的用户最后发帖时间
                OnlineUsers.UpdatePostTime(olid);

                #region 设置提示信息和跳转链接
                if (sb.Length > 0)
                {
                    SetUrl(base.ShowTopicAspxRewrite(topicinfo.Tid, 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>");
                        AddMsgLine(sb.Append("</table>").ToString());
                    }
                }
                else
                {
                    SetShowBackLink(false);
                    if (useradminid != 1)
                    {
                        //是否需要审核
                        if (UserAuthority.NeedAudit(forum, useradminid, topicinfo, userid, disablepost))
                        {
                            SetUrl(base.ShowForumAspxRewrite(forumid, forumpageid));
                            SetMetaRefresh();
                            AddMsgLine("发表主题成功, 但需要经过审核才可以显示. 返回该版块");
                        }
                        else
                            PostTopicSucceed(Forums.GetValues(forum.Postcredits), topicinfo, topicinfo.Tid);
                    }
                    else
                        PostTopicSucceed(Forums.GetValues(forum.Postcredits), topicinfo, topicinfo.Tid);
                }
                #endregion

                ForumUtils.WriteCookie("postmessage", "");
                SetLastPostedForumCookie();

                //如果已登录就不需要再登录
                if (needlogin && userid > 0)
                    needlogin = false;
            }
            else //非提交操作
                AddLinkCss(BaseConfigs.GetForumPath + "templates/" + templatepath + "/editor.css", "css");
        }
示例#28
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 > 1)//如果不是ajax,则应该是带pageid的参数
                {
                    if (config.Aspxrewrite == 1)
                        SetUrl(string.Format("showtopic-{0}-{2}{1}#{3}", topic.Tid, config.Extname, pageid, postinfo.Pid));
                    else
                        SetUrl(string.Format("showtopic.aspx?topicid={0}&forumpage={3}&page={2}#{1}", topic.Tid, postinfo.Pid, 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");
        }
示例#29
0
文件: Stats.cs 项目: khaliyo/DiscuzNT
        public static ShortUserInfo[] GetUserOnlinetime(string field)
        {
            IDataReader reader = DatabaseProvider.GetInstance().GetUserByOnlineTime(field);

            List<ShortUserInfo> list = new List<ShortUserInfo>();

            while (reader.Read())
            {
                ShortUserInfo u = new ShortUserInfo();
                u.Username = reader["username"].ToString();
                u.Uid = TypeConverter.ObjectToInt(reader["uid"]);
                u.Oltime = TypeConverter.ObjectToInt(reader[field]);
                u.Password = u.Secques = u.Nickname = u.Bday = string.Empty;

                list.Add(u);
            }
            reader.Close();

            return list.ToArray();
        }
示例#30
0
 /// <summary>
 /// 写用户积分信息及用户组别COOKIE
 /// </summary>
 /// <param name="userInfo">用户信息</param>
 /// <param name="groupTitle">用户组名</param>
 public static void WriteUserCreditsCookie(ShortUserInfo userInfo, string groupTitle)
 {
     if (userInfo == null)
         return;
     string[] validScoreName = Discuz.Forum.Scoresets.GetValidScoreName();
     string[] scoreUnit = Discuz.Forum.Scoresets.GetValidScoreUnit();
     string scoreInfo = "积分:" + userInfo.Credits + ",";
     scoreInfo += "用户组:" + groupTitle + ",";
     for (int i = 0; i < validScoreName.Length; i++)
     {
         if (!Utils.StrIsNullOrEmpty(validScoreName[i]))
         {
             switch ("Extcredits" + i)
             {
                 case "Extcredits1":
                     scoreInfo += validScoreName[i] + ": " + userInfo.Extcredits1 + scoreUnit[1] + ","; break;
                 case "Extcredits2":
                     scoreInfo += validScoreName[i] + ": " + userInfo.Extcredits2 + scoreUnit[2] + ","; break;
                 case "Extcredits3":
                     scoreInfo += validScoreName[i] + ": " + userInfo.Extcredits3 + scoreUnit[3] + ","; break;
                 case "Extcredits4":
                     scoreInfo += validScoreName[i] + ": " + userInfo.Extcredits4 + scoreUnit[4] + ","; break;
                 case "Extcredits5":
                     scoreInfo += validScoreName[i] + ": " + userInfo.Extcredits5 + scoreUnit[5] + ","; break;
                 case "Extcredits6":
                     scoreInfo += validScoreName[i] + ": " + userInfo.Extcredits6 + scoreUnit[6] + ","; break;
                 case "Extcredits7":
                     scoreInfo += validScoreName[i] + ": " + userInfo.Extcredits7 + scoreUnit[7] + ","; break;
                 case "Extcredits8":
                     scoreInfo += validScoreName[i] + ": " + userInfo.Extcredits8 + scoreUnit[8] + ","; break;
             }
         }
     }
     HttpCookie cookie = HttpContext.Current.Request.Cookies["dntusertips"];
     if (cookie == null)
     {
         cookie = new HttpCookie("dntusertips");
     }
     cookie.Values["userinfotips"] = Utils.UrlEncode(scoreInfo.TrimEnd(','));
     cookie.Expires = DateTime.Now.AddMinutes(5);
     HttpContext.Current.Response.AppendCookie(cookie);
 }