Ejemplo n.º 1
0
 public void AddCmdUserIntegral(int recmd_uid)
 {
     M_User user = new B_User().GetUser(recmd_uid);
     B_Money money = new B_Money();
     if (user != null)
     {
         B_UserGroup group = new B_UserGroup();
         int num = int.Parse(group.Power_UserGroup("Invite", 0, group.GetModel(user.GroupID).GroupPower));
         money.Integral(num, recmd_uid);
     }
 }
Ejemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        IndexUrl = CreateBll.GetIndexUrl();
        string logName = "";
        string pwd = "";
        string cookieType = "";
        string valideCode = "";
        if (Request.Form["txtUserName"] != null && Request.Form["txtPwd"] != null && Request.Form["rbCookie"] != null)
        {
            logName = Function.UrlDecode(Request.Form["txtUserName"].ToString());
            //pwd = Function.MD5Encrypt(Request.Form["txtPwd"].ToString());
            pwd = Request.Form["txtPwd"];
            cookieType = Request.Form["rbCookie"].ToString();
        }
        if (siteBll.GetSiteModel().IsLoginValidate)
        {
            if (Request.Form["txtValidateCode"] == null)
            {
                Function.ShowMsg(0, "<li>请输入验证码</li><li><a href='login.aspx'>重新登录</a></li><li><a href='" + IndexUrl + "'>返回网站首页</a></li>");
            }
            else
            {
                valideCode = Request.Form["txtValidateCode"].ToString().ToLower();
            }
            if (valideCode != Session["ValidateCode"].ToString())
            {
                Function.ShowMsg(0, "<li>对不起,输入的验证码错误.请重新输入</li><li><a href='login.aspx'>重新登录</a></li><li><a href='" + IndexUrl + "'>返回网站首页</a></li>");
            }
        }

        if ((!string.IsNullOrEmpty(logName)) && (!string.IsNullOrEmpty(pwd)))
        {
            B_SiteInfo siteInfo = new B_SiteInfo();
            M_Site siteModel = siteInfo.GetSiteModel();
            M_User model = userBll.GetUser(logName);
            if (model != null && siteModel != null)
            {
                //用户被锁定
                if (model.IsLock == true)
                {
                    Function.ShowMsg(0, "<li>对不起,您已经被锁定,不能登录.</li><li>如果您是新注册用户,您可能需要先激活帐号</li><li><a href='" + IndexUrl + "'>返回网站首页</a></li>");
                }
                if (model.Status == 0)
                {
                    Function.ShowMsg(0, "<li>对不起,您还未通过管理员认证,不能登录.</li><li><a href='" + IndexUrl + "'>返回网站首页</a></li>");
                }
                //用户还在禁止登录时间内
                if (model.ErrorTime > DateTime.Now)
                {
                    Function.ShowMsg(0, "<li>对不起,您已经登录错误 " + siteModel.LogErrorNum + " 次,将被禁止登录 " + siteModel.DisabledLoginTime + " 分钟.</li><li><a href='" + IndexUrl + "'>返回网站首页</a></li>");
                }
                else
                {
                    //用户登录
                    bool flag = userBll.Login(logName, pwd);
                    if (flag && (!string.IsNullOrEmpty(cookieType)))
                    {
                        HttpCookie cookie = new HttpCookie("User");
                        cookie["uId"] = model.UserID.ToString();
                        cookie["logN"] = Function.UrlEncode(model.LogName);
                        cookie["pd"] = model.UserPwd;
                        switch (cookieType)
                        {
                            case "onehour":
                                cookie.Expires = DateTime.Now.AddHours(1);
                                break;
                            case "oneday":
                                cookie.Expires = DateTime.Now.AddDays(1);
                                break;
                            case "oneweek":
                                cookie.Expires = DateTime.Now.AddDays(7);
                                break;
                            case "onemounth":
                                cookie.Expires = DateTime.Now.AddMonths(1);
                                break;
                            case "oneyear":
                                cookie.Expires = DateTime.Now.AddYears(1);
                                break;
                            case "No":
                            default:
                                break;
                        }
                        cookie.Domain = WebConfigurationManager.AppSettings["KYCMS_CookieDomain"];
                        Response.Cookies.Add(cookie);
                        string bbsCookieValue = bbsUserBll.GetUserCookie(Request.Form["txtUserName"],Request.Form["txtPwd"]);
                        bbsUserBll.WriteUserCookie(bbsCookieValue);
                        lbUserName.Text = logName;
                        if (Request.UrlReferrer != null)
                        {
                            ReferUrl = Request.UrlReferrer.ToString();
                        }
                        if (!string.IsNullOrEmpty(Request.QueryString["ReturnUrl"]))
                        {
                            ReferUrl = Request.QueryString["ReturnUrl"].ToString();
                        }

                        //设置自动转向
                        HtmlMeta meta = new HtmlMeta();
                        meta.HttpEquiv = "Refresh";
                        meta.Content = "3;url=" + Server.UrlDecode(ReferUrl);
                        Header.Controls.Add(meta);
                        hyMain.NavigateUrl = "Main.aspx";
                        hyRefer.NavigateUrl = ReferUrl;
                        hyRefer.Text = ReferUrl;
                        hyIndex.NavigateUrl = IndexUrl;

                        //更新登录信息
                        string lastLoginIP = string.Empty;
                        if(Request.UserHostAddress!=null)
                        {
                            lastLoginIP = Request.UserHostAddress;
                        }
                        DateTime currLoginTime = DateTime.Now;
                        DateTime oldLoginTime = model.LastLoginTime;
                        userBll.LoginSuccess(model.UserID, lastLoginIP, currLoginTime);
                        if (oldLoginTime.Date != currLoginTime.Date)
                        {
                            B_Money moneyBll = new B_Money();
                            moneyBll.Integral(siteModel.LoginScore, model.UserID);
                        }
                    }

                    //登录失败
                    //检查错误次数,如果达到设定次数,
                    //则更新禁止登录时间
                    else
                    {
                        //修改时间
                        if (model.ErrorNum >= (siteModel.LogErrorNum - 1))
                        {
                            DateTime errorTime = DateTime.Now.AddMinutes(siteModel.DisabledLoginTime);
                            userBll.LoginFailOnErrorNum(model.UserID, errorTime);
                            Function.ShowMsg(0, "<li>对不起,您已经登录错误 " + siteModel.LogErrorNum + " 次,将被禁止登录 " + siteModel.DisabledLoginTime + " 分钟.</li><li><a href='" + IndexUrl + "'>返回网站首页</a></li>");
                        }
                        // 修改次数
                        else
                        {
                            userBll.LoginFailError(model.UserID);
                            Function.ShowMsg(0, "<li>对不起,登录失败!请检查您的用户名和密码.</li><li><a href='Login.aspx'>重新登录</a>(您还有" + (siteModel.LogErrorNum - model.ErrorNum) + "次机会)</li><li><a href='" + IndexUrl + "'>返回网站首页</a></li>");
                        }
                    }
                }
            }

            //用户不存在
            else
            {
                Function.ShowMsg(0,"<li>对不起,此用户不存在</li><li><a href='Reg.aspx'>注册新用户</a></li><li><a href='Login.aspx'>重新登录</a></li>");
            }
        }

        //post过来的数据不合法
        else
        {
            Response.Redirect("Login.aspx");
        }
    }
