示例#1
0
        public void TestRevEnc()
        {
            //可逆加密
            //des
            string desEncode = DEncryptUtils.DESEncrypt(txt, key);

            Console.WriteLine("des加密值:" + desEncode);
            Assert.AreEqual(txt, DEncryptUtils.DESDecrypt(desEncode, key));

            //aes
            string aesEncode = DEncryptUtils.AESEncrypt(txt);

            Console.WriteLine("aes加密值:" + aesEncode);
            Assert.AreEqual(txt, DEncryptUtils.AESDecrypt(aesEncode));

            //base64
            string base64Encode = DEncryptUtils.Base64Encrypt(txt);

            Console.WriteLine("base64加密值:" + aesEncode);
            Assert.AreEqual(txt, DEncryptUtils.Base64Decrypt(base64Encode));

            //xor
            string xor = DEncryptUtils.GetXORCode(txt, key);

            Console.WriteLine("xor加密值:" + xor);
            Assert.AreEqual(txt, DEncryptUtils.GetXORCode(xor, key));
        }
示例#2
0
        public void ProcessRequest(HttpContext context)
        {
            string userId  = context.Request.Form["user[userId]"];
            string oldPwd  = context.Request.Form["user[old-pwd]"];
            string newPwd1 = context.Request.Form["user[new-pwd-1]"];
            string s       = "{\"status\":\"error\"}";
            bool   b       = false;

            MemberEntity memberEntity = MemberBll.Instance.GetModel(Convert.ToInt32(userId));

            if (memberEntity != null)
            {
                if (memberEntity.Password == DEncryptUtils.Encrypt3DES(oldPwd))
                {
                    memberEntity.Password = DEncryptUtils.Encrypt3DES(newPwd1);
                    b = MemberBll.Instance.Update(memberEntity);
                    if (b)
                    {
                        s = "{\"status\":\"success\"}";
                    }
                }
            }

            context.Response.ContentType = "text/plain";
            context.Response.Write(s);
        }
示例#3
0
        public static UserInfo GetLoginUser()
        {
            int    intUserID = -1;
            string text      = string.Empty;

            if (HttpContext.Current.Request.Cookies["singoouser"] != null && HttpContext.Current.Request.Cookies["singoouser"]["uid"] != null)
            {
                intUserID = WebUtils.GetInt(HttpContext.Current.Request.Cookies["singoouser"]["uid"], -1);
            }
            if (HttpContext.Current.Request.Cookies["singoouser"] != null && HttpContext.Current.Request.Cookies["singoouser"]["pwd"] != null)
            {
                text = HttpContext.Current.Request.Cookies["singoouser"]["pwd"].ToString();
                text = HttpUtility.UrlDecode(text);
            }
            UserInfo userById = User.GetUserById(intUserID);
            UserInfo result;

            if (userById != null && DEncryptUtils.DESEncode(userById.Password) == text)
            {
                result = userById;
            }
            else
            {
                result = null;
            }
            return(result);
        }
示例#4
0
        public void ProcessRequest(HttpContext context)
        {
            string userId       = DEncryptUtils.DESDecrypt(CookieHelper.GetCookieValue("52cos", "user_id")).Replace("\0", "");
            string type         = context.Request.Form["comment_parent"];
            string workId       = context.Request.Form["comment_post_ID"];
            string replyContent = context.Request.Form["comment"];
            string s            = "{\"status\":\"error\"}";

            if (userId.Trim() != "")
            {
                ReplyEntity replyEntity = new ReplyEntity();
                replyEntity.User_id      = userId;
                replyEntity.type         = type;
                replyEntity.workId       = workId;
                replyEntity.ReplyContent = replyContent;
                replyEntity.ReleaseTime  = DateTime.Now;
                //插入回复表
                if (ReplyBll.Instance.Add(replyEntity) > 0)
                {
                    // todo 更新作品时间
                    s = "{\"status\":\"success\"}";
                }
            }

            context.Response.ContentType = "text/plain";
            context.Response.Charset     = "utf-8";
            context.Response.Write(s);
        }
示例#5
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            string text = WebUtils.GetQueryString("file");

            try
            {
                text = DEncryptUtils.DESDecode(text);
            }
            catch
            {
                text = string.Empty;
            }
            string text2 = base.Server.MapPath(text);

            if (System.IO.File.Exists(text2))
            {
                FileUploadInfo model = PageBase.dbo.GetModel <FileUploadInfo>(" select top 1 * from sys_FileUpload where VirtualPath='" + text + "' ");
                if (model != null)
                {
                    model.DownloadCount++;
                    FileUpload.Update(model);
                }
                ResponseUtils.ResponseFile(text2);
            }
            else
            {
                base.Response.Write(base.GetCaption("CMS_FileNotExist"));
                base.Response.End();
            }
        }
示例#6
0
        protected void btnok_Click(object sender, System.EventArgs e)
        {
            bool        flag     = false;
            AccountInfo dataById = Account.GetDataById(base.LoginAccount.AutoID);
            string      text     = WebUtils.GetString(this.oldpwd.Text);
            string      @string  = WebUtils.GetString(this.newpwd1.Text);
            string      string2  = WebUtils.GetString(this.newpwd2.Text);
            string      string3  = WebUtils.GetString(this.TextBox3.Text);
            string      string4  = WebUtils.GetString(this.TextBox4.Text);

            if (!string.IsNullOrEmpty(text))
            {
                text = DEncryptUtils.SHA512Encrypt(text);
                if (!base.LoginAccount.Password.Equals(text))
                {
                    base.ShowMsg("原密码不正确!");
                }
                else if (@string.Length < 6)
                {
                    base.ShowMsg("新密码不能少于6个字符!");
                }
                else if (string2 != @string)
                {
                    base.ShowMsg("两次密码输入不一致!");
                }
                else
                {
                    dataById.Password = DEncryptUtils.SHA512Encrypt(@string);
                    flag = true;
                }
            }
            dataById.Email  = string3;
            dataById.Mobile = string4;
            if (Account.Update(dataById))
            {
                if (flag)
                {
                    PageBase.log.AddEvent(base.LoginAccount.AccountName, "管理员修改帐户密码成功", 2);
                    HttpContext.Current.Session["Account"] = null;
                    HttpContext.Current.Session.Remove("Account");
                    FormsAuthentication.SignOut();
                    base.Response.Redirect("/Platform/h5/login");
                }
            }
            else
            {
                PageBase.log.AddEvent(base.LoginAccount.AccountName, "管理员修改帐户资料时发生了错误", 2);
                base.ShowMsg("修改失败,发生不可预知的错误");
            }
        }
