Ejemplo n.º 1
0
        public void SetUserGroupRaterange(int scoreid)
        {
            #region 设置用户组积分范围

            bool isupdate = true;

            foreach (DataRow dr in Scoresets.GetScoreSet().Rows)
            {
                if ((dr["id"].ToString() != "1") && (dr["id"].ToString() != "2"))
                {
                    if (dr[scoreid + 1].ToString().Trim() != "0")
                    {
                        isupdate = false;
                        break;
                    }
                }
            }

            if (isupdate)
            {
                foreach (DataRow dr in UserGroups.GetRateRange(scoreid).Rows)
                {
                    UserGroups.UpdateRateRange(dr["raterange"].ToString().Replace(scoreid + ",True,", scoreid + ",False,"), Utils.StrToInt(dr["groupid"], 0));
                }
            }

            #endregion
        }
Ejemplo n.º 2
0
        public void SetUserGroupRaterange(int scoreid)
        {
            bool flag = true;

            foreach (DataRow dataRow in Scoresets.GetScoreSet().Rows)
            {
                if (dataRow["id"].ToString() != "1" && dataRow["id"].ToString() != "2" && dataRow[scoreid + 1].ToString().Trim() != "0")
                {
                    flag = false;
                    break;
                }
            }
            if (flag)
            {
                //foreach (DataRow dataRow2 in UserGroups.GetRateRange(scoreid).Rows)
                //{
                //	UserGroups.UpdateRateRange(dataRow2["raterange"].ToString().Replace(scoreid + ",True,", scoreid + ",False,"), dataRow2["groupid"].ToInt(0));
                //}
                foreach (var item in UserGroup.FindAllWithCache())
                {
                    item.Raterange = item.Raterange.Replace(scoreid + ",True,", scoreid + ",False,");
                    item.Update();
                }
            }
        }
        private DataTable LoadDataInfo()
        {
            #region 加载数据信息

            //DataTable dt = UserGroups.GroupParticipateScore(DNTRequest.GetInt("groupid", 0));
            //if (dt.Rows.Count <= 0)
            //    return null;

            //if (dt.Rows[0][0].ToString().Trim() == "")
            //    return RemoveEmptyRows(NewParticipateScore());

            //return RemoveEmptyRows(GroupParticipateScore(dt.Rows[0][0].ToString().Trim()));
            templateDT = UserGroups.GroupParticipateScore(DNTRequest.GetInt("groupid", 0));
            DataRow scoresetname = Scoresets.GetScoreSet().Rows[0];
            string  validrow     = "";

            for (int count = 0; count < 8; count++)
            {
                if ((scoresetname[count + 2].ToString().Trim() != "") && (scoresetname[count + 2].ToString().Trim() != "0"))
                {
                    templateDT.Rows[count]["ScoreName"] = scoresetname[count + 2].ToString().Trim();
                    validrow = validrow + "," + count;
                }

                if (IsValidScoreName(count + 1))
                {
                    validrow = validrow + "," + count;
                }
            }
            ViewState["validrow"] = validrow + ",";
            return(templateDT);

            #endregion
        }
Ejemplo n.º 4
0
 protected void DataGrid_Cancel(Object sender, DataGridCommandEventArgs E)
 {
     #region 取消编辑
     DataGrid1.EditItemIndex = -1;
     DataGrid1.DataSource    = AbsScoreSet(Scoresets.GetScoreSet());
     DataGrid1.DataBind();
     #endregion
 }
Ejemplo n.º 5
0
        public bool IsValidScoreName(int scoreid)
        {
            bool result = false;

            foreach (DataRow dataRow in Scoresets.GetScoreSet().Rows)
            {
                if (dataRow["id"].ToString() != "1" && dataRow["id"].ToString() != "2" && dataRow[scoreid + 1].ToString().Trim() != "0")
                {
                    result = true;
                    break;
                }
            }
            return(result);
        }
        public DataTable NewParticipateScore()
        {
            #region 初始化并装入默认数据

            templateDT.Columns.Clear();
            templateDT.Columns.Add("id", Type.GetType("System.Int32"));
            templateDT.Columns.Add("available", Type.GetType("System.Boolean"));
            templateDT.Columns.Add("ScoreCode", Type.GetType("System.String"));
            templateDT.Columns.Add("ScoreName", Type.GetType("System.String"));
            templateDT.Columns.Add("Min", Type.GetType("System.String"));
            templateDT.Columns.Add("Max", Type.GetType("System.String"));
            templateDT.Columns.Add("MaxInDay", Type.GetType("System.String"));

            for (int rowcount = 0; rowcount < 8; rowcount++)
            {
                DataRow dr = templateDT.NewRow();
                dr["id"]        = rowcount + 1;
                dr["available"] = false;
                dr["ScoreCode"] = "extcredits" + Convert.ToString(rowcount + 1);
                dr["ScoreName"] = "";
                dr["Min"]       = "";
                dr["Max"]       = "";
                dr["MaxInDay"]  = "";
                templateDT.Rows.Add(dr);
            }
            DataRow scoresetname = Scoresets.GetScoreSet().Rows[0];
            string  validrow     = "";

            for (int count = 0; count < 8; count++)
            {
                if ((scoresetname[count + 2].ToString().Trim() != "") && (scoresetname[count + 2].ToString().Trim() != "0"))
                {
                    templateDT.Rows[count]["ScoreName"] = scoresetname[count + 2].ToString().Trim();

                    validrow = validrow + "," + count;
                }

                if (IsValidScoreName(count + 1))
                {
                    validrow = validrow + "," + count;
                }
            }
            ViewState["validrow"] = validrow + ",";
            return(templateDT);

            #endregion
        }
        //private void DelRec_Click(object sender, EventArgs e)
        //{
        //    #region 删除指定条件的日志信息

        //    if (this.CheckCookie())
        //    {
        //        string condition = "";
        //        condition = AdminModeratorLogs.GetDeleteModeratorManageCondition(Request.Form["deleteMode"].ToString(),
        //            DNTRequest.GetString("id").ToString(), deleteNum.Text.ToString(), deleteFrom.SelectedDate.ToString());
        //        if (condition != "")
        //        {
        //            AdminRateLogs.DeleteLog(condition);
        //            Response.Redirect("forum_ratescorelog.aspx");
        //        }
        //        else
        //        {
        //            base.RegisterStartupScript( "", "<script>alert('您未选中任何选项或输入参数错误!');window.location.href='forum_ratescorelog.aspx';</script>");
        //        }
        //    }
        //    #endregion去掉这个功能
        //}

        public string ExtcreditsStr(string extcredits, string score)
        {
            #region 提取扩展积分字段并显示

            DataRow dr = Scoresets.GetScoreSet().Rows[0];

            string extcredit = "";
            switch (extcredits)
            {
            case "1":
                extcredit = dr["extcredits1"].ToString() + " " + score;
                break;

            case "2":
                extcredit = dr["extcredits2"].ToString() + " " + score;
                break;

            case "3":
                extcredit = dr["extcredits3"].ToString() + " " + score;
                break;

            case "4":
                extcredit = dr["extcredits4"].ToString() + " " + score;
                break;

            case "5":
                extcredit = dr["extcredits5"].ToString() + " " + score;
                break;

            case "6":
                extcredit = dr["extcredits6"].ToString() + " " + score;
                break;

            case "7":
                extcredit = dr["extcredits7"].ToString() + " " + score;
                break;

            case "8":
                extcredit = dr["extcredits8"].ToString() + " " + score;
                break;
            }
            return(extcredit);

            #endregion
        }
        //private DataTable RemoveEmptyRows(DataTable dt)
        //{
        //    DataRow[] drs = dt.Select("ScoreName=''");
        //    foreach (DataRow dr in drs)
        //    {
        //        dt.Rows.Remove(dr);
        //    }
        //    return dt;
        //}

        //public DataTable NewParticipateScore()
        //{
        //    #region 初始化并装入默认数据

        //    templateDT.Columns.Clear();
        //    templateDT.Columns.Add("id", Type.GetType("System.Int32"));
        //    templateDT.Columns.Add("available", Type.GetType("System.Boolean"));
        //    templateDT.Columns.Add("ScoreCode", Type.GetType("System.String"));
        //    templateDT.Columns.Add("ScoreName", Type.GetType("System.String"));
        //    templateDT.Columns.Add("Min", Type.GetType("System.String"));
        //    templateDT.Columns.Add("Max", Type.GetType("System.String"));
        //    templateDT.Columns.Add("MaxInDay", Type.GetType("System.String"));

        //    for (int rowcount = 0; rowcount < 8; rowcount++)
        //    {
        //        DataRow dr = templateDT.NewRow();
        //        dr["id"] = rowcount + 1;
        //        dr["available"] = false;
        //        dr["ScoreCode"] = "extcredits" + Convert.ToString(rowcount + 1);
        //        dr["ScoreName"] = "";
        //        dr["Min"] = "";
        //        dr["Max"] = "";
        //        dr["MaxInDay"] = "";
        //        templateDT.Rows.Add(dr);
        //    }
        //    DataRow scoresetname = Scoresets.GetScoreSet().Rows[0];
        //    string validrow = "";

        //    for (int count = 0; count < 8; count++)
        //    {
        //        if ((scoresetname[count + 2].ToString().Trim() != "") && (scoresetname[count + 2].ToString().Trim() != "0"))
        //        {
        //            templateDT.Rows[count]["ScoreName"] = scoresetname[count + 2].ToString().Trim();
        //            validrow = validrow + "," + count;
        //        }

        //        if (IsValidScoreName(count + 1))
        //            validrow = validrow + "," + count;
        //    }
        //    ViewState["validrow"] = validrow + ",";
        //    return templateDT;

        //    #endregion
        //}

        public bool IsValidScoreName(int scoreid)
        {
            #region 是否是有效的积分名称

            bool isvalid = false;

            foreach (DataRow dr in Scoresets.GetScoreSet().Rows)
            {
                if ((dr["id"].ToString() != "1") && (dr["id"].ToString() != "2") && (dr[scoreid + 1].ToString().Trim() != "0"))
                {
                    isvalid = true;
                    break;
                }
            }
            return(isvalid);

            #endregion
        }
Ejemplo n.º 9
0
        public string ExtcreditsStr(string extcredits, string score)
        {
            DataRow dataRow = Scoresets.GetScoreSet().Rows[0];
            string  result  = "";

            switch (extcredits)
            {
            case "1":
                result = dataRow["extcredits1"].ToString() + " " + score;
                break;

            case "2":
                result = dataRow["extcredits2"].ToString() + " " + score;
                break;

            case "3":
                result = dataRow["extcredits3"].ToString() + " " + score;
                break;

            case "4":
                result = dataRow["extcredits4"].ToString() + " " + score;
                break;

            case "5":
                result = dataRow["extcredits5"].ToString() + " " + score;
                break;

            case "6":
                result = dataRow["extcredits6"].ToString() + " " + score;
                break;

            case "7":
                result = dataRow["extcredits7"].ToString() + " " + score;
                break;

            case "8":
                result = dataRow["extcredits8"].ToString() + " " + score;
                break;
            }
            return(result);
        }