Ejemplo n.º 3
0
    protected void btnSoftSaveAs_Click(object sender, EventArgs e)
    {
        bool flag = CheckValidate();
        if (flag)
        {
            #region //添加软件
            DownLoadmodel.Id = Id;
            if(Id>0)
            {
                  DownLoadmodel = DownLoadBll.GetDownLoadData(Id);
            }
            if (!string.IsNullOrEmpty(Request.Form["ddlColId"]))
                DownLoadmodel.ColId = int.Parse(Request.Form["ddlColId"]);
            DownLoadmodel.Title = txtSoftName.Text.Trim();
            DownLoadmodel.UserCateId = int.Parse(ddlUserCate.SelectedValue);
            DownLoadmodel.TitleFontType = 0;
            DownLoadmodel.TitleType = 1;

            DownLoadmodel.Edition = txtSoftEdition.Text.Trim();
            DownLoadmodel.PlayAddress = txtSoftPlayAddress.Text.Trim();
            DownLoadmodel.UId = UserModel.UserID;
            DownLoadmodel.UName = UserModel.LogName;
            DownLoadmodel.UserType = 0;

            #region 关键字

            string tagIdStr = string.Empty;
            string nameStr = txtTagName.Text.Trim();
            if (nameStr.Length != 0)
            {
                if (nameStr.StartsWith("|"))
                    nameStr = nameStr.Substring(1, nameStr.Length - 1);
                if (nameStr.EndsWith("|"))
                    nameStr = nameStr.Substring(0, nameStr.Length - 1);
                B_Tag tagBll = new B_Tag();
                DataRow dr = tagBll.AddTagStr(nameStr, ChannelModel.ModelType, 0, "后台管理员");
                if (dr != null)
                {
                    tagIdStr = "|" + dr[0] + "|";
                    nameStr = "|" + dr[1] + "|";
                }
                else
                {
                    tagIdStr = "";
                    nameStr = "";
                }
            }
            DownLoadmodel.TagIdStr = tagIdStr;
            DownLoadmodel.TagNameStr = nameStr;
            #endregion

            DownLoadmodel.AddTime = DateTime.Now;
            DownLoadmodel.UpdateTime = DateTime.Now;
            if (txtSoftOS.Text.Trim().Length == 0)
                DownLoadmodel.DownLoadOS = "";
            else
                DownLoadmodel.DownLoadOS = "|" + txtSoftOS.Text.Trim() + "|";
            DownLoadmodel.Language = ddlSoftLanguage.SelectedValue;
            DownLoadmodel.WarrantType = ddlSoftWarrantType.SelectedValue;
            DownLoadmodel.RegAddress = txtSoftRegAddress.Text.Trim();

            if (ChannelModel.VerifyType == 0)
                DownLoadmodel.Status = 3;
            else
                DownLoadmodel.Status = 0;
            DownLoadmodel.Content = txtSoftRemark.Text.Trim();
            DownLoadmodel.PointCount = int.Parse(txtSoftPoint.Text.Trim());
            DownLoadmodel.IsDeleted = false;
            DownLoadmodel.DownLoadDisplePwd = txtSoftDisplePwd.Text.Trim();
            DownLoadmodel.DownLoadType = ddlSoftType.SelectedValue;
            DownLoadmodel.DownLoadSize = txtSoftSize.Text.Trim();
            if (Id <= 0)
                DownLoadmodel.IsOpened = 2;
            #region 继承栏目相关设置
            if (Id <= 0)
            {
                if (!string.IsNullOrEmpty(Request.Form["ddlColId"]) && Request.Form["ddlColId"] != "-1")
                {
                    ColumnModel = ColumnBll.GetColumn(int.Parse(Request.Form["ddlColId"].ToString()));
                    DownLoadmodel.TemplatePath = ColumnModel.InfoTemplatePath;
                    DownLoadmodel.PageType = ColumnModel.InfoPageType;
                    DownLoadmodel.ChargeType = ColumnModel.ChargeType;
                    DownLoadmodel.ChargeHourCount = ColumnModel.ChargeHourCount;
                    DownLoadmodel.ChargeViewCount = ColumnModel.ChargeViewCount;
                }
            }
            #endregion
            #endregion
            if (Id > 0)
                Id = DownLoadBll.Update(DownLoadmodel);
            else
                Id = DownLoadBll.Add(DownLoadmodel);
            AddressModel.AddressId = Convert.ToInt32(hfAddressId.Value);
            AddressModel.AddressName = "下载地址1";
            AddressModel.AddressNum = 1;
            AddressModel.AddressPath = txtSoftAddressPath.Text.Trim();
            AddressModel.DownLoadDataId = Id;
            AddressModel.DownLoadServerID = -1;
            if (AddressModel.AddressId > 0)
            { AddressBll.Update(AddressModel); }
            else
            {
                AddressBll.Add(AddressModel);
                #region 增加积分
                //如果频道不需要审核,添加积分
                if (ChannelModel.VerifyType == 0)
                {
                    if (UserModel == null)
                        return;
                    if (UserGroupBll == null)
                        return;
                    string scale = UserGroupBll.Power_UserGroup("Contribute", 0, UserGroupModel.GroupPower);
                    int score = int.Parse(scale) * ColumnModel.ScoreReward;
                    B_Money moneyBll = new B_Money();
                    moneyBll.Integral(score, UserModel.UserID);
                }
                #endregion
            }
            Response.Redirect("InfoList.aspx?ChId=" + ChId + "&ColId=" + DownLoadmodel.ColId);

        }
    }