示例#7
0
        protected void btn_Export_Click(object sender, System.EventArgs e)
        {
            DataTable dataTable = PageBase.dbo.GetDataTable("SELECT AutoID AS 自动编号,OrderNo AS 订单编号,UserName AS 会员名称,  CASE OrderStatus WHEN 0 THEN '待审核' WHEN 1 THEN '待付款' WHEN 10 THEN '配货中' WHEN 11 THEN '已发货' WHEN 12 THEN '已签收' WHEN 99 THEN '已完结' WHEN -1 THEN '订单作废' WHEN -2 THEN '退货' END  AS 订单状态,   AddOrderMethod AS 添加方式,Consignee AS 收件人,Province AS 省份,City AS 城市,   Address AS 地址,Phone AS 电话,Mobile AS 手机,PayName AS 支付方式,Remark AS 备注,   OrderTotalAmount AS 订单金额,OrderShippingFee AS 订单运费,OrderAddTime AS 创建时间   FROM shop_Orders WHERE " + this.GetCondition());

            if (dataTable != null && dataTable.Rows.Count > 0)
            {
                string path = base.Server.MapPath(base.ExportFolder + "Orders.xls");
                DataToXSL.CreateXLS(dataTable, path, true);
                base.Response.Redirect("/include/download?file=" + DEncryptUtils.DESEncode(base.ExportFolder + "Orders.xls"));
            }
            else
            {
                base.ShowMsg("没有找到任何记录");
            }
        }
示例#8
0
        public void ProcessRequest(HttpContext context)
        {
            string       code         = context.Request.Form["user[token]"];
            string       pwd          = context.Request.Form["user[pwd]"];
            bool         b            = false;
            DataTable    dt           = MemberBll.Instance.GetList("code='" + code + "'").Tables[0];
            MemberEntity memberEntity = MemberBll.Instance.GetModel(Convert.ToInt32(dt.Rows[0]["User_id"]));

            memberEntity.Password   = DEncryptUtils.Encrypt3DES(pwd);
            memberEntity.Activation = "1";
            b = MemberBll.Instance.Update(memberEntity);
            context.Response.ContentType = "text/plain";
            context.Response.Charset     = "utf-8";
            context.Response.Write(b);
        }
示例#9
0
        public void TestUnRevEnc()
        {
            //不可逆加密
            //md5
            string md5 = DEncryptUtils.MD5Encrypt(txt); //md5是2次加密,且会截断字符串,这样网上的暴力破解不了

            Console.WriteLine("MD5:" + md5);
            Assert.AreEqual(md5, DEncryptUtils.MD5Encrypt(txt));

            //sha512 比md5更安全的不可逆加密方法
            string sha512 = DEncryptUtils.SHA512Encrypt(txt);

            Console.WriteLine("sha512:" + sha512);
            Assert.AreEqual(sha512, DEncryptUtils.SHA512Encrypt(txt));
        }
示例#10
0
 protected void btn_ExportXML_Click(object sender, System.EventArgs e)
 {
     System.Collections.Generic.List <CategoryInfo> list = (System.Collections.Generic.List <CategoryInfo>)SinGooCMS.BLL.Category.GetCacheChildCate(0);
     if (list != null && list.Count > 0)
     {
         System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\" ?><CategoryTemplate>");
         foreach (CategoryInfo current in list)
         {
             stringBuilder.Append(this.NodeToXml(current));
         }
         stringBuilder.Append("</CategoryTemplate>");
         string path = base.Server.MapPath(base.ExportFolder + "CategoryData.xml");
         System.IO.File.WriteAllText(path, stringBuilder.ToString(), System.Text.Encoding.UTF8);
         base.Response.Redirect("/Include/Download?file=" + DEncryptUtils.DESEncode(base.ExportFolder + "CategoryData.xml"));
     }
     else
     {
         base.ShowMsg("没有找到任何记录");
     }
 }
示例#11
0
        public void ProcessRequest(HttpContext context)
        {
            string email    = context.Request.Form["user[email]"];
            string pwd      = context.Request.Form["user[pwd]"];
            string remember = context.Request.Form["user[remember]"];

            int       i = -1;
            DataTable dt;

            if (email.IndexOf("@", StringComparison.Ordinal) > -1)
            {
                dt = MemberBll.Instance.GetList("Email='" + email + "' AND Password='******'").Tables[0];
            }
            else
            {
                dt = MemberBll.Instance.GetList("User_name='" + email + "' AND Password='******'").Tables[0];
            }

            if (dt.Rows.Count > 0)
            {
                CookieHelper cookieHelper = null;
                if (remember == "1") //下次自动登录,设置cookie为一个月
                {
                    cookieHelper = new CookieHelper("52cos", DateTime.Now.AddMonths(1));
                }
                else
                {
                    cookieHelper = new CookieHelper("52cos");                                                  //默认关闭浏览器,失效
                }
                cookieHelper.SetCookie("user_id", DEncryptUtils.DESEncrypt(dt.Rows[0]["User_id"].ToString())); //将user_id添加到cookie
                cookieHelper.SetCookie("pwd", dt.Rows[0]["Password"].ToString());                              //将Password添加到cookie
                i = 1;
            }
            else
            {
                i = 0;
            }
            context.Response.ContentType = "text/plain";
            context.Response.Charset     = "utf-8";
            context.Response.Write(i);
        }