Ejemplo n.º 10
0
        private DataTable LoadDataInfo()
        {
            this.templateDT = UserGroups.GroupParticipateScore(DNTRequest.GetInt("groupid", 0));
            DataRow dataRow = Scoresets.GetScoreSet().Rows[0];
            string  text    = "";

            for (int i = 0; i < 8; i++)
            {
                if (!dataRow[i + 2].ToString().IsNullOrEmpty() && dataRow[i + 2].ToString().Trim() != "0")
                {
                    this.templateDT.Rows[i]["ScoreName"] = dataRow[i + 2].ToString().Trim();
                    text = text + "," + i;
                }
                if (this.IsValidScoreName(i + 1))
                {
                    text = text + "," + i;
                }
            }
            this.ViewState["validrow"] = text + ",";
            return(this.templateDT);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 创建用户信息
        /// </summary>
        /// <param name="tmpUsername"></param>
        /// <param name="email"></param>
        /// <param name="tmpBday"></param>
        /// <returns></returns>
        private UserInfo CreateUser(string tmpUsername, string email, string tmpBday)
        {
            // 如果找不到0积分的用户组则用户自动成为待验证用户
            UserInfo userinfo = new UserInfo();

            userinfo.Username      = tmpUsername;
            userinfo.Nickname      = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("nickname")));
            userinfo.Password      = DNTRequest.GetString("password");
            userinfo.Secques       = ForumUtils.GetUserSecques(DNTRequest.GetInt("question", 0), DNTRequest.GetString("answer"));
            userinfo.Gender        = DNTRequest.GetInt("gender", 0);
            userinfo.Adminid       = 0;
            userinfo.Groupexpiry   = 0;
            userinfo.Extgroupids   = "";
            userinfo.Regip         = DNTRequest.GetIP();
            userinfo.Joindate      = Utils.GetDateTime();
            userinfo.Lastip        = DNTRequest.GetIP();
            userinfo.Lastvisit     = Utils.GetDateTime();
            userinfo.Lastactivity  = Utils.GetDateTime();
            userinfo.Lastpost      = Utils.GetDateTime();
            userinfo.Lastpostid    = 0;
            userinfo.Lastposttitle = "";
            userinfo.Posts         = 0;
            userinfo.Digestposts   = 0;
            userinfo.Oltime        = 0;
            userinfo.Pageviews     = 0;
            userinfo.Credits       = 0;
            userinfo.Extcredits1   = Scoresets.GetScoreSet(1).Init;
            userinfo.Extcredits2   = Scoresets.GetScoreSet(2).Init;
            userinfo.Extcredits3   = Scoresets.GetScoreSet(3).Init;
            userinfo.Extcredits4   = Scoresets.GetScoreSet(4).Init;
            userinfo.Extcredits5   = Scoresets.GetScoreSet(5).Init;
            userinfo.Extcredits6   = Scoresets.GetScoreSet(6).Init;
            userinfo.Extcredits7   = Scoresets.GetScoreSet(7).Init;
            userinfo.Extcredits8   = Scoresets.GetScoreSet(8).Init;
            //userinfo.Avatarshowid = 0;
            userinfo.Email      = email;
            userinfo.Bday       = tmpBday;
            userinfo.Sigstatus  = DNTRequest.GetInt("sigstatus", 1) != 0 ? 1 : 0;
            userinfo.Tpp        = DNTRequest.GetInt("tpp", 0);
            userinfo.Ppp        = DNTRequest.GetInt("ppp", 0);
            userinfo.Templateid = DNTRequest.GetInt("templateid", 0);
            userinfo.Pmsound    = DNTRequest.GetInt("pmsound", 0);
            userinfo.Showemail  = DNTRequest.GetInt("showemail", 0);
            userinfo.Salt       = "";

            int receivepmsetting = config.Regadvance == 0 ? 3 : DNTRequest.GetInt("receivesetting", 3);//关于短信息枚举值的设置看ReceivePMSettingType类型注释,此处不禁止用户接受系统短信息

            //foreach (string rpms in DNTRequest.GetString("receivesetting").Split(','))
            //{
            //    if (!Utils.StrIsNullOrEmpty(rpms))
            //        receivepmsetting = receivepmsetting | int.Parse(rpms);
            //}

            //if (config.Regadvance == 0)
            //    receivepmsetting = 7;

            userinfo.Newsletter   = (ReceivePMSettingType)receivepmsetting;
            userinfo.Invisible    = DNTRequest.GetInt("invisible", 0);
            userinfo.Newpm        = config.Welcomemsg == 1 ? 1 : 0;
            userinfo.Medals       = "";
            userinfo.Accessmasks  = DNTRequest.GetInt("accessmasks", 0);
            userinfo.Website      = Utils.HtmlEncode(DNTRequest.GetString("website"));
            userinfo.Icq          = Utils.HtmlEncode(DNTRequest.GetString("icq"));
            userinfo.Qq           = Utils.HtmlEncode(DNTRequest.GetString("qq"));
            userinfo.Yahoo        = Utils.HtmlEncode(DNTRequest.GetString("yahoo"));
            userinfo.Msn          = Utils.HtmlEncode(DNTRequest.GetString("msn"));
            userinfo.Skype        = Utils.HtmlEncode(DNTRequest.GetString("skype"));
            userinfo.Location     = Utils.HtmlEncode(DNTRequest.GetString("location"));
            userinfo.Customstatus = (usergroupinfo.Allowcstatus == 1) ? Utils.HtmlEncode(DNTRequest.GetString("customstatus")) : "";
            //userinfo.Avatar = @"avatars\common\0.gif";
            //userinfo.Avatarwidth = 0;
            //userinfo.Avatarheight = 0;
            userinfo.Bio       = ForumUtils.BanWordFilter(DNTRequest.GetString("bio"));
            userinfo.Signature = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("signature")));

            PostpramsInfo postpramsinfo = new PostpramsInfo();

            postpramsinfo.Usergroupid        = usergroupid;
            postpramsinfo.Attachimgpost      = config.Attachimgpost;
            postpramsinfo.Showattachmentpath = config.Showattachmentpath;
            postpramsinfo.Hide                   = 0;
            postpramsinfo.Price                  = 0;
            postpramsinfo.Sdetail                = userinfo.Signature;
            postpramsinfo.Smileyoff              = 1;
            postpramsinfo.Bbcodeoff              = 1 - usergroupinfo.Allowsigbbcode;
            postpramsinfo.Parseurloff            = 1;
            postpramsinfo.Showimages             = usergroupinfo.Allowsigimgcode;
            postpramsinfo.Allowhtml              = 0;
            postpramsinfo.Smiliesinfo            = Smilies.GetSmiliesListWithInfo();
            postpramsinfo.Customeditorbuttoninfo = Editors.GetCustomEditButtonListWithInfo();
            postpramsinfo.Smiliesmax             = config.Smiliesmax;
            userinfo.Sightml = UBB.UBBToHTML(postpramsinfo);

            userinfo.Authtime = Utils.GetDateTime();

            //邮箱激活链接验证
            if (config.Regverify == 1)
            {
                userinfo.Authstr  = ForumUtils.CreateAuthStr(20);
                userinfo.Authflag = 1;
                userinfo.Groupid  = 8;
                SendEmail(tmpUsername, DNTRequest.GetString("password").Trim(), DNTRequest.GetString(config.Antispamregisteremail).Trim(), userinfo.Authstr);
            }
            //系统管理员进行后台验证
            else if (config.Regverify == 2)
            {
                userinfo.Authstr  = DNTRequest.GetString("website");
                userinfo.Groupid  = 8;
                userinfo.Authflag = 1;
            }
            else
            {
                userinfo.Authstr  = "";
                userinfo.Authflag = 0;
                userinfo.Groupid  = UserCredits.GetCreditsUserGroupId(0).Groupid;
            }
            userinfo.Realname = DNTRequest.GetString("realname");
            userinfo.Idcard   = DNTRequest.GetString("idcard");
            userinfo.Mobile   = DNTRequest.GetString("mobile");
            userinfo.Phone    = DNTRequest.GetString("phone");

            //第三方加密验证模式
            if (config.Passwordmode > 1 && PasswordModeProvider.GetInstance() != null)
            {
                userinfo.Uid = PasswordModeProvider.GetInstance().CreateUserInfo(userinfo);
            }
            else
            {
                userinfo.Password = Utils.MD5(userinfo.Password);
                userinfo.Uid      = Users.CreateUser(userinfo);
            }
            return(userinfo);
        }
Ejemplo n.º 12
0
        protected override void ShowPage()
        {
            pagetitle = "用户控制面板";

            string jsCreditsRateArray = "";

            foreach (DataRow dr in Scoresets.GetScorePaySet(0).Rows)
            {
                jsCreditsRateArray += "creditsrate[" + dr["id"] + "] = " + dr["rate"] + ";\r\n";
            }
            jscreditsratearray = string.Format(jscreditsratearray, jsCreditsRateArray);

            if (!IsLogin())
            {
                return;
            }

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

                bool isPasswordError = true;

                switch (config.Passwordmode)
                {
                case 1:    //动网兼容模式
                {
                    isPasswordError = Utils.MD5(DNTRequest.GetString("password")) != password;
                    break;
                }

                case 0:    //默认模式
                {
                    isPasswordError = Utils.MD5(DNTRequest.GetString("password")) != password;
                    break;
                }

                default:     //第三方加密验证模式
                {
                    if (PasswordModeProvider.GetInstance() != null)
                    {
                        isPasswordError = !PasswordModeProvider.GetInstance().CheckPassword(user, DNTRequest.GetString("password"));
                    }
                    break;
                }
                }
                if (isPasswordError)
                {
                    AddErrLine("密码错误");
                    return;
                }

                int paynum = DNTRequest.GetInt("paynum", 0);
                if (paynum <= 0)
                {
                    AddErrLine("数量必须是大于0的整数");
                    return;
                }
                if (DNTRequest.GetInt("extcredits1", 0) < 1 || DNTRequest.GetInt("extcredits2", 0) < 1 || DNTRequest.GetInt("extcredits1", 0) > 8 || DNTRequest.GetInt("extcredits2", 0) > 8)
                {
                    AddErrLine("请正确选择要兑换的积分类型!");
                    return;
                }
                if (DNTRequest.GetInt("extcredits1", 0) == DNTRequest.GetInt("extcredits2", 0))
                {
                    AddErrLine("不能兑换相同类型的积分");
                    return;
                }

                //对交易后的积分增减进行修改设置
                UserExtcreditsInfo extcredits1info = Scoresets.GetScoreSet(DNTRequest.GetInt("extcredits1", 0));
                UserExtcreditsInfo extcredits2info = Scoresets.GetScoreSet(DNTRequest.GetInt("extcredits2", 0));
                if (Utils.StrIsNullOrEmpty(extcredits1info.Name) || Utils.StrIsNullOrEmpty(extcredits2info.Name))
                {
                    AddErrLine("错误的输入!");
                    return;
                }
                if ((Users.GetUserExtCredits(userid, DNTRequest.GetInt("extcredits1", 0)) - paynum) < Scoresets.GetExchangeMinCredits())
                {
                    AddErrLine("抱歉, 您的 \"" + extcredits1info.Name + "\" 不足." + Scoresets.GetExchangeMinCredits());
                    return;
                }

                UserInfo userInfo = Users.GetUserInfo(userid);

                float extcredit2paynum = (float)Math.Round(paynum * (extcredits1info.Rate / extcredits2info.Rate) * (1 - creditstax), 2);
                Users.UpdateUserExtCredits(userid, DNTRequest.GetInt("extcredits1", 0), paynum * -1);
                Users.UpdateUserExtCredits(userid, DNTRequest.GetInt("extcredits2", 0), extcredit2paynum);
                CreditsLogs.AddCreditsLog(userid, userid, DNTRequest.GetInt("extcredits1", 0), DNTRequest.GetInt("extcredits2", 0), paynum, extcredit2paynum, Utils.GetDateTime(), 1);

                SetUrl("usercpcreaditstransferlog.aspx");
                SetMetaRefresh();
                SetShowBackLink(false);
                AddMsgLine("积分兑换完毕, 正在返回积分兑换与转帐记录");
            }
        }
        public void LoadScoreInf(string fid, string fieldName)
        {
            #region 加载积分策略信息

            if (fieldName == "postcredits")
            {
                Literal1.Text = "发主题积分策略";
            }
            else
            {
                Literal1.Text = "发回复积分策略";
            }

            DataTable dt = Forums.GetForumField(Utils.StrToInt(fid, 0), fieldName);
            if (dt.Rows.Count == 0)
            {
                Response.Write("<script>alert('数据不存在');</script>");
            }
            else
            {
                string credits = dt.Rows[0][0].ToString().Trim();
                if ((credits != "") && (credits != "0"))
                {
                    string[] creditInfo = credits.Split(',');
                    available.SelectedValue = creditInfo[0].Trim();
                    extcredits1.Text        = creditInfo[1].Trim();
                    extcredits2.Text        = creditInfo[2].Trim();
                    extcredits3.Text        = creditInfo[3].Trim();
                    extcredits4.Text        = creditInfo[4].Trim();
                    extcredits5.Text        = creditInfo[5].Trim();
                    extcredits6.Text        = creditInfo[6].Trim();
                    extcredits7.Text        = creditInfo[7].Trim();
                    extcredits8.Text        = creditInfo[8].Trim();
                }
            }

            DataRow dr = Scoresets.GetScoreSet().Rows[0];

            if (dr[2].ToString().Trim() != "")
            {
                extcredits1name.Text = dr[2].ToString().Trim();
            }
            else
            {
                extcredits1.Enabled = false;
            }

            if (dr[3].ToString().Trim() != "")
            {
                extcredits2name.Text = dr[3].ToString().Trim();
            }
            else
            {
                extcredits2.Enabled = false;
            }

            if (dr[4].ToString().Trim() != "")
            {
                extcredits3name.Text = dr[4].ToString().Trim();
            }
            else
            {
                extcredits3.Enabled = false;
            }

            if (dr[5].ToString().Trim() != "")
            {
                extcredits4name.Text = dr[5].ToString().Trim();
            }
            else
            {
                extcredits4.Enabled = false;
            }

            if (dr[6].ToString().Trim() != "")
            {
                extcredits5name.Text = dr[6].ToString().Trim();
            }
            else
            {
                extcredits5.Enabled = false;
            }

            if (dr[7].ToString().Trim() != "")
            {
                extcredits6name.Text = dr[7].ToString().Trim();
            }
            else
            {
                extcredits6.Enabled = false;
            }

            if (dr[8].ToString().Trim() != "")
            {
                extcredits7name.Text = dr[8].ToString().Trim();
            }
            else
            {
                extcredits7.Enabled = false;
            }

            if (dr[9].ToString().Trim() != "")
            {
                extcredits8name.Text = dr[9].ToString().Trim();
            }
            else
            {
                extcredits8.Enabled = false;
            }

            #endregion
        }