Ejemplo n.º 4
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        CheckValidate();
        int sColId = int.Parse(Request.Form["ddlColId"]);

        #region 系统字段获取值
        string sTitle = txtTitle.Text;
        string sTitleColor = txtTitleColor.Text;
        string sTitleFontType = ddlTitleFontType.SelectedValue;

        int sTitleType = 1;
        if (rbImg.Checked == true)
        {
            sTitleType = 2;
        }
        string sTitleImgPath = txtTitleImgPath.Text;
        int sUId = UserModel.UserID;
        string sUName = UserModel.LogName;
        string sUserType = "0";
        int sAdminUId = 0;
        string sAdminUName = "";

        int sStatus = 0;

        if (((Button)sender).ID == "btnSaveCaoGao")
        {
            sStatus = -1;
        }
        else if (((Button)sender).ID == "Button2")
        {
            if (ChannelModel != null)
            {
                if (ChannelModel.VerifyType == 0)
                {
                    sStatus = 3;
                }
            }
        }

        int sHitCount = int.Parse(txtHitCount.Text);
        DateTime sAddTime = DateTime.Now;
        DateTime sUpdateTime = DateTime.Now;
        string sTemplatePath = txtTemplatePath.Text;
        int sPageType = int.Parse(rdBtnPageType.SelectedValue);

        int sIsCreated = 0;
        //if (chkBoxIsCreate.Checked)
        //{
        //    sIsCreated = 1;
        //}
        int sUserCateId = int.Parse(ddlUserCate.SelectedValue);
        int sPointCount = int.Parse(txtPointCount.Text);
        string rdBtnChargeType = Request.Form["ChargeType"];
        int sChargeType = 0;

        if (rdBtnChargeType == "rdBtnChargeType1")
        {
            sChargeType = 1;
        }
        else if (rdBtnChargeType == "rdBtnChargeType2")
        {
            sChargeType = 2;
        }
        else if (rdBtnChargeType == "rdBtnChargeType3")
        {
            sChargeType = 3;
        }
        else if (rdBtnChargeType == "rdBtnChargeType4")
        {
            sChargeType = 4;
        }
        else if (rdBtnChargeType == "rdBtnChargeType5")
        {
            sChargeType = 5;
        }
        else if (rdBtnChargeType == "rdBtnChargeType6")
        {
            sChargeType = 6;
        }

        //继承栏目相关设置
        ColumnModel = ColumnBll.GetColumn(sColId);

        int sChargeHourCount = int.Parse(txtChargeHourCount.Text);
        int sChargeViewCount = int.Parse(txtChargeViewCount.Text);
        int sIsOpened = int.Parse(rdBtnIsOpened.SelectedValue);

        string sGroupIdStr = "";

        if (sIsOpened == 0)
        {
            sGroupIdStr = "|";
            foreach (ListItem li in chkBoxGroupIdStr.Items)
            {
                if (li.Selected)
                {
                    sGroupIdStr += li.Value + "|";
                }
            }
        }

        int sIsDeleted = 0;

        int sIsRecommend = 0;
        //if (chkBoxIsRecommend.Checked)
        //{
        //    sIsRecommend = 1;
        //}

        int sIsTop = 0;
        //if (chkBoxIsTop.Checked)
        //{
        //    sIsTop = 1;
        //}

        int sIsFocus = 0;
        //if (chkBoxIsFocus.Checked)
        //{
        //    sIsFocus = 1;
        //}

        int sIsSideShow = 0;
        //if (chkBoxIsSideShow.Checked)
        //{
        //    sIsSideShow = 1;
        //}

        #region 关键字
        string sTagIdStr = string.Empty;
        string sTagNameStr = txtTagNameStr.Text.Trim();
        if (sTagNameStr.Length != 0)
        {
            if (sTagNameStr.StartsWith("|"))
                sTagNameStr = sTagNameStr.Substring(1, sTagNameStr.Length - 1);
            if (sTagNameStr.EndsWith("|"))
                sTagNameStr = sTagNameStr.Substring(0, sTagNameStr.Length - 1);
            B_Tag tagBll = new B_Tag();
            DataRow dr = tagBll.AddTagStr(sTagNameStr, ChannelModel.ModelType, 0, "后台管理员");
            if (dr != null)
            {
                sTagIdStr = "|" + dr[0] + "|";
                sTagNameStr = "|" + dr[1] + "|";
            }
            else
            {
                sTagIdStr = "";
                sTagNameStr = "";
            }
        }
        #endregion

        int sIsAllowComment =0;
        if (ColumnModel.IsAllowComment)
        {
            sIsAllowComment = 1;
        }

        string idStr = "";
        string sSpecialIdStr = "";
        for (int i = 0; i < lBoxTopicIdStr.Items.Count; i++)
        {
            if (lBoxTopicIdStr.Items[i].Selected)
            {
                idStr += lBoxTopicIdStr.Items[i].Value + "|";
            }
        }
        if (idStr != "")
        {
            sSpecialIdStr = "|" + idStr;
        }

        //if (sIsCreated)
        //{
        //}
        #endregion

        //定义DataTable
        DataTable dt = new DataTable();
        dt.Columns.Add(new DataColumn("FieldName", typeof(string)));
        dt.Columns.Add(new DataColumn("FieldValue", typeof(string)));

        #region
        DataRow dr0 = dt.NewRow();
        dr0[0] = "ColId";
        dr0[1] = sColId;
        dt.Rows.Add(dr0);

        DataRow dr1 = dt.NewRow();
        dr1[0] = "Title";
        dr1[1] = sTitle;
        dt.Rows.Add(dr1);

        DataRow dr2 = dt.NewRow();
        dr2[0] = "TitleColor";
        dr2[1] = sTitleColor;
        dt.Rows.Add(dr2);

        DataRow dr3 = dt.NewRow();
        dr3[0] = "TitleFontType";
        dr3[1] = sTitleFontType;
        dt.Rows.Add(dr3);

        DataRow dr4 = dt.NewRow();
        dr4[0] = "TitleType";
        dr4[1] = sTitleType;
        dt.Rows.Add(dr4);

        DataRow dr5 = dt.NewRow();
        dr5[0] = "TitleImgPath";
        dr5[1] = sTitleImgPath;
        dt.Rows.Add(dr5);

        DataRow dr6 = dt.NewRow();
        dr6[0] = "UId";
        dr6[1] = sUId;
        dt.Rows.Add(dr6);

        DataRow dr7 = dt.NewRow();
        dr7[0] = "UName";
        dr7[1] = sUName;
        dt.Rows.Add(dr7);

        DataRow dr8 = dt.NewRow();
        dr8[0] = "UserType";
        dr8[1] = sUserType;
        dt.Rows.Add(dr8);

        DataRow dr9 = dt.NewRow();
        dr9[0] = "AdminUId";
        dr9[1] = sAdminUId;
        dt.Rows.Add(dr9);

        DataRow dr10 = dt.NewRow();
        dr10[0] = "AdminUName";
        dr10[1] = sAdminUName;
        dt.Rows.Add(dr10);

        DataRow dr11 = dt.NewRow();
        dr11[0] = "Status";
        dr11[1] = sStatus;
        dt.Rows.Add(dr11);

        DataRow dr12 = dt.NewRow();
        dr12[0] = "HitCount";
        dr12[1] = sHitCount;
        dt.Rows.Add(dr12);

        DataRow dr13 = dt.NewRow();
        dr13[0] = "AddTime";
        dr13[1] = sAddTime;
        dt.Rows.Add(dr13);

        DataRow dr14 = dt.NewRow();
        dr14[0] = "UpdateTime";
        dr14[1] = sUpdateTime;
        dt.Rows.Add(dr14);

        DataRow dr15 = dt.NewRow();
        dr15[0] = "TemplatePath";
        dr15[1] = sTemplatePath;
        dt.Rows.Add(dr15);

        DataRow dr16 = dt.NewRow();
        dr16[0] = "PageType";
        dr16[1] = sPageType;
        dt.Rows.Add(dr16);

        DataRow dr17 = dt.NewRow();
        dr17[0] = "IsCreated";
        dr17[1] = sIsCreated;
        dt.Rows.Add(dr17);

        DataRow dr18 = dt.NewRow();
        dr18[0] = "UserCateId";
        dr18[1] = sUserCateId;
        dt.Rows.Add(dr18);

        DataRow dr19 = dt.NewRow();
        dr19[0] = "PointCount";
        dr19[1] = sPointCount;
        dt.Rows.Add(dr19);

        DataRow dr20 = dt.NewRow();
        dr20[0] = "ChargeType";
        dr20[1] = sChargeType;
        dt.Rows.Add(dr20);

        DataRow dr21 = dt.NewRow();
        dr21[0] = "ChargeHourCount";
        dr21[1] = sChargeHourCount;
        dt.Rows.Add(dr21);

        DataRow dr22 = dt.NewRow();
        dr22[0] = "ChargeViewCount";
        dr22[1] = sChargeViewCount;
        dt.Rows.Add(dr22);

        DataRow dr23 = dt.NewRow();
        dr23[0] = "IsOpened";
        dr23[1] = sIsOpened;
        dt.Rows.Add(dr23);

        DataRow dr24 = dt.NewRow();
        dr24[0] = "GroupIdStr";
        dr24[1] = sGroupIdStr;
        dt.Rows.Add(dr24);

        DataRow dr25 = dt.NewRow();
        dr25[0] = "IsDeleted";
        dr25[1] = sIsDeleted;
        dt.Rows.Add(dr25);

        DataRow dr26 = dt.NewRow();
        dr26[0] = "IsRecommend";
        dr26[1] = sIsRecommend;
        dt.Rows.Add(dr26);

        DataRow dr27 = dt.NewRow();
        dr27[0] = "IsTop";
        dr27[1] = sIsTop;
        dt.Rows.Add(dr27);

        DataRow dr28 = dt.NewRow();
        dr28[0] = "IsFocus";
        dr28[1] = sIsFocus;
        dt.Rows.Add(dr28);

        DataRow dr29 = dt.NewRow();
        dr29[0] = "IsSideShow";
        dr29[1] = sIsSideShow;
        dt.Rows.Add(dr29);

        DataRow dr30 = dt.NewRow();
        dr30[0] = "TagIdStr";
        dr30[1] = sTagIdStr;
        dt.Rows.Add(dr30);

        DataRow dr31 = dt.NewRow();
        dr31[0] = "TagNameStr";
        dr31[1] = sTagNameStr;
        dt.Rows.Add(dr31);

        DataRow dr32 = dt.NewRow();
        dr32[0] = "IsAllowComment";
        dr32[1] = sIsAllowComment;
        dt.Rows.Add(dr32);

        DataRow dr33 = dt.NewRow();
        dr33[0] = "SpecialIdStr";
        dr33[1] = sSpecialIdStr;
        dt.Rows.Add(dr33);
        #endregion

        //以下是自动添加字段获得值
        DataTable dt1 = new DataTable();
        dt1 = BModelField.GetList(ChannelModel.ModelType);

        for (int i = 0; i < dt1.Rows.Count; i++)
        {
            DataRow dr = dt.NewRow();
            dr[0] = dt1.Rows[i]["Name"].ToString();

            //联动获取数据开始
            //二级联动
            if (dt1.Rows[i]["Type"].ToString() == "ErLinkageType")
            {
                dr[1] = Request.Form["txt_" + dt1.Rows[i]["Name"].ToString()];
                dt.Rows.Add(dr);

                dr = dt.NewRow();
                dr[0] = dt1.Rows[i]["Name"].ToString() + "_Id";
                dr[1] = Request.Form["txt_" + dt1.Rows[i]["Name"].ToString() + "_Id"];
                dt.Rows.Add(dr);

                string SmallName = BModelField.GetFieldContent(dt1.Rows[i]["Content"].ToString(), 2, 1);
                dr = dt.NewRow();
                dr[0] = SmallName;
                dr[1] = Request.Form["txt_" + SmallName];
                dt.Rows.Add(dr);

                dr = dt.NewRow();
                dr[0] = SmallName + "_Id";
                dr[1] = Request.Form["txt_" + SmallName + "_Id"];
                dt.Rows.Add(dr);
            }
            else
            {
                switch (dt1.Rows[i]["Type"].ToString())
                {
                    case "ListBoxType":
                        if (Request.Form["txt_" + dt1.Rows[i]["Name"].ToString() + ""] == "" || Request.Form["txt_" + dt1.Rows[i]["Name"].ToString() + ""] == null)
                        {
                            dr[1] = Request.Form["txt_" + dt1.Rows[i]["Name"].ToString() + ""];
                        }
                        else
                        {
                            dr[1] = Request.Form["txt_" + dt1.Rows[i]["Name"].ToString() + ""].Replace(" ", "").ToString();
                        }
                        dr[1] = "," + dr[1] + ",";
                        break;
                    case "MultipleTextType":
                        dr[1] = Request.Form["txt_" + dt1.Rows[i]["Name"].ToString() + ""];
                        break;
                    default:
                        dr[1] = Request.Form["txt_" + dt1.Rows[i]["Name"].ToString() + ""];
                        break;
                }
                dt.Rows.Add(dr);
            }
        }

        //添加信息
        BInfoModel.AddInfoModel(dt, MInfoModel.TableName);
        ColumnModel = ColumnBll.GetColumn(int.Parse(Request.Form["ddlColId"].ToString()));
        if (ChannelModel.VerifyType == 0)
        {
            if (UserModel == null)
                return;
            if (UserGroupBll == null)
                return;
            string scale = UserGroupBll.Power_UserGroup("Contribute", 0, UserGroupModel.GroupPower);
            int score = int.Parse(scale) * ColumnModel.ScoreReward;
            B_Money moneyBll = new B_Money();
            moneyBll.Integral(score, UserModel.UserID);
        }
        Function.ShowMsg(1, "<li>成功添加信息</li><li><a href='info/InfoList.aspx?ChId=" + ChannelId + "&ColId=" + sColId + "'>返回信息列表</a> <a href='info/AddInfo.aspx?ChId=" + ChannelId + "'>继续添加</a></li>");
    }
