示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string name     = Common.DTRequest.GetFormString("name");
            string username = Common.DTRequest.GetFormString("username");
            string departid = Common.DTRequest.GetFormString("departid");
            string password = Common.DTRequest.GetFormString("password");
            string note     = Common.DTRequest.GetFormString("note");

            int flg = 0;

            if (!bll.Exists(username))
            {
                Model.users model = new Model.users();
                model.name     = name;
                model.departid = departid;
                model.username = username;
                model.password = password;
                model.role     = 0;
                model.addtime  = DateTime.Now.ToString();
                model.note     = note;
                if (bll.Add(model) > 0)
                {
                    flg = 1;
                }
            }
            else
            {
                //用户名存在
                flg = 2;
            }
        }
示例#2
0
        protected void btn_add_Click(object sender, EventArgs e)
        {
            string name       = txt_name.Value;
            string departid   = txt_departid.Value;
            string username   = txt_username.Value;
            string password   = L_pass.Value;
            string repassword = L_repass.Value;

            if (!bll.Exists(username))
            {
                Model.users model = new Model.users();
                model.name     = name;
                model.departid = departid;
                model.username = username;
                model.password = password;
                model.role     = 0;
                model.addtime  = DateTime.Now.ToString();
                model.note     = txt_note.Value;
                bll.Add(model);
            }
            else
            {
                //用户名存在
            }
        }
示例#3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string turl       = DTcms.Common.DTRequest.GetString("turl");
            int    inviter_id = DTcms.Common.DTRequest.GetQueryInt("inviterfrom");

            if (!string.IsNullOrEmpty(turl))
            {
                Common.Utils.WriteCookie(Common.DTKeys.COOKIE_URL_REFERRER, turl);
            }
            if (inviter_id > 0)
            {
                BLL.users userBll = new BLL.users();
                if (userBll.Exists(inviter_id))
                {
                    Model.users userModel = userBll.GetModel(inviter_id);
                    if (userModel.inviter_id > 0)
                    {
                        Common.Utils.WriteCookie("inviter", inviter_id.ToString());
                    }
                }
            }
            Response.Write("inviter:" + Common.Utils.GetCookie("inviter"));
            Response.Write("<br />turl:" + Common.Utils.GetCookie(Common.DTKeys.COOKIE_URL_REFERRER));

            Response.Redirect(GetCodeUrl(appId, Server.UrlEncode("http://www.yuedujing.com/wx_share_init.aspx")));
        }
示例#4
0
        private void validate_username(HttpContext context)
        {
            string username = Vincent._DTcms.DTRequest.GetString("param");

            //如果为Null,退出
            if (string.IsNullOrEmpty(username))
            {
                context.Response.Write("{ \"info\":\"用户名不可为空\", \"status\":\"n\" }");
                return;
            }
            //过滤注册用户名字符
            string[] strArray = userConfig.regkeywords.Split(',');
            foreach (string s in strArray)
            {
                if (s.ToLower() == username.ToLower())
                {
                    context.Response.Write("{ \"info\":\"该用户名不可用\", \"status\":\"n\" }");
                    return;
                }
            }
            BLL.users bll = new BLL.users();
            //查询数据库
            if (!bll.Exists(username.Trim()))
            {
                context.Response.Write("{ \"info\":\"该用户名可用\", \"status\":\"y\" }");
                return;
            }
            context.Response.Write("{ \"info\":\"该用户名已被注册\", \"status\":\"n\" }");
            return;
        }
示例#5
0
        private bool DoAdd()
        {
            bool result = false;

            Model.users model = new Model.users();
            BLL.users   bll   = new BLL.users();

            model.group_id = int.Parse(ddlGroupId.SelectedValue);

            //只允许加团长
            //if(model.group_id != 4){
            //    JscriptMsg("只允许添加团长级别的用户!", "", "Error");
            //    return false;
            //}
            model.PreId        = 0; // int.Parse(DropDownList1.SelectedValue); ;         //团长只允许放在 公司下面
            model.Leftor_right = 0; //团长不区分左右区

            model.Provinces = this.provinces1.Value;
            model.City      = this.city1.Value;

            model.status = int.Parse(rblStatus.SelectedValue);
            //检测用户名是否重复
            if (bll.Exists(txtUserName.Text.Trim()))
            {
                return(false);
            }
            model.user_name = Vincent._DTcms.Utils.DropHTML(txtUserName.Text.Trim());
            //获得6位的salt加密字符串
            model.salt = Vincent._DTcms.Utils.GetCheckCode(6);
            //以随机生成的6位字符串做为密钥加密
            model.password  = _DESEncrypt.Encrypt(txtPassword.Text.Trim(), model.salt);
            model.email     = Vincent._DTcms.Utils.DropHTML(txtEmail.Text);
            model.nick_name = Vincent._DTcms.Utils.DropHTML(txtNickName.Text);
            model.avatar    = Vincent._DTcms.Utils.DropHTML(txtAvatar.Text);
            model.sex       = rblSex.SelectedValue;
            DateTime _birthday;

            if (DateTime.TryParse(txtBirthday.Text.Trim(), out _birthday))
            {
                model.birthday = _birthday;
            }
            model.telphone = Vincent._DTcms.Utils.DropHTML(txtTelphone.Text.Trim());
            model.mobile   = Vincent._DTcms.Utils.DropHTML(txtMobile.Text.Trim());
            model.qq       = Vincent._DTcms.Utils.DropHTML(txtQQ.Text);
            model.address  = Vincent._DTcms.Utils.DropHTML(txtAddress.Text.Trim());
            model.amount   = decimal.Parse(txtAmount.Text.Trim());
            model.point    = int.Parse(txtPoint.Text.Trim());
            //model.exp = int.Parse(txtExp.Text.Trim());
            model.reg_time = DateTime.Now;
            model.reg_ip   = Vincent._DTcms.DTRequest.GetIP();

            if (bll.Add(model, 1) > 0)
            {
                AddAdminLog(Vincent._DTcms.DTEnums.ActionEnum.Add.ToString(), "添加用户:" + model.user_name); //记录日志
                result = true;
            }
            return(result);
        }
示例#6
0
 /// <summary>
 /// 返回用户头像图片地址
 /// </summary>
 /// <param name="user_name">用户ID</param>
 /// <returns>String</returns>
 public string get_user_avatar(int user_id)
 {
     BLL.users bll = new BLL.users();
     if (!bll.Exists(user_id))
     {
         return("");
     }
     return(bll.Get(user_id).avatar);
 }
示例#7
0
 /// <summary>
 /// 返回用户头像图片地址
 /// </summary>
 /// <param name="user_name">用户名</param>
 /// <returns>String</returns>
 protected string get_user_avatar(string user_name)
 {
     BLL.users bll = new BLL.users();
     if (!bll.Exists(user_name))
     {
         return("");
     }
     return(bll.GetModel(user_name).avatar);
 }
示例#8
0
 /// <summary>
 /// 返回用户头像昵称
 /// </summary>
 /// <param name="user_name">用户名</param>
 /// <returns>String</returns>
 public string get_user_nick_name(string user_name)
 {
     BLL.users bll = new BLL.users();
     if (!bll.Exists(user_name))
     {
         return("");
     }
     return(bll.GetModel("user_name='" + user_name + "' and status<3", "top 1 *", "").nick_name);
 }
示例#9
0
 /// <summary>
 /// 返回用户头像图片地址
 /// </summary>
 /// <param name="user_name">用户名</param>
 /// <returns>String</returns>
 protected string get_user_avatar(string user_name)
 {
     BLL.users bll = new BLL.users();
     if (!bll.Exists(user_name))
     {
         return "";
     }
     return bll.GetModel(user_name).avatar;
 }
示例#10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string username = Common.DTRequest.GetQueryString("username");

            BLL.users bll = new BLL.users();
            if (bll.Exists(username))
            {
                Model.users model = bll.GetModel(username);
                HttpContext.Current.Session[DTKeys.SESSION_USER_INFO] = model;
                Session.Timeout = 45;
                Response.Redirect("usercenter.aspx?action=index");
            }
        }