Ejemplo n.º 14
0
        public void LoadScoreInf()
        {
            #region 加载积分策略信息

            Literal1.Text       = "转向地址和推广积分策略";
            txtTransferUrl.Text = Spread.Config.SpreadConfigs.GetConfig().TransferUrl;

            string credits = Spread.Config.SpreadConfigs.GetConfig().SpreadCredits;
            if ((credits != "") && (credits != "0"))
            {
                string[] creditinf = credits.Split(',');
                extcredits1.Text = creditinf[0].Trim();
                extcredits2.Text = creditinf[1].Trim();
                extcredits3.Text = creditinf[2].Trim();
                extcredits4.Text = creditinf[3].Trim();
                extcredits5.Text = creditinf[4].Trim();
                extcredits6.Text = creditinf[5].Trim();
                extcredits7.Text = creditinf[6].Trim();
                extcredits8.Text = creditinf[7].Trim();
            }
            else
            {
                extcredits1.Text = "";
                extcredits2.Text = "";
                extcredits3.Text = "";
                extcredits4.Text = "";
                extcredits5.Text = "";
                extcredits6.Text = "";
                extcredits7.Text = "";
                extcredits8.Text = "";
            }

            DataRow dr = Scoresets.GetScoreSet().Rows[0];

            if (dr[2].ToString().Trim() != "")
            {
                extcredits1name.Text = dr[2].ToString().Trim();
            }
            else
            {
                extcredits1.Enabled = false;
            }

            if (dr[3].ToString().Trim() != "")
            {
                extcredits2name.Text = dr[3].ToString().Trim();
            }
            else
            {
                extcredits2.Enabled = false;
            }

            if (dr[4].ToString().Trim() != "")
            {
                extcredits3name.Text = dr[4].ToString().Trim();
            }
            else
            {
                extcredits3.Enabled = false;
            }

            if (dr[5].ToString().Trim() != "")
            {
                extcredits4name.Text = dr[5].ToString().Trim();
            }
            else
            {
                extcredits4.Enabled = false;
            }

            if (dr[6].ToString().Trim() != "")
            {
                extcredits5name.Text = dr[6].ToString().Trim();
            }
            else
            {
                extcredits5.Enabled = false;
            }

            if (dr[7].ToString().Trim() != "")
            {
                extcredits6name.Text = dr[7].ToString().Trim();
            }
            else
            {
                extcredits6.Enabled = false;
            }

            if (dr[8].ToString().Trim() != "")
            {
                extcredits7name.Text = dr[8].ToString().Trim();
            }
            else
            {
                extcredits7.Enabled = false;
            }

            if (dr[9].ToString().Trim() != "")
            {
                extcredits8name.Text = dr[9].ToString().Trim();
            }
            else
            {
                extcredits8.Enabled = false;
            }

            #endregion
        }
Ejemplo n.º 15
0
        /// <summary>创建用户信息</summary>
        private static UserInfo CreateUser(GeneralConfigInfo config, IPKSPrincipal principal, bool isAdmin)
        {
            var tmpUsername = principal.Identity.Name;
            // 如果找不到0积分的用户组则用户自动成为待验证用户
            UserInfo userinfo = new UserInfo();

            userinfo.Username      = tmpUsername;
            userinfo.Nickname      = tmpUsername;
            userinfo.Password      = Guid.NewGuid().ToString();
            userinfo.Secques       = "";
            userinfo.Gender        = 0;
            userinfo.Adminid       = isAdmin ? 1 : 0;
            userinfo.Groupexpiry   = 0;
            userinfo.Extgroupids   = "";
            userinfo.Regip         = DNTRequest.GetIP();
            userinfo.Joindate      = Discuz.Common.Utils.GetDateTime();
            userinfo.Lastip        = userinfo.Regip;
            userinfo.Lastvisit     = userinfo.Joindate;
            userinfo.Lastactivity  = userinfo.Joindate;
            userinfo.Lastpost      = userinfo.Joindate;
            userinfo.Lastpostid    = 0;
            userinfo.Lastposttitle = "";
            userinfo.Posts         = 0;
            userinfo.Digestposts   = 0;
            userinfo.Oltime        = 0;
            userinfo.Pageviews     = 0;
            userinfo.Credits       = 0;
            userinfo.Extcredits1   = Scoresets.GetScoreSet(1).Init;
            userinfo.Extcredits2   = Scoresets.GetScoreSet(2).Init;
            userinfo.Extcredits3   = Scoresets.GetScoreSet(3).Init;
            userinfo.Extcredits4   = Scoresets.GetScoreSet(4).Init;
            userinfo.Extcredits5   = Scoresets.GetScoreSet(5).Init;
            userinfo.Extcredits6   = Scoresets.GetScoreSet(6).Init;
            userinfo.Extcredits7   = Scoresets.GetScoreSet(7).Init;
            userinfo.Extcredits8   = Scoresets.GetScoreSet(8).Init;
            //userinfo.Avatarshowid = 0;
            userinfo.Email      = principal.Identity.Email ?? "";
            userinfo.Bday       = "";
            userinfo.Sigstatus  = 1;
            userinfo.Tpp        = 0;
            userinfo.Ppp        = 0;
            userinfo.Templateid = 0;
            userinfo.Pmsound    = 0;
            userinfo.Showemail  = 0;
            userinfo.Salt       = "";

            int receivepmsetting = 3;//关于短信息枚举值的设置看ReceivePMSettingType类型注释,此处不禁止用户接受系统短信息

            //foreach (string rpms in DNTRequest.GetString("receivesetting").Split(','))
            //{
            //    if (!Utils.StrIsNullOrEmpty(rpms))
            //        receivepmsetting = receivepmsetting | int.Parse(rpms);
            //}

            //if (config.Regadvance == 0)
            //    receivepmsetting = 7;

            userinfo.Newsletter   = (ReceivePMSettingType)receivepmsetting;
            userinfo.Invisible    = 0;
            userinfo.Newpm        = config.Welcomemsg == 1 ? 1 : 0;
            userinfo.Medals       = "";
            userinfo.Accessmasks  = 0;
            userinfo.Website      = "";
            userinfo.Icq          = "";
            userinfo.Qq           = "";
            userinfo.Yahoo        = "";
            userinfo.Msn          = "";
            userinfo.Skype        = "";
            userinfo.Location     = "";
            userinfo.Customstatus = "";
            //userinfo.Avatar = @"avatars\common\0.gif";
            //userinfo.Avatarwidth = 0;
            //userinfo.Avatarheight = 0;
            userinfo.Bio       = "";
            userinfo.Signature = "";

            var usergroupid   = isAdmin ? 1 : 7;
            var usergroupinfo = UserGroups.GetUserGroupInfo(usergroupid);

            PostpramsInfo postpramsinfo = new PostpramsInfo();

            postpramsinfo.Usergroupid        = usergroupid;
            postpramsinfo.Attachimgpost      = config.Attachimgpost;
            postpramsinfo.Showattachmentpath = config.Showattachmentpath;
            postpramsinfo.Hide                   = 0;
            postpramsinfo.Price                  = 0;
            postpramsinfo.Sdetail                = userinfo.Signature;
            postpramsinfo.Smileyoff              = 1;
            postpramsinfo.Bbcodeoff              = 1 - usergroupinfo.Allowsigbbcode;
            postpramsinfo.Parseurloff            = 1;
            postpramsinfo.Showimages             = usergroupinfo.Allowsigimgcode;
            postpramsinfo.Allowhtml              = 0;
            postpramsinfo.Smiliesinfo            = Smilies.GetSmiliesListWithInfo();
            postpramsinfo.Customeditorbuttoninfo = Editors.GetCustomEditButtonListWithInfo();
            postpramsinfo.Smiliesmax             = config.Smiliesmax;
            userinfo.Sightml = UBB.UBBToHTML(postpramsinfo);

            userinfo.Authtime = userinfo.Joindate;

            if (isAdmin)
            {
                userinfo.Authstr  = "";
                userinfo.Authflag = 0;
                userinfo.Groupid  = usergroupid;
            }
            //邮箱激活链接验证
            else if (config.Regverify == 1)
            {
                userinfo.Authstr  = ForumUtils.CreateAuthStr(20);
                userinfo.Authflag = 1;
                userinfo.Groupid  = 8;
                //SendEmail(tmpUsername, DNTRequest.GetString("password").Trim(), DNTRequest.GetString(config.Antispamregisteremail).Trim(), userinfo.Authstr);
                //Emails.DiscuzSmtpMail(tmpUsername, emailaddress, password, authstr);
            }
            //系统管理员进行后台验证
            else if (config.Regverify == 2)
            {
                userinfo.Authstr  = "";
                userinfo.Groupid  = 8;
                userinfo.Authflag = 1;
            }
            else
            {
                userinfo.Authstr  = "";
                userinfo.Authflag = 0;
                userinfo.Groupid  = UserCredits.GetCreditsUserGroupId(0).Groupid;
            }
            userinfo.Realname = "";
            userinfo.Idcard   = "";
            userinfo.Mobile   = "";
            userinfo.Phone    = principal.Identity.PhoneNumber;

            //第三方加密验证模式
            if (config.Passwordmode > 1 && PasswordModeProvider.GetInstance() != null)
            {
                userinfo.Uid = PasswordModeProvider.GetInstance().CreateUserInfo(userinfo);
            }
            else
            {
                userinfo.Password = Discuz.Common.Utils.MD5(userinfo.Password);
                userinfo.Uid      = Users.CreateUser(userinfo);
            }
            return(userinfo);
        }