示例#12
0
        public ActionResult Login(LoginViewModel loginViewModel)
        {
            if (TempData["VerificationCode"] == null || TempData["VerificationCode"].ToString() != loginViewModel.VerificationCode?.ToUpper())
            {
                ModelState.AddModelError("VerificationCode", "验证码不正确");
                return(View("Login", loginViewModel));
            }
            var errors = ModelState.Values.SelectMany(v => v.Errors);

            if (ModelState.IsValid)
            {
                Member user = _memberService.Find(loginViewModel.UserName);
                if (user == null)
                {
                    ModelState.AddModelError("UserName", "用户名不存在");
                    return(View("Login", loginViewModel));
                }
                else if (user.Password == DEncryptUtils.Encrypt3DES(loginViewModel.Password))
                {
                    var identity = _memberService.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie);
                    AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
                    AuthenticationManager.SignIn(
                        new AuthenticationProperties()
                    {
                        IsPersistent = loginViewModel.RememberMe
                    }, identity);
                    //return RedirectToAction("Index", "Start");
                    //return Json(new Dictionary<string, string>() { { "status", "success" }, { "message", "登录成功" } });
                    ViewBag.Message = "success";
                    return(View("Login", loginViewModel));
                }
                else
                {
                    ModelState.AddModelError("Password", "密码错误");
                    return(View("Login", loginViewModel));
                }
            }
            ViewBag.Message = "error";
            return(View("Login", loginViewModel));
            //return Json(new Dictionary<string, string>() { { "status", "error" }, { "message", "错误请求" } });
        }
示例#13
0
        public object UpdatePassword(string userId, string oldPwd, string newPwd)
        {
            MemberEntity memberEntity = MemberBll.Instance.GetModel(Convert.ToInt32(userId));

            if (memberEntity != null)
            {
                if (memberEntity.Password == DEncryptUtils.Encrypt3DES(oldPwd))
                {
                    memberEntity.Password = DEncryptUtils.Encrypt3DES(newPwd);
                    if (MemberBll.Instance.Update(memberEntity))
                    {
                        return(new Dictionary <string, string>()
                        {
                            { "status", "200" }, { "message", "修改成功" }
                        });
                    }
                    else
                    {
                        return(new Dictionary <string, string>()
                        {
                            { "status", "400" }, { "message", "修改失败" }
                        });
                    }
                }
                else
                {
                    return(new Dictionary <string, string>()
                    {
                        { "status", "400" }, { "message", "原始密码错误" }
                    });
                }
            }
            else
            {
                return(new Dictionary <string, string>()
                {
                    { "status", "400" }, { "message", "未找到用户" }
                });
            }
        }
示例#14
0
        public ActionResult Password(PasswordViewModel model)
        {
            if (TempData["SMSCode"] == null || TempData["SMSCode"].ToString() != model.SMSCode.ToUpper())
            {
                ModelState.AddModelError("SMSCode", "短信验证码不正确");
                return(PartialView("_PartialPassword", model));
            }
            if (ModelState.IsValid)
            {
                int uid  = Com.Cos.Common.Public.GetLoginUid();
                var user = _memberService.Find(uid);
                if (user.Password != DEncryptUtils.Encrypt3DES(model.OldPassword))
                {
                    ModelState.AddModelError("OldPassword", "密码错误");
                    return(PartialView("_PartialPassword", model));
                }
                else
                {
                    user.Password = DEncryptUtils.Encrypt3DES(model.Password);
                    bool b = _memberService.Update(user);
                    if (b)
                    {
                        AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
                        return(Json(new Dictionary <string, string>()
                        {
                            { "status", "success" }, { "message", "修改成功" }
                        }));
                    }
                    else
                    {
                        return(Json(new Dictionary <string, string>()
                        {
                            { "status", "error" }, { "message", "修改失败" }
                        }));
                    }
                }
            }

            return(PartialView("_PartialPassword", model));
        }
示例#15
0
        public void ProcessRequest(HttpContext context)
        {
            string userId         = DEncryptUtils.DESDecrypt(CookieHelper.GetCookieValue("52cos", "user_id")).Replace("\0", "");
            string classification = context.Request.Form["theme_custom_post_source[type]"];            //作品、合作、活动
            string worksTitle     = context.Request.Form["ctb[post-title]"];                           //作品标题
            string worksExcerpt   = context.Request.Form["ctb[post-excerpt]"];                         //作品摘要
            string worksContent   = context.Request.Form["ctb[post-content]"];                         //作品内容
            string worksType      = context.Request.Form["ctb[cats][]"];                               //作品分类
            string labelDesc      = context.Request.Form["ctb[tags][]"];                               //作品标签
            string source         = context.Request.Form["theme_custom_post_source[source]"];          //来源
            string sourceUrl      = context.Request.Form["theme_custom_post_source[reprint][url]"];    //来源地址
            string author         = context.Request.Form["theme_custom_post_source[reprint][author]"]; //作者
            string cover          = context.Request.Form["ctb[thumbnail-id]"];                         //封面id
            string imgs           = context.Request.Form["ctb[attach-ids][]"];                         //原图id组

            int i = 0;

            string[] types = worksType.Split(',');
            string[] imgss = imgs.Split(',');
            if (classification == "works") //作品
            {
                i = SaveWorks(userId, worksTitle, worksExcerpt, worksContent, labelDesc, source, sourceUrl, author, cover, types);
            }
            if (classification == "reprint") //合作
            {
                i = SaveReprint(userId, worksTitle, worksExcerpt, worksContent, cover);
            }
            if (classification == "activity") //活动
            {
                i = SaveActivity(userId, worksTitle, worksExcerpt, worksContent, cover);
            }



            context.Response.ContentType = "text/plain";
            context.Response.Charset     = "utf-8";
            context.Response.Write(i);
        }
示例#16
0
        public void ProcessRequest(HttpContext context)
        {
            string userId = DEncryptUtils.DESDecrypt(CookieHelper.GetCookieValue("52cos", "user_id")).Replace("\0", "");
            string img    = context.Request.Form["b4"];
            string strReturn;

            MemberEntity memberEntity = MemberBll.Instance.GetModel(Convert.ToInt32(userId));

            memberEntity.Portrait = UploadFile.UploadImg(img, "Upload\\Portrait\\");
            bool b = MemberBll.Instance.Update(memberEntity);

            if (b)
            {
                strReturn = "{\"status\":\"success\"}";
            }
            else
            {
                strReturn = "{\"status\":\"error\"}";
            }

            context.Response.ContentType = "text/plain";
            context.Response.Charset     = "utf-8";
            context.Response.Write(strReturn);
        }