示例#11
0
        private bool DoAdd()
        {
            bool result = false;

            Model.users model = new Model.users();
            BLL.users   bll   = new BLL.users();

            model.group_id = int.Parse(ddlGroupId.SelectedValue);
            model.status   = int.Parse(rblStatus.SelectedValue);
            //检测用户名是否重复
            if (bll.Exists(txtUserName.Text.Trim()))
            {
                JscriptMsg("用户名已存在!", "", "Error");
                return(false);
            }
            model.user_name = Utils.DropHTML(txtUserName.Text.Trim());
            //获得6位的salt加密字符串
            model.salt = Utils.GetCheckCode(6);
            //以随机生成的6位字符串做为密钥加密
            model.password  = DESEncrypt.Encrypt(txtPassword.Text.Trim(), model.salt);
            model.email     = Utils.DropHTML(txtEmail.Text);
            model.nick_name = Utils.DropHTML(txtNickName.Text);
            model.avatar    = Utils.DropHTML(txtAvatar.Text);
            model.sex       = rblSex.SelectedValue;
            DateTime _birthday;

            if (DateTime.TryParse(txtBirthday.Text.Trim(), out _birthday))
            {
                model.birthday = _birthday;
            }
            model.telphone  = Utils.DropHTML(txtTelphone.Text.Trim());
            model.mobile    = Utils.DropHTML(txtMobile.Text.Trim());
            model.qq        = Utils.DropHTML(txtQQ.Text);
            model.address   = Utils.DropHTML(txtAddress.Text.Trim());
            model.amount    = decimal.Parse(txtAmount.Text.Trim());
            model.point     = int.Parse(txtPoint.Text.Trim());
            model.exp       = int.Parse(txtExp.Text.Trim());
            model.reg_time  = DateTime.Now;
            model.reg_ip    = DTRequest.GetIP();
            model.province  = Convert.ToInt32(ddl_province.SelectedValue);
            model.city      = Convert.ToInt32(ddl_city.SelectedValue);
            model.district  = Convert.ToInt32(ddl_district.SelectedValue);
            model.user_type = Convert.ToInt32(rb_user_type.SelectedValue);
            if (bll.Add(model) > 0)
            {
                AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加用户:" + model.user_name); //记录日志
                result = true;
            }
            return(result);
        }
示例#12
0
        /// <summary>
        /// 返回用户头像图片地址
        /// </summary>
        /// <param name="user_name">用户名</param>
        /// <returns>String</returns>
        public string get_user_avatar(string user_name)
        {
            string avatar = string.Empty;

            BLL.users bll = new BLL.users();
            if (!bll.Exists(user_name))
            {
                return("");
            }
            avatar = bll.GetModel("user_name='" + user_name + "' and status<3", "top 1 *", "").avatar;
            if (avatar == "")
            {
                avatar = "/images/noavatar_middle.gif";
            }
            return(avatar);
        }
示例#13
0
        private void user_username(HttpContext context)
        {
            //string username = Vincent._DTcms.Utils.ToHtml(Vincent._DTcms.DTRequest.GetFormString("name").Trim());
            string username = _Request.GetString("name");

            BLL.users bll = new BLL.users();

            if (bll.Exists(username.Trim()))
            {
                context.Response.Write("{\"status\":0, \"msg\":\"该用户名已被注册\"}");
                return;
            }
            else
            {
                context.Response.Write("{\"status\":1, \"msg\":\"用户名可用\"}");
                return;
            }
        }
示例#14
0
 public void chkUserNmae()
 {
     if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["name"]))
     {
         string UserName = HttpContext.Current.Request.QueryString["name"];
         if (bllUSER.Exists(UserName))
         {
             HttpContext.Current.Response.Write("1");
         }
         else
         {
             HttpContext.Current.Response.Write("0");
         }
     }
     else
     {
         HttpContext.Current.Response.Write("1");
     }
 }
示例#15
0
        private void validate_usermobile(HttpContext context)
        {
            string usermobile = Vincent._DTcms.DTRequest.GetString("param");

            //如果为Null,退出
            if (string.IsNullOrEmpty(usermobile))
            {
                context.Response.Write("{ \"info\":\"手机号不可为空\", \"status\":\"n\" }");
                return;
            }
            BLL.users bll = new BLL.users();
            //查询数据库
            if (!bll.Exists(usermobile.Trim()))
            {
                context.Response.Write("{ \"info\":\"该手机号可用\", \"status\":\"y\" }");
                return;
            }
            context.Response.Write("{ \"info\":\"该手机号已被注册\", \"status\":\"n\" }");
            return;
        }
示例#16
0
        public void AddUser()
        {
            string name     = Common.DTRequest.GetFormString("name");
            string username = Common.DTRequest.GetFormString("username");
            string departid = Common.DTRequest.GetFormString("departid");
            string password = Common.DTRequest.GetFormString("password");
            string note     = Common.DTRequest.GetFormString("note");

            BLL.users bll = new BLL.users();

            string strmsg = "";

            if (!bll.Exists(username))
            {
                Model.users model = new Model.users();
                model.name     = name;
                model.departid = departid;
                model.username = username;
                model.password = password;
                model.role     = 0;
                model.addtime  = DateTime.Now.ToString();
                model.note     = note;
                if (bll.Add(model) > 0)
                {
                    strmsg = @"{Success:true,Msg:'添加成功'}";
                }
            }
            else
            {
                //用户名存在
                strmsg = @"{Success:false,Msg:'用户名已存在'}";
            }

            object objjson = JsonConvert.DeserializeObject(strmsg);//系列化Json数据

            Context.Response.Write(objjson.ToString());
            Context.Response.End();
        }
示例#17
0
        private void validate_username(HttpContext context)
        {
            string username    = DTRequest.GetFormString("username");
            string oldusername = DTRequest.GetFormString("oldusername");

            //如果为Null,退出
            if (string.IsNullOrEmpty(username))
            {
                context.Response.Write("false");
                return;
            }
            Model.userconfig userConfig = new BLL.userconfig().loadConfig(Utils.GetXmlMapPath(DTKeys.FILE_USER_XML_CONFING));
            //过滤注册用户名字符
            string[] strArray = userConfig.regkeywords.Split(',');
            foreach (string s in strArray)
            {
                if (s.ToLower() == username.ToLower())
                {
                    context.Response.Write("false");
                    return;
                }
            }
            //检查是否修改操作
            if (username == oldusername)
            {
                context.Response.Write("true");
                return;
            }
            BLL.users bll = new BLL.users();
            //查询数据库
            if (bll.Exists(username.Trim()))
            {
                context.Response.Write("false");
                return;
            }
            context.Response.Write("true");
            return;
        }
示例#18
0
        private void user_register(HttpContext context)
        {
            string code     = Vincent._DTcms.DTRequest.GetFormString("txtCode").Trim();
            string salt     = Vincent._DTcms.DTRequest.GetFormString("txtSalt").Trim();
            string username = Vincent._DTcms.Utils.ToHtml(Vincent._DTcms.DTRequest.GetFormString("txtName").Trim());
            string password = Vincent._DTcms.DTRequest.GetFormString("txtPwd").Trim();
            //string mobile = Vincent._DTcms.Utils.ToHtml(Vincent._DTcms.DTRequest.GetFormString("txtMobile").Trim());
            string userip     = Vincent._DTcms.DTRequest.GetIP();
            string saltstring = "";

            #region 检查各项并提示

            BLL.users   bll   = new BLL.users();
            Model.users model = new Model.users();
            //if (bll.ExistsMobile(username))
            //{
            //    HttpContext.Current.Response.Clear();
            //    HttpContext.Current.Response.Write("{\"status\":0, \"msg\":\"该手机号已经注册!\"}");
            //    HttpContext.Current.Response.End();
            //    return;
            //}
            if (salt != "")
            {
                saltstring = bll.GetSalt(salt);
            }
            if (bll.Exists(username.Trim()))
            {
                context.Response.Write("{\"status\":0, \"msg\":\"该用户名已被注册!\"}");
                return;
            }
            //检查是否开启会员功能
            if (siteConfig.memberstatus == 0)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,会员功能已关闭,无法注册!\"}");
                return;
            }
            if (userConfig.regstatus == 0)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,系统暂不允许注册新用户!\"}");
                return;
            }
            if (code.ToLower() != (_Cookie.GetCookie(Vincent._DTcms.DTKeys.SESSION_SMS_CODE).ToString()).ToLower())
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,你的手机验证码不正确!\"}");
                return;
            }
            #endregion

            //保存注册信息
            model.group_id   = 1;                                    //普通用户注册
            model.user_name  = username;
            model.salt       = Vincent._DTcms.Utils.GetCheckCode(6); //获得6位的salt加密字符串
            model.password   = _DESEncrypt.Encrypt(password, model.salt);
            model.mobile     = username;
            model.reg_ip     = userip;
            model.parentSalt = saltstring;
            model.reg_time   = DateTime.Now;
            model.isMobile   = 1;
            model.strcode    = Vincent._DTcms.Utils.GetCheckCode(20);//生成随机码
            //设置对应的状态
            switch (userConfig.regverify)
            {
            case 0:
                model.status = 0;     //正常
                break;

            case 3:
                model.status = 2;     //人工审核
                break;

            default:
                model.status = 1;     //待验证
                break;
            }
            int newId = bll.Add(model);
            if (newId < 1)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"系统故障,请联系网站管理员!\"}");
                return;
            }
            model = bll.GetModel(newId);

            if (model != null)
            {
                context.Session[Vincent._DTcms.DTKeys.SESSION_USER_INFO] = model;
                context.Session.Timeout = 45;

                //防止Session提前过期
                Vincent._DTcms.Utils.WriteCookie(Vincent._DTcms.DTKeys.COOKIE_USER_NAME_REMEMBER, "BuysingooShop", model.user_name);
                Vincent._DTcms.Utils.WriteCookie(Vincent._DTcms.DTKeys.COOKIE_USER_PWD_REMEMBER, "BuysingooShop", model.password);

                //写入登录日志
                new BLL.user_login_log().Add(model.id, model.user_name, "会员登录");
                context.Response.Write("{\"status\":1, \"msg\":\"注册成功,欢迎成为本站会员!\"}");
            }
            else
            {
                context.Response.Write("{\"status\":0, \"msg\":\"注册失败!\"}");
            }
        }
