コード例 #1
0
ファイル: EX_Admin.cs プロジェクト: zwkjgs/LebiShop
 /// <summary>
 /// 判断登录状态
 /// </summary>
 /// <returns></returns>
 public static bool LoginStatus()
 {
     if (HttpContext.Current.Session["admin"] == null)
     {
         var    nv    = CookieTool.GetCookie("Master");
         int    uid   = 0;
         string uhash = "";
         string uname = "";
         if (nv.Count > 1)
         {
             if (!string.IsNullOrEmpty(nv.Get("id")) && !string.IsNullOrEmpty(nv.Get("hash")) && !string.IsNullOrEmpty(nv.Get("name")))
             {
                 //uid = StringUtils.StrToInt(nv.Get("id"), 0);
                 int.TryParse(nv.Get("id"), out uid);
                 uhash = nv.Get("hash");
                 uname = nv.Get("name");
                 Lebi_Administrator master = B_Lebi_Administrator.GetModel(uid);
                 if (CheckAdmin(master, uhash, uname, true))
                 {
                     SetSession(master);
                     return(true);
                 }
                 else
                 {
                     return(false);
                 }
             }
             return(false);
         }
         return(false);
     }
     return(true);
 }
コード例 #2
0
        public void LoadTheme()
        {
            string themecode = "";
            string language  = "";
            int    siteid    = 0;
            var    nv        = CookieTool.GetCookie("ThemeStatus");

            if (!string.IsNullOrEmpty(nv.Get("language")))
            {
                language = nv.Get("language");
            }
            if (!string.IsNullOrEmpty(nv.Get("theme")))
            {
                themecode = nv.Get("theme");
            }
            if (!string.IsNullOrEmpty(nv.Get("site")))
            {
                int.TryParse(nv.Get("site"), out siteid);
            }
            if (siteid == 0)
            {
                siteid = ShopCache.GetMainSite().id;
            }
            LoadTheme(themecode, siteid, language, "", false);
        }
コード例 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            site_supplier = new Site_Supplier();

            CookieTool.DeleteCookie("User");
            Response.Redirect(site_supplier.AdminPath + "/login.aspx?url=" + HttpUtility.UrlEncode(RequestTool.GetUrlReferrerNonDomain()) + "");
        }
コード例 #4
0
 protected override void LoadPage(string themecode, int siteid, string languagecode, string pcode)
 {
     LoadTheme(themecode, siteid, languagecode, pcode);
     if (CurrentUser.id == 0)
     {
         //未登录
         if (SYS.IsAnonymousUser != "1")
         {
             Response.Redirect(URL("P_Login", "" + HttpUtility.UrlEncode(RequestTool.GetRequestUrlNonDomain()) + "," + GetUrlToken(RequestTool.GetRequestUrlNonDomain()) + ""));
         }
     }
     if (SYS.IsSupplierCash == "1")
     {
         int sid = Rint_Para("0");
         supplier = B_Lebi_Supplier.GetModel(sid);
     }
     if (supplier == null)
     {
         supplier = new Lebi_Supplier();
     }
     CookieTool.SetCookieString("supplier", supplier.id.ToString(), 60);
     path   = "<a href=\"" + URL("P_Index", "") + "\" class=\"home\" title=\"" + Tag("首页") + "\"><span>" + Tag("首页") + "</span></a><em class=\"home\">&raquo;</em><a href=\"" + URL("P_Basket", "") + "\"><span>" + Tag("购物车") + "</span></a><em>&raquo;</em><a href=\"" + URL("P_CheckOut", "") + "\"><span>" + Tag("收银台") + "</span></a>";
     basket = new Basket();
     if (basket.Products.Count == 0)
     {
         Response.Redirect(URL("P_Basket", ""));
     }
     if (CurrentUser.id > 0)
     {
         cards      = B_Lebi_Card.GetList("User_id=" + CurrentUser.id + " and Type_id_CardType=312 and Type_id_CardStatus in (201,203) and Time_End>'" + FormatTime(System.DateTime.Now) + "'", "id asc");//状态为已发放或部分使用
         moneycards = B_Lebi_Card.GetList("User_id=" + CurrentUser.id + " and Type_id_CardType=311 and Type_id_CardStatus in (201,203) and Time_End>'" + FormatTime(System.DateTime.Now) + "'", "id asc");
     }
     ProPerty135 = B_Lebi_ProPerty.GetList("Type_id_ProPertyType=135", "Sort desc");
 }