Ejemplo n.º 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Cache.SetNoStore();
        bool reviewIsCheck = false;
        B_Review bll = new B_Review();
        B_SiteInfo SiteBll = new B_SiteInfo();
        B_User bllUser = new B_User();
        M_Review model = new M_Review();
        M_User userModel = null;
        if (Request.Form["txtIsLogin"] == "False")
        {
            if (Request.Form["btnSubmit"] == "登录")
            {
                bool flaglogin = true;
                string msgBox = string.Empty;
                if (Request.Form["UserName"].ToString().Trim() == "")
                {
                    flaglogin = false;
                    msgBox = "<script>alert('用户名必须填写');window.location.href('" + Request.UrlReferrer.ToString() + "');</script>";
                }
                else if (Request.Form["userPwd"].ToString().Trim() == "")
                {
                    flaglogin = false;
                    msgBox = "<script>alert('密码必须填写');window.location.href('" + Request.UrlReferrer.ToString() + "');</script>";
                }
                if (flaglogin)
                {

                    ltMsg.Text = "";
                    string logName = "";
                    string pwd = "";
                    string cookieType = "";

                    logName = Function.UrlDecode(Request.Form["UserName"].ToString());
                    pwd = Function.MD5Encrypt(Request.Form["userPwd"].ToString());
                    cookieType = "No";

                    if ((!string.IsNullOrEmpty(logName)) && (!string.IsNullOrEmpty(pwd)))
                    {
                        B_SiteInfo siteInfo = new B_SiteInfo();
                        M_Site siteModel = siteInfo.GetSiteModel();
                        M_User modelLogin = bllUser.GetUser(logName);
                        if (modelLogin != null && siteModel != null)
                        {

                                //用户登录
                                bool flag = bllUser.Login(logName, pwd);
                                if (flag && (!string.IsNullOrEmpty(cookieType)))
                                {
                                    HttpCookie cookie = new HttpCookie("User");
                                    cookie["uId"] = modelLogin.UserID.ToString();
                                    cookie["logN"] = modelLogin.LogName;
                                    cookie["pd"] = modelLogin.UserPwd;
                                    switch (cookieType)
                                    {
                                        case "onehour":
                                            cookie.Expires = DateTime.Now.AddHours(1);
                                            break;
                                        case "oneday":
                                            cookie.Expires = DateTime.Now.AddDays(1);
                                            break;
                                        case "oneweek":
                                            cookie.Expires = DateTime.Now.AddDays(7);
                                            break;
                                        case "onemounth":
                                            cookie.Expires = DateTime.Now.AddMonths(1);
                                            break;
                                        case "oneyear":
                                            cookie.Expires = DateTime.Now.AddYears(1);
                                            break;
                                        case "No":
                                        default:
                                            break;
                                    }
                                    Response.Cookies.Add(cookie);

                                    string lastLoginIP = string.Empty;
                                    if (Request.UserHostAddress != null)
                                    {
                                        lastLoginIP = Request.UserHostAddress;
                                    }
                                    DateTime currLoginTime = DateTime.Now;
                                    DateTime oldLoginTime = modelLogin.LastLoginTime;
                                    bllUser.LoginSuccess(modelLogin.UserID, lastLoginIP, currLoginTime);
                                    if (oldLoginTime.Date != currLoginTime.Date)
                                    {
                                        B_Money moneyBll = new B_Money();
                                        moneyBll.Integral(siteModel.LoginScore, modelLogin.UserID);
                                    }

                                    msgBox = "<script>alert('登录成功');window.location.href('" + Request.UrlReferrer.ToString() + "');</script>";
                                }
                                else
                                {
                                    msgBox = "<script>alert('登录失败');window.location.href('" + Request.UrlReferrer.ToString() + "');</script>";
                                }
                        }
                        else
                        {
                            msgBox = "<script>alert('登录失败');window.location.href('" + Request.UrlReferrer.ToString() + "');</script>";
                        }
                    }
                }
                    ltMsg.Text = msgBox;
            }
            else
            {
                if (Request.Form["hidNoName"].ToString() == "False")
                {
                    ltMsg.Text = "<script>alert('本系统设置了不允许匿名评论,请先登录');window.location.href('" + Request.UrlReferrer.ToString() + "');</script>";
                }
                else
                {
                    //根据栏目的设置,对论评论审核进行初始化
                    if (Request.Form["hidColCommentSet"].ToString() == "True")
                        reviewIsCheck = false;
                    else
                        reviewIsCheck = true;

                    string validateCode = string.Empty;
                    string flag = Request.Form["hidValidate"];
                    if (flag == "True")
                    {
                        if (Session["ValidateCode"] == null)
                        {
                            Response.Write("<script language='javascript'>alert('你在登陆页面停留的时间过长,验证码已经失效');window.history.back();</script>");
                            Response.End();
                        }
                        //验证码错误
                        validateCode = Session["ValidateCode"].ToString().ToLower();
                        if (validateCode.ToLower() != Request.Form["txtValidate"].ToString().Trim().ToLower())
                        {
                            Response.Write("<script language='javascript'>alert('验证码错误');window.history.back();</script>");
                            Response.End();
                        }
                    }

                    if (bllUser.IsLogin())
                    {
                        M_User loginUserModel = bllUser.GetCookie();
                        userModel = bllUser.GetUser(loginUserModel.LogName);
                    }

                    model.ModelType = int.Parse(Request.Form["hidModeType"].ToString());
                    model.InfoId = Request.Form["hidNewsId"].ToString();

                    if (Request.Form["hidUserGroupViewIsCheck"] == "True" && bllUser.IsLogin())
                        reviewIsCheck = true;
                    model.IsCheck = reviewIsCheck;

                    model.ReviewTitle = "";                                    //评论标题

                    model.IsArgue = false;
                    model.IsSquare = 3;

                    model.BrarNum = 0;
                    model.FightNum = 0;

                    model.IsElite = false;
                    model.ReviewContent = SiteBll.GetFiltering(Request.Form["txtContent"].ToString());           //评论内容
                    model.ReviewTime = DateTime.Now;                                                       //评论时间
                    if (bllUser.IsLogin())                                             //是否是登录用户
                        model.UserNum = userModel.UserID.ToString();
                    else
                        model.UserNum = "0";
                    model.ReviewIP = Request.UserHostAddress;     //评论用户的IP

                    if (bll.Add(model))
                    {
                        if (!reviewIsCheck)
                            ltMsg.Text = "<script>alert('评论成功,将在审核后显示出来');window.location.href('" + Request.UrlReferrer.ToString() + "');</script>";
                        else
                            ltMsg.Text = "<script>window.location.href('" + Request.UrlReferrer.ToString() + "');</script>";
                    }
                }
            }
        }
        else
        {
            if (Request.Form["hidNoName"].ToString() == "False")
            {
                ltMsg.Text = "<script>alert('本系统设置了不允许匿名评论,请先登录');window.location.href('" + Request.UrlReferrer.ToString() + "');</script>";
            }
            else
            {
                //根据栏目的设置,对论评论审核进行初始化
                if (Request.Form["hidColCommentSet"].ToString() == "True")
                    reviewIsCheck = false;
                else
                    reviewIsCheck = true;

                string validateCode = string.Empty;
                string flag = Request.Form["hidValidate"];
                if (flag == "True")
                {
                    if (Session["ValidateCode"] == null)
                    {
                        Response.Write("<script language='javascript'>alert('你在登陆页面停留的时间过长,验证码已经失效');window.history.back();</script>");
                        Response.End();
                    }
                    //验证码错误
                    validateCode = Session["ValidateCode"].ToString().ToLower();
                    if (validateCode.ToLower() != Request.Form["txtValidate"].ToString().Trim().ToLower())
                    {
                        Response.Write("<script language='javascript'>alert('验证码错误');window.history.back();</script>");
                        Response.End();
                    }
                }

                if (bllUser.IsLogin())
                {
                    M_User loginUserModel = bllUser.GetCookie();
                    userModel = bllUser.GetUser(loginUserModel.LogName);
                }

                model.ModelType = int.Parse(Request.Form["hidModeType"].ToString());
                model.InfoId = Request.Form["hidNewsId"].ToString();
                if (Request.Form["hidUserGroupViewIsCheck"] == "True" && bllUser.IsLogin())
                    reviewIsCheck = true;
                model.IsCheck = reviewIsCheck;

                model.ReviewTitle = "";                                    //评论标题

                model.IsArgue = false;
                model.IsSquare = 3;

                model.BrarNum = 0;
                model.FightNum = 0;

                model.IsElite = false;
                model.ReviewContent = SiteBll.GetFiltering(Request.Form["txtContent"].ToString());           //评论内容
                model.ReviewTime = DateTime.Now;                                                       //评论时间
                if (bllUser.IsLogin())                                             //是否是登录用户
                    model.UserNum = userModel.UserID.ToString();
                else
                    model.UserNum = "0";
                model.ReviewIP = Request.UserHostAddress;     //评论用户的IP

                if (bll.Add(model))
                {
                    if (!reviewIsCheck)
                        ltMsg.Text = "<script>alert('评论成功,将在审核后显示出来');window.location.href('" + Request.UrlReferrer.ToString() + "');</script>";
                    else
                        ltMsg.Text = "<script>window.location.href('" + Request.UrlReferrer.ToString() + "');</script>";
                }
            }
        }
    }