示例#19
0
 private void validate_username(HttpContext context)
 {
     string username = DTRequest.GetString("username");
     //如果为Null,退出
     if (string.IsNullOrEmpty(username))
     {
         context.Response.Write("null");
         return;
     }
     //过滤注册用户名字符
     string[] strArray = userConfig.regkeywords.Split(',');
     foreach (string s in strArray)
     {
         if (s.ToLower() == username.ToLower())
         {
             context.Response.Write("lock");
             return;
         }
     }
     BLL.users bll = new BLL.users();
     //查询数据库
     if (!bll.Exists(username.Trim()))
     {
         context.Response.Write("true");
         return;
     }
     context.Response.Write("false");
     return;
 }
示例#20
0
        private void user_repassword(HttpContext context)
        {
            string code = context.Request.Form["txtCode"];
            string strcode = context.Request.Form["hideCode"];
            string password = context.Request.Form["txtPassword"];

            //校检验证码
            string result = verify_code(context, code);
            if (result != "success")
            {
                context.Response.Write(result);
                return;
            }
            //检查验证字符串
            if (string.IsNullOrEmpty(strcode))
            {
                context.Response.Write("{\"msg\":0, \"msgbox\":\"系统找不到邮件验证的字符串!\"}");
                return;
            }
            //检查输入的新密码
            if (string.IsNullOrEmpty(password))
            {
                context.Response.Write("{\"msg\":0, \"msgbox\":\"请输入您的新密码!\"}");
                return;
            }

            BLL.user_code codeBll = new BLL.user_code();
            Model.user_code codeModel = codeBll.GetModel(strcode);
            if (codeModel == null)
            {
                context.Response.Write("{\"msg\":0, \"msgbox\":\"邮件验证的字符串不存在或已过期!\"}");
                return;
            }
            //验证用户是否存在
            BLL.users userBll = new BLL.users();
            if (!userBll.Exists(codeModel.user_id))
            {
                context.Response.Write("{\"msg\":0, \"msgbox\":\"该用户不存在或已被删除!\"}");
                return;
            }
            Model.users userModel = userBll.GetModel(codeModel.user_id);
            //执行修改操作
            userModel.password = DESEncrypt.Encrypt(password);
            userBll.Update(userModel);
            //更改验证字符串状态
            codeModel.count = 1;
            codeModel.status = 1;
            codeBll.Update(codeModel);
            context.Response.Write("{\"msg\":1, \"msgbox\":\"修改密码成功,请记住您的新密码!\"}");
            return;
        }
示例#21
0
        private void user_register(HttpContext context)
        {
            string code = DTRequest.GetFormString("txtCode").Trim();
            string invitecode = DTRequest.GetFormString("txtInviteCode").Trim();
            string username = DTRequest.GetFormString("txtUserName").Trim();
            string password = DTRequest.GetFormString("txtPassword").Trim();
            string email = DTRequest.GetFormString("txtEmail").Trim();
            string userip = DTRequest.GetIP();

            #region 检查各项并提示
            //检查是否开启会员功能
            if (siteConfig.memberstatus == 0)
            {
                context.Response.Write("{\"msg\":0, \"msgbox\":\"对不起,会员功能已被关闭,无法注册新会员!\"}");
                return;
            }
            if (userConfig.regstatus == 0)
            {
                context.Response.Write("{\"msg\":0, \"msgbox\":\"对不起,系统暂不允许注册新用户!\"}");
                return;
            }
            //校检验证码
            string result = verify_code(context, code);
            if (result != "success")
            {
                context.Response.Write(result);
                return;
            }
            //检查用户输入信息是否为空
            if (username == "" || password == "")
            {
                context.Response.Write("{\"msg\":0, \"msgbox\":\"用户名和密码不能为空!\"}");
                return;
            }
            if (email == "")
            {
                context.Response.Write("{\"msg\":0, \"msgbox\":\"电子邮箱不能为空!\"}");
                return;
            }

            //检查用户名
            BLL.users bll = new BLL.users();
            Model.users model = new Model.users();
            if (bll.Exists(username))
            {
                context.Response.Write("{\"msg\":0, \"msgbox\":\"该用户名已经存在!\"}");
                return;
            }
            //检查同一IP注册时隔
            if (userConfig.regctrl > 0)
            {
                if (bll.Exists(userip, userConfig.regctrl))
                {
                    context.Response.Write("{\"msg\":0, \"msgbox\":\"对不起,同一IP在" + userConfig.regctrl + "小时内不能注册多个用户!\"}");
                    return;
                }
            }
            //不允许同一Email注册不同用户
            if (userConfig.regemailditto == 0)
            {
                if (bll.ExistsEmail(email))
                {
                    context.Response.Write("{\"msg\":0, \"msgbox\":\"Email不允许重复注册,如果你忘记用户名,请找回密码!\"}");
                    return;
                }
            }
            //检查默认组别是否存在
            Model.user_groups modelGroup = new BLL.user_groups().GetDefault();
            if (modelGroup == null)
            {
                context.Response.Write("{\"msg\":0, \"msgbox\":\"系统尚未分组,请联系管理员设置会员分组!\"}");
                return;
            }
            //检查是否通过邀请码注册
            if (userConfig.regstatus == 2)
            {
                string result1 = verify_invite_reg(username, invitecode);
                if (result1 != "success")
                {
                    context.Response.Write(result1);
                    return;
                }
            }
            #endregion

            //保存注册信息
            model.group_id = modelGroup.id;
            model.user_name = username;
            model.password = DESEncrypt.Encrypt(password);
            model.email = email;
            model.reg_ip = userip;
            model.reg_time = DateTime.Now;
            model.is_lock = userConfig.regverify; //设置为对应状态
            int newId = bll.Add(model);
            if (newId < 1)
            {
                context.Response.Write("{\"msg\":0, \"msgbox\":\"系统故障,注册失败,请联系网站管理员!\"}");
                return;
            }
            model = bll.GetModel(newId);
            //赠送积分金额
            if (modelGroup.point > 0)
            {
                new BLL.point_log().Add(model.id, model.user_name, modelGroup.point, "注册赠送积分");
            }
            if (modelGroup.amount > 0)
            {
                new BLL.amount_log().Add(model.id, model.user_name, DTEnums.AmountTypeEnum.SysGive.ToString(), modelGroup.amount, "注册赠送金额", 1);
            }
            //判断是否发送站内短消息
            if (userConfig.regmsgstatus == 1)
            {
                new BLL.user_message().Add(1, "", model.user_name, "欢迎您成为本站会员", userConfig.regmsgtxt);
            }
            //需要Email验证
            if (userConfig.regverify == 1)
            {
                string result2 = verify_email(model);
                if (result2 != "success")
                {
                    context.Response.Write(result2);
                    return;
                }
                context.Response.Write("{\"msg\":1, \"url\":\"" + new Web.UI.BasePage().linkurl("register") + "?action=sendmail&username="******"\", \"msgbox\":\"注册成功,请进入邮箱验证激活账户!\"}");
            }
            //需要人工审核
            else if (userConfig.regverify == 2)
            {
                context.Response.Write("{\"msg\":1, \"url\":\"" + new Web.UI.BasePage().linkurl("register") + "?action=verify&username="******"\", \"msgbox\":\"注册成功,请等待审核通过!\"}");
            }
            else
            {
                context.Response.Write("{\"msg\":1, \"url\":\"" + new Web.UI.BasePage().linkurl("register") + "?action=succeed&username="******"\", \"msgbox\":\"恭喜您,注册成功啦!\"}");
            }
            return;
        }
