Exemplo n.º 1
0
        /// 注册
        /// </summary>
        public void regist(HttpContext context)
        {
            string outmsg    = "{\"status\":1,\"msg\":\"注册成功!\"}";
            string mobile    = _Request.GetString("mobile");
            string usersname = _Request.GetString("usersname");
            string password  = _Request.GetString("password");
            string usersaera = _Request.GetString("usersaera");
            string usernick  = _Request.GetString("usernick");//y用户昵称



            string userPwd1 = Vincent._MD5Encrypt.GetMD5(password.Trim());

            Model.users model = new Model.users();
            BLL.users   bll   = new BLL.users();
            model.user_name    = mobile;
            model.mobile       = mobile;
            model.isEmail      = 0;
            model.isMobile     = 0;
            model.Parentid     = 0;
            model.Leftor_right = 0;
            model.MarketId     = 0;
            model.OrganizeId   = 0;
            model.PreId        = 0;
            model.nick_name    = usernick;//用户昵称
            //model.password = Vincent._DESEncrypt.Encrypt(password.Trim());
            //model.password = Vincent._DESEncrypt.Encrypt(password.Trim());
            model.salt     = Vincent._DTcms.Utils.GetCheckCode(6); //获得6位的salt加密字符串
            model.password = _DESEncrypt.Encrypt(password, model.salt);
            if (!bll.ExistsMobile(mobile))
            {
                int id = bll.AddPc(model);
                if (id > 0)
                {
                    DataTable dt = bll.GetList(0, "id  =" + id + " ", "id asc").Tables[0];
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        outmsg = CreateJsonParameters(dt);
                    }
                    //// 保存session值
                    context.Session[DTKeys.SESSION_USER_INFO] = model;
                    context.Session.Timeout = 45;
                    context.Response.Clear();
                    context.Response.Write(outmsg);
                    context.Response.End();
                }
                else
                {
                    context.Response.Clear();
                    context.Response.Write("{\"status\":0,\"msg\":\"注册未成功!\"}");
                    context.Response.End();
                }
            }
            else
            {
                context.Response.Clear();
                context.Response.Write("{\"status\":0,\"msg\":\"注册未成功!\"}");
                context.Response.End();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 检测推荐码是否存在
        /// </summary>
        /// <param name="context"></param>
        private void user_salt(HttpContext context)
        {
            //string username = Vincent._DTcms.Utils.ToHtml(Vincent._DTcms.DTRequest.GetFormString("name").Trim());
            string usersalt = _Request.GetString("salt");

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

            if (!bll.ExistsMobile(usersalt.Trim()))
            {
                context.Response.Write("该推荐码不可用");
                return;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 获取手机短信验证码
        /// </summary>
        public void GetMobileMsgcode(HttpContext context)
        {
            string mobile = _Request.GetString("mobile", "");



            BLL.users bll       = new BLL.users();
            string    outresult = "";

            if (string.IsNullOrEmpty(mobile))
            {
                outresult = "{\"status\":\"n\",\"info\":\"手机号不能为空\"}";
                context.Response.Clear();
                context.Response.Write(outresult);
                context.Response.End();
            }
            if (bll.ExistsMobile(mobile))
            {
                outresult = "{\"status\":\"n\",\"info\":\"手机号已被注册\"}";
                context.Response.Clear();
                context.Response.Write(outresult);
                context.Response.End();
            }

            Random rd      = new Random();
            int    msgcode = rd.Next(100000, 999999);

            var messageNum = Vincent._MobileMessage.SendMessageCode(msgcode.ToString(), mobile);

            if (messageNum >= 0)
            {
                //写Session,设置验证码有效期,比如10分钟
                _Session.SetSession(DTKeys.SESSION_CODE, msgcode.ToString());
                _Cookie.SetCookie(DTKeys.SESSION_SMS_CODE, msgcode.ToString(), 600);

                outresult = "{\"status\":\"y\",\"info\":" + msgcode + "}";
            }
            else
            {
                outresult = "{\"status\":\"n\",\"info\":\"短信发送失败\"}";
            }

            context.Response.Clear();
            context.Response.Write(outresult);
            context.Response.End();
        }
Exemplo n.º 4
0
        /// <summary>
        /// 检测手机号是否存在
        /// </summary>
        /// <param name="context"></param>
        private void user_mobile(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.ExistsMobile(username.Trim()))
            {
                context.Response.Write("{\"status\":0, \"msg\":\"该手机号已被注册\"}");
                return;
            }
            else
            {
                context.Response.Write("{\"status\":1, \"msg\":\"手机号可用\"}");
                return;
            }
        }
Exemplo n.º 5
0
        private void user_info_edit(HttpContext context)
        {
            //检查用户是否登录
            Model.users model = new BasePage().GetUserInfo();
            if (model == null)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,用户尚未登录或已超时!\"}");
                return;
            }
            string nick_name = Utils.ToHtml(DTRequest.GetFormString("txtNickName"));
            string sex = DTRequest.GetFormString("rblSex");
            string birthday = DTRequest.GetFormString("txtBirthday");
            string email = Utils.ToHtml(DTRequest.GetFormString("txtEmail"));
            string mobile = Utils.ToHtml(DTRequest.GetFormString("txtMobile"));
            string telphone = Utils.ToHtml(DTRequest.GetFormString("txtTelphone"));
            string qq = Utils.ToHtml(DTRequest.GetFormString("txtQQ"));
            string msn = Utils.ToHtml(DTRequest.GetFormString("txtMsn"));
            string province = Utils.ToHtml(DTRequest.GetFormString("txtProvince"));
            string city = Utils.ToHtml(DTRequest.GetFormString("txtCity"));
            string area = Utils.ToHtml(DTRequest.GetFormString("txtArea"));
            string address = Utils.ToHtml(context.Request.Form["txtAddress"]);
            //检查昵称
            if (string.IsNullOrEmpty(nick_name))
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,请输入您的姓名昵称!\"}");
                return;
            }
            //检查省市区
            if (string.IsNullOrEmpty(province) || string.IsNullOrEmpty(city) || string.IsNullOrEmpty(area))
            {
                context.Response.Write("{\"status\":0, \"msg\":\"对不起,请选择您所在的省市区!\"}");
                return;
            }
            BLL.users bll = new BLL.users();
            //检查手机,如开启手机注册或使用手机登录需要检查
            if (userConfig.regstatus == 2 || userConfig.mobilelogin == 1)
            {
                if (string.IsNullOrEmpty(mobile))
                {
                    context.Response.Write("{\"status\":0, \"msg\":\"对不起,请输入您的手机号码!\"}");
                    return;
                }
                if (model.mobile != mobile && bll.ExistsMobile(mobile))
                {
                    context.Response.Write("{\"status\":0, \"msg\":\"对不起,该手机号码已被使用!\"}");
                    return;
                }
            }
            //检查邮箱,如开启邮箱注册或使用邮箱登录需要检查
            if (userConfig.regstatus == 3 || userConfig.emaillogin == 1)
            {
                if (string.IsNullOrEmpty(email))
                {
                    context.Response.Write("{\"status\":0, \"msg\":\"对不起,请输入您的电子邮箱!\"}");
                    return;
                }
                if (model.email != email && bll.ExistsEmail(email))
                {
                    context.Response.Write("{\"status\":0, \"msg\":\"对不起,该电子邮箱已被使用!\"}");
                    return;
                }
            }

            //开始写入数据库
            model.nick_name = nick_name;
            model.sex = sex;
            DateTime _birthday;
            if (DateTime.TryParse(birthday, out _birthday))
            {
                model.birthday = _birthday;
            }
            model.email = email;
            model.mobile = mobile;
            model.telphone = telphone;
            model.qq = qq;
            model.msn = msn;
            model.area = province + "," + city + "," + area;
            model.address = address;

            bll.Update(model);
            context.Response.Write("{\"status\":1, \"msg\":\"账户资料已修改成功!\"}");
            return;
        }
