示例#1
0
        private void DoAdd()
        {
            Model.users model = new Model.users();
            BLL.users   bll   = new BLL.users();

            model.group_id = 1;
            model.status   = 0;
            //检测用户名是否重复
            //if (bll.Exists(txtUserName.Value.Trim()))
            //{
            //    return;
            //}
            model.user_name = Utils.DropHTML(tel.Value.Trim());
            //获得6位的salt加密字符串
            model.salt = Utils.GetCheckCode(6);
            //以随机生成的6位字符串做为密钥加密
            model.password = DESEncrypt.Encrypt(txtPassword.Value.Trim(), model.salt);
            model.reg_time = DateTime.Now;
            model.reg_ip   = DTRequest.GetIP();
            model.mobile   = tel.Value.Trim();
            if (bll.Add(model) > 0)
            {
                Session[DTKeys.SESSION_USER_INFO] = bll.GetModel(tel.Value.Trim());
                //AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加用户:" + model.user_name); //记录日志
                Response.Redirect("/web/member.aspx");
            }
            //return result;
        }
示例#2
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;
            }
        }
示例#3
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
            {
                //用户名存在
            }
        }
示例#4
0
        private bool DoAdd()
        {
            bool result = true;

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

            model.group_id = Utils.StringToNum(ddlGroupId.SelectedValue);
            switch (model.group_id)
            {
            case 1:
                model.point = 0;
                break;

            case 2:
                model.point = 50;
                break;

            case 3:
                model.point = 100;
                break;

            case 4:
                model.point = 150;
                break;
            }
            model.isVip = 0;
            if (chkVip.Checked == true)
            {
                model.isVip = 1;
            }
            model.is_lock   = Utils.StringToNum(rblIsLock.SelectedValue);
            model.user_name = txtUserName.Text.Trim();
            model.password  = DESEncrypt.Encrypt(txtPassword.Text);
            model.email     = txtEmail.Text;
            model.nick_name = txtNickName.Text;
            model.avatar    = txtAvatar.Text;
            model.sex       = rblSex.SelectedValue;
            DateTime _birthday;

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

            if (bll.Add(model) < 1)
            {
                result = false;
            }
            return(result);
        }
示例#5
0
        public string UserRegedit(string username, string msgcode, string password)
        {
            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);
            }
            //if (bll.Exists(username.Trim()))
            //{
            //    outresult = "{\"status\":\"n\",\"info\":\"该用户名已被注册\"}";
            //    return outresult;
            //}
            //保存注册信息
            model.group_id     = 0; //未购买的普通用户
            model.Parentid     = 0; //未购买的用户,不排网络
            model.Leftor_right = 0; //未购买的用户,不排网络区域

            model.mobile   = username;
            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;

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

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

            int newId = bll.Add(model);

            if (newId < 1)
            {
                outresult = "{\"status\":\"n\",\"info\":\"系统故障,请联系网站管理员!\"}";
                return(outresult);
            }
            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);
            }
        }
示例#6
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);
        }
示例#7
0
        private bool DoAdd()
        {
            bool result = true;

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

            model.group_id = Utils.StringToNum(ddlGroupId.SelectedValue);
            model.gongsi   = txtLinkUrl.Text.Trim();
            model.note     = txtNote.Text;
            model.jingli   = txtContent.Value;
            model.exp      = Utils.StringToNum(txtSortId.Text.Trim());
            //model.isVip = 0;
            //if (chkVip.Checked == true)
            //{
            //    model.isVip = 1;
            //}
            //model.is_lock = Utils.StringToNum(rblIsLock.SelectedValue);
            model.user_name = txtUserName.Text.Trim();
            model.password  = DESEncrypt.Encrypt("111");
            //model.email = txtEmail.Text;
            model.nick_name = txtLogSpec.Text;
            model.avatar    = txtAvatar.Text;
            // model.sex = rblSex.SelectedValue;
            //DateTime _birthday;
            //if (DateTime.TryParse(txtBirthday.Text.Trim(), out _birthday))
            //{
            //    model.birthday = _birthday;
            //}
            model.telphone = txtTelphone.Text.Trim();
            //model.mobile = txtMobile.Text.Trim();
            //model.qq = txtQQ.Text;
            model.address = txtAddress.Text.Trim();
            //model.amount = decimal.Parse(txtAmount.Text.Trim());
            //model.exp = Utils.StringToNum(txtExp.Text.Trim());
            model.reg_time = DateTime.Now;
            model.reg_ip   = DTRequest.GetIP();
            //if (chkPoint.Checked == true)
            //{
            //    model.exp = 1;
            //}
            //else
            //{
            //    model.exp = 0;
            //}
            if (bll.Add(model) < 1)
            {
                result = false;
            }
            return(result);
        }