Ejemplo n.º 16
0
 protected void DataGrid_Cancel(object sender, DataGridCommandEventArgs E)
 {
     this.DataGrid1.EditItemIndex = -1;
     this.DataGrid1.DataSource    = Scoresets.GetScoreSet();
     this.DataGrid1.DataBind();
 }
Ejemplo n.º 17
0
        public void LoadScoreInf(string fid, string fieldName)
        {
            if (fieldName == "postcredits")
            {
                this.Literal1.Text = "发主题积分策略";
            }
            else
            {
                this.Literal1.Text = "发回复积分策略";
            }
            //DataTable forumField = Forums.GetForumField(fid.ToInt(0), fieldName);
            //if (forumField.Rows.Count == 0)
            var f = XForum.FindByID(fid.ToInt());

            if (f == null)
            {
                base.Response.Write("<script>alert('数据不存在');</script>");
            }
            else
            {
                //string text = forumField.Rows[0][0].ToString().Trim();
                var text = (f as IXForum).PostcrEdits;
                if (text != "" && text != "0")
                {
                    string[] array = text.Split(',');
                    this.available.SelectedValue = array[0].Trim();
                    this.extcredits1.Text        = array[1].Trim();
                    this.extcredits2.Text        = array[2].Trim();
                    this.extcredits3.Text        = array[3].Trim();
                    this.extcredits4.Text        = array[4].Trim();
                    this.extcredits5.Text        = array[5].Trim();
                    this.extcredits6.Text        = array[6].Trim();
                    this.extcredits7.Text        = array[7].Trim();
                    this.extcredits8.Text        = array[8].Trim();
                }
            }
            DataRow dataRow = Scoresets.GetScoreSet().Rows[0];

            if (!dataRow[2].ToString().IsNullOrEmpty())
            {
                this.extcredits1name.Text = dataRow[2].ToString().Trim();
            }
            else
            {
                this.extcredits1.Enabled = false;
            }
            if (!dataRow[3].ToString().IsNullOrEmpty())
            {
                this.extcredits2name.Text = dataRow[3].ToString().Trim();
            }
            else
            {
                this.extcredits2.Enabled = false;
            }
            if (!dataRow[4].ToString().IsNullOrEmpty())
            {
                this.extcredits3name.Text = dataRow[4].ToString().Trim();
            }
            else
            {
                this.extcredits3.Enabled = false;
            }
            if (!dataRow[5].ToString().IsNullOrEmpty())
            {
                this.extcredits4name.Text = dataRow[5].ToString().Trim();
            }
            else
            {
                this.extcredits4.Enabled = false;
            }
            if (!dataRow[6].ToString().IsNullOrEmpty())
            {
                this.extcredits5name.Text = dataRow[6].ToString().Trim();
            }
            else
            {
                this.extcredits5.Enabled = false;
            }
            if (!dataRow[7].ToString().IsNullOrEmpty())
            {
                this.extcredits6name.Text = dataRow[7].ToString().Trim();
            }
            else
            {
                this.extcredits6.Enabled = false;
            }
            if (!dataRow[8].ToString().IsNullOrEmpty())
            {
                this.extcredits7name.Text = dataRow[8].ToString().Trim();
            }
            else
            {
                this.extcredits7.Enabled = false;
            }
            if (!dataRow[9].ToString().IsNullOrEmpty())
            {
                this.extcredits8name.Text = dataRow[9].ToString().Trim();
                return;
            }
            this.extcredits8.Enabled = false;
        }
Ejemplo n.º 18
0
        protected override void ShowPage()
        {
            //pagetitle = "编辑帖子";
            #region 判断是否是灌水
            AdminGroupInfo admininfo = AdminGroups.GetAdminGroupInfo(usergroupid);
            this.disablepostctrl = 0;
            if (admininfo != null)
            {
                disablepostctrl = admininfo.Disablepostctrl;
            }
            #endregion

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

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

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

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

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

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

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

            #endregion

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

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

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

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

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

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

            #endregion

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

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

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

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

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

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

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

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

                if (IsErr())
                {
                    return;
                }

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

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

                if (IsErr())
                {
                    return;
                }

                UserCredits.UpdateUserCredits(userid);

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

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

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

                // 删除主题游客缓存
                if (postinfo.Layer == 0)
                {
                    ForumUtils.DeleteTopicCacheFile(topic.Tid);
                }
            }
            else
            {
                AddLinkCss(BaseConfigs.GetForumPath + "templates/" + templatepath + "/editor.css", "css");
            }
        }
Ejemplo n.º 19
0
        protected override void ShowPage()
        {
            pagetitle = "用户控制面板";

            creditstax = Scoresets.GetCreditsTax();

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

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

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

                if (Utils.MD5(DNTRequest.GetString("password")) != password)
                {
                    AddErrLine("密码错误");
                    return;
                }

                int paynum = DNTRequest.GetInt("paynum", 0);
                if (paynum <= 0)
                {
                    AddErrLine("数量必须是大于等于0的整数");
                    return;
                }

                int fromto = Discuz.Forum.Users.GetUserID(DNTRequest.GetString("fromto").Trim());
                if (fromto == -1)
                {
                    AddErrLine("指定的转帐接受人不存在");
                    return;
                }

                int extcredits = DNTRequest.GetInt("extcredits", 0);
                if (extcredits < 1 || extcredits > 8)
                {
                    AddErrLine("请正确选择要转帐的金币类型!");
                    return;
                }

                //对转帐后的金币增减进行修改设置
                UserExtcreditsInfo extcreditsinfo = Scoresets.GetScoreSet(extcredits);
                if (extcreditsinfo.Name.Trim() == "")
                {
                    AddErrLine("错误的输入!");
                    return;
                }


                //UserInfo __userinfo = Discuz.Forum.Users.GetUserInfo(userid);
                if ((Discuz.Forum.Users.GetUserExtCredits(userid, extcredits) - paynum) < Scoresets.GetTransferMinCredits())
                {
                    AddErrLine(string.Format("抱歉, 您的 \"{0}\" 不足.系统当前规定转帐余额不得小于{1}", extcreditsinfo.Name, Scoresets.GetTransferMinCredits().ToString()));
                    return;
                }

                //计算并更新2个扩展金币的新值
                float topaynum = (float)Math.Round(paynum * (1 - creditstax), 2);
                Discuz.Forum.Users.UpdateUserExtCredits(userid, extcredits, paynum * -1);
                Discuz.Forum.Users.UpdateUserExtCredits(fromto, extcredits, topaynum);
                CreditsLogs.AddCreditsLog(userid, fromto, extcredits, extcredits, paynum, topaynum, Utils.GetDateTime(),
                                          2);

                SetUrl("usercpcreaditstransferlog.aspx");
                SetMetaRefresh();
                SetShowBackLink(false);
                AddMsgLine("金币转帐完毕, 正在返回金币兑换与转帐记录");
            }

            score             = Scoresets.GetValidScoreName();
            extcreditspaylist = Scoresets.GetScorePaySet(1);
        }
Ejemplo n.º 20
0
        private User CreateUser(string userName, string nickname, string email, string birthday)
        {
            var userInfo = new User();

            userInfo.Name          = userName;
            userInfo.Email         = email;
            userInfo.Bday          = birthday;
            userInfo.NickName      = nickname;
            userInfo.Password      = Utils.MD5(ForumUtils.CreateAuthStr(16));
            userInfo.Secques       = "";
            userInfo.Gender        = DNTRequest.GetInt("gender", 0);
            userInfo.AdminID       = 0;
            userInfo.GroupExpiry   = 0;
            userInfo.ExtGroupIds   = "";
            userInfo.RegIP         = userInfo.LastIP = WebHelper.UserHost;
            userInfo.JoinDate      = userInfo.LastVisit = userInfo.LastActivity = userInfo.LastPost = DateTime.Now;
            userInfo.LastPostID    = 0;
            userInfo.LastPostTitle = "";
            userInfo.Posts         = 0;
            userInfo.DigestPosts   = 0;
            userInfo.OLTime        = 0;
            userInfo.PageViews     = 0;
            userInfo.Credits       = 0;
            userInfo.ExtCredits1   = Scoresets.GetScoreSet(1).Init;
            userInfo.ExtCredits2   = Scoresets.GetScoreSet(2).Init;
            userInfo.ExtCredits3   = Scoresets.GetScoreSet(3).Init;
            userInfo.ExtCredits4   = Scoresets.GetScoreSet(4).Init;
            userInfo.ExtCredits5   = Scoresets.GetScoreSet(5).Init;
            userInfo.ExtCredits6   = Scoresets.GetScoreSet(6).Init;
            userInfo.ExtCredits7   = Scoresets.GetScoreSet(7).Init;
            userInfo.ExtCredits8   = Scoresets.GetScoreSet(8).Init;
            userInfo.Sigstatus     = ((DNTRequest.GetInt("sigstatus", 1) != 0) ? 1 : 0);
            userInfo.Tpp           = DNTRequest.GetInt("tpp", 0);
            userInfo.Ppp           = DNTRequest.GetInt("ppp", 0);
            userInfo.TemplateID    = DNTRequest.GetInt("templateid", 0);
            userInfo.Pmsound       = DNTRequest.GetInt("pmsound", 0);
            userInfo.ShowEmail     = DNTRequest.GetInt("showemail", 0) != 0;
            userInfo.Salt          = "";
            int newsletter = (this.config.Regadvance == 0) ? 3 : DNTRequest.GetInt("receivesetting", 3);

            //userInfo.Newsletter = (ReceivePMSettingType)newsletter;
            userInfo.NewsLetter  = newsletter;
            userInfo.Invisible   = DNTRequest.GetInt("invisible", 0) != 0;
            userInfo.Newpm       = ((this.config.Welcomemsg == 1) ? 1 : 0) != 0;
            userInfo.AccessMasks = DNTRequest.GetInt("accessmasks", 0);

            var uf = userInfo.Field;

            uf.Medals       = "";
            uf.Website      = DNTRequest.GetHtmlEncodeString("website");
            uf.Icq          = DNTRequest.GetHtmlEncodeString("icq");
            uf.qq           = DNTRequest.GetHtmlEncodeString("qq");
            uf.Yahoo        = DNTRequest.GetHtmlEncodeString("yahoo");
            uf.Msn          = DNTRequest.GetHtmlEncodeString("msn");
            uf.Skype        = DNTRequest.GetHtmlEncodeString("skype");
            uf.Location     = DNTRequest.GetHtmlEncodeString("location");
            uf.Customstatus = usergroupinfo.AllowCstatus ? DNTRequest.GetHtmlEncodeString("customstatus") : "";
            uf.Bio          = ForumUtils.BanWordFilter(DNTRequest.GetString("bio"));
            uf.Signature    = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("signature")));
            uf.Sightml      = UBB.UBBToHTML(new PostpramsInfo
            {
                Usergroupid        = this.usergroupid,
                Attachimgpost      = this.config.Attachimgpost,
                Showattachmentpath = this.config.Showattachmentpath,
                Hide                   = 0,
                Price                  = 0,
                Sdetail                = uf.Signature,
                Smileyoff              = 1,
                BBCode                 = this.usergroupinfo.AllowSigbbCode,
                Parseurloff            = 1,
                Showimages             = this.usergroupinfo.AllowSigimgCode ? 1 : 0,
                Allowhtml              = 0,
                Smiliesinfo            = Smilies.GetSmiliesListWithInfo(),
                Customeditorbuttoninfo = Editors.GetCustomEditButtonListWithInfo(),
                Smiliesmax             = this.config.Smiliesmax
            });
            uf.AuthTime = DateTime.Now;
            uf.RealName = DNTRequest.GetString("realname");
            uf.Idcard   = DNTRequest.GetString("idcard");
            uf.Mobile   = DNTRequest.GetString("mobile");
            uf.Phone    = DNTRequest.GetString("phone");
            if (this.config.Regverify == 2)
            {
                uf.Authstr       = DNTRequest.GetString("website");
                userInfo.GroupID = 8;
                uf.Authflag      = 1;
            }
            else
            {
                uf.Authstr       = "";
                uf.Authflag      = 0;
                userInfo.GroupID = CreditsFacade.GetCreditsUserGroupId(0f).ID;
            }
            //userInfo.ID = Users.CreateUser(userInfo);
            userInfo.Save();
            return(userInfo);
        }