示例#22
0
        private bool DoAdd()
        {
            bool result = false;

            Model.users model = new Model.users();
            BLL.users   bll   = new BLL.users();

            model.group_id = int.Parse(ddlGroupId.SelectedValue);
            model.status   = int.Parse(rblStatus.SelectedValue);
            //檢測用戶名是否重複
            if (bll.Exists(txtUserName.Text.Trim()))
            {
                return(false);
            }
            model.user_name = Utils.DropHTML(txtUserName.Text.Trim());
            //獲得6位的salt加密字串
            model.salt = Utils.GetCheckCode(6);
            //以隨機生成的6位字串做為金鑰加密
            model.password  = DESEncrypt.Encrypt(txtPassword.Text.Trim(), model.salt);
            model.email     = Utils.DropHTML(txtEmail.Text);
            model.nick_name = Utils.DropHTML(txtNickName.Text);
            model.avatar    = Utils.DropHTML(txtAvatar.Text);
            model.sex       = rblSex.SelectedValue;
            DateTime _birthday;

            if (DateTime.TryParse(txtBirthday.Text.Trim(), out _birthday))
            {
                model.birthday = _birthday;
            }
            model.telphone = Utils.DropHTML(txtTelphone.Text.Trim());
            model.mobile   = Utils.DropHTML(txtMobile.Text.Trim());

            model.address = Utils.DropHTML(txtAddress.Text.Trim());
            model.amount  = Utils.StrToInt(txtAmount.Text.Trim(), 0);
            model.point   = Utils.StrToInt(txtPoint.Text.Trim(), 0);

            model.reg_time = DateTime.Now;
            model.reg_ip   = TWRequest.GetIP();
            if (TWRequest.GetFormString("txt_guo") == "台灣")
            {
                model.area = TWRequest.GetFormString("txt_guo") + "," + TWRequest.GetFormString("txt_state") + "," + TWRequest.GetFormString("txt_city");
            }
            else
            {
                model.area = TWRequest.GetFormString("txt_guo") + "," + TWRequest.GetFormString("txt_state1") + "," + TWRequest.GetFormString("txt_city1");
            }
            model.qq = TWRequest.GetFormString("txt_zip");
            if (cbExp.Checked)
            {
                model.exp = 1;
            }
            else
            {
                model.exp = 0;
            }
            if (bll.Add(model) > 0)
            {
                AddAdminLog(TWEnums.ActionEnum.Add.ToString(), "添加用戶:" + model.user_name); //記錄日誌
                result = true;
            }
            return(result);
        }
示例#23
0
 private void validate_username(HttpContext context)
 {
     string username = DTRequest.GetFormString("username");
     string oldusername = DTRequest.GetFormString("oldusername");
     //如果为Null,退出
     if (string.IsNullOrEmpty(username))
     {
         context.Response.Write("false");
         return;
     }
     Model.userconfig userConfig = new BLL.userconfig().loadConfig(Utils.GetXmlMapPath(DTKeys.FILE_USER_XML_CONFING));
     //过滤注册用户名字符
     string[] strArray = userConfig.regkeywords.Split(',');
     foreach (string s in strArray)
     {
         if (s.ToLower() == username.ToLower())
         {
             context.Response.Write("false");
             return;
         }
     }
     //检查是否修改操作
     if (username == oldusername)
     {
         context.Response.Write("true");
         return;
     }
     BLL.users bll = new BLL.users();
     //查询数据库
     if (bll.Exists(username.Trim()))
     {
         context.Response.Write("false");
         return;
     }
     context.Response.Write("true");
     return;
 }
 private void validate_username(HttpContext context)
 {
     string user_name = MXRequest.GetString("param");
     //如果为Null,退出
     if (string.IsNullOrEmpty(user_name))
     {
         context.Response.Write("{ \"info\":\"请输入用户名\", \"status\":\"n\" }");
         return;
     }
     Model.userconfig userConfig = new BLL.userconfig().loadConfig();
     //过滤注册用户名字符
     string[] strArray = userConfig.regkeywords.Split(',');
     foreach (string s in strArray)
     {
         if (s.ToLower() == user_name.ToLower())
         {
             context.Response.Write("{ \"info\":\"用户名不可用\", \"status\":\"n\" }");
             return;
         }
     }
     BLL.users bll = new BLL.users();
     //查询数据库
     if (bll.Exists(user_name.Trim()))
     {
         context.Response.Write("{ \"info\":\"用户名已重复\", \"status\":\"n\" }");
         return;
     }
     context.Response.Write("{ \"info\":\"用户名可用\", \"status\":\"y\" }");
     return;
 }
示例#25
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            BLL.users   userBll = new BLL.users();
            BLL.manager mBll    = new BLL.manager();
            Model.users user    = null;
            string      action  = context.Request.QueryString["action"];
            DataTable   dt      = null;

            BLL.BarCode bllBar = null;
            switch (action)
            {
            case "username":
                if (userBll.Exists(context.Request.QueryString["username"]))
                {
                    context.Response.Write("false");
                }
                else
                {
                    context.Response.Write("true");
                }
                break;

            case "adminusername":
                if (mBll.Exists(context.Request.QueryString["username"]))
                {
                    context.Response.Write("false");
                }
                else
                {
                    context.Response.Write("true");
                }
                break;

            case "tel":
                if (userBll.ExistsMobile(context.Request.Form["param"]))
                {
                    context.Response.Write("{\"info\":\"该手机已存在!\",\"status\":\"n\"}");
                }
                else
                {
                    context.Response.Write("{\"info\":\"" + context.Request.Form["param"] + "为新用户,成功累计积分后系统自动注册为正式会员,默认密码为123456\",\"status\":\"y\"}");
                }
                break;

            case "tel2":
                if (userBll.ExistsMobile(context.Request.QueryString["tel"]))
                {
                    context.Response.Write("false");
                }
                else
                {
                    context.Response.Write("true");
                }
                break;

            case "IntegralCode":
                bllBar = new BLL.BarCode();
                DataSet ds = null;
                ds = bllBar.QueryIntegralCode(context.Request.Form["param"]);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && Convert.ToInt32(ds.Tables[0].Rows[0]["state"]) < 4)
                {
                    context.Response.Write("{\"info\":\"验证通过!\",\"status\":\"y\"}");
                }
                else
                {
                    context.Response.Write("{\"info\":\"该积分码不存在或已兑换!\",\"status\":\"n\"}");
                }
                break;

            case "UserIntegralCode":
                bllBar = new BLL.BarCode();
                ds     = bllBar.QueryIntegralCode(context.Request.QueryString["IntegralCode"]);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && Convert.ToInt32(ds.Tables[0].Rows[0]["state"]) < 4)
                {
                    context.Response.Write("true");
                }
                else
                {
                    context.Response.Write("false");
                }
                break;

            case "Username":
                BLL.users bll = new BLL.users();
                //查询数据库
                if (!bll.Exists(context.Request.QueryString["Username"]))
                {
                    context.Response.Write("true");
                }
                else
                {
                    context.Response.Write("false");
                }
                break;

            case "Exit":
                context.Session[DTKeys.SESSION_USER_INFO] = null;
                break;

            case "SearchLogisticsCode":
                bllBar = new BLL.BarCode();
                dt     = bllBar.GetBarCodeByLogisticsCode(context.Request.QueryString["LogisticsCode"]);
                if (dt != null)
                {
                    IsoDateTimeConverter timeFormat2 = new IsoDateTimeConverter();
                    timeFormat2.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                    context.Response.Write(JsonConvert.SerializeObject(dt, timeFormat2));
                }
                else
                {
                    context.Response.Write("false");
                }
                break;

            case "SearchIntegralCode":
                bllBar = new BLL.BarCode();
                dt     = bllBar.GetBarCodeByIntegralCode(context.Request.QueryString["IntegralCode"]);

                if (dt != null)
                {
                    IsoDateTimeConverter timeFormat2 = new IsoDateTimeConverter();
                    timeFormat2.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                    context.Response.Write(JsonConvert.SerializeObject(dt, timeFormat2));
                }
                else
                {
                    context.Response.Write("false");
                }
                break;

            case "State":
                context.Response.Write(Convert.ToInt32(context.Request.QueryString["State"]).ToEnumDescriptionString(typeof(EnumList.StateList)));
                break;

            case "OrderState":
                context.Response.Write(Convert.ToInt32(context.Request.QueryString["State"]).ToEnumDescriptionString(typeof(EnumList.OrderState)));
                break;

            //更换头像之后替换用户信息session
            case "Avatar":
                user = context.Session[DTKeys.SESSION_USER_INFO] as Model.users;
                user = userBll.GetModel(user.user_name);
                context.Session[DTKeys.SESSION_USER_INFO] = user;
                break;
            }
        }