示例#17
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            string value = "fail";
            string text  = WebUtils.GetQueryString("key");

            if (!string.IsNullOrEmpty(text))
            {
                try
                {
                    text = DEncryptUtils.DESDecode(text);
                }
                catch
                {
                    text = string.Empty;
                }
                UserInfo userByName = SinGooCMS.BLL.User.GetUserByName(text);
                if (userByName == null)
                {
                    this.Alert(base.GetCaption("UserAct_MemberNotExistOrDeleted"), "/");
                }
                else
                {
                    userByName.Status = 99;
                    if (SinGooCMS.BLL.User.Update(userByName))
                    {
                        value = "success";
                    }
                }
            }
            else
            {
                this.Alert(base.GetCaption("UserAct_InvalidParameter"));
            }
            base.Put("actresult", value);
            base.UsingClient("user/会员激活.html");
        }
示例#18
0
        public void CreateCheckCodeImage()
        {
            string checkCode = GenerateCheckCode();

            _codestring = checkCode;
            if (checkCode == null || checkCode.Trim() == String.Empty)
            {
                return;
            }

            int codeW    = 80;
            int codeH    = 22;
            int fontSize = 16;

            Random rnd = new Random();

            //颜色列表,用于验证码、噪线、噪点
            Color[] color = { Color.Black, Color.Red, Color.Blue, Color.Green, Color.Orange, Color.Brown, Color.Brown, Color.DarkBlue };
            //字体列表,用于验证码
            string[] font = { "Times New Roman", "Verdana", "Arial", "Gungsuh", "Impact" };

            //创建画布
            Bitmap   bmp = new Bitmap(codeW, codeH);
            Graphics g   = Graphics.FromImage(bmp);

            g.Clear(Color.White);
            //画噪线
            for (int i = 0; i < 1; i++)
            {
                int   x1  = rnd.Next(codeW);
                int   y1  = rnd.Next(codeH);
                int   x2  = rnd.Next(codeW);
                int   y2  = rnd.Next(codeH);
                Color clr = color[rnd.Next(color.Length)];
                g.DrawLine(new Pen(clr), x1, y1, x2, y2);
            }
            //画验证码字符串
            for (int i = 0; i < checkCode.Length; i++)
            {
                string fnt = font[rnd.Next(font.Length)];
                Font   ft  = new Font(fnt, fontSize);
                Color  clr = color[rnd.Next(color.Length)];
                g.DrawString(checkCode[i].ToString(), ft, new SolidBrush(clr), (float)i * 20 + 8, (float)0);
            }
            //画噪点
            for (int i = 0; i < 100; i++)
            {
                int   x   = rnd.Next(bmp.Width);
                int   y   = rnd.Next(bmp.Height);
                Color clr = color[rnd.Next(color.Length)];
                bmp.SetPixel(x, y, clr);
            }
            //清除该页输出缓存,设置该页无缓存
            System.Web.HttpContext.Current.Response.Buffer          = true;
            System.Web.HttpContext.Current.Response.ExpiresAbsolute = System.DateTime.Now.AddMilliseconds(0);
            System.Web.HttpContext.Current.Response.Expires         = 0;
            System.Web.HttpContext.Current.Response.CacheControl    = "no-cache";
            System.Web.HttpContext.Current.Response.AppendHeader("Pragma", "No-Cache");
            try
            {
                //将验证码图片写入内存流,并将其以 "image/Png" 格式输出
                MemoryStream ms = new MemoryStream();
                bmp.Save(ms, ImageFormat.Png);

                //写入cookie
                if (_codetype == VerifyCodeType.Web)
                {
                    //清除该页输出缓存,设置该页无缓存
                    System.Web.HttpContext.Current.Response.Buffer          = true;
                    System.Web.HttpContext.Current.Response.ExpiresAbsolute = System.DateTime.Now.AddMilliseconds(0);
                    System.Web.HttpContext.Current.Response.Expires         = 0;
                    System.Web.HttpContext.Current.Response.CacheControl    = "no-cache";
                    System.Web.HttpContext.Current.Response.AppendHeader("Pragma", "No-Cache");
                    System.Web.HttpContext.Current.Response.ClearContent();
                    System.Web.HttpContext.Current.Response.ContentType = "image/Png";
                    System.Web.HttpContext.Current.Response.BinaryWrite(ms.ToArray());
                    CookieUtils.SetCookie("gif", DEncryptUtils.DESEncode(intResult.ToString()), 3600 * 24 * 30);
                }
            }
            finally
            {
                //显式释放资源
                bmp.Dispose();
                g.Dispose();
            }
        }
示例#19
0
 /// <summary>
 /// 密码解密
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button4_Click(object sender, EventArgs e)
 {
     textBox1.Text = DEncryptUtils.Decrypt3DES(textBox2.Text);
 }