示例#8
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);
        }
示例#9
0
        private void DoAdd()
        {
            Model.users model = new Model.users();
            BLL.users   bll   = new BLL.users();

            model.group_id = 1;
            model.status   = 0;
            //检测用户名是否重复
            //if (bll.Exists(txtUserName.Text.Trim()))
            //{
            //    return;
            //}
            model.user_name = tel.Text.Trim();
            model.salt      = Utils.GetCheckCode(6);
            //以随机生成的6位字符串做为密钥加密
            model.password = DESEncrypt.Encrypt("123456", model.salt);
            model.reg_time = DateTime.Now;
            model.reg_ip   = DTRequest.GetIP();
            model.mobile   = tel.Text.Trim();
            List <string> list       = new List <string>();
            string        aa         = Request.Form["IntegralCode"];
            var           codes_list = Request.Form["IntegralCode"].Split(',');

            BLL.BarCode bllBar = new BLL.BarCode();
            DataSet     ds     = null;

            ds = bllBar.QueryIntegralRatioSum(Request.Form["IntegralCode"]);
            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < codes_list.Length; i++)
                {
                    if (!list.Contains(codes_list[i]))
                    {
                        list.Add(codes_list[i]);
                    }
                }

                if (bll.Add(model, Convert.ToInt32(ds.Tables[0].Rows[0][0]), list))
                {
                    ClientScript.RegisterStartupScript(GetType(), "", "TipSuccess();", true);
                }
                else
                {
                    ClientScript.RegisterStartupScript(GetType(), "", "TipFail();", true);
                }
            }
        }
示例#10
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();
        }
示例#11
0
        private bool DoAdd()
        {
            bool result = true;

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

            model.group_id  = int.Parse(ddlGroupId.SelectedValue);
            model.is_lock   = int.Parse(rblIsLock.SelectedValue);
            model.user_name = txtUserName.Text.Trim();
            model.password  = DESEncrypt.Encrypt(txtPassword.Text);
            model.email     = txtEmail.Text;
            model.nick_name = txtNickName.Text;
            model.avatar    = txtAvatar.Text;
            model.sex       = rblSex.SelectedValue;
            DateTime _birthday;

            if (DateTime.TryParse(txtBirthday.Text.Trim(), out _birthday))
            {
                model.birthday = _birthday;
            }
            model.telphone = txtTelphone.Text.Trim();
            model.mobile   = txtMobile.Text.Trim();
            model.qq       = txtQQ.Text;
            model.address  = 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();

            if (bll.Add(model) < 1)
            {
                result = false;
            }
            return(result);
        }
示例#12
0
        public ActionResult Add(FormCollection collection)
        {
            Model.users model = new Model.users();
            model.LoginPwd           = HttpContext.Request.Form["LoginPwd"].ToString();
            model.FriendshipPolicyId = 1;
            model.NickName           = HttpContext.Request.Form["NickName"].ToString();
            model.FaceId             = 8;
            model.Sex         = HttpContext.Request.Form["Sex"].ToString();
            model.Age         = Convert.ToInt32(HttpContext.Request.Form["Age"]);
            model.Name        = "张珊";
            model.StarId      = 8;
            model.BloodTypeId = 3;
            string strJson = "";

            if (bll.Add(model) > 0)
            {
                strJson = "{\"type\":\"1\",\"msg\":\"新增成功!\"}";
            }
            else
            {
                strJson = "{\"type\":\"0\",\"msg\":\"新增失败!\"}";
            }
            return(Json(strJson, JsonRequestBehavior.AllowGet));
        }