示例#26
0
        private bool DoAdd()
        {
            bool result = false;
            Model.users model = new Model.users();
            BLL.users bll = new BLL.users();

            model.group_id = int.Parse(ddlGroupId.SelectedValue);
            model.status = int.Parse(rblStatus.SelectedValue);
            //检测用户名是否重复
            if (bll.Exists(txtUserName.Text.Trim()))
            {
                JscriptMsg("用户名已存在!", "", "Error");
                return false;
            }
            model.user_name = Utils.DropHTML(txtUserName.Text.Trim());
            //获得6位的salt加密字符串
            model.salt = Utils.GetCheckCode(6);
            //以随机生成的6位字符串做为密钥加密
            model.password = DESEncrypt.Encrypt(txtPassword.Text.Trim(), model.salt);
            model.email = Utils.DropHTML(txtEmail.Text);
            model.nick_name = Utils.DropHTML(txtNickName.Text);
            model.avatar = Utils.DropHTML(txtAvatar.Text);
            model.sex = rblSex.SelectedValue;
            DateTime _birthday;
            if (DateTime.TryParse(txtBirthday.Text.Trim(), out _birthday))
            {
                model.birthday = _birthday;
            }
            model.telphone = Utils.DropHTML(txtTelphone.Text.Trim());
            model.mobile = Utils.DropHTML(txtMobile.Text.Trim());
            model.qq = Utils.DropHTML(txtQQ.Text);
            model.address = Utils.DropHTML(txtAddress.Text.Trim());
            model.amount = decimal.Parse(txtAmount.Text.Trim());
            model.point = int.Parse(txtPoint.Text.Trim());
            model.exp = int.Parse(txtExp.Text.Trim());
            model.reg_time = DateTime.Now;
            model.reg_ip = DTRequest.GetIP();
            model.province = Convert.ToInt32(ddl_province.SelectedValue);
            model.city = Convert.ToInt32(ddl_city.SelectedValue);
            model.district = Convert.ToInt32(ddl_district.SelectedValue);
            model.user_type = Convert.ToInt32(rb_user_type.SelectedValue);
            if (bll.Add(model) > 0)
            {
                AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加用户:" + model.user_name); //记录日志
                result = true;
            }
            return result;
        }