示例#20
0
        public static LoginStatus UserLogin(string strLoginName, string strEncryPassword, ref UserInfo userRef)
        {
            SqlParameter[] arrParam = new SqlParameter[]
            {
                new SqlParameter("@loginname", strLoginName)
            };
            userRef = BizBase.dbo.GetModel <UserInfo>(BizBase.dbo.ExecProcReReader("p_System_UserLogin", arrParam));
            LoginLogInfo last = LoginLog.GetLast(UserType.User, strLoginName);
            LoginStatus  result;

            if (userRef == null)
            {
                result = LoginStatus.UserNameIncorrect;
            }
            else if (last != null && last.LoginFailCount >= ConfigProvider.Configs.TryLoginTimes && (DateTime.Now - last.AutoTimeStamp).TotalMinutes < 5.0)
            {
                result = LoginStatus.MutilLoginFail;
            }
            else if (strEncryPassword != userRef.Password)
            {
                new LogManager().AddLoginLog(UserType.User, strLoginName, false);
                result = LoginStatus.PasswordIncorrect;
            }
            else if (userRef.Status != 99)
            {
                result = LoginStatus.StatusNotAllow;
            }
            else
            {
                HttpCookie httpCookie = new HttpCookie("singoouser");
                httpCookie.Values["uid"]      = userRef.AutoID.ToString();
                httpCookie.Values["uname"]    = HttpUtility.UrlEncode(userRef.UserName);
                httpCookie.Values["nickname"] = HttpUtility.UrlEncode(userRef.NickName);
                httpCookie.Values["pwd"]      = HttpUtility.UrlEncode(DEncryptUtils.DESEncode(userRef.Password));
                string cookieTime = ConfigProvider.Configs.CookieTime;
                if (cookieTime != null)
                {
                    if (!(cookieTime == "一周"))
                    {
                        if (cookieTime == "一年")
                        {
                            httpCookie.Expires = DateTime.Now.AddYears(1);
                        }
                    }
                    else
                    {
                        httpCookie.Expires = DateTime.Now.AddDays(7.0);
                    }
                }
                HttpContext.Current.Response.Cookies.Add(httpCookie);
                userRef.LoginCount++;
                userRef.LastLoginIP   = IPUtils.GetIP();
                userRef.LastLoginTime = DateTime.Now;
                if (string.IsNullOrEmpty(userRef.Province))
                {
                    TaoBaoAreaInfo iPAreaFromTaoBao = IPUtils.GetIPAreaFromTaoBao(IPUtils.GetIP());
                    if (iPAreaFromTaoBao != null)
                    {
                        userRef.Country  = iPAreaFromTaoBao.data.country;
                        userRef.Province = iPAreaFromTaoBao.data.region;
                        userRef.City     = iPAreaFromTaoBao.data.city;
                        userRef.County   = iPAreaFromTaoBao.data.county;
                    }
                }
                User.Update(userRef);
                new LogManager().AddLoginLog(UserType.User, strLoginName, true);
                result = LoginStatus.Success;
            }
            return(result);
        }
示例#21
0
        public void ProcessRequest(HttpContext context)
        {
            string    nickname = context.Request.Form["user[nickname]"];
            string    email    = context.Request.Form["user[email]"];
            string    pwd      = context.Request.Form["user[pwd]"];
            string    s        = "{\"status\":\"error\"}";
            bool      b        = false;
            DataTable dt       = MemberBll.Instance.GetList("Email='" + email + "'").Tables[0];

            if (dt.Rows.Count > 0)
            {
                s = "{\"status\":\"exist\"}";
                return;
            }

            MemberEntity memberEntity = new MemberEntity();

            memberEntity.User_name = "";
            memberEntity.Email     = email;
            memberEntity.Password  = DEncryptUtils.Encrypt3DES(pwd);
            memberEntity.Real_name = "";
            memberEntity.nickname  = nickname;
            memberEntity.Gender    = memberEntity.Birthday = memberEntity.Phone_tel = memberEntity.Phone_mob = memberEntity.Im_qq = memberEntity.Im_msn
                                                                                                                                        = memberEntity.In_skype = memberEntity.Im_yahoo = memberEntity.Im_aliww = memberEntity.Outer_id
                                                                                                                                                                                                                      = memberEntity.Feed_config = "";
            memberEntity.Portrait   = "/Upload/Portrait/1.jpg";
            memberEntity.Reg_time   = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            memberEntity.Last_login = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            memberEntity.Last_ip    = new BasePage().ClientIP;
            memberEntity.Logins     = 0;
            memberEntity.Ugrade     = 1;
            memberEntity.Status     = 1;
            memberEntity.reward     = 0;
            memberEntity.CNbi       = 0;
            memberEntity.integral   = 0;
            memberEntity.ardent     = 0;
            memberEntity.Growth     = 0;
            memberEntity.code       = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(Guid.NewGuid().ToString(), "MD5");
            memberEntity.Activation = "0";
            memberEntity.Describe   = "";
            memberEntity.Shenjia    = 0;
            memberEntity.Bean       = "0";

            StringBuilder mailBody = new StringBuilder();

            mailBody.AppendFormat(EmailConfig.Instance._EmailBody, memberEntity.nickname, HttpContext.Current.Request.Url.Host, memberEntity.code);

            //发送注册邮件
            b = MemberApi.SendRegisterMail(memberEntity.nickname, memberEntity.code, memberEntity.Email);
            if (b)
            {
                b = MemberBll.Instance.Add(memberEntity) > 0;
                if (b)
                {
                    CookieHelper cookieHelper = new CookieHelper("52cos", DateTime.Now.AddMonths(1));
                    dt = MemberBll.Instance.GetList("Email='" + memberEntity.Email + "' and Password='******'").Tables[0];
                    cookieHelper.SetCookie("user_id", DEncryptUtils.DESEncrypt(dt.Rows[0]["User_id"].ToString())); //将user_id添加到cookie
                    cookieHelper.SetCookie("pwd", memberEntity.Password);                                          //将Password添加到cookie
                    s = "{\"status\":\"success\"}";
                }
            }


            context.Response.ContentType = "text/plain";
            context.Response.Write(s);
        }