Exemplo n.º 6
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;
        }
Exemplo n.º 7
0
        private void user_oauth_register(HttpContext context)
        {
            //检查URL参数
            if (context.Session["oauth_name"] == null)
            {
                context.Response.Write("{\"status\": 0, \"msg\": \"错误提示:授权参数不正确!\"}");
                return;
            }
            //获取授权信息
            string result = Utils.UrlExecute(siteConfig.webpath + "api/oauth/" + context.Session["oauth_name"].ToString() + "/result_json.aspx");
            if (result.Contains("error"))
            {
                context.Response.Write("{\"status\": 0, \"msg\": \"错误提示:请检查URL是否正确!\"}");
                return;
            }
            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();
            //反序列化JSON
            Dictionary<string, object> dic = JsonHelper.DataRowFromJSON(result);
            if (dic["ret"].ToString() != "0")
            {
                context.Response.Write("{\"status\": 0, \"msg\": \"错误代码:" + dic["ret"] + "," + dic["msg"] + "\"}");
                return;
            }
            BLL.users bll = new BLL.users();
            Model.users model = new Model.users();
            //如果开启手机登录要验证手机
            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;
                }
            }
            //检查默认组别是否存在
            Model.user_groups modelGroup = new BLL.user_groups().GetDefault();
            if (modelGroup == null)
            {
                context.Response.Write("{\"status\":0, \"msg\":\"用户尚未分组,请联系管理员!\"}");
                return;
            }
            //保存注册信息
            model.group_id = modelGroup.id;
            model.user_name = bll.GetRandomName(10); //随机用户名
            model.salt = Utils.GetCheckCode(6); //获得6位的salt加密字符串
            model.password = DESEncrypt.Encrypt(password, model.salt);
            model.email = email;
            model.mobile = mobile;
            if (!string.IsNullOrEmpty(dic["nick"].ToString()))
            {
                model.nick_name = dic["nick"].ToString();
            }
            if (dic["avatar"].ToString().StartsWith("http://"))
            {
                model.avatar = dic["avatar"].ToString();
            }
            if (!string.IsNullOrEmpty(dic["sex"].ToString()))
            {
                model.sex = dic["sex"].ToString();
            }
            if (!string.IsNullOrEmpty(dic["birthday"].ToString()))
            {
                model.birthday = Utils.StrToDateTime(dic["birthday"].ToString());
            }
            model.reg_ip = userip;
            model.reg_time = DateTime.Now;
            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, "注册赠送金额");
            }
            //判断是否发送欢迎消息
            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.emailssl, 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);
                }
            }
            //绑定到对应的授权类型
            Model.user_oauth oauthModel = new Model.user_oauth();
            oauthModel.oauth_name = dic["oauth_name"].ToString();
            oauthModel.user_id = model.id;
            oauthModel.user_name = model.user_name;
            oauthModel.oauth_access_token = dic["oauth_access_token"].ToString();
            oauthModel.oauth_openid = dic["oauth_openid"].ToString();
            new BLL.user_oauth().Add(oauthModel);

            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, "会员登录");
            //返回URL
            context.Response.Write("{\"status\":1, \"msg\":\"会员登录成功!\"}");
            return;
        }