示例#27
0
        private void user_register(HttpContext context)
        {
            string site = DTRequest.GetQueryString("site").Trim(); //当前站点
            string code = DTRequest.GetFormString("txtCode").Trim();
            string username = Utils.ToHtml(DTRequest.GetFormString("txtUserName").Trim());
            string password = DTRequest.GetFormString("txtPassword").Trim();
            string email = Utils.ToHtml(DTRequest.GetFormString("txtEmail").Trim());
            string mobile = Utils.ToHtml(DTRequest.GetFormString("txtMobile").Trim());
            string userip = DTRequest.GetIP();

            #region 验证各种参数信息
            //检查站点目录是否正确
            if (string.IsNullOrEmpty(site))
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,网站传输参数有误!\"}");
                return;
            }
            //检查是否开启会员功能
            if (siteConfig.memberstatus == 0)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,会员功能已关闭,无法注册!\"}");
                return;
            }
            if (userConfig.regstatus == 0)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,系统暂不允许注册新用户!\"}");
                return;
            }
            //检查用户输入信息是否为空
            if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,用户名和密码不能为空!\"}");
                return;
            }
            //如果开启手机注册则要验证手机
            if (userConfig.regstatus == 2 && string.IsNullOrEmpty(mobile))
            {
                context.Response.Write("{\"status\":0, \"msg\":\"错误:手机号码不能为空!\"}");
                return;
            }
            //如果开启邮箱注册则要验证邮箱
            if (userConfig.regstatus == 3 && string.IsNullOrEmpty(email))
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,电子邮箱不能为空!\"}");
                return;
            }
            //检查用户名
            BLL.users bll = new BLL.users();
            if (bll.Exists(username))
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,该用户名已经存在!\"}");
                return;
            }
            //如果开启手机登录要验证手机
            if (userConfig.mobilelogin == 1 && !string.IsNullOrEmpty(mobile))
            {
                if (bll.ExistsMobile(mobile))
                {
                    context.Response.Write("{\"status\":0, \"msg\":\"对不起,该手机号码已被使用!\"}");
                    return;
                }
            }
            //如果开启邮箱登录要验证邮箱
            if (userConfig.emaillogin == 1 && !string.IsNullOrEmpty(email))
            {
                if (bll.ExistsEmail(email))
                {
                    context.Response.Write("{\"status\":0, \"msg\":\"对不起,该电子邮箱已被使用!\"}");
                    return;
                }
            }
            //检查同一IP注册时隔
            if (userConfig.regctrl > 0)
            {
                if (bll.Exists(userip, userConfig.regctrl))
                {
                    context.Response.Write("{\"status\":0, \"msg\":\"对不起,同IP在" + userConfig.regctrl + "小时内禁止重复注册!\"}");
                    return;
                }
            }
            //检查默认组别是否存在
            Model.user_groups modelGroup = new BLL.user_groups().GetDefault();
            if (modelGroup == null)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"用户尚未分组,请联系网站管理员!\"}");
                return;
            }
            //检查验证码是否正确
            switch (userConfig.regstatus)
            {
                case 1: //验证网页验证码
                    string result1 = verify_code(context, code);
                    if (result1 != "success")
                    {
                        context.Response.Write(result1);
                        return;
                    }
                    break;
                case 2: //验证手机验证码
                    string result2 = verify_sms_code(context, code);
                    if (result2 != "success")
                    {
                        context.Response.Write(result2);
                        return;
                    }
                    break;
                case 4: //验证邀请码
                    string result4 = verify_invite_reg(username, code);
                    if (result4 != "success")
                    {
                        context.Response.Write(result4);
                        return;
                    }
                    break;
            }
            #endregion

            #region 保存用户注册信息
            Model.users model = new Model.users();
            model.group_id = modelGroup.id;
            model.user_name = username;
            model.salt = Utils.GetCheckCode(6); //获得6位的salt加密字符串
            model.password = DESEncrypt.Encrypt(password, model.salt);
            model.email = email;
            model.mobile = mobile;
            model.reg_ip = userip;
            model.reg_time = DateTime.Now;
            //设置用户状态
            if (userConfig.regstatus == 3)
            {
                model.status = 1; //待验证
            }
            else if (userConfig.regverify == 1)
            {
                model.status = 2; //待审核
            }
            else
            {
                model.status = 0; //正常
            }
            //开始写入数据库
            model.id = bll.Add(model);
            if (model.id < 1)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"系统故障,请联系网站管理员!\"}");
                return;
            }
            //检查用户组是否需要赠送积分
            if (modelGroup.point > 0)
            {
                new BLL.user_point_log().Add(model.id, model.user_name, modelGroup.point, "注册赠送积分", false);
            }
            //检查用户组是否需要赠送金额
            if (modelGroup.amount > 0)
            {
                new BLL.user_amount_log().Add(model.id, model.user_name, modelGroup.amount, "注册赠送金额");
            }
            #endregion

            #region 是否发送欢迎消息
            if (userConfig.regmsgstatus == 1) //站内短消息
            {
                new BLL.user_message().Add(1, string.Empty, model.user_name, "欢迎您成为本站会员", userConfig.regmsgtxt);
            }
            else if (userConfig.regmsgstatus == 2 && !string.IsNullOrEmpty(email)) //发送邮件
            {
                //取得邮件模板内容
                Model.mail_template mailModel = new BLL.mail_template().GetModel("welcomemsg");
                if (mailModel != null)
                {
                    //替换标签
                    string mailTitle = mailModel.maill_title;
                    mailTitle = mailTitle.Replace("{username}", model.user_name);
                    string mailContent = mailModel.content;
                    mailContent = mailContent.Replace("{webname}", siteConfig.webname);
                    mailContent = mailContent.Replace("{weburl}", siteConfig.weburl);
                    mailContent = mailContent.Replace("{webtel}", siteConfig.webtel);
                    mailContent = mailContent.Replace("{username}", model.user_name);
                    //发送邮件
                    DTMail.sendMail(siteConfig.emailsmtp,siteConfig.emailssl, siteConfig.emailusername, siteConfig.emailpassword, siteConfig.emailnickname,
                        siteConfig.emailfrom, model.email, mailTitle, mailContent);
                }
            }
            else if (userConfig.regmsgstatus == 3 && !string.IsNullOrEmpty(mobile)) //发送短信
            {
                Model.sms_template smsModel = new BLL.sms_template().GetModel("welcomemsg"); //取得短信内容
                if (smsModel != null)
                {
                    //替换标签
                    string msgContent = smsModel.content;
                    msgContent = msgContent.Replace("{webname}", siteConfig.webname);
                    msgContent = msgContent.Replace("{weburl}", siteConfig.weburl);
                    msgContent = msgContent.Replace("{webtel}", siteConfig.webtel);
                    msgContent = msgContent.Replace("{username}", model.user_name);
                    //发送短信
                    string tipMsg = string.Empty;
                    new BLL.sms_message().Send(model.mobile, msgContent, 2, out tipMsg);
                }
            }
            #endregion

            //需要Email验证
            if (userConfig.regstatus == 3)
            {
                string result2 = send_verify_email(site, model); //发送验证邮件
                if (result2 != "success")
                {
                    context.Response.Write(result2);
                    return;
                }
                context.Response.Write("{\"status\":1, \"msg\":\"注册成功,请进入邮箱验证激活账户!\", \"url\":\""
                    + new Web.UI.BasePage().getlink(site, new Web.UI.BasePage().linkurl("register", "?action=sendmail&username="******"\"}");
            }
            //需要人工审核
            else if (userConfig.regverify == 1)
            {
                context.Response.Write("{\"status\":1, \"msg\":\"注册成功,请等待审核通过!\", \"url\":\""
                    + new Web.UI.BasePage().getlink(site, new Web.UI.BasePage().linkurl("register", "?action=verify&username="******"\"}");
            }
            else
            {
                context.Session[DTKeys.SESSION_USER_INFO] = model;
                context.Session.Timeout = 45;
                //防止Session提前过期
                Utils.WriteCookie(DTKeys.COOKIE_USER_NAME_REMEMBER, "DTcms", model.user_name);
                Utils.WriteCookie(DTKeys.COOKIE_USER_PWD_REMEMBER, "DTcms", model.password);
                //写入登录日志
                new BLL.user_login_log().Add(model.id, model.user_name, "会员登录");
                context.Response.Write("{\"status\":1, \"msg\":\"注册成功,欢迎成为本站会员!\", \"url\":\""
                    + new Web.UI.BasePage().getlink(site, new Web.UI.BasePage().linkurl("usercenter", "index")) + "\"}");
            }
            return;
        }
示例#28
0
        private void user_repassword(HttpContext context)
        {
            string strcode = DTRequest.GetFormString("hideCode"); //取回密码字符串
            string password = DTRequest.GetFormString("txtPassword"); //重设后的密码

            //检查验证字符串
            if (string.IsNullOrEmpty(strcode))
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,校检码字符串不能为空!\"}");
                return;
            }
            //检查输入的新密码
            if (string.IsNullOrEmpty(password))
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,请输入您的新密码!\"}");
                return;
            }

            BLL.user_code codeBll = new BLL.user_code();
            Model.user_code codeModel = codeBll.GetModel(strcode);
            if (codeModel == null)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,校检码不存在或已过期!\"}");
                return;
            }
            //验证用户是否存在
            BLL.users userBll = new BLL.users();
            if (!userBll.Exists(codeModel.user_id))
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,该用户不存在或已被删除!\"}");
                return;
            }
            Model.users userModel = userBll.GetModel(codeModel.user_id);
            //执行修改操作
            userModel.password = DESEncrypt.Encrypt(password, userModel.salt);
            userBll.Update(userModel);
            //更改验证字符串状态
            codeModel.count = 1;
            codeModel.status = 1;
            codeBll.Update(codeModel);
            context.Response.Write("{\"status\":1, \"msg\":\"修改密码成功,请记住新密码!\"}");
            return;
        }
示例#29
0
        /// <summary>
        /// 添加分配账户员工
        /// </summary>
        /// <param name="context"></param>
        private void dealing_users(HttpContext context)
        {
            string username = DTRequest.GetString("username");
            string password = DTRequest.GetString("psd");
            string phone = DTRequest.GetString("phone");
            string email = DTRequest.GetString("email");
            string real_name = DTRequest.GetString("real_name");
            int branch = DTRequest.GetFormInt("branch_id");
            Model.users model = new Model.users();
            BLL.users bll = new BLL.users();
            Model.users model1 = new BasePage().GetUserInfo();
            if (model1 == null)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,请重新登录!\"}");
                return;
            }

            if (bll.Exists(username))
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,该账户名已存在!\"}");
                return;

            }
            model.user_name = username;
            model.password = password;
            model.telphone = phone;
            model.real_name = real_name;
            model.email = email;
            model.branch_id = branch;
            model.user_status = 3;
            model.user_type = 1;
            model.parent_id = model1.id;
            model.group_id = 1;
            if (bll.Add(model) > 0)
            {
                context.Response.Write("{\"status\":1, \"msg\":\"添加员工成功!\"}");
                return;

            }
            else
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,添加员工失败!\"}");
                return;

            }
        }