示例#22
0
        /// <summary>
        /// 账号注册
        /// </summary>
        /// <param name="nickname">昵称</param>
        /// <param name="acc">邮箱</param>
        /// <param name="pwd">密码(未加密)</param>
        /// <returns></returns>
        public static string Register(string nickname, string acc, string pwd)
        {
            string email, phone;

            if (RegexUtil.IsEmail(acc))
            {
                email = acc;
                phone = "";
            }
            else
            {
                phone = acc;
                email = "";
            }

            MemberEntity memberEntity = new MemberEntity();

            memberEntity.User_name = "";
            memberEntity.Email     = email;
            memberEntity.Password  = DEncryptUtils.Encrypt3DES(pwd);
            memberEntity.Real_name = "";
            memberEntity.nickname  = nickname;
            memberEntity.Phone_mob = phone;
            memberEntity.Gender    = memberEntity.Birthday = memberEntity.Phone_tel = memberEntity.Im_qq = memberEntity.Im_msn
                                                                                                               = memberEntity.In_skype = memberEntity.Im_yahoo = memberEntity.Im_aliww = memberEntity.Outer_id
                                                                                                                                                                                             = memberEntity.Feed_config = "";
            memberEntity.Portrait   = "/Upload/Portrait/1.jpg";
            memberEntity.Reg_time   = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            memberEntity.Last_login = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            memberEntity.Last_ip    = IpHelper.GetUserIp();
            memberEntity.Logins     = 0;
            memberEntity.Ugrade     = 1;
            memberEntity.Status     = 1;
            memberEntity.reward     = 0;
            memberEntity.CNbi       = 0;
            memberEntity.integral   = 0;
            memberEntity.ardent     = 0;
            memberEntity.Growth     = 0;
            memberEntity.Describe   = "";
            memberEntity.Shenjia    = 0;
            memberEntity.Bean       = "";
            memberEntity.code       = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(Guid.NewGuid().ToString(), "MD5");
            memberEntity.Activation = "0";
            if (RegexUtil.IsEmail(acc))
            {
                if (SendRegisterMail(nickname, memberEntity.code, email))
                {
                    if (MemberBll.Instance.Add(memberEntity) > 0)
                    {
                        return("注册成功");
                    }
                    else
                    {
                        return("账号信息保存失败");
                    }
                }
                else
                {
                    return("邮件发生失败");
                }
            }
            else
            {
                if (MemberBll.Instance.Add(memberEntity) > 0)
                {
                    return("注册成功");
                }
                else
                {
                    return("账号信息保存失败");
                }
            }
        }
示例#23
0
 public object LoginValidate(string acc, string pwd)
 {
     if (RegexUtil.IsEmail(acc))
     {
         DataTable dt = MemberBll.Instance.GetList("Email='" + acc + "' AND Password='******'").Tables[0];
         if (dt.Rows.Count > 0)
         {
             return(new Dictionary <string, string>()
             {
                 { "status", "200" }, { "UserId", dt.Rows[0]["User_id"].ToString() }
             });
         }
         else
         {
             return(new Dictionary <string, string>()
             {
                 { "status", "400" }, { "message", "邮箱或密码不正确" }
             });
         }
     }
     else
     {
         DataTable dt = MemberBll.Instance.GetList("Phone_mob='" + acc + "' AND Password='******'").Tables[0];
         if (dt.Rows.Count > 0)
         {
             return(new Dictionary <string, string>()
             {
                 { "status", "200" }, { "UserId", dt.Rows[0]["User_id"].ToString() }
             });
         }
         else
         {
             return(new Dictionary <string, string>()
             {
                 { "status", "400" }, { "message", "手机号或密码不正确" }
             });
         }
     }
 }
示例#24
0
        protected void btn_Export_Click(object sender, System.EventArgs e)
        {
            DataTable dataTable = PageBase.dbo.GetDataTable("SELECT AutoID AS Ma,UserName AS TenDangNhap,Email,Mobile, RealName,Gender,Birthday, AutoTimeStamp,LoginCount,LastLoginTime FROM cms_User WHERE " + this.GetCondition());

            if (dataTable != null && dataTable.Rows.Count > 0)
            {
                string text = base.ExportFolder + StringUtils.GetRandomNumber() + ".xls";
                DataToXSL.CreateXLS(dataTable, base.Server.MapPath(text), true);
                ScriptManager.RegisterStartupScript(this.UpdatePanel1, typeof(UpdatePanel), "download", "<script>location='/include/download?file=" + DEncryptUtils.DESEncode(text) + "'</script>", false);
            }
            else
            {
                base.ShowMsg("Không có dữ liệu tìm thấy");
            }
        }
示例#25
0
 public static string GetEncodePwd(string strOrigialPwd)
 {
     return(DEncryptUtils.MD5EnCode(DEncryptUtils.MD5EnCode(strOrigialPwd)));
 }
示例#26
0
 protected void Page_Load(object sender, System.EventArgs e)
 {
     if (base.IsPost)
     {
         UserInfo userInfo = new UserInfo();
         userInfo = SinGooCMS.BLL.User.GetUserByName(WebUtils.GetFormString("_uname"));
         if (userInfo == null)
         {
             base.WriteJsonTip(base.GetCaption("GetPwd_UserNotExist"));
         }
         else
         {
             base.WriteJsonTip(true, "用户名正确", UrlRewrite.Get("resetpwd_url") + "?uid=" + DEncryptUtils.DESEncode(userInfo.AutoID.ToString()));
         }
     }
     else
     {
         base.UsingClient("user/找回密码.html");
     }
 }
示例#27
0
        /// <summary>
        /// 创建图片并保存在内存中
        /// </summary>
        /// <param name="checkCode"></param>
        public void CreateCheckCodeImage()
        {
            string checkCode = GenerateCheckCode();

            _codestring = checkCode;
            if (checkCode == null || checkCode.Trim() == String.Empty)
            {
                return;
            }

            System.Drawing.Bitmap image = new System.Drawing.Bitmap((int)Math.Ceiling((checkCode.Length * 10.5)), 18);
            Graphics g = Graphics.FromImage(image);


            //生成随机生成器
            Random random = new Random();

            //清空图片背景色
            g.Clear(Color.White);

            #region
            //画图片的背景噪音线
            for (int i = 0; i < 20; i++)
            {
                int x1 = random.Next(image.Width);
                int x2 = random.Next(image.Width);
                int y1 = random.Next(image.Height);
                int y2 = random.Next(image.Height);

                g.DrawLine(new Pen(Color.Silver), x1, y1, x2, y2);
            }
            #endregion

            Font font = new System.Drawing.Font("Arial", 11, (System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic));
            System.Drawing.Drawing2D.LinearGradientBrush brush = new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(0, 0, image.Width, image.Height), Color.Blue, Color.DarkRed, 1.2f, true);
            g.DrawString(checkCode, font, brush, 2, 2);

            #region
            //画图片的前景噪音点
            for (int i = 0; i < 100; i++)
            {
                int x = random.Next(image.Width);
                int y = random.Next(image.Height);

                image.SetPixel(x, y, Color.FromArgb(random.Next()));
            }

            //画图片的边框线
            g.DrawRectangle(new Pen(Color.Silver), 0, 0, image.Width - 1, image.Height - 1);
            #endregion

            try
            {
                System.IO.MemoryStream ms = new System.IO.MemoryStream();
                image.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
                if (_codetype == VerifyCodeType.Web)
                {
                    //清除该页输出缓存,设置该页无缓存
                    System.Web.HttpContext.Current.Response.Buffer          = true;
                    System.Web.HttpContext.Current.Response.ExpiresAbsolute = System.DateTime.Now.AddMilliseconds(0);
                    System.Web.HttpContext.Current.Response.Expires         = 0;
                    System.Web.HttpContext.Current.Response.CacheControl    = "no-cache";
                    System.Web.HttpContext.Current.Response.AppendHeader("Pragma", "No-Cache");
                    System.Web.HttpContext.Current.Response.ClearContent();
                    System.Web.HttpContext.Current.Response.ContentType = "image/Gif";
                    System.Web.HttpContext.Current.Response.BinaryWrite(ms.ToArray());

                    CookieUtils.SetCookie("gif", DEncryptUtils.DESEncode(checkCode), 3600 * 24 * 30);
                }
                else
                {
                    _codeimg = image;
                }
            }
            finally
            {
                //显式释放资源
                image.Dispose();
                g.Dispose();
            }
        }