Exemplo n.º 8
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;
        }
Exemplo n.º 9
0
        public string SendMsgCode(string mobile)
        {
            BLL.users bll       = new BLL.users();
            string    outresult = "";

            if (string.IsNullOrEmpty(mobile))
            {
                outresult = "{\"status\":\"n\",\"info\":\"手机号不能为空\"}";
                return(outresult);
            }

            if (bll.ExistsMobile(mobile))
            {
                //outresult = "{\"status\":\"n\",\"info\":\"改手机号已注册\"}";
                //return outresult;
            }
            else
            {
                //注册到数据库中去
                string outmsg   = "n";
                string realname = "";
                string password = "";

                int preId      = 0;
                int marketId   = 0;
                int organizeId = 0;

                var jsondata = GetUserRegedit2(mobile, "", password, marketId, organizeId, preId, realname);
                if (!string.IsNullOrEmpty(jsondata))
                {
                    if (!jsondata.Contains("已被注册"))
                    {
                        outmsg = "{\"status\":\"y\",\"info\":" + jsondata + "}";
                    }

                    _Log.SaveMessage("注册成功:" + mobile + "/" + password + "/" + mobile + "/" + marketId + "/" + organizeId + "/" + preId);
                }
                else
                {
                    _Log.SaveMessage("注册失败:" + mobile + "/" + password + "/" + mobile + "/" + marketId + "/" + organizeId + "/" + preId);
                }
            }

            Random rd      = new Random();
            int    msgcode = rd.Next(100000, 999999);

            //写短信数据,发SMS
            var message_name    = _Utility.GetConfigAppSetting("message_name");
            var message_pwd     = _Utility.GetConfigAppSetting("message_pwd");
            var message_content = _Utility.GetConfigAppSetting("message_content");

            message_content = message_content.Replace("num", msgcode.ToString());

            var MessageNum = Vincent._MobileMessage.SendMessageCode(msgcode.ToString(), mobile);

            Model.userconfig userConfig = new BLL.userconfig().loadConfig();
            if (MessageNum >= 0)
            {
                //写Session,设置验证码有效期,比如10分钟
                //_Session.SetSession(DTKeys.SESSION_CODE, smscoderand);
                userConfig.regstatus = 2;
                _Cookie.SetCookie(Vincent._DTcms.DTKeys.SESSION_SMS_CODE, msgcode.ToString(), 600);
                outresult = "{\"status\":\"y\",\"info\":" + msgcode + "}";
            }
            else
            {
                outresult = "{\"status\":\"n\",\"info\":\"短信发送失败\"}";
            }

            return(outresult);
        }