Ejemplo n.º 21
0
        protected override void ShowPage()
        {
            topictitle = "";
            forumnav   = "";

            ////加载帖内广告
            //inpostad = Advertisements.GetInPostAd("", fid, templatepath, postlist.Count > ppp ? ppp : postlist.Count);

            //AdminGroupInfo admininfo = AdminGroups.GetAdminGroupInfo(useradminid);

            showpayments = DNTRequest.GetInt("showpayments", 0);
            buyit        = DNTRequest.GetInt("buyit", 0);
            topicid      = DNTRequest.GetInt("topicid", -1);
            // 如果主题ID非数字
            if (topicid == -1)
            {
                AddErrLine(WRONG_TOPIC);
                return;
            }

            // 获取该主题的信息
            TopicInfo topic = Topics.GetTopicInfo(topicid);

            // 如果该主题不存在
            if (topic == null)
            {
                AddErrLine(NOT_EXIST_TOPIC);
                return;
            }

            if (topic.Posterid == userid)
            {
                HttpContext.Current.Response.Redirect(base.ShowTopicAspxRewrite(topic.Tid, 0));
                return;
            }

            if (topic.Price <= 0)
            {
                HttpContext.Current.Response.Redirect(base.ShowTopicAspxRewrite(topic.Tid, 0));
                return;
            }

            topictitle = topic.Title.Trim();
            topicprice = topic.Price;
            poster     = topic.Poster;
            posterid   = topic.Posterid;
            pagetitle  = topictitle.Trim();
            forumid    = topic.Fid;
            ForumInfo forum = Forums.GetForumInfo(forumid);

            forumname = forum.Name.Trim();
            forumnav  = ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname);

            //判断是否为回复可见帖, price=0为非购买可见(正常), price>0 为购买可见, price=-1为购买可见但当前用户已购买
            price = 0;
            if (topic.Price > 0)
            {
                price = topic.Price;
                if (PaymentLogs.IsBuyer(topicid, userid) || (Utils.StrDateDiffHours(topic.Postdatetime, Scoresets.GetMaxChargeSpan()) > 0 && Scoresets.GetMaxChargeSpan() != 0))//判断当前用户是否已经购买
                {
                    price = -1;
                }
            }

            if (useradminid != 0)
            {
                ismoder = Moderators.IsModer(useradminid, userid, forumid) ? 1 : 0;
            }

            if (topic.Readperm > usergroupinfo.Readaccess && topic.Posterid != userid && useradminid != 1 &&
                ismoder != 1)
            {
                AddErrLine(string.Format("本主题阅读权限为: {0}, 您当前的身份 \"{1}\" 阅读权限不够", topic.Readperm.ToString(), usergroupinfo.Grouptitle));
                return;
            }

            if (topic.Displayorder == -1)
            {
                AddErrLine("此主题已被删除!");
                return;
            }

            if (topic.Displayorder == -2)
            {
                AddErrLine("此主题未经审核!");
                return;
            }

            if (forum.Password != "" &&
                Utils.MD5(forum.Password) != ForumUtils.GetCookie("forum" + forumid.ToString() + "password"))
            {
                AddErrLine("本版块被管理员设置了密码");
                //SetBackLink("showforum-" + forumid.ToString() + config.Extname);
                HttpContext.Current.Response.Redirect("showforum-" + forumid.ToString() + config.Extname, true);
                return;
            }

            if (!Forums.AllowViewByUserID(forum.Permuserlist, userid))        //判断当前用户在当前版块浏览权限
            {
                if (forum.Viewperm == null || forum.Viewperm == string.Empty) //当板块权限为空时,按照用户组权限
                {
                    if (usergroupinfo.Allowvisit != 1)
                    {
                        AddErrLine("您当前的身份 \"" + usergroupinfo.Grouptitle + "\" 没有浏览该版块的权限");
                        return;
                    }
                }
                else //当板块权限不为空,按照板块权限
                {
                    if (!Forums.AllowView(forum.Viewperm, usergroupid))
                    {
                        AddErrLine("您没有浏览该版块的权限");
                        return;
                    }
                }
            }

            userextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetCreditsTrans());
            maxincpertopic     = Scoresets.GetMaxIncPerTopic();
            maxchargespan      = Scoresets.GetMaxChargeSpan();
            creditstax         = Scoresets.GetCreditsTax() * 100;

            netamount = topicprice - topicprice * creditstax / 100;
            if (topicprice > maxincpertopic)
            {
                netamount = maxincpertopic - maxincpertopic * creditstax / 100;
            }

            if (price != -1)
            {
                IDataReader reader = Users.GetUserInfoToReader(userid);
                if (reader == null)
                {
                    AddErrLine(NO_PERMISSION);
                    return;
                }

                if (!reader.Read())
                {
                    AddErrLine(NO_PERMISSION);
                    reader.Close();
                    return;
                }

                if (Utils.StrToFloat(reader["extcredits" + Scoresets.GetCreditsTrans().ToString()], 0) < topic.Price)
                {
                    AddErrLine(string.Format(NOT_ENOUGH_MONEY_TO, Utils.StrToFloat(reader["extcredits" + Scoresets.GetCreditsTrans().ToString()], 0), topic.Price));
                    reader.Close();

                    return;
                }

                userlastprice = Utils.StrToFloat(reader["extcredits" + Scoresets.GetCreditsTrans().ToString()], 0) - topic.Price;
                reader.Close();
            }



            //如果不是提交...
            if (!ispost)
            {
                buyers = PaymentLogs.GetPaymentLogByTidCount(topic.Tid);

                //显示购买信息列表
                if (showpayments == 1)
                {
                    //得到当前用户请求的页数
                    pageid = DNTRequest.GetInt("page", 1);
                    //获取主题总数
                    //获取总页数
                    pagecount = buyers % pagesize == 0 ? buyers / pagesize : buyers / pagesize + 1;
                    if (pagecount == 0)
                    {
                        pagecount = 1;
                    }
                    //修正请求页数中可能的错误
                    if (pageid < 1)
                    {
                        pageid = 1;
                    }
                    if (pageid > pagecount)
                    {
                        pageid = pagecount;
                    }

                    //获取收入记录并分页显示
                    paymentloglist = PaymentLogs.GetPaymentLogByTid(pagesize, pageid, topic.Tid);
                }

                //判断是否为回复可见帖, hide=0为非回复可见(正常), hide>0为回复可见, hide=-1为回复可见但当前用户已回复
                int hide = 0;
                if (topic.Hide == 1)
                {
                    hide = topic.Hide;
                    if (Posts.IsReplier(topicid, userid))
                    {
                        hide = -1;
                    }
                }

                PostpramsInfo _postpramsinfo = new PostpramsInfo();
                _postpramsinfo.Fid                = forum.Fid;
                _postpramsinfo.Tid                = topicid;
                _postpramsinfo.Jammer             = forum.Jammer;
                _postpramsinfo.Pagesize           = 5;
                _postpramsinfo.Pageindex          = 1;
                _postpramsinfo.Getattachperm      = forum.Getattachperm;
                _postpramsinfo.Usergroupid        = usergroupid;
                _postpramsinfo.Attachimgpost      = config.Attachimgpost;
                _postpramsinfo.Showattachmentpath = config.Showattachmentpath;
                _postpramsinfo.Hide               = hide;
                _postpramsinfo.Price              = price;
                _postpramsinfo.Ubbmode            = false;

                _postpramsinfo.Showimages             = forum.Allowimgcode;
                _postpramsinfo.Smiliesinfo            = Smilies.GetSmiliesListWithInfo();
                _postpramsinfo.Customeditorbuttoninfo = Editors.GetCustomEditButtonListWithInfo();
                _postpramsinfo.Smiliesmax             = config.Smiliesmax;
                _postpramsinfo.Bbcodemode             = config.Bbcodemode;

                lastpostlist = Posts.GetLastPostList(_postpramsinfo);
            }
            else
            {
                int reval = PaymentLogs.BuyTopic(userid, topic.Tid, topic.Posterid, topic.Price, netamount);
                if (reval > 0)
                {
                    SetUrl(base.ShowTopicAspxRewrite(topic.Tid, 0));

                    SetMetaRefresh();
                    SetShowBackLink(false);
                    AddMsgLine(PURCHASE_SUCCESS);
                    return;
                }
                else
                {
                    SetBackLink(base.ShowForumAspxRewrite(topic.Fid, 0));

                    if (reval == -1)
                    {
                        AddErrLine(NOT_ENOUGH_MONEY);
                        return;
                    }
                    else if (reval == -2)
                    {
                        AddErrLine(NO_PERMISSION);
                        return;
                    }
                    else
                    {
                        AddErrLine(UNKNOWN_REASON);
                        return;
                    }
                }
            }
        }
Ejemplo n.º 22
0
        public void LoadScoreInf(string fid, string fieldname)
        {
            DataRow dataRow = Scoresets.GetScoreSet().Rows[0];

            if (dataRow[2].ToString().Trim() != "")
            {
                this.extcredits1name.Text = dataRow[2].ToString().Trim();
            }
            else
            {
                if (!this.IsValidScoreName(1))
                {
                    this.extcredits1.Enabled = false;
                }
            }
            if (dataRow[3].ToString().Trim() != "")
            {
                this.extcredits2name.Text = dataRow[3].ToString().Trim();
            }
            else
            {
                if (!this.IsValidScoreName(2))
                {
                    this.extcredits2.Enabled = false;
                }
            }
            if (dataRow[4].ToString().Trim() != "")
            {
                this.extcredits3name.Text = dataRow[4].ToString().Trim();
            }
            else
            {
                if (!this.IsValidScoreName(3))
                {
                    this.extcredits3.Enabled = false;
                }
            }
            if (dataRow[5].ToString().Trim() != "")
            {
                this.extcredits4name.Text = dataRow[5].ToString().Trim();
            }
            else
            {
                if (!this.IsValidScoreName(4))
                {
                    this.extcredits4.Enabled = false;
                }
            }
            if (dataRow[6].ToString().Trim() != "")
            {
                this.extcredits5name.Text = dataRow[6].ToString().Trim();
            }
            else
            {
                if (!this.IsValidScoreName(5))
                {
                    this.extcredits5.Enabled = false;
                }
            }
            if (dataRow[7].ToString().Trim() != "")
            {
                this.extcredits6name.Text = dataRow[7].ToString().Trim();
            }
            else
            {
                if (!this.IsValidScoreName(6))
                {
                    this.extcredits6.Enabled = false;
                }
            }
            if (dataRow[8].ToString().Trim() != "")
            {
                this.extcredits7name.Text = dataRow[8].ToString().Trim();
            }
            else
            {
                if (!this.IsValidScoreName(7))
                {
                    this.extcredits7.Enabled = false;
                }
            }
            if (dataRow[9].ToString().Trim() != "")
            {
                this.extcredits8name.Text = dataRow[9].ToString().Trim();
            }
            else
            {
                if (!this.IsValidScoreName(8))
                {
                    this.extcredits8.Enabled = false;
                }
            }
            this.lblScoreCalFormula.Text = Scoresets.GetScoreCalFormula();
        }