示例#13
0
        private void user_oauth_register(HttpContext context)
        {
            //检查URL参数
            if (context.Session["oauth_name"] == null)
            {
                context.Response.Write("{\"status\": 0, \"msg\": \"错误提示:授权参数不正确!\"}");
                return;
            }
            //获取授权信息
            string result = Vincent._DTcms.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;
            }
            //反序列化JSON
            Dictionary <string, object> dic = JsonMapper.ToObject <Dictionary <string, object> >(result);

            if (dic["ret"].ToString() != "0")
            {
                context.Response.Write("{\"status\": 0, \"msg\": \"错误代码:" + dic["ret"] + "," + dic["msg"] + "\"}");
                return;
            }

            string password = Vincent._DTcms.DTRequest.GetFormString("txtPassword").Trim();
            string email    = Vincent._DTcms.Utils.ToHtml(Vincent._DTcms.DTRequest.GetFormString("txtEmail").Trim());
            string mobile   = Vincent._DTcms.Utils.ToHtml(Vincent._DTcms.DTRequest.GetFormString("txtMobile").Trim());
            string userip   = Vincent._DTcms.DTRequest.GetIP();

            BLL.users   bll   = new BLL.users();
            Model.users model = new Model.users();
            //检查默认组别是否存在
            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      = Vincent._DTcms.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 = Vincent._DTcms.Utils.StrToDateTime(dic["birthday"].ToString());
            }
            model.reg_ip   = userip;
            model.reg_time = DateTime.Now;
            model.status   = 0; //设置为正常状态
            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, Vincent._DTcms.DTEnums.AmountTypeEnum.SysGive.ToString(), modelGroup.amount, "注册赠送金额", 1);
            }
            //判断是否发送欢迎消息
            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);
                    //发送邮件
                    _Email.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);
                }
            }
            //绑定到对应的授权类型
            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[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, "会员登录");
            //返回URL
            context.Response.Write("{\"status\":1, \"msg\":\"会员登录成功!\"}");
            return;
        }
示例#14
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;
        }
示例#15
0
        protected void btnlogin_Click(object sender, ImageClickEventArgs e)
        {
            bool result = true;

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

            //model.is_lock = int.Parse(rblIsLock.SelectedValue);
            model.user_name = txtusername.Value.Trim();
            model.password  = DESEncrypt.Encrypt(txtpassword.Value);
            model.email     = txtemall.Value;
            model.nick_name = txtName.Value;
            if (fileUpImage.HasFile)
            {
                string extendName = fileUpImage.FileName.Substring(fileUpImage.FileName.LastIndexOf('.'));
                string filename   = DateTime.Now.ToString("yyyyMMddhhmmss") + extendName;
                if (!System.IO.Directory.Exists(Server.MapPath("upload/user/")))
                {
                    System.IO.Directory.CreateDirectory(Server.MapPath("upload/user/"));
                }

                fileUpImage.SaveAs(Server.MapPath("upload/user/" + filename));
                model.avatar = filename;
            }
            //model.sex = rblSex.SelectedValue;
            //DateTime _birthday;
            //if (DateTime.TryParse(txtBirthday.Text.Trim(), out _birthday))
            //{
            //    model.birthday = _birthday;
            //}
            model.mobile = txtphone.Value.Trim();
            //model.qq = "";
            model.address = txtAddress.Value.Trim();
            model.amount  = 0;
            model.point   = 0;
            switch (type)
            {
            case 1:
                model.amount = 0;
                break;

            case 2:
                model.amount = 100;
                break;

            case 3:
                model.amount = 200;
                break;

            case 4:
                model.amount = 300;
                break;
            }

            model.exp      = 0;
            model.reg_time = DateTime.Now;
            model.reg_ip   = DTRequest.GetIP();

            //if (ddlGroup.SelectedValue == "0")
            //{
            //    model.group_id = 1;
            //}
            //else
            //{
            model.group_id = Utils.StringToNum(ddlGroup.SelectedValue);
            model.dianming = txtIntroduce.Value;
            //model.dianmiaoshu = dianmiaoshu.Value;
            //model.congye = congye.Value;
            model.gongsi   = gongsi.Value;
            model.fuwuquyu = CompanyName.Value;
            //model.fuwuquyu = fuwuquyu.Value;
            //model.shuxishequ = shuxishequ.Value;
            //model.fuwutechang = fuwutechang.Value;
            //model.jingli = jingli.Value;
            //model.zhengshu = zhengshu.Value;
            model.note    = note.Value;
            model.is_lock = 1;
            //}
            if (bll.Add(model) < 1)
            {
                this.Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('網路異常,請重試')</script>");
            }
            else
            {
                login();
                //this.Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('註冊成功,請登入');window.location.href='login.aspx'</script>");
            }
        }
示例#16
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\":\"注册失败!\"}");
            }
        }
示例#17
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;

            }
        }