示例#30
0
        private void user_register(HttpContext context)
        {
            string code = DTRequest.GetFormString("txtCode").Trim();
            string invitecode = DTRequest.GetFormString("txtInviteCode").Trim();
            string username = Utils.ToHtml(DTRequest.GetFormString("txtUserName").Trim());
            string password = DTRequest.GetFormString("txtPassword").Trim();
            string email = Utils.ToHtml(DTRequest.GetFormString("txtEmail").Trim());
            string mobile = Utils.ToHtml(DTRequest.GetFormString("txtMobile").Trim());
            string userip = DTRequest.GetIP();

            #region 检查各项并提示
            //检查是否开启会员功能
            if (siteConfig.memberstatus == 0)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,会员功能已关闭,无法注册!\"}");
                return;
            }
            if (userConfig.regstatus == 0)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,系统暂不允许注册新用户!\"}");
                return;
            }
            //校检验证码,如果注册使用手机短信则只需验证手机验证码,否则使用网页验证码
            if (userConfig.regstatus == 2) //手机验证码
            {
                string result = verify_sms_code(context, code);
                if (result != "success")
                {
                    context.Response.Write(result);
                    return;
                }
            }
            else //网页验证码
            {
                string result = verify_code(context, code);
                if (result != "success")
                {
                    context.Response.Write(result);
                    return;
                }
            }
            //检查用户输入信息是否为空
            if (username == "" || password == "")
            {
                context.Response.Write("{\"status\":0, \"msg\":\"错误:用户名和密码不能为空!\"}");
                return;
            }
            if (userConfig.regemailditto == 0 && email == "")
            {
                context.Response.Write("{\"status\":0, \"msg\":\"错误:电子邮箱不能为空!\"}");
                return;
            }
            if (userConfig.mobilelogin == 1 && mobile == "")
            {
                context.Response.Write("{\"status\":0, \"msg\":\"错误:手机号码不能为空!\"}");
                return;
            }

            //检查用户名
            BLL.users bll = new BLL.users();
            Model.users model = new Model.users();
            if (bll.Exists(username))
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,该用户名已经存在!\"}");
                return;
            }
            //检查同一IP注册时隔
            if (userConfig.regctrl > 0)
            {
                if (bll.Exists(userip, userConfig.regctrl))
                {
                    context.Response.Write("{\"status\":0, \"msg\":\"对不起,同IP在" + userConfig.regctrl + "小时内禁止重复注册!\"}");
                    return;
                }
            }
            //不允许同一Email注册不同用户
            if (userConfig.regemailditto == 0 || userConfig.emaillogin == 1)
            {
                if (bll.ExistsEmail(email))
                {
                    context.Response.Write("{\"status\":0, \"msg\":\"对不起,该邮箱已被注册!\"}");
                    return;
                }
            }
            //不允许同一手机号码注册不同用户
            if (userConfig.mobilelogin == 1)
            {
                if (bll.ExistsMobile(mobile))
                {
                    context.Response.Write("{\"status\":0, \"msg\":\"对不起,该手机号码已被注册!\"}");
                    return;
                }
            }
            //检查默认组别是否存在
            Model.user_groups modelGroup = new BLL.user_groups().GetDefault();
            if (modelGroup == null)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"用户尚未分组,请联系网站管理员!\"}");
                return;
            }
            //检查是否通过邀请码注册
            if (userConfig.regstatus == 2)
            {
                string result1 = verify_invite_reg(username, invitecode);
                if (result1 != "success")
                {
                    context.Response.Write(result1);
                    return;
                }
            }
            #endregion

            //保存注册信息
            model.group_id = modelGroup.id;
            model.user_name = username;
            model.salt = Utils.GetCheckCode(6); //获得6位的salt加密字符串
            model.password = DESEncrypt.Encrypt(password, model.salt);
            model.email = email;
            model.mobile = mobile;
            model.reg_ip = userip;
            model.reg_time = DateTime.Now;
            //设置对应的状态
            switch (userConfig.regverify)
            {
                case 0:
                    model.status = 0; //正常
                    break;
                case 3:
                    model.status = 2; //人工审核
                    break;
                default:
                    model.status = 1; //待验证
                    break;
            }
            int newId = bll.Add(model);
            if (newId < 1)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"系统故障,请联系网站管理员!\"}");
                return;
            }
            model = bll.GetModel(newId);
            //赠送积分金额
            if (modelGroup.point > 0)
            {
                new BLL.user_point_log().Add(model.id, model.user_name, modelGroup.point, "注册赠送积分", false);
            }
            if (modelGroup.amount > 0)
            {
                new BLL.user_amount_log().Add(model.id, model.user_name, DTEnums.AmountTypeEnum.SysGive.ToString(), modelGroup.amount, "注册赠送金额", 1);
            }

            #region 判断是否发送欢迎消息
            if (userConfig.regmsgstatus == 1) //站内短消息
            {
                new BLL.user_message().Add(1, "", model.user_name, "欢迎您成为本站会员", userConfig.regmsgtxt);
            }
            else if (userConfig.regmsgstatus == 2) //发送邮件
            {
                //取得邮件模板内容
                Model.mail_template mailModel = new BLL.mail_template().GetModel("welcomemsg");
                if (mailModel != null)
                {
                    //替换标签
                    string mailTitle = mailModel.maill_title;
                    mailTitle = mailTitle.Replace("{username}", model.user_name);
                    string mailContent = mailModel.content;
                    mailContent = mailContent.Replace("{webname}", siteConfig.webname);
                    mailContent = mailContent.Replace("{weburl}", siteConfig.weburl);
                    mailContent = mailContent.Replace("{webtel}", siteConfig.webtel);
                    mailContent = mailContent.Replace("{username}", model.user_name);
                    //发送邮件
                    DTMail.sendMail(siteConfig.emailsmtp, siteConfig.emailusername, siteConfig.emailpassword, siteConfig.emailnickname,
                        siteConfig.emailfrom, model.email, mailTitle, mailContent);
                }
            }
            else if (userConfig.regmsgstatus == 3 && mobile != "") //发送短信
            {
                Model.sms_template smsModel = new BLL.sms_template().GetModel("welcomemsg"); //取得短信内容
                if (smsModel != null)
                {
                    //替换标签
                    string msgContent = smsModel.content;
                    msgContent = msgContent.Replace("{webname}", siteConfig.webname);
                    msgContent = msgContent.Replace("{weburl}", siteConfig.weburl);
                    msgContent = msgContent.Replace("{webtel}", siteConfig.webtel);
                    msgContent = msgContent.Replace("{username}", model.user_name);
                    //发送短信
                    string tipMsg = string.Empty;
                    new BLL.sms_message().Send(model.mobile, msgContent, 2, out tipMsg);
                }
            }
            #endregion

            //需要Email验证
            if (userConfig.regverify == 1)
            {
                string result2 = verify_email(model);
                if (result2 != "success")
                {
                    context.Response.Write(result2);
                    return;
                }
                context.Response.Write("{\"status\":1, \"url\":\"" + new Web.UI.BasePage().linkurl("register") + "?action=sendmail&username="******"\", \"msg\":\"注册成功,请进入邮箱验证激活账户!\"}");
            }
            //手机短信验证
            else if (userConfig.regverify == 2)
            {
                string result3 = verify_mobile(model);
                if (result3 != "success")
                {
                    context.Response.Write(result3);
                    return;
                }
                context.Response.Write("{\"status\":1, \"url\":\"" + new Web.UI.BasePage().linkurl("register") + "?action=sendsms&username="******"\", \"msg\":\"注册成功,请查收短信验证激活账户!\"}");
            }
            //需要人工审核
            else if (userConfig.regverify == 3)
            {
                context.Response.Write("{\"status\":1, \"url\":\"" + new Web.UI.BasePage().linkurl("register") + "?action=verify&username="******"\", \"msg\":\"注册成功,请等待审核通过!\"}");
            }
            else
            {
                context.Session[DTKeys.SESSION_USER_INFO] = model;
                context.Session.Timeout = 45;

                //防止Session提前过期
                Utils.WriteCookie(DTKeys.COOKIE_USER_NAME_REMEMBER, "DTcms", model.user_name);
                Utils.WriteCookie(DTKeys.COOKIE_USER_PWD_REMEMBER, "DTcms", model.password);

                //写入登录日志
                new BLL.user_login_log().Add(model.id, model.user_name, "会员登录");

                context.Response.Write("{\"status\":1, \"url\":\"" + new Web.UI.BasePage().linkurl("register") + "?action=succeed&username="******"\", \"msg\":\"注册成功,欢迎成为本站会员!\"}");
            }
            return;
        }
示例#31
0
        private bool DoAdd()
        {
            bool result = false;

            Model.users model = new Model.users();
            BLL.users   bll   = new BLL.users();

            model.group_id = int.Parse(ddlGroupId.SelectedValue);
            model.status   = int.Parse(rblStatus.SelectedValue);
            //检测用户名是否重复
            if (bll.Exists(txtUserName.Text.Trim()))
            {
                return(false);
            }
            model.user_name = Utils.DropHTML(txtUserName.Text.Trim());
            //获得6位的salt加密字符串
            model.salt = Utils.GetCheckCode(6);
            //以随机生成的6位字符串做为密钥加密
            model.password  = DESEncrypt.Encrypt(txtPassword.Text.Trim(), model.salt);
            model.email     = Utils.DropHTML(txtEmail.Text);
            model.nick_name = Utils.DropHTML(txtNickName.Text);
            model.avatar    = Utils.DropHTML(txtAvatar.Text);
            model.sex       = rblSex.SelectedValue;
            DateTime _birthday;

            if (DateTime.TryParse(txtBirthday.Text.Trim(), out _birthday))
            {
                model.birthday = _birthday;
            }
            model.telphone = Utils.DropHTML(txtTelphone.Text.Trim());
            model.mobile   = Utils.DropHTML(txtMobile.Text.Trim());
            model.qq       = Utils.DropHTML(txtQQ.Text);
            model.address  = Utils.DropHTML(txtAddress.Text.Trim());
            //model.amount = decimal.Parse(txtAmount.Text.Trim());
            model.point = int.Parse(txtPoint.Text.Trim());
            //model.exp = int.Parse(txtExp.Text.Trim());
            model.reg_time       = DateTime.Now;
            model.reg_ip         = DTRequest.GetIP();
            model.id_card_number = txtIdCard.Text.Trim();
            model.real_name      = txtRealName.Text.Trim();

            int userId = bll.Add(model);

            if (0 < userId)
            {
                // 会员部功能,被推荐人自动归组
                if (ddlServingGroup.SelectedValue != "")
                {
                    context.li_user_group_servers.InsertOnSubmit(new li_user_group_servers
                    {
                        group_id     = Convert.ToInt32(ddlServingGroup.Text),
                        serving_user = userId
                    });
                }
                // 创建借款人信息
                UpdateLoanerInfo(userId, model.reg_time);

                // 保存身份证照片
                try
                {
                    var user = context.dt_users.First(u => u.id == userId);
                    LoadAlbum(user, Agp2pEnums.AlbumTypeEnum.IdCard);
                    context.SubmitChanges();
                }
                catch (Exception ex)
                {
                    AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加用户出错:" + ex.Message);
                }
                AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加用户:" + model.user_name); //记录日志
                result = true;
            }
            return(result);
        }