コード例 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ReturnURL.Text = CommonLogic.QueryStringCanBeDangerousContent("ReturnURL");
            if (ReturnURL.Text.IndexOf("<script>", StringComparison.InvariantCultureIgnoreCase) != -1)
            {
                throw new ArgumentException("SECURITY EXCEPTION");
            }

            string errorMsg = CommonLogic.QueryStringCanBeDangerousContent("ErrorMsg");

            if (errorMsg.Trim().Length != 0)
            {
                ErrorMsgLabel.Text = errorMsg;
                ErrorPanel.Visible = true;
            }

            RequireSecurePage();

            if (!Page.IsPostBack)
            {
                DoingCheckout.Checked = CommonLogic.QueryStringBool("checkout");
                if (ReturnURL.Text.Length == 0)
                {
                    ReturnURL.Text = CommonLogic.QueryStringBool("checkout") ? "shoppingcart.aspx?checkout=true" : "default.aspx";
                }

                try
                {
                    string cookieValue = CookieTool.GetValue(REMEMBERME_COOKIE_NAME);
                    if (!string.IsNullOrEmpty(cookieValue) && CommonLogic.IsValidGuid(cookieValue))
                    {
                        var customerGuid       = new Guid(cookieValue);
                        var rememberMeCustomer = Customer.Find(customerGuid);
                        EMail.Text = rememberMeCustomer.EMail;
                        this.Password.Attributes.Add("value", rememberMeCustomer.GetPassword());
                        this.PersistLogin.Checked = true;
                    }
                }
                catch
                {
                    EMail.Text    = string.Empty;
                    Password.Text = string.Empty;
                }

                SignUpLink.NavigateUrl = "createaccount.aspx?checkout=" + DoingCheckout.Checked.ToString();
            }

            if (AppLogic.AppConfigBool("SecurityCodeRequiredOnStoreLogin"))
            {
                // Create a random code and store it in the Session object.
                SecurityCodePanel.Visible  = true;
                SecurityImagePanel.Visible = true;
                SecurityImage.ImageUrl     = "Captcha.ashx?id=1";
            }

            HeaderMsg.SetContext = this;
        }
コード例 #6
0
        /// <summary>
        /// ASP.NET에서 현재 요청과 관련된 현재 상태(예: 세션 상태)를 가져오는 경우 발생하는 이벤트에 대한 핸들러입니다.<br/>
        /// 사용자의 Locale 정보를 읽어서 현재 Context의 CultureInfo를 설정합니다.
        /// </summary>
        public virtual void OnBeginRequest(object sender, EventArgs e)
        {
            CultureInfo culture = null;

            // 사용자가 지정한 Locale을 사용할 경우
            if (UseUserLocale)
            {
                try {
                    var cultureName = CookieTool.Get(UserLocaleCookieName);

                    // 쿠키에 User Locale 정보가 저장되어 있다면
                    if (cultureName.IsNotWhiteSpace())
                    {
                        culture = new CultureInfo(cultureName);

                        if (IsDebugEnabled)
                        {
                            log.Debug("쿠키로부터 User Locale 정보를 얻었습니다. User Locale=[{0}]", cultureName);
                        }
                    }
                    else if (HttpContext.Current.Request.UserLanguages != null)
                    {
                        var language = HttpContext.Current.Request.UserLanguages.FirstOrDefault();

                        if (language.IsNotWhiteSpace())
                        {
                            culture = new CultureInfo(language);
                            if (IsDebugEnabled)
                            {
                                log.Debug("사용자 Browser의 UserLanguage중에 첫번째 것을 User Locale로 사용합니다. language=[{0}", language);
                            }
                        }
                    }
                }
                catch (Exception ex) {
                    if (log.IsInfoEnabled)
                    {
                        log.Info("쿠키로부터 User Locale 정보를 수집하는데 실패했습니다. 무시하고 시스템 기준값을 사용합니다.");
                        log.Info(ex);
                    }
                }
            }

            // 사용자 culture를 지정하지 못했다면, 현재 시스템의 Thread Context의 Culture를 지정합니다.
            if (culture.IsNullCulture())
            {
                culture = CultureInfo.CurrentCulture;

                if (IsDebugEnabled)
                {
                    log.Debug("시스템 설정 기준의 Locale을 사용합니다. Culture=[{0}]", culture.Name);
                }
            }

            SetCurrentCulture(culture);
        }
コード例 #7
0
ファイル: ajax_user.aspx.cs プロジェクト: yzbjack/LebiShop
 /// <summary>
 /// 验证微信是否已经授权-绑定账号
 /// </summary>
 public void wechatbind()
 {
     if (CurrentUser.bind_weixin_id != "")
     {
         CookieTool.DeleteCookie("qrcodeid");
         Response.Write("{\"msg\":\"OK\"}");
         return;
     }
     Response.Write("{\"msg\":\"NO\"}");
 }
コード例 #8
0
        protected void LocaleKey_Changed(object sender, EventArgs e)
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo(localeKeys.SelectedValue);

            var cookieName = ConfigTool.GetAppSettings("Localization.UserLocale.CookieName", "_LOCALE_KEY_");

            CookieTool.Set(cookieName, localeKeys.SelectedValue);

            Response.Redirect(Request.RawUrl);
        }
コード例 #9
0
 /// <summary>
 /// 管理员退出登录
 /// </summary>
 /// <returns></returns>
 public void LoginOut()
 {
     try
     {
         Log.Add("退出系统", "Login");
         CookieTool.DeleteCookie("User");
         Response.Write("OK");
     }
     catch
     {
     }
 }
コード例 #10
0
ファイル: ajax_login.aspx.cs プロジェクト: zwkjgs/LebiShop
 /// <summary>
 /// 管理员退出登录
 /// </summary>
 /// <returns></returns>
 public void LoginOut()
 {
     try
     {
         Log.Add("退出系统", "Login", EX_Admin.CurrentAdmin().id.ToString(), EX_Admin.CurrentAdmin());
         CookieTool.DeleteCookie("Master");
         Response.Write("OK");
     }
     catch
     {
     }
 }