示例#18
0
        protected void btnlogin_Click(object sender, ImageClickEventArgs e)
        {
            bool result = true;

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

            model.user_name = DTRequest.GetFormString("ctl00$ContentPlaceHolder1$txtusername");
            model.password  = DESEncrypt.Encrypt(DTRequest.GetFormString("ctl00$ContentPlaceHolder1$txtpassword"));
            model.email     = DTRequest.GetFormString("ctl00$ContentPlaceHolder1$txtemall");
            model.nick_name = DTRequest.GetFormString("ctl00$ContentPlaceHolder1$txtName");
            if (fileUpImage.HasFile)
            {
                string extendName = fileUpImage.FileName.Substring(fileUpImage.FileName.LastIndexOf('.'));
                string filename   = DateTime.Now.ToString("yyyyMMddhhmmss") + extendName;
                if (!System.IO.Directory.Exists(Server.MapPath("upload/user/")))
                {
                    System.IO.Directory.CreateDirectory(Server.MapPath("upload/user/"));
                }

                fileUpImage.SaveAs(Server.MapPath("upload/user/" + filename));
                model.avatar = filename;
            }
            //model.sex = rblSex.SelectedValue;
            //DateTime _birthday;
            //if (DateTime.TryParse(txtBirthday.Text.Trim(), out _birthday))
            //{
            //    model.birthday = _birthday;
            //}
            model.telphone = DTRequest.GetFormString("ctl00$ContentPlaceHolder1$txtTel");
            model.mobile   = DTRequest.GetFormString("ctl00$ContentPlaceHolder1$txtphone");
            //model.qq = "";
            model.address = model.address = DTRequest.GetFormString("ctl00$ContentPlaceHolder1$txtcity") + "|" + DTRequest.GetFormString("ctl00$ContentPlaceHolder1$txtcity1") + "|" + txtZip.Text + "|" + DTRequest.GetFormString("ctl00$ContentPlaceHolder1$txtAddress");;
            model.amount  = 0;
            model.point   = 0;
            //switch (type)
            //{
            //    case 1:
            //        model.amount = 0;
            //        break;
            //    case 2:
            //        model.amount = 100;
            //        break;
            //    case 3:
            //        model.amount = 200;
            //        break;
            //    case 4:
            //        model.amount = 300;
            //        break;
            //}

            model.exp      = 0;
            model.reg_time = DateTime.Now;
            model.reg_ip   = DTRequest.GetIP();

            //if (ddlGroup.SelectedValue == "0")
            //{
            //    model.group_id = 1;
            //}
            //else
            //{
            model.group_id = Utils.StringToNum(DTRequest.GetFormString("ctl00$ContentPlaceHolder1$ddlGroup"));
            model.dianming = DTRequest.GetFormString("ctl00$ContentPlaceHolder1$txtIntroduce");
            //model.dianmiaoshu = dianmiaoshu.Value;
            //model.congye = congye.Value;
            model.gongsi   = DTRequest.GetFormString("ctl00$ContentPlaceHolder1$gongsi");
            model.fuwuquyu = DTRequest.GetFormString("ctl00$ContentPlaceHolder1$CompanyName");
            //model.fuwuquyu = fuwuquyu.Value;
            //model.shuxishequ = shuxishequ.Value;
            //model.fuwutechang = fuwutechang.Value;
            //model.jingli = jingli.Value;
            //model.zhengshu = zhengshu.Value;
            model.note    = DTRequest.GetFormString("ctl00$ContentPlaceHolder1$note");
            model.is_lock = 1;
            //}
            int bk = bll.Add(model);

            if (bk < 1)
            {
                this.Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('網路異常,請重試')</script>");
            }
            else
            {
                setEmail(bk);
                this.Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('註冊完成,請查收電子郵件並依照步驟完成帳戶啟動');window.location.href='index.aspx'</script>");
            }
        }
示例#19
0
        private bool DoAdd()
        {
            bool result = true;
            Model.users model = new Model.users();
            BLL.users bll = new BLL.users();

            model.group_id = int.Parse(ddlGroupId.SelectedValue);
            model.is_lock = int.Parse(rblIsLock.SelectedValue);
            model.user_name = txtUserName.Text.Trim();
            model.password = DESEncrypt.Encrypt(txtPassword.Text);
            model.email = txtEmail.Text;
            model.nick_name = txtNickName.Text;
            model.avatar = txtAvatar.Text;
            model.sex = rblSex.SelectedValue;
            DateTime _birthday;
            if (DateTime.TryParse(txtBirthday.Text.Trim(), out _birthday))
            {
                model.birthday = _birthday;
            }
            model.telphone = txtTelphone.Text.Trim();
            model.mobile = txtMobile.Text.Trim();
            model.qq = txtQQ.Text;
            model.address = 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();

            if (bll.Add(model) < 1)
            {
                result = false;
            }
            return result;
        }
