Ejemplo n.º 1
0
        public ActionResult AjaxCaptcha()
        {
            this.Response.ContentType = "image/jpeg";
            EnImage enImg = new EnImage();

            enImg.ImgFont  = new Font(FontFamily.GenericSerif, 21, GraphicsUnit.Pixel);
            enImg.ImgColor = EnObject.listColor[0];
            enImg.Height   = 30;
            enImg.Width    = 80;

            string count = this.Request.QueryString["ct"];

            if (string.IsNullOrEmpty(count))
            {
                count = "4";
            }
            if (!new Regex(@"\d{0,127}").IsMatch(count))
            {
                count = "4";
            }

            NCaptcha cca = NCaptcha.GenerateAndDraw(byte.Parse(count), this.Response.OutputStream, enImg, true);

            NModel.EnObject.CaptchaSessionName = cca.SetSessionName;

            return(View());
        }
Ejemplo n.º 2
0
        //
        // GET: /NLCQ/
        public ActionResult Reg()
        {
            NModel.NewsPager model_pager = LoadConfig("/nlcq/reg");

            string _Captcha         = this.Request.Form["Captcha"];
            string password         = this.Request.Form["password"];
            string isCueLoginStatus = this.Request["isCueLoginStatus"];

            //验证码
            if (!string.IsNullOrEmpty(_Captcha) && !string.IsNullOrEmpty(NModel.EnObject.GetCodeValue + ""))
            {
                if (_Captcha.Equals(NModel.EnObject.GetCodeValue + ""))
                {
                    String JsonStr = "";

                    NModel.DB_User model    = new NModel.DB_User();
                    BLL.DB_User    bll_User = new BLL.DB_User();

                    bool isGet = Tool.NStr.PostForSetVal <NModel.DB_User>(ref model, ref JsonStr, "");

                    bool isUserNameExists = !String.IsNullOrEmpty(model.User_Name) && bll_User.ExistsName(model.User_Name);

                    if (isGet && !isUserNameExists)
                    {
                        bool isUserEmailExists = !String.IsNullOrEmpty(model.User_Email) && bll_User.ExistsEmail(model.User_Email);
                        if (!isUserEmailExists)
                        {
                            if (!string.IsNullOrEmpty(model.User_PW) && !string.IsNullOrEmpty(password))
                            {
                                //密码是否相同
                                if (model.User_PW.Trim().Equals(password.Trim()))
                                {
                                    model.User_PW = NMd5.GetMd5Hash(model.User_PW);
                                    //增加数据
                                    if (bll_User.AddFree(model) > 0)
                                    {
                                        bll_User.CheckLogin(model.User_Name, model.User_PW, _Captcha, true);
                                        Tool.NMsg.AlertAndRedirect("注册成功", "/nlcq/index");
                                    }

                                    //登录

                                    //刷新验证码
                                    NCaptcha.Generate(NModel.EnObject.UserCodeSessionName);
                                }
                            }
                        }
                    }
                    bll_User.Close();
                }
            }

            // if(isGet&&model.)

            return(View(model_pager));
        }