コード例 #11
0
 /// <summary>
 /// 清空购物车|收藏夹
 /// </summary>
 public static void Clear(Lebi_User CurrentUser, int t)
 {
     if (CurrentUser.id > 0)//已经登录
     {
         B_Lebi_User_Product.Delete("user_id=" + CurrentUser.id + " and type_id_UserProductType=" + t + "");
     }
     else//未登录
     {
         string CookieName      = "UserProduct" + t;
         NameValueCollection nv = new NameValueCollection();
         CookieTool.WriteCookie(CookieName, nv, 0);
     }
 }
コード例 #12
0
ファイル: WebAppTool.cs プロジェクト: 15831944/NFramework
        ///<summary>
        /// 입력
        ///</summary>
        /// <typeparam name="T">유형</typeparam>
        ///<param name="name">명</param>
        ///<param name="value">값</param>
        ///<param name="expiredDate">만료일자(웹인 경우만 해당)</param>
        ///<param name="domain">도메인(웹인 경우만 해당)</param>
        public static void SetValue <T>(string name, T value, DateTime?expiredDate = null, string domain = null)
        {
            name.ShouldNotBeWhiteSpace("name");

            if (WebTool.IsWebContext)
            {
                CookieTool.SetChuck(name, value, expiredDate, domain);
            }
            else
            {
                Local.Data[name] = value;
            }
        }
コード例 #13
0
        /// <summary>
        /// 处理语言标签
        /// </summary>
        /// <param name="content"></param>
        /// <returns></returns>
        public string Tag(string content)
        {
            var    nv       = CookieTool.GetCookie("ThemeStatus");
            string langcode = "";

            if (!string.IsNullOrEmpty(nv.Get("language")))
            {
                langcode = nv.Get("language");
                return(Language.Tag(content, langcode));
            }

            return(Language.Tag(content, CurrentLanguage.Code));
        }
コード例 #14
0
        protected override void OnLoad(EventArgs e)
        {
            //if (IsWap())
            //{
            //    int pt = RequestTool.RequestInt("pt", 0);
            //    reqPage = reqPage.ToLower();
            //    if (pt == 0 && !reqPage.Contains("/wap") && !reqPage.Contains("/inc/") && !reqPage.Contains("ajax") && !reqPage.Contains("/theme/"))
            //    {
            //        reqPage = "/wap" + RequestTool.GetRequestUrlNonDomain();
            //        if (reqPage.Contains("?"))
            //        {
            //            reqPage = reqPage + "&pt=1";
            //        }
            //        else
            //        {
            //            reqPage = reqPage + "?pt=1";
            //        }
            //        Server.Transfer(reqPage);
            //        Response.End();
            //        return;
            //    }
            //}

            //页面载入检查
            PageLoadCheck();
            //推广账户代码
            string v = RequestTool.RequestString("v");

            if (v != "")
            {
                NameValueCollection nvs = new NameValueCollection();
                nvs.Add("id", v);
                CookieTool.WriteCookie("parentuser", nvs, 7);
            }
            //微信访问需要先登录
            string weixinlogin = RequestTool.RequestString("weixinlogin");

            if (weixinlogin == "1")
            {
                if (CurrentUser.id == 0 && IsWechat())
                {
                    string backurl = HttpUtility.UrlEncode(RequestTool.GetRequestUrlNonDomain());
                    Response.Redirect(WebPath + "/platform/redirect_weixin.aspx?backurl=" + backurl);
                    return;
                }
            }
            //Response.Write(CurrentSite.id);
            //<-{获取分销ID
            DT_id = GetDT();
            base.OnLoad(e);
        }
コード例 #15
0
        /// <summary>
        /// 处理语言
        /// </summary>
        /// <param name="content"></param>
        /// <param name="lang"></param>
        /// <returns></returns>
        public string Lang(string content)
        {
            var    nv       = CookieTool.GetCookie("ThemeStatus");
            string langcode = "";

            //if (!string.IsNullOrEmpty(nv.Get("language")))
            //{
            //    langcode = nv.Get("language");
            //    //return langcode;
            //    return Language.Content(content, langcode);
            //}
            //return CurrentLanguage.Code;
            return(Language.Content(content, CurrentLanguage.Code));
        }
コード例 #16
0
        /// <summary>
        /// 返回当前币种
        /// 前台使用
        /// </summary>
        /// <returns></returns>
        public static Lebi_Currency CurrentCurrency(Lebi_Language lang)
        {
            string        code  = CookieTool.GetCookieString("Currency");
            Lebi_Currency model = B_Lebi_Currency.GetModel("Code=lbsql{'" + code + "'}");

            if (model == null)
            {
                model = B_Lebi_Currency.GetModel(lang.Currency_id);
            }
            if (model == null)
            {
                return(DefaultCurrency());
            }
            return(model);
        }
コード例 #17
0
ファイル: ajax_user.aspx.cs プロジェクト: yzbjack/LebiShop
        /// <summary>
        /// 退出登录
        /// </summary>
        public void User_LoginOut()
        {
            CookieTool.DeleteCookie("User");
            string url = URL("P_Index", "");

            if (IsWechat())
            {
                if (url.Contains("&weixinlogin=1"))
                {
                    url = url.Replace("&weixinlogin=1", "");
                }
                else
                {
                    url = url.Replace("?weixinlogin=1", "");
                }
            }
            Response.Write("{\"msg\":\"OK\",\"mes\":\"" + Tag("已退出登录") + "\",\"url\":\"" + url + "\"}");
        }