示例#20
0
        protected void reg()
        {
            type = DTRequest.GetFormInt("ctl00$ContentPlaceHolder1$type");
            bool result = true;

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

            //model.is_lock = int.Parse(rblIsLock.SelectedValue);
            model.user_name = DTRequest.GetFormString("ctl00$ContentPlaceHolder1$txtusername");
            model.password  = DESEncrypt.Encrypt(DTRequest.GetFormString("ctl00$ContentPlaceHolder1$txtpassword"));
            model.email     = DTRequest.GetFormString("ctl00$ContentPlaceHolder1$txtemall");
            model.nick_name = DTRequest.GetFormString("ctl00$ContentPlaceHolder1$txtName");
            //if (fileUpImage.HasFile)
            //{
            //    string extendName = fileUpImage.FileName.Substring(fileUpImage.FileName.LastIndexOf('.'));
            //    string filename = DateTime.Now.ToString("yyyyMMddhhmmss") + extendName;
            //    if (!System.IO.Directory.Exists(Server.MapPath("upload/user/")))
            //    {
            //        System.IO.Directory.CreateDirectory(Server.MapPath("upload/user/"));
            //    }

            //    fileUpImage.SaveAs(Server.MapPath("upload/user/" + filename));
            //    model.avatar = filename;
            //}
            //model.sex = rblSex.SelectedValue;
            //DateTime _birthday;
            //if (DateTime.TryParse(txtBirthday.Text.Trim(), out _birthday))
            //{
            //    model.birthday = _birthday;
            //}
            model.mobile = DTRequest.GetFormString("ctl00$ContentPlaceHolder1$txtphone");
            //model.qq = "";
            model.address = DTRequest.GetFormString("ctl00$ContentPlaceHolder1$txtAddress");
            model.amount  = 0;
            model.point   = 0;
            switch (type)
            {
            case 1:
                model.amount = 0;
                break;

            case 2:
                model.amount = 100;
                break;

            case 3:
                model.amount = 200;
                break;

            case 4:
                model.amount = 300;
                break;
            }

            model.exp      = 0;
            model.reg_time = DateTime.Now;
            model.reg_ip   = DTRequest.GetIP();

            //if (ddlGroup.SelectedValue == "0")
            //{
            //    model.group_id = 1;
            //}
            //else
            //{
            model.group_id = Utils.StringToNum(DTRequest.GetFormString("ctl00$ContentPlaceHolder1$ddlGroup"));
            model.dianming = DTRequest.GetFormString("ctl00$ContentPlaceHolder1$txtIntroduce");
            //model.dianmiaoshu = dianmiaoshu.Value;
            //model.congye = congye.Value;
            model.gongsi   = DTRequest.GetFormString("ctl00$ContentPlaceHolder1$gongsi");
            model.fuwuquyu = DTRequest.GetFormString("ctl00$ContentPlaceHolder1$CompanyName");
            //model.fuwuquyu = fuwuquyu.Value;
            //model.shuxishequ = shuxishequ.Value;
            //model.fuwutechang = fuwutechang.Value;
            //model.jingli = jingli.Value;
            //model.zhengshu = zhengshu.Value;
            model.note    = DTRequest.GetFormString("ctl00$ContentPlaceHolder1$note");
            model.is_lock = 1;
            //}
            int bk = bll.Add(model);

            if (bk < 1)
            {
                this.Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('網路異常,請重試')</script>");
            }
            else
            {
                setEmail();
                Utils.WriteCookie("LoginUserID", bk.ToString());
                //ToFirstPay(bk);
                //this.Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('註冊成功,請登入');window.location.href='login.aspx'</script>");
            }
        }
示例#21
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);
            }
        }
示例#22
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;
            }
        }
示例#23
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;
        }
示例#24
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string type = context.Request.QueryString["type"];

            Model.users model     = null;
            BLL.users   bll_users = new BLL.users();
            switch (type)
            {
            case "select":
                break;

            case "exchange":
                BLL.users   modelbll = new BLL.users();
                BLL.BarCode bllBar   = new BLL.BarCode();
                DataSet     ds       = null;
                ds = bllBar.QueryIntegralCode(context.Request.QueryString["IntegralCode"]);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    if (Convert.ToInt32(ds.Tables[0].Rows[0]["state"]) < 4)
                    {
                        string uip = string.Empty;
                        if (HttpContext.Current.Request.ServerVariables["HTTP_VIA"] != null)
                        {
                            uip = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
                        }
                        else
                        {
                            uip = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString();
                        }
                        model = context.Session[DTKeys.SESSION_USER_INFO] as Model.users;
                        if (bllBar.UserChange(Convert.ToInt32(ds.Tables[0].Rows[0]["IntegralRatio"]), model.user_name, context.Request.QueryString["IntegralCode"], uip))
                        {
                            context.Response.Write("true");
                        }
                        else
                        {
                            context.Response.Write("false");
                        }
                    }
                    else
                    {
                        context.Response.Write("false");
                    }
                }
                else
                {
                    context.Response.Write("false");
                }
                break;

            case "exchangeall":
                //string ip = string.Empty;
                //if (HttpContext.Current.Request.ServerVariables["HTTP_VIA"] != null)
                //{
                //    ip = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
                //}
                //else
                //{
                //    ip = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString();
                //}

                model           = new Model.users();
                model.group_id  = 1;
                model.status    = 0;
                model.user_name = context.Request.QueryString["tel"];
                model.salt      = Utils.GetCheckCode(6);
                //以随机生成的6位字符串做为密钥加密
                model.password = DESEncrypt.Encrypt("123456", model.salt);
                model.reg_time = DateTime.Now;
                model.reg_ip   = DTRequest.GetIP();
                model.telphone = context.Request.QueryString["tel"];
                string        codes      = context.Request.QueryString["codes"];
                List <string> list       = new List <string>();
                var           codes_list = codes.Split(',');
                for (int i = 1; i < codes_list.Length; i++)
                {
                    if (!list.Contains(codes_list[i]))
                    {
                        list.Add(codes_list[i]);
                    }
                }

                if (bll_users.Add(model, 1, list))
                {
                    context.Response.Write("true");
                }
                else
                {
                    context.Response.Write("false");
                }
                break;
            }
        }