Ejemplo n.º 23
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;
            }

            //检查是否具有管理权限
            IsModer();
            int price = GetTopicPrice(topic);

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

            if (postid > 0 && Posts.GetPostInfo(topicid, postid) == null)
            {
                AddErrLine("该帖可能已被删除 " + string.Format("<a href=\"{0}\">[返回主题]</a>", ShowTopicAspxRewrite(topicid, 1)));
                return;
            }
            //将版块加入到已访问版块列表中
            ForumUtils.SetVisitedForumsCookie(forumid.ToString());

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

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

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

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

            //获取主题类型
            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 = config.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

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

            //更新页面Meta信息
            if (postlist != null && postlist.Count > 0)
            {
                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);

            //如果是从
            if (DNTRequest.GetInt("fromfav", 0) > 0)
            {
                Favorites.UpdateUserFavoriteViewTime(userid, topicid);
            }
            //UserCredits.UpdateUserCredits(userInfo);此方法与后台积分设置中的条目不匹配,故注释
        }
Ejemplo n.º 24
0
        /// <summary>
        /// 注册用户
        /// </summary>
        /// <returns></returns>
        public string Register()
        {
            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,email"))
            {
                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();
            string email    = GetParam("email").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_ALREADY_EXIST;
                return(returnStr);
            }

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

            if (!CheckEmail(email))
            {
                ErrorCode = (int)ErrorType.API_EC_EMAIL;
                return(returnStr);
            }

            UserInfo userInfo = new UserInfo();

            userInfo.Username      = username;
            userInfo.Nickname      = string.Empty;
            userInfo.Password      = isMD5Passwd ? password : Utils.MD5(password);
            userInfo.Secques       = string.Empty;
            userInfo.Gender        = 0;
            userInfo.Adminid       = 0;
            userInfo.Groupexpiry   = 0;
            userInfo.Extgroupids   = "";
            userInfo.Regip         = DNTRequest.GetIP();
            userInfo.Joindate      = Utils.GetDateTime();
            userInfo.Lastip        = DNTRequest.GetIP();
            userInfo.Lastvisit     = Utils.GetDateTime();
            userInfo.Lastactivity  = Utils.GetDateTime();
            userInfo.Lastpost      = Utils.GetDateTime();
            userInfo.Lastpostid    = 0;
            userInfo.Lastposttitle = "";
            userInfo.Posts         = 0;
            userInfo.Digestposts   = 0;
            userInfo.Oltime        = 0;
            userInfo.Pageviews     = 0;
            userInfo.Credits       = 0;
            userInfo.Extcredits1   = Scoresets.GetScoreSet(1).Init;
            userInfo.Extcredits2   = Scoresets.GetScoreSet(2).Init;
            userInfo.Extcredits3   = Scoresets.GetScoreSet(3).Init;
            userInfo.Extcredits4   = Scoresets.GetScoreSet(4).Init;
            userInfo.Extcredits5   = Scoresets.GetScoreSet(5).Init;
            userInfo.Extcredits6   = Scoresets.GetScoreSet(6).Init;
            userInfo.Extcredits7   = Scoresets.GetScoreSet(7).Init;
            userInfo.Extcredits8   = Scoresets.GetScoreSet(8).Init;
            userInfo.Email         = email;
            userInfo.Bday          = string.Empty;
            userInfo.Sigstatus     = 0;

            userInfo.Tpp        = 0;
            userInfo.Ppp        = 0;
            userInfo.Templateid = 0;
            userInfo.Pmsound    = 0;
            userInfo.Showemail  = 0;
            userInfo.Salt       = "0";
            int receivepmsetting = Config.Regadvance == 0 ? 7 : 1;

            userInfo.Newsletter   = (ReceivePMSettingType)receivepmsetting;
            userInfo.Invisible    = 0;
            userInfo.Newpm        = Config.Welcomemsg == 1 ? 1 : 0;
            userInfo.Medals       = "";
            userInfo.Accessmasks  = 0;
            userInfo.Website      = string.Empty;
            userInfo.Icq          = string.Empty;
            userInfo.Qq           = string.Empty;
            userInfo.Yahoo        = string.Empty;
            userInfo.Msn          = string.Empty;
            userInfo.Skype        = string.Empty;
            userInfo.Location     = string.Empty;
            userInfo.Customstatus = string.Empty;
            userInfo.Bio          = string.Empty;
            userInfo.Signature    = string.Empty;
            userInfo.Sightml      = string.Empty;
            userInfo.Authtime     = Utils.GetDateTime();

            //邮箱激活链接验证
            if (Config.Regverify == 1)
            {
                userInfo.Authstr  = ForumUtils.CreateAuthStr(20);
                userInfo.Authflag = 1;
                userInfo.Groupid  = 8;
                Emails.DiscuzSmtpMail(username, email, string.Empty, userInfo.Authstr);
            }
            //系统管理员进行后台验证
            else if (Config.Regverify == 2)
            {
                userInfo.Authstr  = string.Empty;
                userInfo.Groupid  = 8;
                userInfo.Authflag = 1;
            }
            else
            {
                userInfo.Authstr  = "";
                userInfo.Authflag = 0;
                userInfo.Groupid  = UserCredits.GetCreditsUserGroupId(0).Groupid;
            }
            userInfo.Realname = string.Empty;
            userInfo.Idcard   = string.Empty;
            userInfo.Mobile   = string.Empty;
            userInfo.Phone    = string.Empty;

            if (Config.Passwordmode > 1 && PasswordModeProvider.GetInstance() != null)
            {
                userInfo.Uid = PasswordModeProvider.GetInstance().CreateUserInfo(userInfo);
            }
            else
            {
                userInfo.Uid = Discuz.Forum.Users.CreateUser(userInfo);
            }

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

            Statistics.ReSetStatisticsCache();

            //信息同步通知不会发向当前请求接口的应用程序,所以此处应保留,以支持论坛向其他关联应用程序发送通知
            Sync.UserRegister(userInfo.Uid, userInfo.Username, userInfo.Password, ApiKey);

            UserCredits.UpdateUserCredits(userInfo.Uid);

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

            RegisterResponse rr = new RegisterResponse();

            rr.Uid = userInfo.Uid;

            return(SerializationHelper.Serialize(rr));
        }
Ejemplo n.º 25
0
        protected override void ShowPage()
        {
            pagetitle = "用户控制面板";

            if (!IsLogin())
            {
                return;
            }

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

                bool isPasswordError = true;

                switch (config.Passwordmode)
                {
                case 1:    //动网兼容模式
                {
                    isPasswordError = Utils.MD5(DNTRequest.GetString("password")) != password;
                    break;
                }

                case 0:    //默认模式
                {
                    isPasswordError = Utils.MD5(DNTRequest.GetString("password")) != password;
                    break;
                }

                default:     //第三方加密验证模式
                {
                    if (PasswordModeProvider.GetInstance() != null)
                    {
                        isPasswordError = !PasswordModeProvider.GetInstance().CheckPassword(user, DNTRequest.GetString("password"));
                    }
                    break;
                }
                }
                if (isPasswordError)
                {
                    AddErrLine("密码错误");
                    return;
                }

                int paynum = DNTRequest.GetInt("paynum", 0);
                if (paynum <= 0)
                {
                    AddErrLine("数量必须是大于等于0的整数");
                    return;
                }
                int fromto = Users.GetUserId(DNTRequest.GetString("fromto").Trim());
                if (fromto == -1)
                {
                    AddErrLine("指定的转帐接受人不存在");
                    return;
                }
                int extcredits = DNTRequest.GetInt("extcredits", 0);
                if (extcredits < 1 || extcredits > 8)
                {
                    AddErrLine("请正确选择要转帐的积分类型!");
                    return;
                }
                //对转帐后的积分增减进行修改设置
                string extcreditsName = Scoresets.GetScoreSet(extcredits).Name.Trim();
                if (Utils.StrIsNullOrEmpty(extcreditsName))
                {
                    AddErrLine("错误的输入!");
                    return;
                }
                if ((Users.GetUserExtCredits(userid, extcredits) - paynum) < Scoresets.GetTransferMinCredits())
                {
                    AddErrLine(string.Format("抱歉, 您的 \"{0}\" 不足.系统当前规定转帐余额不得小于{1}", extcreditsName, Scoresets.GetTransferMinCredits().ToString()));
                    return;
                }

                //计算并更新2个扩展积分的新值
                float toPayNum = (float)Math.Round(paynum * (1 - creditstax), 2);
                Users.UpdateUserExtCredits(userid, extcredits, paynum * -1);
                Users.UpdateUserExtCredits(fromto, extcredits, toPayNum);
                CreditsLogs.AddCreditsLog(userid, fromto, extcredits, extcredits, paynum, toPayNum, Utils.GetDateTime(), 2);

                SetUrl("usercpcreaditstransferlog.aspx");
                SetMetaRefresh();
                SetShowBackLink(false);
                AddMsgLine("积分转帐完毕, 正在返回积分兑换与转帐记录");
            }
        }