Ejemplo n.º 6
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        string MyChangeValue = ChangeValue.Text;

        string MyMoneyType = MoneyType.SelectedValue;
        string MyMoneyType1 = MoneyType1.SelectedValue;

        string MyPassWord = PassWord.Text;
        //
        Muser = Buser.GetCookie();

        M_User Muser_1 = new M_User();
        int UserId=Muser.UserID;
        Muser_1 = Buser.GetUser(UserId);

        string MyUserIntegral=UserIntegral.Text;
        string MyUserYellowBoy=UserYellowBoy.Text;
        string MyUserExpireDay=UserExpireDay.Text;

        string SuLabel = "";
        string SucLabel = "";
        string SucLabelValue = "";

        #region 验证判断
        if (!Function.CheckNumberNotZero(MyChangeValue))
        {
            Function.ShowMsg(0, "<li>请输入一个大于0的整数</li><li><a href='javascript:window.history.back(-1)'>返回上一步</a></li>");
        }

        if (MyMoneyType == "0" || MyMoneyType1 == "0")
        {
            Function.ShowMsg(0, "<li>请选择转换栏目</li><li><a href='javascript:window.history.back(-1)'>返回上一步</a></li>");
        }

        if (MyPassWord == "" || MyPassWord == null)
        {
            Function.ShowMsg(0, "<li>请输入登陆密码</li><li><a href='javascript:window.history.back(-1)'>返回上一步</a></li>");
        }

        if (Muser_1.UserPwd != Function.MD5Encrypt(MyPassWord))
        {
            Function.ShowMsg(0, "<li>登陆密码输入错误</li><li><a href='javascript:window.history.back(-1)'>返回上一步</a></li>");
        }
        #endregion

        B_Money BMoney = new B_Money();

        #region 数值判断
        #region 金币判断
        if (MyMoneyType == "1")    //如果是金币
        {
            SuLabel = "" + GUnitName.Text + "金币";

            if (Muser_1.YellowBoy < int.Parse(MyChangeValue))
            {
                Function.ShowMsg(0, "<li>金币不足,请重新输入</li><li><a href='javascript:window.history.back(-1)'>返回上一步</a></li>");
            }
            else
            {
                //金币
                if (MyMoneyType1=="1")
                {
                    Function.ShowMsg(0, "<li>金币无需再次换成金币</li><li><a href='javascript:window.history.back(-1)'>返回上一步</a></li>");
                }

                //积分
                if (MyMoneyType1 == "2")
                {
                    BMoney.YellowBoy(-decimal.Parse(MyChangeValue), UserId);    //更新金币(减少)
                    BMoney.Integral(int.Parse(MyChangeValue) * int.Parse(MyUserIntegral) / int.Parse(MyUserYellowBoy), UserId); //积分

                    SucLabel = "点积分";
                    SucLabelValue = (int.Parse(MyChangeValue) * int.Parse(MyUserIntegral) / int.Parse(MyUserYellowBoy)).ToString();
                }

                //有效期
                if (MyMoneyType1 == "3")
                {
                    BMoney.YellowBoy(-decimal.Parse(MyChangeValue), UserId);    //更新金币(减少)
                    BMoney.ExpireTime(int.Parse(MyChangeValue) * int.Parse(MyUserExpireDay) / int.Parse(MyUserYellowBoy), UserId); //有效期

                    SucLabel = "天有效期";
                    SucLabelValue = (int.Parse(MyChangeValue) * int.Parse(MyUserExpireDay) / int.Parse(MyUserYellowBoy)).ToString();
                }
            }
        }
        #endregion

        #region 积分判断
        if (MyMoneyType == "2")    //如果是积分
        {
            SuLabel = "点积分";
            if (Muser_1.Integral < int.Parse(MyChangeValue))
            {
                Function.ShowMsg(0, "<li>积分不足,请重新输入</li><li><a href='javascript:window.history.back(-1)'>返回上一步</a></li>");
            }
            else
            {
                //积分
                if (MyMoneyType1 == "2")
                {
                    Function.ShowMsg(0, "<li>积分无需再次换成积分</li><li><a href='javascript:window.history.back(-1)'>返回上一步</a></li>");
                }

                //金币
                if (MyMoneyType1 == "1")
                {
                    BMoney.Integral(-int.Parse(MyChangeValue), UserId);    //更新积分(减少)
                    BMoney.YellowBoy(decimal.Parse(MyChangeValue) * decimal.Parse(MyUserYellowBoy) / decimal.Parse(MyUserIntegral), UserId); //金币

                    SucLabel = "" + GUnitName.Text + "金币";
                    SucLabelValue = (int.Parse(MyChangeValue) * decimal.Parse(MyUserYellowBoy) / int.Parse(MyUserIntegral)).ToString();
                }

                //有效期
                if (MyMoneyType1 == "3")
                {
                    BMoney.Integral(-int.Parse(MyChangeValue), UserId);    //更新积分(减少)
                    BMoney.ExpireTime(int.Parse(MyChangeValue) * int.Parse(MyUserExpireDay) / int.Parse(MyUserIntegral), UserId); //有效期.

                    SucLabel = "天有效期";
                    SucLabelValue = (int.Parse(MyChangeValue) * int.Parse(MyUserExpireDay) / int.Parse(MyUserIntegral)).ToString();
                }
            }
        }
        #endregion

        #region 有效期判断
        if (MyMoneyType == "3")    //如果是有效期
        {
            SuLabel = "天有效期";
            TimeSpan ts1 = new TimeSpan(Muser_1.ExpireTime.Ticks);
            TimeSpan ts2 = new TimeSpan(DateTime.Now.Ticks);

            if (ts1.Subtract(ts2).Days < int.Parse(MyChangeValue))
            {
                Function.ShowMsg(0, "<li>有效期天数不足,请重新输入</li><li><a href='javascript:window.history.back(-1)'>返回上一步</a></li>");
            }
            else
            {
                //有效期
                if (MyMoneyType1 == "3")
                {
                    Function.ShowMsg(0, "<li>有效期无需再次换成有效期</li><li><a href='javascript:window.history.back(-1)'>返回上一步</a></li>");
                }

                //金币
                if (MyMoneyType1 == "1")
                {
                    BMoney.ExpireTime(-int.Parse(MyChangeValue), UserId);    //更新有效期(减少)
                    BMoney.YellowBoy(decimal.Parse(MyChangeValue) * decimal.Parse(MyUserYellowBoy) / decimal.Parse(MyUserExpireDay), UserId); //金币

                    SucLabel = "" + GUnitName.Text + "金币";
                    SucLabelValue = (decimal.Parse(MyChangeValue) * decimal.Parse(MyUserYellowBoy) / int.Parse(MyUserExpireDay)).ToString();
                }

                //积分
                if (MyMoneyType1 == "2")
                {
                    BMoney.ExpireTime(-int.Parse(MyChangeValue), UserId);    //更新积分(减少)
                    BMoney.Integral(int.Parse(MyChangeValue) * int.Parse(MyUserIntegral) / int.Parse(MyUserExpireDay), UserId); //积分

                    SucLabel = "点积分";
                    SucLabelValue = (int.Parse(MyChangeValue) * int.Parse(MyUserIntegral) / int.Parse(MyUserExpireDay)).ToString();
                }
            }
        }
        #endregion
        #endregion

        //记录日志
        B_UserLog logBll = new B_UserLog();
        M_UserLog logModel = new M_UserLog();
        logModel.AddTime = DateTime.Now;
        logModel.Description = "成功将" + MyChangeValue + "" + SuLabel + "兑换成" + SucLabelValue + "" + SucLabel;
        logModel.InfoId = 0;
        logModel.ModelType = 0;
        logModel.Point = 0;
        logModel.UserId = Muser_1.UserID;
        logModel.UserName = Muser_1.LogName;
        logBll.Add(logModel);

        Function.ShowMsg(1, "<li>成功将" + MyChangeValue + "" + SuLabel + "兑换成" + SucLabelValue + "" + SucLabel + "</li><li><a href='Money/MoneyChange.aspx'>返回财富兑换</a></li>");
    }