示例#28
0
        public ActionResult Register(RegisterViewModel registerViewModel)
        {
            if (TempData["VerificationCode"] == null || TempData["VerificationCode"].ToString() != registerViewModel.VerificationCode.ToUpper())
            {
                ModelState.AddModelError("VerificationCode", "验证码不正确");
                return(View("Register", registerViewModel));
            }

            var errors = ModelState.Values.SelectMany(v => v.Errors);

            if (ModelState.IsValid)
            {
                Member member = new Member
                {
                    User_name  = "",
                    Portrait   = "/Upload/Portrait/1.jpg",
                    Last_login = DateTime.Now,
                    Last_ip    = "1.1.1.1",
                    nickname   = registerViewModel.NickName,
                    Password   = DEncryptUtils.Encrypt3DES(registerViewModel.Password),
                    Status     = 1,
                    Reg_time   = DateTime.Now
                };
                string str = registerViewModel.Email;
                if (RegexUtil.IsMobilePhone(str)) //是用手机号注册
                {
                    if (TempData["SMSCode"] == null || TempData["SMSCode"].ToString() != registerViewModel.SMSCode.ToUpper())
                    {
                        ModelState.AddModelError("SMSCode", "短信验证码不正确");
                        return(View("Register", registerViewModel));
                    }
                    member.Phone_mob = str;
                }
                else //邮箱注册
                {
                    member.Email = str;
                }
                using (TransactionScope ts = new TransactionScope())
                {
                    member = _memberService.Add(member);
                    var lottery = new Lottery()
                    {
                        AcId        = 0,
                        AddTime     = DateTime.Now,
                        LotteryCode = "0",
                        UserId      = member.User_id,
                        Status      = 1
                    };
                    _lotteryService.Add(lottery);
                    ts.Complete();
                }

                if (member.User_id > 0)
                {
                    //return Json(new Dictionary<string, string>() { { "status", "success" }, { "message", "注册成功" } });

                    ViewBag.IsShow = 1;
                    return(View("Register", registerViewModel));
                }
                else
                {
                    //ModelState.AddModelError("", "注册失败!");
                    //return JavaScript("alert('服务器异常,请稍后再试!');");
                    ViewBag.Message = "error";
                    return(View("Register", registerViewModel));
                }
            }
            ViewBag.Message = "error";
            return(View("Register", registerViewModel));
        }