Ejemplo n.º 3
0
        public ActionResult SendToEMailCode()
        {
            NCaptcha.Generate(NModel.EnObject.UserCodeSessionName);

            DateTime?dt = (DateTime?)NModel.EnObject.GetTimeValue;

            try
            {
                DateTime?dt1 = DateTime.Now;
                TimeSpan?ts  = dt1 - dt;

                double s = 0;
                if (ts != null)
                {
                    s = ts.Value.TotalSeconds;
                }

                if (s >= 62 || ts == null)
                {
                    string toEmail = this.Server.UrlDecode(this.Request["to"]);
                    string code    = NModel.EnObject.GetCodeValue;

                    BLL.DB_WebConfig bll_WebConfig = new BLL.DB_WebConfig();

                    NModel.DB_WebConfig model_WebConfig = bll_WebConfig.GetModel((long?)4);

                    model_WebConfig = model_WebConfig != null ? model_WebConfig : new NModel.DB_WebConfig();
                    bll_WebConfig.Close();
                    bool isOk = Tool.NEmail.SendTo(model_WebConfig.WebConfig_ServerAdrress, model_WebConfig.WebConfig_SendEmail,
                                                   model_WebConfig.WebConfig_SendPw, model_WebConfig.WebConfig_SendName + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss-fff"), toEmail, model_WebConfig.WebConfig_ToName,
                                                   model_WebConfig.WebConfig_SubContent + "验证码:" + code, model_WebConfig.WebConfig_SubTitle + "" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss-fff"));
                    if (isOk)
                    {
                        NModel.EnObject.SetEmailValue = toEmail;

                        NModel.EnObject.SetTimeValue = DateTime.Now;
                        this.Response.Write("{ \"info\":\"已发送到邮箱,请查看验证码 邮箱->" + toEmail + "\" , \"status\":\"y\" }");
                    }
                    else
                    {
                        this.Response.Write("{ \"info\":\"发送失败\", \"status\":\"n\" }");
                    }
                }
                else
                {
                    this.Response.Write("{ \"info\":\"发送时间没到" + s + "秒\", \"status\":\"n\" }");
                }
            }
            catch (Exception ex)
            {
            }

            return(View());
        }
Ejemplo n.º 4
0
        public ActionResult GSendToEMailCode()
        {
            NCaptcha.Generate(NModel.EnObject.UserCodeSessionName);

            DateTime?dt = (DateTime?)NModel.EnObject.GetTimeValue;

            {
                try
                {
                    DateTime?dt1 = DateTime.Now;
                    TimeSpan?ts  = dt1 - dt;

                    double s = 0;
                    if (ts != null)
                    {
                        s = ts.Value.TotalSeconds;
                    }

                    if (s >= 72 || ts == null)
                    {
                        NModel.DB_User model   = NModel.EnObject.GetFindUserValue as NModel.DB_User;
                        string         toEmail = model.User_Email + "";
                        string         code    = NModel.EnObject.GetCodeValue;

                        bool isOk = Tool.NEmail.SendTo("smtp.126.com", "*****@*****.**",
                                                       "87658543", "你找谁", toEmail, "",
                                                       "验证码:" + code, "你找谁找回密码验证码");
                        if (isOk)
                        {
                            NModel.EnObject.SetEmailValue = toEmail;

                            NModel.EnObject.SetTimeValue = DateTime.Now;
                            this.Response.Write("{ \"info\":\"已发送到邮箱,请查看验证码\", \"status\":\"y\" }");
                        }
                        else
                        {
                            this.Response.Write("{ \"info\":\"发送失败\", \"status\":\"n\" }");
                        }
                    }
                    else
                    {
                        this.Response.Write("{ \"info\":\"发送时间没到" + s + "秒\", \"status\":\"n\" }");
                    }
                }
                catch (Exception ex)
                {
                }

                return(View());
            }
        }
Ejemplo n.º 5
0
        public ActionResult ImgCaptcha()
        {
            string color = this.Request.QueryString["color"];

            ;
            this.Response.ContentType = "image/jpeg";
            EnImage enImg = new EnImage();

            enImg.ImgFont = new Font(FontFamily.GenericSerif, 30, GraphicsUnit.Pixel);

            try
            {
                enImg.ImgColor = System.Drawing.ColorTranslator.FromHtml("#009B4C");
            }
            catch (Exception ex)
            {
                enImg.ImgColor = EnObject.listColor[7];
            }

            enImg.Height = 40;
            enImg.Width  = 120;

            string count = this.Request.QueryString["ct"];

            if (string.IsNullOrEmpty(count))
            {
                count = "4";
            }
            if (!new Regex(@"\d{0,127}").IsMatch(count))
            {
                count = "4";
            }

            NCaptcha cca = NCaptcha.GenerateAndDraw(byte.Parse(count), this.Response.OutputStream, enImg, true);

            NModel.EnObject.SetCodeValue       = cca.GenerateString;
            NModel.EnObject.CaptchaSessionName = cca.SetSessionName;

            return(View());
        }
Ejemplo n.º 6
0
        public bool CheckLogin(string name, string pw, string code)
        {
            if (NTool.IsSessionEquals(NModel.EnObject.CaptchaSessionName, code))
            {
                NCaptcha.Generate(true);

                NModel.Admin_User cModel_User = this.ExistsNamePw((name + "").ToLower(), NMd5.GetMd5Hash(pw).ToLower());
                if (cModel_User != null && cModel_User.User_ID > 0)
                {
                    HttpContext.Current.Session[NModel.EnObject.LoginSessionName]        = cModel_User.User_Name;
                    HttpContext.Current.Session[NModel.EnObject.CurrentLoginSessionName] = cModel_User;

                    BLL.DB_Session    cModel         = new DB_Session();
                    NModel.DB_Session cModel_Session = new NModel.DB_Session();
                    cModel_Session.Session_DB_Name = base.TableName;
                    cModel_Session.Session_UserID  = cModel_User.User_ID;

                    cModel_Session.Session_CID     = (HttpContext.Current.Session.SessionID + "");
                    cModel_Session.Session_Status  = 1;
                    cModel_Session.Session_EndTime = DateTime.Parse(DateTime.Now.AddHours(60).ToString("s"));
                    ///DateTime.Parse(DateTime.Now.AddHours(60).ToString("yyyy-MM-dd hh:mm:ss"));
                    cModel_Session.Session_AddTime = DateTime.Parse(DateTime.Now.ToString("s"));

                    if (cModel.Add(cModel_Session) > 0)
                    {
                        cModel.Close();

                        Tool.NTool.AddCookie(base.TableName, cModel_Session.Session_CID + "_" + cModel_User.User_ID, 60);
                        return(true);
                    }
                    ;
                    cModel.Close();
                }
            }

            return(false);
        }