示例#25
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string code = Common.DTRequest.GetString("code");
                if (!string.IsNullOrEmpty(code))
                {
                    string openid  = Utils.GetCookie("wx_openid");
                    string unionid = Utils.GetCookie("wx_unionid");
                    if (string.IsNullOrEmpty(openid) || string.IsNullOrEmpty(unionid))
                    {
                        OAuthAccessTokenResult oauthResult = OAuthApi.GetAccessToken(appId, appSecret, code);
                        Utils.WriteCookie("wx_openid", oauthResult.openid);
                        Utils.WriteCookie("wx_unionid", oauthResult.unionid);
                        openid  = oauthResult.openid;
                        unionid = oauthResult.unionid;
                    }

                    //if (string.IsNullOrEmpty(accessToken) || tokenTime > DateTime.Now.AddMinutes(-30))
                    //{
                    //    accessToken = AccessTokenContainer.GetAccessToken(appId);
                    //    tokenTime = DateTime.Now;
                    //}
                    //UserInfoJson userInfo = UserApi.Info(accessToken, oauthResult.openid);

                    BLL.users bll = new BLL.users();
                    if (bll.ExistsWxOpenID(openid))
                    {
                        LogHelper.WriteDebugLog("[wx_init] login,wx_open_id:" + openid);
                        LogHelper.WriteDebugLog("[wx_init] login,UnionID:" + unionid);
                        List <Model.users> list = bll.GetModelByWx(openid);

                        Session[DTKeys.SESSION_USER_INFO] = list;
                        Session.Timeout = 45;

                        foreach (Model.users model in list)
                        {
                            //检查用户二维码
                            if (!Common.Utils.FileExists("/upload/InviterQRCode/" + model.id + ".png"))
                            {
                                string url = (siteConfig.weburl.StartsWith("http://") ? siteConfig.weburl : "http://" + siteConfig.weburl) + "/inviter.aspx?from=" + model.id;
                                Bitmap img = Common.QRCode.Create_ImgCode(url, 4);
                                Common.QRCode.SaveImg(Server.MapPath("~/upload/InviterQRCode/"), model.id + ".png", img);
                            }
                        }

                        Response.Write("inviter:" + Common.Utils.GetCookie("inviter"));
                        Response.Write("<br />turl:" + Common.Utils.GetCookie(Common.DTKeys.COOKIE_URL_REFERRER));

                        //Utils.WriteCookie(DTKeys.COOKIE_WEIXIN_FOCUS_ON, userInfo.subscribe.ToString());
                        Response.Redirect("login.aspx?wxopenid=" + openid + "&turl=" + Server.UrlEncode(Utils.GetCookie(DTKeys.COOKIE_URL_REFERRER)));
                    }
                    else
                    {
                        Response.Write("inviter:" + Common.Utils.GetCookie("inviter"));
                        Response.Write("<br />turl:" + Common.Utils.GetCookie(Common.DTKeys.COOKIE_URL_REFERRER));
                        LogHelper.WriteDebugLog("[wx_init] register,wx_open_id:" + openid);
                        try
                        {
                            #region 用户注册

                            Model.user_groups modelGroup = new BLL.user_groups().GetDefault();

                            #region 保存用户注册信息
                            Model.users model = new Model.users();
                            model.group_id  = modelGroup.id;
                            model.user_name = openid;
                            model.salt      = Utils.GetCheckCode(6); //获得6位的salt加密字符串
                            model.password  = "******";
                            model.email     = openid + "@yuedujing.com";
                            model.mobile    = string.Empty;
                            model.reg_ip    = DTRequest.GetIP();
                            model.reg_time  = DateTime.Now;
                            model.nick_name = "新用户";


                            //设置用户状态
                            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)
                            {
                                return;
                            }

                            //检查用户二维码
                            if (!Common.Utils.FileExists("/upload/InviterQRCode/" + model.id + ".png"))
                            {
                                string url = (siteConfig.weburl.StartsWith("http://") ? siteConfig.weburl : "http://" + siteConfig.weburl) + "/inviter.aspx?from=" + model.id;
                                Bitmap img = Common.QRCode.Create_ImgCode(url, 4);
                                Common.QRCode.SaveImg(Server.MapPath("~/upload/InviterQRCode/"), model.id + ".png", img);
                            }
                            //检查用户组是否需要赠送积分
                            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 (bll.ExistsWxOpenID(openid))
                            {
                                LogHelper.WriteDebugLog("[wx_init] login,wx_open_id:" + openid);
                                LogHelper.WriteDebugLog("[wx_init] login,UnionID:" + unionid);
                                model = new Model.users();
                                model = bll.GetModelByWx(openid).First();
                                Session[DTKeys.SESSION_USER_INFO] = model;
                                Session.Timeout = 45;

                                //检查用户二维码
                                if (!Common.Utils.FileExists("/upload/InviterQRCode/" + model.id + ".png"))
                                {
                                    string url = (siteConfig.weburl.StartsWith("http://") ? siteConfig.weburl : "http://" + siteConfig.weburl) + "/inviter.aspx?from=" + model.id;
                                    Bitmap img = Common.QRCode.Create_ImgCode(url, 4);
                                    Common.QRCode.SaveImg(Server.MapPath("~/upload/InviterQRCode/"), model.id + ".png", img);
                                }

                                Response.Write("inviter:" + Common.Utils.GetCookie("inviter"));
                                Response.Write("<br />turl:" + Common.Utils.GetCookie(Common.DTKeys.COOKIE_URL_REFERRER));
                                //Utils.WriteCookie(DTKeys.COOKIE_WEIXIN_FOCUS_ON, userInfo.subscribe.ToString());
                                Response.Redirect("login.aspx?wxopenid=" + openid + "&turl=" + Utils.GetCookie(DTKeys.COOKIE_URL_REFERRER));
                            }
                            #endregion

                            #endregion
                        }
                        catch
                        {
                            //Utils.WriteCookie(DTKeys.COOKIE_WEIXIN_FOCUS_ON, userInfo.subscribe.ToString());
                            Response.Redirect("register.aspx?wxopenid=" + openid + "&turl=" + Utils.GetCookie(DTKeys.COOKIE_URL_REFERRER));
                        }
                    }
                }
                else
                {
                    Response.Redirect("login.aspx");
                }
            }
        }