Ejemplo n.º 7
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        string MyChangeValue = ChangeValue.Text;

        string MyMoneyType = MoneyType.SelectedValue;
        string MySendUser = SendUser.Text;
        string MyMoneyType_1 = MoneyType.SelectedItem.Text;
        string MyGUnitName = "";

        //汇率
        Msite = Bsiteinfo.GetSiteModel();

        if (MyMoneyType == "1")
        {
            MyGUnitName = Msite.GUnitName.ToString();
        }

        if (MyMoneyType == "2")
        {
            MyGUnitName = "点";
        }

        if (MyMoneyType == "3")
        {
            MyGUnitName = "天";
        }

        string MyPassWord = PassWord.Text;
        //
        Muser = Buser.GetCookie();

        M_User Muser_1 = new M_User();
        int UserId = Muser.UserID;
        Muser_1 = Buser.GetUser(UserId);

        #region 验证判断
        if (!Function.CheckNumberNotZero(MyChangeValue))
        {
            Function.ShowMsg(0, "<li>请输入一个大于0的整数</li><li><a href='Money/MoneySend.aspx'>返回上一步</a></li>");
        }

        if (MyMoneyType == "0")
        {
            Function.ShowMsg(0, "<li>请选择转换栏目</li><li><a href='Money/MoneySend.aspx'>返回上一步</a></li>");
        }

        if (MySendUser == "0")
        {
            Function.ShowMsg(0, "<li>请输入赠送用户名称</li><li><a href='Money/MoneySend.aspx>返回上一步</a></li>");
        }

        if (MyPassWord == "" || MyPassWord == null)
        {
            Function.ShowMsg(0, "<li>请输入登陆密码</li><li><a href='Money/MoneySend.aspx'>返回上一步</a></li>");
        }

        if (Muser_1.UserPwd != Function.MD5Encrypt(MyPassWord))
        {
            Function.ShowMsg(0, "<li>登陆密码输入错误</li><li><a href='Money/MoneySend.aspx'>返回上一步</a></li>");
        }
        #endregion

        #region 判断用户输入赠送用户的合法性

        B_Money BMoney = new B_Money();

        if (Buser.GetUser(MySendUser) == null)
        {
            Function.ShowMsg(0, "<li>赠送的用户不存在</li><li><a href='Money/MoneySend.aspx'>返回上一步</a></li>");
        }
        else
        {
            int SendUserId=Buser.GetUser(MySendUser).UserID;
            if (MyMoneyType == "1")
            {
                if (Muser_1.YellowBoy < int.Parse(MyChangeValue))
                {
                    Function.ShowMsg(0, "<li>金币不足,请重新输入</li><li><a href='Money/MoneySend.aspx'>返回上一步</a></li>");
                }
                else
                {
                    BMoney.YellowBoy(decimal.Parse(MyChangeValue), SendUserId);
                    BMoney.YellowBoy(-decimal.Parse(MyChangeValue), UserId);
                }
            }

            if (MyMoneyType == "2")
            {
                if (Muser_1.Integral < int.Parse(MyChangeValue))
                {
                    Function.ShowMsg(0, "<li>积分不足,请重新输入</li><li><a href='Money/MoneySend.aspx'>返回上一步</a></li>");
                }
                else
                {
                    BMoney.Integral(int.Parse(MyChangeValue), SendUserId);
                    BMoney.Integral(-int.Parse(MyChangeValue), UserId);
                }
            }

            if (MyMoneyType == "3")
            {
                TimeSpan ts1 = new TimeSpan(Muser_1.ExpireTime.Ticks);
                TimeSpan ts2 = new TimeSpan(DateTime.Now.Ticks);

                if (ts1.Subtract(ts2).Days < int.Parse(MyChangeValue))
                {
                    Function.ShowMsg(0, "<li>有效期天数不足,请重新输入</li><li><a href='Money/MoneySend.aspx'>返回上一步</a></li>");
                }
                else
                {
                    BMoney.ExpireTime(int.Parse(MyChangeValue), SendUserId);
                    BMoney.ExpireTime(-int.Parse(MyChangeValue), UserId);
                }
            }
        }

        #endregion
        //记录日志
        B_UserLog logBll = new B_UserLog();
        M_UserLog logModel = new M_UserLog();
        logModel.AddTime = DateTime.Now;
        logModel.Description = "成功赠送给[" + MySendUser + "]" + MyChangeValue + "" + MyGUnitName + "" + MyMoneyType_1;
        logModel.InfoId = 0;
        logModel.ModelType = 0;
        logModel.Point = 0;
        logModel.UserId = Muser_1.UserID;
        logModel.UserName = Muser_1.LogName;
        logBll.Add(logModel);

        Function.ShowMsg(1, "<li>成功赠送给[" + MySendUser + "]" + MyChangeValue + "" + MyGUnitName + "" + MyMoneyType_1 + "</li><li><a href='Money/MoneySend.aspx'>返回财富赠送</a></li>");
    }