コード例 #18
0
ファイル: ajax_user.aspx.cs プロジェクト: yzbjack/LebiShop
        /// <summary>
        /// 修改购物车产品
        /// </summary>
        public void UserBasket_Edit()
        {
            int t = 142;
            //int num = RequestTool.RequestInt("num", 1);//默认数量1
            string property               = RequestTool.RequestSafeString("property");
            string CookieName             = "UserProduct" + t;
            List <Lebi_User_Product> pros = Basket.UserProduct(CurrentUser, t);

            foreach (Lebi_User_Product pro in pros)
            {
                pro.count = RequestTool.RequestInt("BasketCount" + pro.Product_id, 1);//默认数量1
                pro.count = pro.count < 1 ? 1 : pro.count;
            }
            if (CurrentUser.id > 0 && CurrentUser.IsAnonymous == 0)//已经登录
            {
                foreach (Lebi_User_Product pro in pros)
                {
                    B_Lebi_User_Product.Update(pro);
                }
            }
            else//未登录
            {
                NameValueCollection nv = CookieTool.GetCookie(CookieName);
                string key, userproduct;
                foreach (Lebi_User_Product pro in pros)
                {
                    key         = "p" + pro.Product_id.ToString();
                    userproduct = nv.Get(key);
                    if (string.IsNullOrEmpty(userproduct))
                    {
                        //nv.Add(key, pro.count.ToString());
                        nv.Add(key, pro.count.ToString() + "|" + property);
                    }
                    else
                    {
                        nv.Set(key, pro.count.ToString() + "|" + property);
                    }
                }

                CookieTool.WriteCookie(CookieName, nv, 365);
            }
            Response.Write("{\"msg\":\"OK\"}");
        }
コード例 #19
0
        /// <summary>
        /// 发送邮件验证码
        /// </summary>
        public void GetEmailCheckCode()
        {
            string email = RequestTool.RequestSafeString("email");

            CurrentUser.Email    = email;
            CurrentUser.Language = CurrentLanguage.Code;
            string mcode = RequestTool.RequestString("m");

            try
            {
                int emailcount = B_Lebi_User.Counts("Email=lbsql{'" + email + "'} and IsCheckedEmail=1");
                if (emailcount > 0)
                {
                    Response.Write("{\"msg\":\"" + Tag("此邮箱已经注册") + "\"}");
                    return;
                }
                int    Count  = 0;
                string Count_ = CookieTool.GetCookie("GetEmailCheckCode_" + CurrentUser.Email).Get("Count");
                int.TryParse(Count_, out Count);
                if (Count > 5)
                {
                    Response.Write("{\"msg\":\"" + Tag("已超出当日使用次数") + "\"}");
                    return;
                }
                string servermcode = Session["mcode"] == null ? "" : (string)Session["mcode"];
                if (servermcode != mcode || servermcode == "")
                {
                    Response.Write("{\"msg\":\"" + Tag("发送失败,请刷新页面后重试") + "\"}");
                    return;
                }
                Email.SendEmail_checkcode(CurrentUser);
                Count++;
                NameValueCollection nvs = new NameValueCollection();
                nvs.Add("Count", Count.ToString());
                CookieTool.WriteCookie("GetEmailCheckCode_" + CurrentUser.Email, nvs, 1);
                Response.Write("{\"msg\":\"OK\"}");
            }
            catch
            {
                Response.Write("{\"msg\":\"" + Tag("发送失败,请联系客服") + "\"}");
            }
        }
コード例 #20
0
        /// <summary>
        /// 发送手机验证码
        /// </summary>
        public void GetPhoneCheckCode()
        {
            string phone = RequestTool.RequestSafeString("phone");

            CurrentUser.MobilePhone = phone;
            CurrentUser.Language    = CurrentLanguage.Code;
            string mcode = RequestTool.RequestString("m");

            try
            {
                int phonecount = B_Lebi_User.Counts("MobilePhone=lbsql{'" + phone + "'} and IsCheckedMobilePhone=1");
                if (phonecount > 0)
                {
                    Response.Write("{\"msg\":\"" + Tag("此手机号已经注册") + "\"}");
                    return;
                }
                int    Count  = 0;
                string Count_ = CookieTool.GetCookie("GetPhoneCheckCode_" + CurrentUser.MobilePhone).Get("Count");
                int.TryParse(Count_, out Count);
                if (Count > 5)
                {
                    Response.Write("{\"msg\":\"" + Tag("已超出当日使用次数") + "\"}");
                    return;
                }
                string servermcode = Session["mcode"] == null ? "1" : (string)Session["mcode"];
                if (servermcode != mcode || servermcode == "")
                {
                    Response.Write("{\"msg\":\"" + Tag("发送失败,请刷新页面后重试") + "" + servermcode + "\"}");
                    return;
                }
                SMS.SendSMS_checkcode(CurrentUser);
                Count++;
                NameValueCollection nvs = new NameValueCollection();
                nvs.Add("Count", Count.ToString());
                CookieTool.WriteCookie("GetPhoneCheckCode_" + CurrentUser.MobilePhone, nvs, 1);
                Response.Write("{\"msg\":\"OK\"}");
            }
            catch
            {
                Response.Write("{\"msg\":\"" + Tag("发送失败,请联系客服") + "\"}");
            }
        }