示例#26
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;
        }
示例#27
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;
        }
        private bool DoAdd()
        {
            bool result = true;
            Model.users model = new Model.users();
            BLL.users bll = new BLL.users();

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

            int number = bll.GetOnlyCodeNumber();

            model.user_name = "sxzh" + number.ToString();//txtUserName.Text.Trim();
            model.password = DESEncrypt.Encrypt(txtPassword.Text);
            model.email = txtEmail.Text;
            model.nick_name = txtNickName.Text;
            model.avatar = txtAvatar.Text;
            model.sex = rblSex.SelectedValue;
            DateTime _birthday;
            if (DateTime.TryParse(txtBirthday.Text.Trim(), out _birthday))
            {
                model.birthday = _birthday;
            }
            model.telphone = txtTelphone.Text.Trim();
            model.mobile = txtMobile.Text.Trim();
            model.qq = txtQQ.Text;
            model.address = txtAddress.Text.Trim();
            model.amount = decimal.Parse(txtAmount.Text.Trim());
            model.point = int.Parse(txtPoint.Text.Trim());
            model.exp = 0;// int.Parse(txtExp.Text.Trim());
            model.reg_time = DateTime.Now;
            model.reg_equ = txtRegEqu.Text.Trim();
            model.guid_card = txtGuidCard.Text.Trim();
            model.card = txtCard.Text.Trim();
            model.age = int.Parse(txtAge.Text.Trim());
            model.work_type = int.Parse(rblWorkType.SelectedValue);
            model.description = Utils.ToHtml(txtContent.Text.Trim());
            model.work_age = ddlWorkAge.SelectedValue.ToString();
            if (bll.Add(model) < 1)
            {
                result = false;
            }
            return result;
        }