Ejemplo n.º 8
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        string valideCode = "";
        lbMsg.Text = "";
        if (Request.Form["txtUserName"] != null && Request.Form["txtPwd"] != null)
        {
            logName = Function.UrlDecode(Request.Form["txtUserName"].ToString());
            pwd = Function.MD5Encrypt(Request.Form["txtPwd"].ToString());
        }
        if (siteBll.GetSiteModel().IsLoginValidate)
        {
            if (Request.Form["txtValidateCode"] == null)
            {
                lbMsg.Text = "<script>alert('请输入验证码')</script>";
                return;
            }
            else
            {
                valideCode = Request.Form["txtValidateCode"].ToString().ToLower();
            }
            if (Session["ValidateCode"] != null)
            {
                if (valideCode != Session["ValidateCode"].ToString())
                {
                    lbMsg.Text = "<script>alert('对不起,输入的验证码错误.请重新输入');</script>";
                    imgCode.ImageUrl = "~/common/Code.aspx";
                }
            }
            else
            {
                lbMsg.Text = "<script>alert('对不起,您在本页停留时间太长,请退出');hiddenIframe();</script>";
            }
        }
        B_SiteInfo siteInfo = new B_SiteInfo();
        M_Site siteModel = siteInfo.GetSiteModel();
        M_User model = userBll.GetUser(logName);
        if (model != null && siteModel != null)
        {
            //用户被锁定
            if (model.IsLock == true)
            {
                lbMsg.Text = "<script>alert('对不起,您已经被锁定,不能登录.')</script>";
                return;
            }
            //用户还在禁止登录时间内
            if (model.ErrorTime > DateTime.Now)
            {
                lbMsg.Text = "<script>alert('对不起,您已经登录错误 " + siteModel.LogErrorNum + " 次,将被禁止登录 " + siteModel.DisabledLoginTime + " 分钟.')</script>";
                return;
            }
            else
            {
                //用户登录
                bool flag = userBll.Login(logName, pwd);
                if (flag)
                {
                    HttpCookie cookie = new HttpCookie("User");
                    cookie["uId"] = model.UserID.ToString();
                    cookie["logN"] = model.LogName;
                    cookie["pd"] = model.UserPwd;
                    //cookie过期时间20分钟
                    cookie.Expires = DateTime.Now.AddMinutes(20);
                    Response.Cookies.Add(cookie);

                    //更新登录信息
                    string lastLoginIP = string.Empty;
                    if (Request.UserHostAddress != null)
                    {
                        lastLoginIP = Request.UserHostAddress;
                    }
                    DateTime currLoginTime = DateTime.Now;
                    DateTime oldLoginTime = model.LastLoginTime;
                    userBll.LoginSuccess(model.UserID, lastLoginIP, currLoginTime);
                    if (currLoginTime.Date != oldLoginTime.Date)
                    {
                        B_Money moneyBll = new B_Money();
                        moneyBll.Integral(siteModel.LoginScore, model.UserID);
                    }
                    //lbMsg.Text = "<script>hiddenIframe();parent.divLoginInfo.innerHTML=\"" + userBll.GetCookie().LogName + " 您好!┆<a href='../user/main.aspx' target='_blank' target='_blank'>发表文章</a>┆<a href='SignOut.aspx'>安全退出</a>\";</script>";
                    lbMsg.Text = "<script>hiddenIframe();parent.location.reload()</script>";
                }

                //登录失败
                //检查错误次数,如果达到设定次数,
                //则更新禁止登录时间
                else
                {
                    //修改时间
                    if (model.ErrorNum >= (siteModel.LogErrorNum - 1))
                    {
                        DateTime errorTime = DateTime.Now.AddMinutes(siteModel.DisabledLoginTime);
                        userBll.LoginFailOnErrorNum(model.UserID, errorTime);
                        lbMsg.Text = "<script>alert('对不起,您已经登录错误 " + siteModel.LogErrorNum + " 次,将被禁止登录 " + siteModel.DisabledLoginTime + " 分钟.')</script>";
                        return;
                    }
                    // 修改次数
                    else
                    {
                        userBll.LoginFailError(model.UserID);
                        lbMsg.Text = "<script>alert('对不起,登录失败!请检查您的用户名和密码.')</script>";
                        return;
                    }
                }
            }
        }

        //用户不存在
        else
        {
            lbMsg.Text = "<script>alert('对不起,此用户不存在')</script>";
            return;
        }
    }