Exemplo n.º 10
0
        public string GetUserRegedit2(string username, string msgcode, string password, int marketId, int organizeId, int preId, string realname)
        {
            string outresult = "{\"status\":\"y\",\"info\":\"恭喜你,注册成功\"}";

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

            if (username == "")
            {
                outresult = "{\"status\":\"n\",\"info\":\"用户名不能为空\"}";
                return(outresult);
            }

            //保存注册信息
            model.group_id     = 1;        //未购买的普通用户
            model.Parentid     = 0;        //未购买的用户,不排网络
            model.Leftor_right = 0;        //未购买的用户,不排网络区域
            model.MarketId     = marketId; //marketId市场ID,一个市场一个ID  默认分配到ID为2的市场

            model.mobile     = username;
            model.real_name  = realname;
            model.nick_name  = realname;
            model.salt       = Vincent._DTcms.Utils.GetCheckCode(6); //获得6位的salt加密字符串
            model.password   = _DESEncrypt.Encrypt(password, model.salt);
            model.reg_time   = DateTime.Now;
            model.strcode    = Vincent._DTcms.Utils.GetCheckCode(20); //生成随机码
            model.status     = 0;                                     //正常
            model.isMobile   = 1;
            model.OrganizeId = organizeId;
            model.PreId      = preId;

            //Random ro = new Random();
            //var no = ro.Next(1000, 9999); //随机一个数

            model.user_name = username; // "jd_" + no.ToString();

            // 判断是否已存在
            if (bll.ExistsMobile(username))
            {
                outresult = "{\"status\":\"n\",\"info\":\"该手机号已被注册!\"}";
                return(outresult);
            }


            int newId = bll.Add(model, 1);

            if (newId < 1)
            {
                outresult = "{\"status\":\"n\",\"info\":\"系统故障,请联系网站管理员!\"}";
                return(outresult);
            }

            //更新会员编号
            if (newId > 0)
            {
                var nick_name = "MC" + (100000 + newId);

                model.nick_name = nick_name;
                model.id        = newId;
                bll.Update(model);
            }

            model = bll.GetModel(newId);
            if (model != null)
            {
                //防止Session提前过期
                Vincent._DTcms.Utils.WriteCookie(Vincent._DTcms.DTKeys.COOKIE_USER_NAME_REMEMBER, "SimpleLife", model.user_name);
                Vincent._DTcms.Utils.WriteCookie(Vincent._DTcms.DTKeys.COOKIE_USER_PWD_REMEMBER, "SimpleLife", model.password);

                //写入登录日志
                new BLL.user_login_log().Add(model.id, model.user_name, "会员登录");
                return(ObjectToJSON(model));
            }
            else
            {
                outresult = "{\"status\":0, \"msg\":\"注册失败!\"}";
                return(outresult);
            }
        }
Exemplo n.º 11
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;
            }
        }