示例#29
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (CookieHelper.GetCookieValue("52cos", "user_id") != null && CookieHelper.GetCookieValue("52cos", "pwd") != "")
            {
                string userId            = DEncryptUtils.DESDecrypt(CookieHelper.GetCookieValue("52cos", "user_id")).Replace("\0", "");
                string pwd               = CookieHelper.GetCookieValue("52cos", "pwd");
                List <MemberEntity> list = MemberBll.Instance.GetModelList("User_id='" + userId + "' AND Password='******'");
                if (list.Count > 0)
                {
                    this.MemberEntity = list[0];

                    if (Session["UserInfo"] == null)
                    {
                        Session["UserInfo"] = this.MemberEntity;
                    }

                    //RecordIp(userId);
                    //UpdateLoginIp(userId);
                    //BindMenu();
                    //#region MyRegion
                    //string s = string.Format(@"<div class='tool tool-me'>
                    //                                <a href='/zl/zl-{1}.html'><!--用户主页地址-->
                    //                                 <img class='avatar' width='32' height='32' src='{0}' alt='avatar'><!--头像-->
                    //                                 <i class='fa fa-angle-down'></i>
                    //                                </a>
                    //                                <div class='box'>
                    //                                 <!-- points -->
                    //                                 <div class='box-points'>
                    //                                  <a href='/zl/zl-{1}.html' alt='0/10000'>
                    //                                   <img src='/Style/img/integral.gif' alt='' width='16' height='16'>
                    //                                   Level {5}
                    //                                  </a>
                    //                                 </div>
                    //                                 <div class='box-points'>
                    //                                  <a href='/yh/history.html'>
                    //                                   <img src='/Style/img/integral.gif' alt='' width='16' height='16' title='{2} 节操 {3} 热心 {4} CN币 {6} 身家'>
                    //                                   {2} 节操 {6} 身家
                    //                                  </a>
                    //                                 </div>
                    //                                 <ul>
                    //                                  <li class=''>
                    //                                   <a href='/yh/dashboard.html'>
                    //                                    <i class='fa fa-dashboard fa-fw'></i>
                    //                                    用户中心
                    //                                   </a>
                    //                                  </li>
                    //                                  <li class=''>
                    //                                   <a href='/yh/contributions.html'>
                    //                                    <i class='fa fa-paint-brush fa-fw'></i>
                    //                                    文章投稿
                    //                                   </a>
                    //                                  </li>
                    //                                  <li class=''>
                    //                                   <a href='/yh/mytg.html'>
                    //                                    <i class='fa fa-lightbulb-o fa-fw'></i>
                    //                                    我的投稿
                    //                                   </a>
                    //                                  </li>
                    //                                  <li class=''>
                    //                                   <a href='/yh/translate.html'>
                    //                                    <i class='fa fa-envelope fa-fw'></i>
                    //                                    私信
                    //                                   </a>
                    //                                  </li>
                    //                                  <li class=''>
                    //                                   <a href='/yh/bomb.html'>
                    //                                    <i class='fa fa-bomb fa-fw'></i>
                    //                                    轰炸小游戏
                    //                                   </a>
                    //                                  </li>
                    //                                  <li class=''>
                    //                                   <a href='/yh/notifications.html'>
                    //                                    <i class='fa fa-bell fa-fw'></i>
                    //                                    我的提醒
                    //                                   </a>
                    //                                  </li>
                    //                                  <li class=''>
                    //                                   <a href='/yh/history.html'>
                    //                                    <i class='fa fa-history fa-fw'></i>
                    //                                    积分历史
                    //                                   </a>
                    //                                  </li>
                    //                                  <li class=''>
                    //                                   <a href='/yh/settings.html'>
                    //                                    <i class='fa fa-cog fa-fw'></i>
                    //                                    我的设置
                    //                                   </a>
                    //                                  </li>
                    //                                  <li class=''>
                    //                                   <a href='/yh/medal.html'>
                    //                                    <i class='fa fa-bookmark fa-fw'></i>
                    //                                    勋章中心
                    //                                   </a>
                    //                                  </li>
                    //                                  <li class=''>
                    //                                   <a href='/yh/lottery.html'>
                    //                                    <i class='fa fa-yelp fa-fw'></i>
                    //                                    积分商城
                    //                                   </a>
                    //                                  </li>
                    //                                  <li class=''>
                    //                                   <a href='/yh/avatar.html'>
                    //                                    <i class='fa fa-github-alt fa-fw'></i>
                    //                                    我的头像
                    //                                   </a>
                    //                                  </li>
                    //                                        <li class=''>
                    //                                   <a href='/yh/recharge.html'>
                    //                                    <i class='fa fa-database'></i>
                    //                                    立刻充值
                    //                                   </a>
                    //                                  </li>
                    //                                        <li class=''>
                    //                                   <a href='/yh/exchange.html'>
                    //                                    <i class='fa fa-link'></i>
                    //                                    发布兑换
                    //                                   </a>
                    //                                  </li>
                    //                                  <li class=''>
                    //                                   <a href='/yh/password.html'>
                    //                                    <i class='fa fa-lock fa-fw'></i>
                    //                                    修改密码
                    //                                   </a>
                    //                                  </li>
                    //                                  <li><a href='/prompts.html'><i class='fa fa-sign-out fa-fw'></i>登出</a></li>
                    //                                 </ul>
                    //                                </div>
                    //                                </div>",
                    //dt.Rows[0]["portrait"], userId, dt.Rows[0]["integral"], dt.Rows[0]["ardent"], dt.Rows[0]["CNbi"], dt.Rows[0]["Ugrade"], dt.Rows[0]["Shenjia"]);
                    //userbar.InnerHtml = s + "<a href=\"javascript:;\" class=\"tool search fa fa-search fa-2x\" data-toggle-target=\"#fm-search\" data-focus-target=\"#fm-search-s\" data-icon-active=\"fa-arrow-down\" data-icon-original=\"fa-search\" title=\"搜索\"></a>";
                    //#endregion
                }
            }
        }
示例#30
0
 protected void Page_Load(object sender, System.EventArgs e)
 {
     if (base.IsPost)
     {
         UserInfo userInfo = new UserInfo();
         userInfo = SinGooCMS.BLL.User.GetUserByName(WebUtils.GetFormString("_uname"));
         string formString = WebUtils.GetFormString("_findpwdtype");
         string strMobile  = string.Empty;
         if (formString.Equals("bymobile"))
         {
             strMobile = userInfo.Mobile;
         }
         else
         {
             strMobile = userInfo.Email;
         }
         string  formString2   = WebUtils.GetFormString("_newpwd");
         SMSInfo lastCheckCode = SMS.GetLastCheckCode(strMobile);
         if (lastCheckCode == null)
         {
             base.WriteJsonTip(base.GetCaption("GetPwd_NoSendMobileValidateCodeYet"));
         }
         else if (string.Compare(WebUtils.GetFormString("_fourcode"), lastCheckCode.ValidateCode, true) != 0)
         {
             base.WriteJsonTip(base.GetCaption("GetPwd_MobileValidateCodeIncorrect"));
         }
         else if (string.IsNullOrEmpty(formString2))
         {
             base.WriteJsonTip(base.GetCaption("GetPwd_NewPwdNotEmpty"));
         }
         else if (formString2.Length < 6)
         {
             base.WriteJsonTip(base.GetCaption("GetPwd_NewPwdLenCannotLess6"));
         }
         else if (SinGooCMS.BLL.User.UpdatePassword(userInfo.AutoID, formString2))
         {
             new MsgService(userInfo).SendFindPwdMsg();
             base.WriteJsonTip(true, base.GetCaption("ResetPwd_Success"), UrlRewrite.Get("resetsuccess_url"));
         }
         else
         {
             base.WriteJsonTip(base.GetCaption("GetPwd_PasswordResetFailed"));
         }
     }
     else
     {
         UserInfo userInfo             = new UserInfo();
         int      intPrimaryKeyIDValue = 0;
         try
         {
             intPrimaryKeyIDValue = WebUtils.GetInt(DEncryptUtils.DESDecode(WebUtils.GetQueryString("uid")));
         }
         catch
         {
             intPrimaryKeyIDValue = 0;
         }
         userInfo = SinGooCMS.BLL.User.GetDataById(intPrimaryKeyIDValue);
         base.Put("curruser", userInfo);
         base.Put("useremail", string.IsNullOrEmpty(userInfo.Email) ? "没有绑定邮箱" : StringUtils.GetAnonymous(userInfo.Email));
         base.Put("usermobile", string.IsNullOrEmpty(userInfo.Mobile) ? "没有绑定手机" : StringUtils.GetAnonymous(userInfo.Mobile));
         base.UsingClient("user/找回密码方式.html");
     }
 }