Ejemplo n.º 26
0
        protected override void ShowPage()
        {
            if (this.oluserinfo.GroupID == 4)
            {
                base.AddErrLine("你所在的用户组,为禁止发言");
                return;
            }
            if (this.userid > 0)
            {
                this.userinfo = BBX.Entity.User.FindByID(this.userid);
            }
            if (HttpContext.Current.Request.RawUrl.Contains("javascript:"))
            {
                base.AddErrLine("非法的链接");
                return;
            }
            this.forum = XForum.FindByID(forumid);
            if (this.forum == null || this.forum.Layer == 0)
            {
                this.forum          = new XForum();
                this.allowposttopic = false;
                base.AddErrLine("错误的论坛ID");
                return;
            }
            this.pagetitle = Utils.RemoveHtml(this.forum.Name);
            this.enabletag = config.Enabletag && this.forum.AllowTag;
            if (this.forum.ApplytopicType == 1)
            {
                this.topictypeselectoptions = Forums.GetCurrentTopicTypesOption(this.forum.Fid, this.forum.TopicTypes);
            }
            if (!String.IsNullOrEmpty(this.forum.Password) && Utils.MD5(this.forum.Password) != ForumUtils.GetCookie("forum" + this.forumid + "password"))
            {
                base.AddErrLine("本版块被管理员设置了密码");
                base.SetBackLink(base.ShowForumAspxRewrite(this.forumid, 0));
                return;
            }
            this.needaudit = UserAuthority.NeedAudit(forum.Fid, forum.Modnewposts, this.useradminid, this.userid, this.usergroupinfo);
            this.smileyoff = forum.AllowSmilies ? 0 : 1;
            this.bbcodeoff = ((this.forum.Allowbbcode == 1 && this.usergroupinfo.AllowCusbbCode) ? 0 : 1);
            //this.allowimg = this.forum.Allowimgcode;
            this.customeditbuttons = Caches.GetCustomEditButtonList();
            if (!UserAuthority.VisitAuthority(this.forum, this.usergroupinfo, this.userid, ref this.msg))
            {
                base.AddErrLine(this.msg);
                this.needlogin = true;
                return;
            }
            if (!UserAuthority.PostAuthority(this.forum, this.usergroupinfo, this.userid, ref this.msg))
            {
                base.AddErrLine(this.msg);
                this.needlogin = true;
                return;
            }
            //string allowAttachmentType = Attachments.GetAllowAttachmentType(this.usergroupinfo, this.forum);
            this.attachextensions       = AttachType.GetAttachmentTypeArray(usergroupinfo, this.forum);
            this.attachextensionsnosize = AttachType.GetAttachmentTypeString(usergroupinfo, this.forum);
            int num = (this.userid > 0) ? Attachment.GetUploadFileSizeByuserid(this.userid) : 0;

            this.attachsize          = this.usergroupinfo.MaxSizeperday - num;
            this.canpostattach       = UserAuthority.PostAttachAuthority(this.forum, this.usergroupinfo, this.userid, ref this.msg);
            this.canhtmltitle        = this.usergroupinfo.AllowHtmlTitle;
            this.creditstrans        = Scoresets.GetTopicAttachCreditsTrans();
            this.userextcreditsinfo  = Scoresets.GetScoreSet(this.creditstrans);
            this.bonusextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetBonusCreditsTrans());
            if (this.forum.AllowSpecialOnly && !Utils.InArray(this.type, "poll,bonus,debate"))
            {
                base.AddErrLine(string.Format("当前版块 \"{0}\" 不允许发表普通主题", this.forum.Name));
                return;
            }
            if (!UserAuthority.PostSpecialAuthority(this.forum, this.type, ref this.msg))
            {
                base.AddErrLine(this.msg);
                return;
            }
            if (!UserAuthority.PostSpecialAuthority(this.usergroupinfo, this.type, ref this.msg))
            {
                base.AddErrLine(this.msg);
                this.needlogin = true;
                return;
            }
            if (this.type == "bonus")
            {
                int bonusCreditsTrans = Scoresets.GetBonusCreditsTrans();
                if (bonusCreditsTrans <= 0)
                {
                    base.AddErrLine("系统未设置\"交易积分设置\", 无法判断当前要使用的(扩展)积分字段, 暂时无法发布悬赏");
                    return;
                }
                this.mybonustranscredits = Users.GetUserExtCredits(this.userid, bonusCreditsTrans);
            }
            this.userGroupInfoList.Sort((x, y) => x.Readaccess - y.Readaccess + (y.ID - x.ID));
            var adminGroupInfo = AdminGroup.FindByID(this.usergroupid);

            this.disablepost = adminGroupInfo != null ? adminGroupInfo.DisablePostctrl : this.usergroupinfo.DisablePeriodctrl;
            if (this.ispost)
            {
                if (!UserAuthority.CheckPostTimeSpan(this.usergroupinfo, adminGroupInfo, this.oluserinfo, this.userinfo, ref this.msg))
                {
                    base.AddErrLine(this.msg);
                    return;
                }
                base.SetBackLink(string.Format("posttopic.aspx?forumid={0}&restore=1&type={1}", this.forumid, this.type));
                ForumUtils.WriteCookie("postmessage", this.postmessage);
                this.NormalValidate(adminGroupInfo, this.postmessage, this.userinfo);
                if (base.IsErr())
                {
                    return;
                }
                if (ForumUtils.IsPostFile())
                {
                    if (Utils.StrIsNullOrEmpty(AttachType.GetAttachmentTypeArray(usergroupinfo, forum)))
                    {
                        base.AddErrLine("系统不允许上传附件");
                    }
                    if (!UserAuthority.PostAttachAuthority(this.forum, this.usergroupinfo, this.userid, ref this.msg))
                    {
                        base.AddErrLine(this.msg);
                    }
                }
                int  topicprice = 0;
                bool isbonus    = this.type == "bonus";
                this.ValidateBonus(ref topicprice, ref isbonus);
                this.ValidatePollAndDebate();
                if (base.IsErr())
                {
                    return;
                }
                if (ForumUtils.IsHidePost(this.postmessage))
                {
                    int arg_5B2_0 = this.usergroupinfo.AllowHideCode ? 1 : 0;
                }
                var topicInfo = this.CreateTopic(adminGroupInfo, this.postmessage, isbonus, topicprice);
                if (base.IsErr())
                {
                    return;
                }
                //var postInfo = this.CreatePost(topicInfo);
                var postInfo = Post.FindByID(topicInfo.LastPostID);
                //if (base.IsErr())
                //{
                //	return;
                //}
                var stringBuilder = new StringBuilder();
                //AttachmentInfo[] array = null;
                string formString = DNTRequest.GetFormString("attachid");
                if (!string.IsNullOrEmpty(formString))
                {
                    var array = Attachments.GetNoUsedAttachmentArray(this.userid, formString);
                    Attachments.UpdateAttachment(array, topicInfo.ID, postInfo.ID, postInfo, ref stringBuilder, this.userid, this.config, this.usergroupinfo);
                }
                Online.UpdateAction(this.olid, UserAction.PostTopic, this.forumid, this.forum.Name, -1, "");
                if (this.isbindconnect && this.feedstatus)
                {
                    // 推送到QQ空间和微博
                    //PushFeed pushFeed = new PushFeed();
                    //pushFeed.TopicPushFeed(topicInfo, postInfo, array, this.feedstatus);
                }
                if (stringBuilder.Length > 0)
                {
                    base.SetUrl(base.ShowTopicAspxRewrite(topicInfo.ID, 0));
                    base.SetMetaRefresh(5);
                    base.SetShowBackLink(true);
                    if (this.infloat == 1)
                    {
                        base.AddErrLine(stringBuilder.ToString());
                        return;
                    }
                    stringBuilder.Insert(0, "<table cellspacing=\"0\" cellpadding=\"4\" border=\"0\"><tr><td colspan=2 align=\"left\"><span class=\"bold\"><nobr>发表主题成功,但图片/附件上传出现问题:</nobr></span><br /></td></tr>");
                    base.AddMsgLine(stringBuilder.Append("</table>").ToString());
                }
                else
                {
                    base.SetShowBackLink(false);
                    if (this.useradminid != 1 && (UserAuthority.NeedAudit(forum.Fid, forum.Modnewposts, this.useradminid, this.userid, this.usergroupinfo) || topicInfo.DisplayOrder == -2))
                    {
                        ForumUtils.WriteCookie("postmessage", "");
                        this.SetLastPostedForumCookie();
                        base.SetUrl(base.ShowForumAspxRewrite(this.forumid, this.forumpageid));
                        base.SetMetaRefresh();
                        base.AddMsgLine("发表主题成功, 但需要经过审核才可以显示. 返回该版块");
                    }
                    else
                    {
                        this.PostTopicSucceed(this.forum, topicInfo);
                    }
                }
                if (this.needlogin && this.userid > 0)
                {
                    this.needlogin = false;
                    return;
                }
            }
            else
            {
                base.AddLinkCss(BaseConfigs.GetForumPath + "templates/" + this.templatepath + "/editor.css", "css");
            }
        }
Ejemplo n.º 27
0
        public void LoadScoreInf(string fid, string fieldname)
        {
            #region 加载积分信息

            DataRow dr = Scoresets.GetScoreSet().Rows[0];
            if (dr[2].ToString().Trim() != "")
            {
                extcredits1name.Text = dr[2].ToString().Trim();
            }
            else
            {
                if (!IsValidScoreName(1))
                {
                    extcredits1.Enabled = false;
                }
            }

            if (dr[3].ToString().Trim() != "")
            {
                extcredits2name.Text = dr[3].ToString().Trim();
            }
            else
            {
                if (!IsValidScoreName(2))
                {
                    extcredits2.Enabled = false;
                }
            }


            if (dr[4].ToString().Trim() != "")
            {
                extcredits3name.Text = dr[4].ToString().Trim();
            }
            else
            {
                if (!IsValidScoreName(3))
                {
                    extcredits3.Enabled = false;
                }
            }


            if (dr[5].ToString().Trim() != "")
            {
                extcredits4name.Text = dr[5].ToString().Trim();
            }
            else
            {
                if (!IsValidScoreName(4))
                {
                    extcredits4.Enabled = false;
                }
            }


            if (dr[6].ToString().Trim() != "")
            {
                extcredits5name.Text = dr[6].ToString().Trim();
            }
            else
            {
                if (!IsValidScoreName(5))
                {
                    extcredits5.Enabled = false;
                }
            }


            if (dr[7].ToString().Trim() != "")
            {
                extcredits6name.Text = dr[7].ToString().Trim();
            }
            else
            {
                if (!IsValidScoreName(6))
                {
                    extcredits6.Enabled = false;
                }
            }


            if (dr[8].ToString().Trim() != "")
            {
                extcredits7name.Text = dr[8].ToString().Trim();
            }
            else
            {
                if (!IsValidScoreName(7))
                {
                    extcredits7.Enabled = false;
                }
            }


            if (dr[9].ToString().Trim() != "")
            {
                extcredits8name.Text = dr[9].ToString().Trim();
            }
            else
            {
                if (!IsValidScoreName(8))
                {
                    extcredits8.Enabled = false;
                }
            }

            lblScoreCalFormula.Text = Scoresets.GetScoreCalFormula();
            #endregion
        }
Ejemplo n.º 28
0
 protected override void ShowPage()
 {
     this.pagetitle = "用户控制面板";
     if (!base.IsLogin())
     {
         return;
     }
     if (DNTRequest.IsPost())
     {
         if (ForumUtils.IsCrossSitePost())
         {
             base.AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。");
             return;
         }
         bool flag = true;
         //switch (this.config.Passwordmode)
         //{
         //    case 0:
         flag = Utils.MD5(DNTRequest.GetString("password")).EqualIgnoreCase(this.password);
         //        break;
         //    case 1:
         //        flag = (Utils.MD5(DNTRequest.GetString("password")) != this.password);
         //        break;
         //    default:
         //        if (PasswordModeProvider.GetInstance() != null)
         //        {
         //            flag = !PasswordModeProvider.GetInstance().CheckPassword(this.user, DNTRequest.GetString("password"));
         //        }
         //        break;
         //}
         if (flag)
         {
             base.AddErrLine("密码错误");
             return;
         }
         int paynum = DNTRequest.GetInt("paynum", 0);
         if (paynum <= 0)
         {
             base.AddErrLine("数量必须是大于等于0的整数");
             return;
         }
         int userId = Users.GetUserId(DNTRequest.GetString("fromto").Trim());
         if (userId <= 0)
         {
             base.AddErrLine("指定的转帐接受人不存在");
             return;
         }
         int int2 = DNTRequest.GetInt("extcredits", 0);
         if (int2 < 1 || int2 > 8)
         {
             base.AddErrLine("请正确选择要转帐的积分类型!");
             return;
         }
         string text = Scoresets.GetScoreSet(int2).Name.Trim();
         if (text.IsNullOrEmpty())
         {
             base.AddErrLine("错误的输入!");
             return;
         }
         if (Users.GetUserExtCredits(this.userid, int2) - (float)paynum < (float)Scoresets.GetTransferMinCredits())
         {
             base.AddErrLine(string.Format("抱歉, 您的 \"{0}\" 不足.系统当前规定转帐余额不得小于{1}", text, Scoresets.GetTransferMinCredits().ToString()));
             return;
         }
         var num = (Int32)Math.Round((double)((float)paynum * (1f - this.creditstax)), 2);
         BBX.Entity.User.UpdateUserExtCredits(this.userid, int2, (float)(paynum * -1));
         BBX.Entity.User.UpdateUserExtCredits(userId, int2, num);
         //CreditsLogs.AddCreditsLog(this.userid, userId, int2, int2, (float)@int, num, Utils.GetDateTime(), 2);
         CreditsLog.Add(this.userid, userId, int2, int2, paynum, num, 2);
         base.SetUrl("usercpcreaditstransferlog.aspx");
         base.SetMetaRefresh();
         base.SetShowBackLink(false);
         base.AddMsgLine("积分转帐完毕, 正在返回积分兑换与转帐记录");
     }
 }