示例#32
0
        /// <summary>
        /// 将在Init事件执行
        /// </summary>
        protected void payment_Init(object sender, EventArgs e)
        {
            //取得处事类型
            action   = DTRequest.GetString("action");
            order_no = DTRequest.GetString("order_no");
            if (order_no.ToUpper().StartsWith("R")) //充值订单
            {
                order_type = DTEnums.AmountTypeEnum.Recharge.ToString().ToLower();
            }
            else if (order_no.ToUpper().StartsWith("B")) //商品订单
            {
                order_type = DTEnums.AmountTypeEnum.BuyGoods.ToString().ToLower();
            }

            switch (action)
            {
            case "confirm":
                if (string.IsNullOrEmpty(action) || string.IsNullOrEmpty(order_no))
                {
                    HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,URL传输参数有误!")));
                    return;
                }
                //是否需要支持匿名购物
                userModel = new Web.UI.BasePage().GetUserInfo();     //取得用户登录信息
                if (orderConfig.anonymous == 0 || order_no.ToUpper().StartsWith("R"))
                {
                    if (userModel == null)
                    {
                        //用户未登录
                        HttpContext.Current.Response.Redirect(linkurl("payment", "?action=login"));
                        return;
                    }
                }
                else if (userModel == null)
                {
                    userModel = new Model.users();
                }
                //检查订单的类型(充值或购物)
                if (order_no.ToUpper().StartsWith("R"))     //充值订单
                {
                    rechargeModel = new BLL.user_recharge().GetModel(order_no);
                    if (rechargeModel == null)
                    {
                        HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,订单号不存在或已删除!")));
                        return;
                    }
                    //检查订单号是否已支付
                    if (rechargeModel.status == 1)
                    {
                        HttpContext.Current.Response.Redirect(linkurl("payment", "?action=succeed&order_no=" + rechargeModel.recharge_no));
                        return;
                    }
                    //检查支付方式
                    payModel = new BLL.payment().GetModel(rechargeModel.payment_id);
                    if (payModel == null)
                    {
                        HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,支付方式不存在或已删除!")));
                        return;
                    }
                    //检查是否线上支付
                    if (payModel.type == 2)
                    {
                        HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,账户充值不允许线下支付!")));
                        return;
                    }
                    order_amount = rechargeModel.amount;     //订单金额
                }
                else if (order_no.ToUpper().StartsWith("B")) //商品订单
                {
                    //检查订单是否存在
                    orderModel = new BLL.orders().GetModel(order_no);
                    if (orderModel == null)
                    {
                        HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,订单号不存在或已删除!")));
                        return;
                    }
                    //检查是否已支付过
                    if (orderModel.payment_status == 2)
                    {
                        HttpContext.Current.Response.Redirect(linkurl("payment", "?action=succeed&order_no=" + orderModel.order_no));
                        return;
                    }
                    //检查支付方式
                    payModel = new BLL.payment().GetModel(orderModel.payment_id);
                    if (payModel == null)
                    {
                        HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,支付方式不存在或已删除!")));
                        return;
                    }
                    //检查是否线下付款
                    if (orderModel.payment_status == 0)
                    {
                        HttpContext.Current.Response.Redirect(linkurl("payment", "?action=succeed&order_no=" + orderModel.order_no));
                        return;
                    }
                    //检查是否积分换购,直接跳转成功页面
                    if (orderModel.order_amount == 0)
                    {
                        //修改订单状态
                        bool result = new BLL.orders().UpdateField(orderModel.order_no, "status=2,payment_status=2,payment_time='" + DateTime.Now + "'");
                        if (!result)
                        {
                            HttpContext.Current.Response.Redirect(linkurl("payment", "?action=error"));
                            return;
                        }
                        HttpContext.Current.Response.Redirect(linkurl("payment", "?action=succeed&order_no=" + orderModel.order_no));
                        return;
                    }
                    order_amount = orderModel.order_amount;     //订单金额
                }
                else
                {
                    HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,找不到您要提交的订单类型!")));
                    return;
                }
                break;

            case "succeed":
                //检查订单的类型(充值或购物)
                if (order_no.ToUpper().StartsWith("R"))     //充值订单
                {
                    rechargeModel = new BLL.user_recharge().GetModel(order_no);
                    if (rechargeModel == null)
                    {
                        HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,订单号不存在或已删除!")));
                        return;
                    }
                }
                else if (order_no.ToUpper().StartsWith("B"))     //商品订单
                {
                    orderModel = new BLL.orders().GetModel(order_no);
                    if (orderModel == null)
                    {
                        HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,订单号不存在或已删除!")));
                        return;
                    }
                }
                else
                {
                    string        pay_id  = order_no;
                    Model.UserPay userPay = new BLL.UserPay().Get("id='" + pay_id + "'");
                    userPay.status = 1;
                    new BLL.UserPay().Update(userPay, "id='" + pay_id + "'");

                    BLL.users         bll        = new BLL.users();
                    string            user_id    = userPay.openid;
                    Model.user_groups modelGroup = new BLL.user_groups().GetDefault();
                    if (!bll.Exists(user_id + "-1"))
                    {
                        Model.users u1 = new Model.users();
                        u1.group_id   = modelGroup.id;
                        u1.user_name  = user_id + "-1";
                        u1.salt       = Utils.GetCheckCode(6); //获得6位的salt加密字符串
                        u1.password   = DESEncrypt.Encrypt("123456", u1.salt);
                        u1.email      = u1.user_name + "@a.com";
                        u1.mobile     = "";
                        u1.reg_ip     = "";
                        u1.nick_name  = "帐户1";
                        u1.reg_time   = DateTime.Now;
                        u1.status     = 0; //正常
                        u1.wx_open_id = user_id;
                        u1.is_show    = 1;
                        u1.id         = bll.Add(u1);
                    }
                    if (!bll.Exists(user_id + "-2"))
                    {
                        Model.users u2 = new Model.users();
                        u2.group_id   = modelGroup.id;
                        u2.user_name  = user_id + "-2";
                        u2.salt       = Utils.GetCheckCode(6); //获得6位的salt加密字符串
                        u2.password   = DESEncrypt.Encrypt("123456", u2.salt);
                        u2.email      = u2.user_name + "@a.com";
                        u2.mobile     = "";
                        u2.reg_ip     = "";
                        u2.nick_name  = "帐户2";
                        u2.reg_time   = DateTime.Now;
                        u2.status     = 0; //正常
                        u2.wx_open_id = user_id;
                        u2.is_show    = 0;

                        //开始写入数据库
                        u2.id = bll.Add(u2);
                    }
                    if (!bll.Exists(user_id + "-3"))
                    {
                        Model.users u3 = new Model.users();
                        u3.group_id   = modelGroup.id;
                        u3.user_name  = user_id + "-3";
                        u3.salt       = Utils.GetCheckCode(6); //获得6位的salt加密字符串
                        u3.password   = DESEncrypt.Encrypt("123456", u3.salt);
                        u3.email      = u3.user_name + "@a.com";
                        u3.nick_name  = "帐户3";
                        u3.mobile     = "";
                        u3.reg_ip     = "";
                        u3.reg_time   = DateTime.Now;
                        u3.status     = 0; //正常
                        u3.wx_open_id = user_id;
                        u3.is_show    = 0;

                        //开始写入数据库
                        u3.id = bll.Add(u3);
                    }
                }
                break;
            }
        }