示例#29
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);
        }
示例#30
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);
        }
示例#31
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;
        }
示例#32
0
        private void user_oauth_register(HttpContext context)
        {
            //检查URL参数
            if (context.Session["oauth_name"] == null)
            {
                context.Response.Write("{\"msg\": 0, \"msgbox\": \"错误提示:授权参数不正确!\"}");
                return;
            }
            //获取授权信息
            string result = Utils.UrlExecute(siteConfig.webpath + "api/oauth/" + context.Session["oauth_name"].ToString() + "/result_json.aspx");
            if (result.Contains("error"))
            {
                context.Response.Write("{\"msg\": 0, \"msgbox\": \"错误提示:请检查URL是否正确!\"}");
                return;
            }
            //反序列化JSON
            Dictionary<string, object> dic = JsonMapper.ToObject<Dictionary<string, object>>(result);
            if (dic["ret"].ToString() != "0")
            {
                context.Response.Write("{\"msg\": 0, \"msgbox\": \"错误代码:" + dic["ret"] + "," + dic["msg"] + "\"}");
                return;
            }

            string password = DTRequest.GetFormString("txtPassword").Trim();
            string email = DTRequest.GetFormString("txtEmail").Trim();
            string userip = DTRequest.GetIP();
            //检查用户名
            BLL.users bll = new BLL.users();
            Model.users model = new Model.users();
            //检查默认组别是否存在
            Model.user_groups modelGroup = new BLL.user_groups().GetDefault();
            if (modelGroup == null)
            {
                context.Response.Write("{\"msg\":0, \"msgbox\":\"系统尚未分组,请联系管理员设置会员分组!\"}");
                return;
            }
            //保存注册信息
            model.group_id = modelGroup.id;
            model.user_name = bll.GetRandomName(10);
            model.password = DESEncrypt.Encrypt(password);
            model.email = email;
            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 = DateTime.Parse(dic["birthday"].ToString());
            }
            model.reg_ip = userip;
            model.reg_time = DateTime.Now;
            model.is_lock = 0; //设置为对应状态
            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);
            }
            //绑定到对应的授权类型
            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, "会员登录", DTRequest.GetIP());
            //返回URL
            context.Response.Write("{\"msg\":1, \"msgbox\":\"会员登录成功!\"}");
            return;
        }
示例#33
0
        //將excel的資料寫入資料庫
        private string InsertGoods(DataTable dt)
        {
            string result = "";

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

            //判斷列名是否規範
            string[] strColumn = { "所屬組別", "真實姓名", "會員賬號", "電子信箱", "密碼", "生日", "性別", "連絡電話", "所在地", "郵遞區號", "地址", "訂閱電子報" };
            int      num       = 0;

            for (int i = 0; i < dt.Columns.Count; i++)
            {
                foreach (string str in strColumn)
                {
                    if (str == dt.Columns[i].ColumnName)
                    {
                        num++;
                    }
                }
            }

            if (num == strColumn.Length)
            {
                //遍歷主件

                foreach (DataRow dr in dt.Rows)
                {
                    if (dr[0].ToString().Trim() != "" && dr[1].ToString().Trim() != "" && dr[2].ToString().Trim() != "" && dr[3].ToString().Trim() != "")
                    {
                        bool updatea = true;
                        try
                        {
                            model = bll.GetModel(dr[2].ToString());
                        }
                        catch (Exception eee) { }
                        if (model == null)
                        {
                            model   = new Model.users();
                            updatea = false;
                        }
                        model.group_id  = dr[0].ToString() == "一般會員" ? 1 : 2;
                        model.nick_name = dr[1].ToString();
                        model.user_name = dr[2].ToString();
                        model.email     = dr[3].ToString();
                        model.salt      = Utils.GetCheckCode(6);
                        model.password  = DESEncrypt.Encrypt(dr[4].ToString(), model.salt);
                        model.birthday  = Utils.StrToDateTime(dr[5].ToString());
                        model.sex       = dr[6].ToString();
                        model.mobile    = dr[7].ToString();
                        model.area      = dr[8].ToString();
                        model.qq        = dr[9].ToString();
                        model.address   = dr[10].ToString();
                        model.exp       = dr[11].ToString() == "是" ? 1 : 0;
                        if (updatea)
                        {
                            bll.Update(model);
                        }
                        else
                        {
                            bll.Add(model);
                        }
                    }
                }
            }
            else
            {
                result = "請檢查excel檔案格式!" + num + strColumn.Length;
            }
            return(result);
        }