コード例 #21
0
        private void SaveUser()
        {
            Response.Cookies.Clear();

            var user = new UserInfo("Peter", "Bromberg",
                                    "101 Park Avenue West", "New York", "NY", "10021",
                                    "*****@*****.**", "petey", "whodunnit");

            // 쿠키 크기를 더 키우면 Browser에서 에러가 발생할 수 있다. 이때에는 Browser의 모든 cookie값을 삭제한 후 재 시도한다.
            for (var i = 0; i < 300; i++)
            {
                // user.FavoriteMovies.Add(i.ToString(), "Favorite Movie Number-" + i.ToString());
                user.FavoriteMovies.Add("Favorite Movie Number-" + i);
            }

            CookieTool.SetChuck(USER_COOKIE, user);
            var size = Request.Cookies[USER_COOKIE].Value.Length;

            lblMessage.Text = string.Format("Save UserInfo to cookie with compression name=[{0}], size=[{1}] bytes.", USER_COOKIE, size);
        }
コード例 #22
0
ファイル: EX_Supplier.cs プロジェクト: yzbjack/LebiShop
        /// <summary>
        /// 当前供应商用户
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public static Lebi_Supplier_User CurrentSupplierUser(Lebi_User user)
        {
            Lebi_Supplier_User model       = null;
            string             supplierid_ = CookieTool.GetCookieString("supplier");
            int supplierid = 0;

            int.TryParse(supplierid_, out supplierid);
            if (supplierid > 0)
            {
                model = B_Lebi_Supplier_User.GetModel("User_id = " + user.id + " and Supplier_id=" + supplierid + " and Type_id_SupplierUserStatus=9011");
            }
            if (model == null)
            {
                model = B_Lebi_Supplier_User.GetList("User_id = " + user.id + " and Type_id_SupplierUserStatus=9011", "").FirstOrDefault();
            }
            if (model == null)
            {
                model = new Lebi_Supplier_User();
            }
            return(model);
        }
コード例 #23
0
ファイル: EX_Admin.cs プロジェクト: zwkjgs/LebiShop
        /// <summary>
        /// 管理员登录
        /// </summary>
        /// <param name="MasterName"></param>
        /// <param name="PWD"></param>
        /// <returns></returns>
        public static bool AdminLogin(string AdminName, string PWD)
        {
            string SafeAdminLogin = RequestTool.GetConfigKey("SafeAdminLogin").Trim();

            if (SafeAdminLogin == "")
            {
                SafeAdminLogin = "******";
            }
            bool ret = false;
            Lebi_Administrator master = B_Lebi_Administrator.GetModel("UserName=lbsql{'" + AdminName + "'} and Type_id_AdminStatus=230");

            if (CheckAdmin(master, PWD, AdminName, false))
            {
                Random Random  = new Random();
                int    RandNum = Random.Next(100000000, 999999999);
                if (SafeAdminLogin == "1")
                {
                    master.RandNum = RandNum;
                    B_Lebi_Administrator.Update(master);
                }
                else
                {
                    RandNum = master.RandNum;
                }
                NameValueCollection nvs = new NameValueCollection();
                nvs.Add("id", master.id.ToString());
                nvs.Add("hash", MD5(RandNum + PWD));
                nvs.Add("name", AdminName);
                CookieTool.WriteCookie("Master", nvs, 365);
                SetSession(master);
                HttpContext.Current.Session["checkCode"] = null;
                ret = true;
                //开启一个线程提交最后登录记录
                Thread thread = new Thread(new ThreadStart(UserLastUse));
                thread.IsBackground = true;//这样能随主程序一起结束
                thread.Start();
            }
            return(ret);
        }
コード例 #24
0
ファイル: ShopPageAgent.cs プロジェクト: zwkjgs/LebiShop
        protected override void OnLoad(EventArgs e)
        {
            //页面载入检查
            PageLoadCheck();

            site = new Site_Agent();
            string themecode    = "";
            int    siteid       = 0;
            string languagecode = "";
            var    nv           = CookieTool.GetCookie("ThemeStatus");

            if (!string.IsNullOrEmpty(nv.Get("theme")))
            {
                themecode = nv.Get("theme");
            }
            if (!string.IsNullOrEmpty(nv.Get("language")))
            {
                languagecode = nv.Get("language");
            }
            if (!string.IsNullOrEmpty(nv.Get("theme")))
            {
                int.TryParse(nv.Get("site"), out siteid);
            }

            if (siteid == 0)
            {
                siteid = ShopCache.GetMainSite().id;
            }
            LoadTheme(themecode, siteid, languagecode, "", true);

            DefaultCurrency = B_Lebi_Currency.GetModel("IsDefault=1");
            if (DefaultCurrency == null)
            {
                DefaultCurrency = B_Lebi_Currency.GetList("", "Sort desc").FirstOrDefault();
            }
            CurrentCurrency = DefaultCurrency;
            base.OnLoad(e);
        }
