示例#1
0
 protected string SetUserGroup(object author)
 {
     string userType = "";
     if (author != null)
     {
         B_User userBll = new B_User();
         M_User userModel = userBll.GetUser(author.ToString());
         B_UserGroup userGroupBll = new B_UserGroup();
         DataTable dt = userGroupBll.ManageList("");
         if (dt.Rows.Count > 0 && userModel != null)
         {
             for (int i = 0; i < dt.Rows.Count; i++)
             {
                 if (dt.Rows[i]["UserGroupId"].ToString() == userModel.GroupID.ToString())
                 {
                     userType = dt.Rows[i]["UserGroupName"].ToString();
                     break;
                 }
             }
         }
     }
     else
     {
         userType = "游客";
     }
     return userType;
 }
示例#2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        InfoTable.Visible = false;
        B_User user = new B_User();
        M_User userModel = user.GetUser(user.GetCookie().UserID);

        B_SiteInfo site = new B_SiteInfo();
        M_Site siteModel = site.GetSiteModel();
        if (userModel != null)
        {
            if (siteModel.IsOpenInvite)
            {
                B_UserGroup groupBll = new B_UserGroup();
                string integral = groupBll.Power_UserGroup("Invite", 0, groupBll.GetModel(userModel.GroupID).GroupPower);
                lbIntegral.Text = integral;
                if (siteModel.Domain.EndsWith("/"))
                {
                    txtUrl.Text = siteModel.Domain + "user/Reg.aspx?TypeId=" + userModel.TypeId + "&recmd_uid=" + userModel.UserID;
                }
                else
                {
                    txtUrl.Text = siteModel.Domain + "/user/Reg.aspx?TypeId=" + userModel.TypeId + "&recmd_uid=" + userModel.UserID;
                }
            }
            else
            {
                InfoTable.Visible = true;
                MainTable.Visible = false;
            }
        }
        else
        {
            Response.Redirect("Login.aspx");
        }
    }
示例#3
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>";
                }
            }
        }
    }
示例#4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        CustomFormId = int.Parse(Request.QueryString["CustomFormId"]);
        dtIsUser = BCustomFormField.GetIsUserList(CustomFormId);
        MCustomForm = BCustomForm.GetModel(CustomFormId);

        if (!Page.IsPostBack)
        {
            //验证
            GetIsOk();

            if (MCustomForm.IsValidate)
            {
                string validateCode = string.Empty;
                if (Session["ValidateCode"] == null)
                {
                    Function.ShowMsg(0, "<li>你在页面停留的时间过长,验证码已经失效</li><li><a href='javascript:window.history.back(-1)'>返回上一步</a></li>");
                }

                validateCode = Session["ValidateCode"].ToString();
                //验证码错误
                if (validateCode != Request.Form["txtValidate"].Trim().ToLower())
                {
                    Function.ShowMsg(0, "<li>验证码错误</li><li><a href='javascript:window.history.back(-1)'>返回上一步</a></li>");
                }
            }

            int sUId = 0;
            string sUName = "匿名用户";

            if (BUser.IsLogin())
            {
                sUId = BUser.GetCookie().UserID;
                sUName = BUser.GetUser(BUser.GetCookie().UserID).LogName;
            }

            //只允许提交一次
            if (MCustomForm.IsSubmitNum)
            {
                //判断是否多次提交
                if (!Function.ReadTempCookies("CustomForm_" + CustomFormId, CustomFormId.ToString()))
                {
                    Function.SaveTempCookies("CustomForm_" + CustomFormId, CustomFormId.ToString());
                }
                else
                {
                    Function.ShowMsg(0, "<li>" + MCustomForm.FormName + "设置用户只能够提交一次数据</li><li><a href='javascript:window.history.back(-1)'>返回上一步</a></li>");
                }
            }

            //金币
            if (sUId != 0)
            {
                B_User buser = new B_User();
                M_User muser = buser.GetUser(sUId);

                if (muser.YellowBoy + MCustomForm.Money < 0)
                {
                    Function.ShowMsg(0, "<li>你剩余的金币不足,无法提交该表单</li><li><a href='javascript:window.history.back(-1)'>返回上一步</a></li>");
                }
                else
                {
                    BMoney.YellowBoy(MCustomForm.Money, sUId);
                }
            }

            string TableName = MCustomForm.TableName;

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

            #region 系统默认字段
            DataRow dr1 = dt.NewRow();
            dr1[0] = "UId";
            dr1[1] = sUId;
            dt.Rows.Add(dr1);

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

            DataRow dr3 = dt.NewRow();
            dr3[0] = "Ip";
            dr3[1] = Request.ServerVariables["REMOTE_ADDR"];
            dt.Rows.Add(dr3);

            DataRow dr4 = dt.NewRow();
            dr4[0] = "AddTime";
            dr4[1] = DateTime.Now.ToString();
            dt.Rows.Add(dr4);

            #endregion

            //以下是自动添加字段获得值
            for (int i = 0; i < dtIsUser.Rows.Count; i++)
            {
                DataRow dr = dt.NewRow();
                dr[0] = dtIsUser.Rows[i]["Name"].ToString();

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

            //添加信息
            BInfoModel.AddInfoModel(dt, TableName);

            Function.ShowMsg(1, "<li>成功提交信息</li><li><a href='javascript:window.history.back(-1)'>返回上一步</a></li>");

            dtIsUser.Clear();
            dtIsUser.Dispose();
        }
    }
示例#5
0
文件: B_User.cs 项目: suizhikuo/KYCMS
 public bool IsLogin()
 {
     B_User user = new B_User();
     if (HttpContext.Current.Request.Cookies["User"] == null)
     {
         return false;
     }
     string logName = string.Empty;
     string str2 = string.Empty;
     if (HttpContext.Current.Request.Cookies["User"]["logN"] != null)
     {
         logName = Ky.Common.Function.UrlDecode(HttpContext.Current.Request.Cookies["User"]["logN"]);
     }
     if (HttpContext.Current.Request.Cookies["User"]["pd"] != null)
     {
         str2 = Ky.Common.Function.UrlDecode(HttpContext.Current.Request.Cookies["User"]["pd"]);
     }
     if ((logName == string.Empty) || (str2 == string.Empty))
     {
         return false;
     }
     M_User user2 = null;
     user2 = user.GetUser(logName);
     if ((user2 == null) || (user2.UserPwd != str2))
     {
         return false;
     }
     return true;
 }