示例#1
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("没有找到任何记录");
     }
 }
示例#2
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();
            }
        }
示例#3
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");
            }
        }
示例#4
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");
     }
 }
示例#5
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();
            }
        }
示例#6
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);
        }