コード例 #25
0
ファイル: ajax_user.aspx.cs プロジェクト: yzbjack/LebiShop
        /// <summary>
        /// 购物车或收藏夹中删除一个商品
        /// 141购物车
        /// 142收藏
        /// 143浏览记录
        /// </summary>
        public void UserProduct_Del()
        {
            int t = RequestTool.RequestInt("type", 141);//默认收藏

            if (t != 141 && t != 142 && t != 143)
            {
                Response.Write("OK");
                return;
            }
            string productid = RequestTool.RequestSafeString("pid");

            if (productid == "all")
            {
                //清空购物车/收藏夹
                Basket.Clear(CurrentUser, t);
            }
            else
            {
                int pid = RequestTool.RequestInt("pid", 0);
                if (EX_User.LoginStatus(CurrentUser))//已经登录
                {
                    B_Lebi_User_Product.Delete("user_id=" + CurrentUser.id + " and product_id=" + pid + " and type_id_UserProductType=" + t + "");
                }
                else//未登录
                {
                    string CookieName      = "UserProduct" + t;
                    NameValueCollection nv = CookieTool.GetCookie(CookieName);
                    string key             = "p" + pid.ToString();
                    string userproduct     = nv.Get(key);
                    if (!string.IsNullOrEmpty(userproduct))
                    {
                        nv.Remove(key);
                    }
                    CookieTool.WriteCookie(CookieName, nv, 365);
                }
            }
            Response.Write("{\"msg\":\"OK\",\"mes\":\"" + Tag("操作成功") + "\"}");
        }
コード例 #26
0
        /// <summary>
        /// CurrentCulture를 지정한 culture로 설정합니다.
        /// </summary>
        /// <param name="culture"></param>
        private static void SetCurrentCulture(CultureInfo culture)
        {
            // UICulture = 'ko'
            // Culture = 'ko-KR'

            Thread.CurrentThread.CurrentUICulture = culture ?? Thread.CurrentThread.CurrentUICulture;

            // NOTE: Culture는 neutral culture를 지정할 수 없고, SpecificCulture를 지정해야 한다.
            //
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Thread.CurrentThread.CurrentUICulture.Name);

            if (IsDebugEnabled)
            {
                log.Debug("Current Thread Culture를 지정했습니다. CurrentUICulture=[{0}], CurrrentCulture=[{1}]",
                          Thread.CurrentThread.CurrentUICulture,
                          Thread.CurrentThread.CurrentCulture);
            }

            if (UseUserLocale)
            {
                CookieTool.Set(UserLocaleCookieName, Thread.CurrentThread.CurrentCulture.Name);
            }
        }
コード例 #27
0
        private void DoPageLoad()
        {
            UserInfo user = null;

            try
            {
                user = CookieTool.GetChuck <UserInfo>(USER_COOKIE);
            }
            catch (Exception ex)
            {
                if (log.IsWarnEnabled)
                {
                    log.WarnException("사용자 정보를 담은 쿠키값을 읽는데 실패했습니다.", ex);
                }
            }

            if (user != null)
            {
                LoadUser(user);
            }

            SaveUser();
        }
コード例 #28
0
ファイル: ajax_user.aspx.cs プロジェクト: yzbjack/LebiShop
        /// <summary>
        /// 验证微信是否已经授权-登陆账号
        /// </summary>
        public void wechatlogin()
        {
            string cid = CookieTool.GetCookieString("qrcodeid");
            int    id  = 0;

            if (cid != "")
            {
                int.TryParse(cid, out id);
                Lebi_weixin_qrcode model = B_Lebi_weixin_qrcode.GetModel(id);
                if (model != null)
                {
                    if (model.User_id > 0)
                    {
                        //CookieTool.SetCookieString("qrcodeid", "0", -1);
                        CookieTool.DeleteCookie("qrcodeid");
                        Lebi_User user = B_Lebi_User.GetModel(model.User_id);
                        EX_User.LoginOK(user);
                        Response.Write("{\"msg\":\"OK\"}");
                        return;
                    }
                }
            }
            Response.Write("{\"msg\":\"NO\"}");
        }