Ejemplo n.º 9
0
    protected void btnAddCateSave_Click(object sender, EventArgs e)
    {
        bool checkForm = CheckValidate();
        if (checkForm)
        {
            if (Id > 0)
            {
                ArticleModel = ArticleBll.GetArticle(Id);
            }
            ArticleModel.Id = Id;
            ArticleModel.ShortContent = SiteBll.GetFiltering(txtShortContent.Text.Trim());
            ArticleModel.ColId = Int32.Parse(Request.Form["ddlColId"].ToString());
            ArticleModel.Title = txtTitle.Text.Trim();
            ArticleModel.LongTitle = txtTitle.Text.Trim();
            ArticleModel.UserCateId = Convert.ToInt32(ddlUserCate.SelectedValue.Trim());
            #region 关键字
            string tagIdStr = string.Empty;
            string nameStr = txtTagNameStr.Text.Trim();
            if (nameStr.Length != 0)
            {
                if (nameStr.StartsWith("|"))
                    nameStr = nameStr.Substring(1, nameStr.Length - 1);
                if (nameStr.EndsWith("|"))
                    nameStr = nameStr.Substring(0, nameStr.Length - 1);
                B_Tag tagBll = new B_Tag();
                DataRow dr = tagBll.AddTagStr(nameStr, ChannelModel.ModelType, UserBll.GetCookie().UserID, UserBll.GetCookie().LogName);
                if (dr != null)
                {
                    tagIdStr = "|" + dr[0] + "|";
                    nameStr = "|" + dr[1] + "|";
                }
                else
                {
                    tagIdStr = "";
                    nameStr = "";
                }
            }
            ArticleModel.TagIdStr = tagIdStr;
            ArticleModel.TagNameStr = nameStr;
            #endregion
            //保存状态Status
            if (((Button)sender).ID == "btnSaveCaoGao")
            {
                ArticleModel.Status = -1;
            }
            else if (((Button)sender).ID == "btnAddCateSave")
            {
                if (ChannelModel != null)
                {
                    if (ChannelModel.VerifyType == 0)
                    {
                        ArticleModel.Status = 3;
                    }
                }
                else
                {
                    ArticleModel.Status = 0;
                }
            }
            ArticleModel.Author = txtAuthor.Text.Trim();
            ArticleModel.Source = txtSource.Text.Trim();
            ArticleModel.ShortContent = SiteBll.GetFiltering(txtShortContent.Text.Trim());
            //录入者ID ,通过传值得到
            ArticleModel.UId = UserModel.UserID;
            //录入者用户名,通过传值得到
            ArticleModel.UName = UserModel.LogName;
            ArticleModel.UserType = 0;
            ArticleModel.TitleType = 1;

            ArticleModel.Content = SiteBll.GetFiltering(txtContent.Value);
            ArticleModel.Content = ArticleModel.Content.Replace(@"<div style=""page-break-after: always""><span style=""display: none"">&nbsp;</span></div>", "{Ky:PAGE}");
            ArticleModel.PointCount = Convert.ToInt32(txtPoint.Text.Trim());
            ArticleModel.AddTime = DateTime.Now;
            ArticleModel.UpdateTime = DateTime.Now;
            ArticleModel.ExpireTime = Convert.ToDateTime("9999-01-01");
            ArticleModel.ViewEndTime = DateTime.Now.AddDays(10).ToString();
            ArticleModel.IsOpened = Convert.ToInt32(hfIsOpened.Value);
            #region 继承栏目相关设置
            if (Id <= 0)
            {
                if (!string.IsNullOrEmpty(Request.Form["ddlColId"]) && Request.Form["ddlColId"] != "-1")
                {
                    ColumnModel = ColumnBll.GetColumn(int.Parse(Request.Form["ddlColId"].ToString()));
                    ArticleModel.TemplatePath = ColumnModel.InfoTemplatePath;
                    ArticleModel.PageType = ColumnModel.InfoPageType;
                    ArticleModel.ChargeType = ColumnModel.ChargeType;
                    ArticleModel.ChargeHourCount = ColumnModel.ChargeHourCount;
                    ArticleModel.ChargeViewCount = ColumnModel.ChargeViewCount;
                    ArticleModel.IsAllowComment = ColumnModel.IsAllowComment;
                }
                // ArticleModel.HitCount = 0;
            }
            #endregion
            //保存
            if (Id > 0)
                ArticleBll.Update(ArticleModel);
            else
            {
                ArticleBll.Add(ArticleModel);
                    #region 增加积分
                //如果频道不需要审核,添加积分
                if (ChannelModel.VerifyType == 0)
                {
                    if (UserModel == null)
                        return;
                    if (UserGroupBll == null)
                        return;
                    string scale = UserGroupBll.Power_UserGroup("Contribute", 0, UserGroupModel.GroupPower);
                    int score = int.Parse(scale) * ColumnModel.ScoreReward;
                    B_Money moneyBll = new B_Money();
                    moneyBll.Integral(score, UserModel.UserID);
                }
                    #endregion
            }
            Response.Redirect("InfoList.aspx?ChId=" + ChId + "&ColId=" + ArticleModel.ColId);
        }
    }
Ejemplo n.º 10
0
    public string AjaxCheckLogin(string UserName, string PassWord, string CookieType, string validate)
    {
        string MyAjaxCheckLogin="";
        //string MyPassWord = Function.MD5Encrypt(PassWord);
        M_Site siteModel = siteInfo.GetSiteModel();
        M_User model = userBll.GetUser(UserName);

        if (siteModel.IsLoginValidate)
        {
            string validateCode = string.Empty;
            if (Session["ValidateCode"] == null)
            {
                MyAjaxCheckLogin = "******";
                return MyAjaxCheckLogin;
            }
            validateCode = Session["ValidateCode"].ToString();
            //验证码错误
            if (validateCode.ToLower() != validate.ToLower())
            {
                MyAjaxCheckLogin = "******";
                return MyAjaxCheckLogin;
            }
        }
        if (model != null && siteModel != null)
        {
            //用户被锁定
            if (model.IsLock == true)
            {
                MyAjaxCheckLogin = "******";
                return MyAjaxCheckLogin;
            }

            //用户还在禁止登录时间内
            if (model.ErrorTime > DateTime.Now)
            {
                MyAjaxCheckLogin = "******" + siteModel.LogErrorNum + " 次,将被系统禁止登录 " + siteModel.DisabledLoginTime + " 分钟.";
                return MyAjaxCheckLogin;
            }
            else
            {
                //用户登录
                bool flag = userBll.Login(UserName, PassWord);
                if (flag)
                {
                    #region
                    System.Web.HttpCookie cookie = new System.Web.HttpCookie("User");
                    cookie["uId"] = model.UserID.ToString();
                    cookie["logN"] = model.LogName;
                    cookie["pd"] = model.UserPwd;
                    //cookie.Expires = DateTime.Now.AddDays(1);
                    System.Web.HttpContext.Current.Response.Cookies.Add(cookie);

                    //更新登录信息
                    string lastLoginIp = string.Empty;
                    if(System.Web.HttpContext.Current.Request.UserHostAddress!=null)
                    {
                         lastLoginIp = System.Web.HttpContext.Current.Request.UserHostAddress;
                    }
                    model.LastLoginIP = System.Web.HttpContext.Current.Request.UserHostAddress;
                    DateTime oldLoginTime = model.LastLoginTime;
                    DateTime currLoginTime = DateTime.Now;

                    userBll.LoginSuccess(model.UserID, lastLoginIp, currLoginTime);
                    if (oldLoginTime.Date != currLoginTime.Date)
                    {
                        B_Money moneyBll = new B_Money();
                        moneyBll.Integral(siteModel.LoginScore, model.UserID);
                    }
                    return "True";
                    #endregion
                }
                else
                {
                    if (model.ErrorNum >= siteModel.LogErrorNum)
                    {
                        DateTime errorTime = DateTime.Now.AddMinutes(siteModel.DisabledLoginTime);
                        userBll.LoginFailOnErrorNum(model.UserID, errorTime);
                    }
                    else
                    {
                        userBll.LoginFailError(model.UserID);
                    }
                    MyAjaxCheckLogin = "******";
                }
            }
        }
        else
        {
            MyAjaxCheckLogin = "******";
        }

        return MyAjaxCheckLogin;
    }