Ejemplo n.º 29
0
        protected override void ShowPage()
        {
            GetPostAds(forumid);

            if (userid > 0 && useradminid > 0)
            {
                AdminGroupInfo admingroupinfo = AdminGroups.GetAdminGroupInfo(usergroupid);
                if (admingroupinfo != null)
                {
                    disablepostctrl = admingroupinfo.Disablepostctrl;
                }
            }

            #region 获取版块信息
            if (forumid == -1)
            {
                AddLinkRss(forumpath + "tools/rss.aspx", "最新主题");
                AddErrLine("无效的版块ID");
                return;
            }
            forum = Forums.GetForumInfo(forumid);
            if (forum == null || forum.Fid < 1)
            {
                if (config.Rssstatus == 1)
                {
                    AddLinkRss(forumpath + "tools/rss.aspx", Utils.EncodeHtml(config.Forumtitle) + " 最新主题");
                }

                AddErrLine("不存在的版块ID");
                return;
            }
            #endregion

            if (config.Rssstatus == 1)
            {
                AddLinkRss(forumpath + "tools/" + base.RssAspxRewrite(forum.Fid), Utils.EncodeHtml(forum.Name) + " 最新主题");
            }

            if (JumpUrl(forum))
            {
                return;
            }

            needaudit = UserAuthority.NeedAudit(forum, useradminid, userid, usergroupinfo);

            // 检查是否具有版主的身份
            if (useradminid > 0)
            {
                ismoder = Moderators.IsModer(useradminid, userid, forumid);
            }

            //设置搜索和排序条件
            SetSearchCondition();

            showforumlogin = IsShowForumLogin(forum);
            pagetitle      = Utils.RemoveHtml(forum.Name);
            navhomemenu    = Caches.GetForumListMenuDivCache(usergroupid, userid, config.Extname);
            forumnav       = ShowForumAspxRewrite(ForumUtils.UpdatePathListExtname(forum.Pathlist.Trim(), config.Extname).Replace("\"showforum", "\"" + forumurl + "showforum"),
                                                  forumid, pageid);
            topicextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetTopicAttachCreditsTrans());
            bonusextcreditsinfo = Scoresets.GetScoreSet(Scoresets.GetBonusCreditsTrans());

            #region 主题分类设置
            if (forum.Applytopictype == 1) //启用主题分类
            {
                topictypeselectoptions = Forums.GetCurrentTopicTypesOption(forum.Fid, forum.Topictypes);
            }

            if (forum.Viewbytopictype == 1) //允许按类别浏览
            {
                topictypeselectlink = Forums.GetCurrentTopicTypesLink(forum.Fid, forum.Topictypes, forumurl + "showforum.aspx");
            }
            #endregion

            //更新页面Meta中的keyword,description项, 提高SEO友好性
            UpdateMetaInfo(Utils.StrIsNullOrEmpty(forum.Seokeywords) ? config.Seokeywords : forum.Seokeywords,
                           Utils.StrIsNullOrEmpty(forum.Seodescription) ? forum.Description : forum.Seodescription,
                           config.Seohead);

            //设置编辑器状态
            SetEditorState();

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

            canposttopic = UserAuthority.PostAuthority(forum, usergroupinfo, userid, ref msg);
            // 如果当前用户非管理员并且论坛设定了禁止发帖时间段,当前时间如果在其中的一个时间段内,不允许用户发帖
            if (useradminid != 1 && usergroupinfo.Disableperiodctrl != 1)
            {
                string visittime = "";
                if (canposttopic && Scoresets.BetweenTime(config.Postbanperiods, out visittime))
                {
                    canposttopic = false;
                }

                isnewbie = UserAuthority.CheckNewbieSpan(userid);
            }

            //是否显示快速发主题编辑器(全局权限判定,版块权限判定,是否是游客,游客需要显示,登录用户是否允许发主题且已过新手见习期)
            if ((config.Fastpost == 1 || config.Fastpost == 3) && forum.Allowspecialonly <= 0 && (userid < 0 || (canposttopic && !isnewbie)))
            {
                canquickpost = true;
            }
            #endregion

            // 得到子版块列表
            if (forum.Subforumcount > 0)
            {
                subforumlist = Forums.GetSubForumCollection(forumid, forum.Colcount, config.Hideprivate, usergroupid, config.Moddisplay);
            }
            if (!forum.Rules.Equals(""))
            {
                forum.Rules = UBB.ParseSimpleUBB(forum.Rules);//替换版规中的UBB
            }
            //获取主题总数
            topiccount = Topics.GetTopicCount(forumid, true, condition);

            #region 设置分页及主题列表信息
            // 得到Tpp设置
            if (tpp <= 0)
            {
                tpp = config.Tpp;
            }

            // 得到Ppp设置
            if (ppp <= 0)
            {
                ppp = config.Ppp;
            }

            //修正请求页数中可能的错误
            if (pageid < 1)
            {
                pageid = 1;
            }

            int toptopicpagecount = 0;

            if (forum.Layer > 0)
            {
                //获取当前页置顶主题列表
                DataRow dr = Topics.GetTopTopicListID(forumid);
                if (dr != null && !Utils.StrIsNullOrEmpty(dr["tid"].ToString()))
                {
                    topiccount = topiccount + TypeConverter.ObjectToInt(dr["tid0Count"]);
                }

                //获取总页数
                pagecount = topiccount % tpp == 0 ? topiccount / tpp : topiccount / tpp + 1;
                if (pagecount == 0)
                {
                    pagecount = 1;
                }
                if (pageid > pagecount)
                {
                    pageid = pagecount;
                }

                if (dr != null && !Utils.StrIsNullOrEmpty(dr["tid"].ToString()))
                {
                    toptopiccount = TypeConverter.ObjectToInt(dr["tidCount"]);
                    if (toptopiccount > tpp * (pageid - 1))
                    {
                        toptopiclist      = Topics.GetTopTopicList(forumid, tpp, pageid, dr["tid"].ToString(), forum.Autoclose, forum.Topictypeprefix);
                        toptopicpagecount = toptopiccount / tpp;
                    }

                    if (toptopicpagecount >= pageid || (pageid == 1 && toptopicpagecount != toptopiccount))
                    {
                        topiclist = GetTopicInfoList(tpp - toptopiccount % tpp, pageid - toptopicpagecount, 0);
                    }
                    else
                    {
                        topiclist = GetTopicInfoList(tpp, pageid - toptopicpagecount, toptopiccount % tpp);
                    }
                }
                else
                {
                    toptopicpagecount = 0;
                    topiclist         = GetTopicInfoList(tpp, pageid, 0);
                }

                //如果topiclist为空则更新当前论坛帖数
                if (topiclist == null || topiclist.Count == 0 || topiclist.Count > topiccount)
                {
                    Forums.SetRealCurrentTopics(forum.Fid);
                }

                SetPageNumber();
                //当版块数大于一个并且当版块数量为一个时不是版块自身时显示下拉菜单
                showvisitedforumsmenu = visitedforums != null && ((visitedforums.Length == 1 && visitedforums[0].Fid != forumid) || visitedforums.Length > 1);
                SetVisitedForumsCookie();
                //保存查看版块的页数
                Utils.WriteCookie("forumpageid", pageid.ToString(), 30);

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

            #region 替换版规中的UBB
            forum.Description = UBB.ParseSimpleUBB(forum.Description);
            #endregion

            #region 更新在线信息
            OnlineUsers.UpdateAction(olid, UserAction.ShowForum.ActionID, forumid, forum.Name, -1, "");

            if ((forumtotalonline < config.Maxonlinelist && (config.Whosonlinestatus == 2 || config.Whosonlinestatus == 3)) || DNTRequest.GetString("showonline") == "yes")
            {
                showforumonline = true;
                onlineuserlist  = OnlineUsers.GetForumOnlineUserCollection(forumid, out forumtotalonline, out forumtotalonlineguest,
                                                                           out forumtotalonlineuser, out forumtotalonlineinvisibleuser);
            }
            //if (DNTRequest.GetString("showonline") != "no")
            //{
            //     showforumonline = false;
            //}

            if (DNTRequest.GetString("showonline") == "no")
            {
                showforumonline = false;
            }
            #endregion

            //修正版主列表
            if (forum.Moderators.Trim() != "")
            {
                string moderHtml = string.Empty;
                foreach (string m in forum.Moderators.Split(','))
                {
                    moderHtml += string.Format("<a href=\"{0}userinfo.aspx?username={1}\">{2}</a>,", forumpath, Utils.UrlEncode(m), m);
                }

                forum.Moderators = moderHtml.TrimEnd(',');
            }

            ForumUtils.UpdateVisitedForumsOptions(forumid);
        }
Ejemplo n.º 30
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)
            {
                forum          = new ForumInfo();//如果不初始化对象,则会报错
                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, usergroupinfo);
            smileyoff         = 1 - forum.Allowsmilies;
            bbcodeoff         = (forum.Allowbbcode == 1 && usergroupinfo.Allowcusbbcode == 1) ? 0 : 1;
            allowimg          = forum.Allowimgcode;
            customeditbuttons = Caches.GetCustomEditButtonList();
            #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

            canhtmltitle = usergroupinfo.Allowhtmltitle == 1;

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

            #region 特殊主题权限判断
            if (forum.Allowspecialonly > 0 && !Utils.InArray(type, "poll,bonus,debate"))
            {
                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);
            }
            userGroupInfoList.Sort(delegate(UserGroupInfo x, UserGroupInfo y) { return((x.Readaccess - y.Readaccess) + (y.Groupid - x.Groupid)); });
            #endregion

            //发帖不受审核、过滤、灌水等限制权限
            AdminGroupInfo admininfo = AdminGroups.GetAdminGroupInfo(usergroupid);
            disablepost = admininfo != null ? admininfo.Disablepostctrl : usergroupinfo.Disableperiodctrl;
            //如果是提交...
            if (ispost)
            {
                #region 判断是否是灌水
                if (!UserAuthority.CheckPostTimeSpan(usergroupinfo, admininfo, oluserinfo, userinfo, ref msg))
                {
                    AddErrLine(msg); return;
                }
                #endregion

                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;
                }

                #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, topicinfo.Tid, postinfo.Pid, postinfo, ref sb, userid, config, usergroupinfo);
                }
                //加入相册
                if (config.Enablealbum == 1 && apb != null)
                {
                    sb.Append(apb.CreateAttachment(attachmentinfo, usergroupid, userid, username));
                }
                #endregion

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

                #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, userid, usergroupinfo) || topicinfo.Displayorder == -2)
                        {
                            ForumUtils.WriteCookie("postmessage", "");
                            SetLastPostedForumCookie();
                            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");
            }
        }