コード例 #29
0
        protected override void OnLoad(EventArgs e)
        {
            if (!Shop.LebiAPI.Service.Instanse.Check("plugin_gongyingshang"))
            {
                Response.Redirect(WebPath + "/");
                Response.End();
                return;
            }
            PageLoadCheck(); //页面载入检查
            #region 当前用户信息
            int selectsupplierid = RequestTool.RequestInt("selectsupplierid");
            if (selectsupplierid > 0)
            {
                //切换超级账号
                string msg = "";
                EX_Supplier.Login(CurrentUser, "", selectsupplierid, out msg);
                CurrentSupplierUser = B_Lebi_Supplier_User.GetModel("User_id = " + CurrentUser.id + " and Supplier_id=" + selectsupplierid + " and Type_id_SupplierUserStatus=9011");
            }
            if (CurrentSupplierUser == null)
            {
                CurrentSupplierUser = EX_Supplier.CurrentSupplierUser(CurrentUser);
            }

            if (CurrentSupplierUser.id == 0)
            {
                Response.Redirect(Shop.Bussiness.Site.Instance.SupplierPath + "/Login.aspx");
                return;
            }
            CurrentSupplier = B_Lebi_Supplier.GetModel(CurrentSupplierUser.Supplier_id);
            if (CurrentSupplier.Type_id_SupplierStatus != 442)
            {
                Response.Redirect(Shop.Bussiness.Site.Instance.SupplierPath + "/Login.aspx");
                return;
            }
            CurrentSupplierUserGroup = B_Lebi_Supplier_UserGroup.GetModel(CurrentSupplierUser.Supplier_UserGroup_id);
            if (CurrentSupplierUserGroup == null)
            {
                CurrentSupplierUserGroup = new Lebi_Supplier_UserGroup();
            }
            if (CurrentSupplier != null)
            {
                CurrentSupplierGroup = B_Lebi_Supplier_Group.GetModel(CurrentSupplier.Supplier_Group_id);

                if (CurrentSupplierGroup == null)
                {
                    CurrentSupplierGroup = new Lebi_Supplier_Group();
                }
            }
            else
            {
                Response.Redirect(Shop.Bussiness.Site.Instance.SupplierPath + "/Login.aspx");
                return;
            }
            DateTime LastDate      = CurrentSupplier.Time_This;
            TimeSpan ts            = System.DateTime.Now - LastDate;
            int      NewEventTimes = 0;
            int.TryParse(SYS.NewEventTimes, out NewEventTimes);
            LeftNewEventTimes = Convert.ToInt32(ts.TotalSeconds % (NewEventTimes / 1000));
            LeftNewEventTimes = NewEventTimes - (LeftNewEventTimes * 1000);
            #endregion

            #region 配合前台主题
            string themecode = "";
            int    siteid    = 0;
            var    nv        = CookieTool.GetCookie("ThemeStatus");
            if (!string.IsNullOrEmpty(nv.Get("theme")))
            {
                themecode = nv.Get("theme");
            }
            if (!string.IsNullOrEmpty(nv.Get("site")))
            {
                int.TryParse(nv.Get("site"), out siteid);
            }
            if (siteid == 0)
            {
                siteid = ShopCache.GetMainSite().id;
            }
            LoadTheme(themecode, siteid, CurrentLanguage.Code, "", true);
            #endregion

            #region 处理菜单
            MenuType = Shop.Tools.CookieTool.GetCookieString("Menu");
            if (MenuType == "")
            {
                MenuType = "Index";
            }

            string menu_ids = "";
            if (CurrentSupplierUserGroup != null && CurrentSupplierUser.User_id != CurrentSupplier.User_id)
            {
                menu_ids = CurrentSupplierUserGroup.Menu_ids;
            }
            else
            {
                CurrentSupplierGroup = B_Lebi_Supplier_Group.GetModel(CurrentSupplier.Supplier_Group_id);
                if (CurrentSupplierGroup != null)
                {
                    menu_ids = CurrentSupplierGroup.Menu_ids;
                }
            }
            //lebi菜单
            if (!Shop.LebiAPI.Service.Instanse.Check("managelicenese"))
            {
                lbmenu = "<ul class=\"tool\"><li><span><a href=\"" + site.AdminPath + "/?desk=1\">" + Tag("桌面") + "</a></span></li></ul>";
                string license = "Copyright 2003-" + DateTime.Now.Year + " <a href=\"http://www.lebi.cn/\" target=\"_blank\" class=\"footcopy\">Lebi.cn</a> , All Rights Reserved. Powered by <a href=\"http://www.lebi.cn/support/license/?url=" + Request.ServerVariables["SERVER_NAME"] + "\" target=\"_blank\" title=\"LebiShop\" class=\"footcopy\">LebiShop</a> V<a href=\"" + site.AdminPath + "/config/version.aspx\">" + SYS.Version + "." + SYS.Version_Son + "</a>";
                try
                {
                    Label LBLicense = (Label)this.Page.FindControl("LBLicense");
                    LBLicense.Text = license;
                }
                catch
                {
                    string strscript = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"><script language='javascript'>";
                    strscript += "document.onreadystatechange = loadlicense;";
                    strscript += "function loadlicense(){";
                    strscript += "if(document.readyState == \"complete\"){";
                    strscript += "if ($(\"#lebicopy\")[0] == undefined) {alert('页面布局异常')}";
                    strscript += "$('#lebicopy').html('" + license + "')";
                    strscript += "}}</script>";
                    Response.Write(strscript);
                }
            }
            else
            {
                lbmenu = "<ul class=\"tool\"><li><span><a href=\"" + site.AdminPath + "/?desk=1\">" + Tag("桌面") + "</a></ul>";
            }
            //处理菜单
            desk     = RequestTool.RequestInt("desk", 0);
            AllMenus = new List <Lebi_Supplier_Menu>();
            List <Lebi_Supplier_Menu> All = B_Lebi_Supplier_Menu.GetList("Isshow=1", "Sort desc");
            string currentgroupmenu       = "," + menu_ids + ",";
            foreach (Lebi_Supplier_Menu m in All)
            {
                if (currentgroupmenu.Contains("," + m.id + ","))
                {
                    AllMenus.Add(m);
                }
            }
            TopMenus = (from m in AllMenus
                        where m.parentid == 0
                        select m).ToList();
            if (desk != 1)
            {
                try
                {
                    var temp = from m in AllMenus
                               where reqPage.Contains(m.URL.ToLower()) && m.parentid > 0 && m.URL != ""
                               select m;
                    //if (temp == null)
                    //    CurrentLeftMenu = new Lebi_Menu();
                    //else
                    //{
                    CurrentLeftMenu = temp.ToList().FirstOrDefault();
                    CurrentTopMenu  = (from m in AllMenus
                                       where m.id == CurrentLeftMenu.parentid
                                       select m).ToList().FirstOrDefault();
                    CurrentTopMenu = (from m in TopMenus
                                      where m.id == CurrentTopMenu.parentid
                                      select m).ToList().FirstOrDefault();
                    ////写入cookie
                    NameValueCollection nvs = new NameValueCollection();
                    nvs.Add("top", CurrentTopMenu.id.ToString());
                    nvs.Add("left", CurrentLeftMenu.id.ToString());
                    CookieTool.WriteCookie("sMenu", nvs, 365);
                    //}
                }
                catch (NullReferenceException)
                {
                    var menu = CookieTool.GetCookie("sMenu");
                    int tid  = 0;
                    int lid  = 0;
                    int.TryParse(menu.Get("top"), out tid);
                    int.TryParse(menu.Get("left"), out lid);
                    CurrentTopMenu = (from m in TopMenus
                                      where m.id == tid
                                      select m).ToList().FirstOrDefault();
                    CurrentLeftMenu = (from m in AllMenus
                                       where m.id == lid
                                       select m).ToList().FirstOrDefault();
                }
            }
            else
            {
                //写入cookie
                NameValueCollection nvs = new NameValueCollection();
                nvs.Add("top", "0");
                nvs.Add("left", "0");
                CookieTool.WriteCookie("sMenu", nvs, 365);
            }
            if (CurrentTopMenu == null)
            {
                CurrentTopMenu = new Lebi_Supplier_Menu();
                desk           = 1;
            }
            #endregion
            Suppliers = GetSuppliers();


            base.OnLoad(e);
        }
コード例 #30
0
ファイル: EX_Supplier.cs プロジェクト: yzbjack/LebiShop
        //public static bool CheckPower(string code, string name)
        //{
        //    if (!Power(code, name))
        //    {
        //        NoPower();
        //        return false;
        //    }
        //    return true;
        //}
        //public static void NoPower()
        //{
        //    HttpContext.Current.Response.Write("{\"msg\":\"权限不足\"}");
        //    HttpContext.Current.Response.End();
        //}
        #endregion

        /// <summary>
        /// 供应商账号登录
        /// </summary>
        /// <param name="user"></param>
        /// <param name="type">账号类型</param>
        /// <param name="supplierid"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static bool Login(Lebi_User user, string type, int supplierid, out string msg, int adminlogin = 0)
        {
            msg = "OK";
            Lebi_Supplier_User supplieruser = null;
            Lebi_Supplier      supplier     = null;

            if (supplierid == 0)
            {
                string supplierid_ = CookieTool.GetCookieString("supplier");
                //int supplierid = 0;
                int.TryParse(supplierid_, out supplierid);
            }
            //string and = "";
            //if (type != "")
            //{
            //    and = " and Supplier_id in (select id from [Lebi_Supplier] where Supplier_Group_id in (select id from [Lebi_Supplier_Group] where type='" + type + "'))";
            //}
            if (supplierid > 0)
            {
                supplier = B_Lebi_Supplier.GetModel(supplierid);
                if (supplier != null)
                {
                    Lebi_Supplier_Group group = B_Lebi_Supplier_Group.GetModel(supplier.Supplier_Group_id);
                    if (group.type == type || type == "")
                    {
                        supplieruser = B_Lebi_Supplier_User.GetModel("User_id = " + user.id + " and Supplier_id=" + supplierid + " and Type_id_SupplierUserStatus=9011");
                    }
                }
            }
            if (supplieruser == null)
            {
                List <Lebi_Supplier_User> users = B_Lebi_Supplier_User.GetList("User_id = " + user.id + " and Type_id_SupplierUserStatus=9011", "");
                if (type == "")
                {
                    foreach (Lebi_Supplier_User u in users)
                    {
                        supplier = B_Lebi_Supplier.GetModel(u.Supplier_id);
                        if (supplier != null)
                        {
                            supplieruser = u;
                            break;
                        }
                    }
                    //supplieruser = users.FirstOrDefault();
                    //if (supplieruser == null)
                    //{
                    //    msg = "User_id = " + user.id + " and Type_id_SupplierUserStatus=9011";
                    //    return false;
                    //}
                    //supplier = B_Lebi_Supplier.GetModel(supplieruser.Supplier_id);
                }
                else
                {
                    foreach (Lebi_Supplier_User u in users)
                    {
                        supplier = B_Lebi_Supplier.GetModel(u.Supplier_id);
                        if (supplier == null)
                        {
                            continue;
                        }
                        Lebi_Supplier_Group group = B_Lebi_Supplier_Group.GetModel(supplier.Supplier_Group_id);
                        if (group.type == type)
                        {
                            supplieruser = u;
                            break;
                        }
                    }
                }
            }
            if (supplieruser == null)
            {
                Log.Add("登陆失败", "Login", "", supplier, "账号:" + user.UserName);
                msg = "登陆失败";
                return(false);
            }
            if (supplier == null)
            {
                Log.Add("登陆失败:账号不存在或不可用", "Login", "", supplier, "账号:" + user.UserName);
                msg = "账号不存在或不可用";
                return(false);
            }
            if (supplier.Type_id_SupplierStatus != 442)
            {
                Log.Add("登陆失败:供应商账号不可用", "Login", "", supplier, "账号:" + user.UserName);
                msg = "供应商账号不可用";
                return(false);
            }
            supplier.Time_Last = supplier.Time_This;
            supplier.Time_This = DateTime.Now;
            supplier.Count_Login++;
            supplier.IP_Last = supplier.IP_This;
            supplier.IP_This = RequestTool.GetClientIP();
            Shop.Tools.CookieTool.SetCookieString("supplier", supplier.id.ToString(), 60 * 24);
            B_Lebi_Supplier.Update(supplier);
            if (adminlogin == 0)
            {
                Log.Add("登陆系统", "Login", "", supplier, "账号:" + user.UserName);
            }
            return(true);
        }