public void OnAuthorization(AuthorizationContext filterContext)
        {
            //Disclaimer isn't on or we're logging into admin
            if (!AppLogic.AppConfigBool("SiteDisclaimerRequired") ||
                CommonLogic.QueryStringCanBeDangerousContent("ReturnURL").Contains(AppLogic.AppConfig("AdminDir")) ||
                HttpContext.Current.Request.RequestContext.RouteData.Values[RouteDataKeys.Controller].ToString().EqualsIgnoreCase(ControllerNames.SiteDisclaimer) ||
                HttpContext.Current.Request.RequestContext.RouteData.Values[RouteDataKeys.Controller].ToString().EqualsIgnoreCase(ControllerNames.Captcha))
            {
                return;
            }

            //Disclaimer is on and has been accepted
            if (CommonLogic.CookieCanBeDangerousContent("SiteDisclaimerAccepted", true).Length != 0)
            {
                return;
            }

            filterContext.Result = new RedirectToRouteResult(
                new RouteValueDictionary
            {
                { RouteDataKeys.Controller, ControllerNames.SiteDisclaimer },
                { RouteDataKeys.Action, ActionNames.Index },
                { RouteDataKeys.ReturnUrl, CommonLogic.QueryStringCanBeDangerousContent("ReturnURL") }
            });
        }
Example #2
0
        public static bool isMobile(bool AllowCookieOverride)
        {
            if (AppLogic.IsAdminSite == true || !MobilePlatform.IsEnabled)
            {
                return(false);
            }

            if (AllowCookieOverride && CommonLogic.CookieCanBeDangerousContent(ForceMobileCookie, false).Length > 0)
            {
                return(CommonLogic.CookieBool(ForceMobileCookie));
            }

            //example userAgentString
            //Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16
            string userAgentString    = CommonLogic.ServerVariables("HTTP_USER_AGENT").ToUpperInvariant();
            string httpAccept         = CommonLogic.ServerVariables("HTTP_ACCEPT");
            string xProfile           = CommonLogic.ServerVariables("HTTP_X_PROFILE");
            string httpProfile        = CommonLogic.ServerVariables("HTTP_PROFILE");
            string userAgentList      = MobilePlatform.UserAgentList ?? String.Empty;      //android, palm, motorola, etc
            string shortUserAgentList = MobilePlatform.ShortUserAgentList ?? String.Empty; //moto, noki, sany, etc

            if (!MobilePlatform.ShowMobileOniPad && userAgentString.Contains("IPAD;"))
            {
                return(false);
            }

            if (httpAccept.Contains("application/vnd.wap.xhtml+xml") || xProfile.Length > 0 || httpProfile.Length > 0)
            {
                SetMobileContextItem(true);
                return(true);
            }

            //check for most common mobile
            string[] agentList = userAgentList.ToUpperInvariant().Split(',');
            //check if userAgentString contains any of our agents in the agentList
            if (agentList.Any(userAgentString.Contains))
            {
                SetMobileContextItem(true);
                return(true);
            }

            //check for mobile that slipped through with longer list of substrings
            string[] shortAgentList = shortUserAgentList.ToUpperInvariant().Split(',');
            //check if userAgentString contains any of our agents in the shortAgentList
            if (shortAgentList.Any(userAgentString.Contains))
            {
                SetMobileContextItem(true);
                return(true);
            }

            return(false);
        }
Example #3
0
        protected void btnPayPalExpressCheckout_Click(object sender, CommandEventArgs e)
        {
            ProcessCart(false, false, false);

            if (CommonLogic.CookieCanBeDangerousContent("PayPalExpressToken", false) == "")
            {
                if (!ThisCustomer.IsRegistered)
                {
                    if (cart.HasRecurringComponents() || (!AppLogic.AppConfigBool("PasswordIsOptionalDuringCheckout") && !AppLogic.AppConfigBool("PayPal.Express.AllowAnonCheckout")))
                    {
                        Response.Redirect("signin.aspx?ReturnUrl='shoppingcart.aspx'");
                    }
                    else
                    {
                        Response.Redirect("checkoutanon.aspx?checkout=true&checkouttype=ppec");
                    }
                }

                if (cart == null)
                {
                    cart = new ShoppingCart(SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, 0, false);
                }

                string url = String.Empty;
                Dictionary <string, string> checkoutOptions = new Dictionary <string, string>();

                if (e.CommandArgument.Equals("ppbml"))
                {
                    checkoutOptions.Add("UserSelectedFundingSource", "BML");
                }

                if (ThisCustomer.IsRegistered && ThisCustomer.PrimaryShippingAddressID != 0)
                {
                    Address shippingAddress = new Address();
                    shippingAddress.LoadByCustomer(ThisCustomer.CustomerID, ThisCustomer.PrimaryShippingAddressID, AddressTypes.Shipping);
                    url = Gateway.StartExpressCheckout(cart, shippingAddress, checkoutOptions);
                }
                else
                {
                    url = Gateway.StartExpressCheckout(cart, null, checkoutOptions);
                }
                Response.Redirect(url);
            }
            else
            {
                Response.Redirect("checkoutshipping.aspx");
            }
        }
        protected void btnPayPalExpressCheckout_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {
            ProcessCart(false, false, false);

            if (CommonLogic.CookieCanBeDangerousContent("PayPalExpressToken", false) == "")
            {
                if (!ThisCustomer.IsRegistered &&
                    !AppLogic.AppConfigBool("PasswordIsOptionalDuringCheckout") &&
                    !AppLogic.AppConfigBool("PayPal.Express.AllowAnonCheckout"))
                {
                    if (AppLogic.ProductIsMLExpress())
                    {
                        Response.Redirect("signin.aspx?ReturnUrl='shoppingcart.aspx'");
                    }
                    else
                    {
                        Response.Redirect("checkoutanon.aspx?checkout=true&checkouttype=ppec");
                    }
                }

                if (cart == null)
                {
                    cart = new ShoppingCart(SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, 0, false);
                }

                string url = String.Empty;
                if (ThisCustomer.IsRegistered && ThisCustomer.PrimaryShippingAddressID != 0)
                {
                    Address shippingAddress = new Address();
                    shippingAddress.LoadByCustomer(ThisCustomer.CustomerID, ThisCustomer.PrimaryShippingAddressID, AddressTypes.Shipping);
                    url = Gateway.StartExpressCheckout(cart, shippingAddress);
                }
                else
                {
                    url = Gateway.StartExpressCheckout(cart, null);
                }

                Response.Redirect(url);
            }
            else
            {
                Response.Redirect("checkoutshipping.aspx");
            }
        }
Example #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.CacheControl = "private";
            Response.Expires      = 0;
            Response.AddHeader("pragma", "no-cache");

            SkinBase.RequireSecurePage();

            Customer thisCustomer   = Customer.Current;
            bool     blnShowReceipt = false;

            //get the values from the querystring
            string strSalesOrderCodeFromQueryString = CommonLogic.QueryStringCanBeDangerousContent("OrderNumber");
            string strCustGuidFromQueryString       = CommonLogic.QueryStringCanBeDangerousContent("CustomerGUID");

            if (thisCustomer.IsNotRegistered)
            {
                //unregistered customers will have values stored in the cookie, get the values and compare to the querystring
                string strOrderNumberFromCookie = CommonLogic.CookieCanBeDangerousContent("OrderNumber", true);
                string strCustGuidFromCookie    = CommonLogic.CookieCanBeDangerousContent("ContactGUID", true);

                //show the receipt only if both the order number and guid match
                blnShowReceipt = strCustGuidFromQueryString.Equals(strCustGuidFromCookie, StringComparison.InvariantCultureIgnoreCase) && strSalesOrderCodeFromQueryString.Equals(strOrderNumberFromCookie, StringComparison.InvariantCultureIgnoreCase);
            }
            else
            {
                //make sure that this customer owns this order to view
                if (thisCustomer.OwnsThisOrder(strSalesOrderCodeFromQueryString))
                {
                    blnShowReceipt = true;
                }
            }

            //show the receipt if it's appropriate to do so
            if (blnShowReceipt && !string.IsNullOrEmpty(strSalesOrderCodeFromQueryString))
            {
                ViewerReport.Report = InterpriseHelper.CreateReport(strSalesOrderCodeFromQueryString);
            }
            else
            {
                Response.Redirect(SE.MakeDriverLink("ordernotfound"));
            }
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Response.CacheControl = "private";
            Response.Expires      = 0;
            Response.AddHeader("pragma", "no-cache");

            if (IsPostBack)
            {
                AppLogic.SetSessionCookie("SiteDisclaimerAccepted", CommonLogic.GetNewGUID());
                Panel1.Visible = false;
                Response.AddHeader("REFRESH", "1; URL=" + ReturnURL.Text);
            }
            else
            {
                DisclaimerContents.Text = new Topic("SiteDisclaimer", 1).Contents;

                AppLogic.SetSessionCookie("SiteDisclaimerAccepted", String.Empty);
                ReturnURL.Text = CommonLogic.QueryStringCanBeDangerousContent("ReturnURL");
                AppLogic.CheckForScriptTag(ReturnURL.Text);
                if (ReturnURL.Text.Length == 0)
                {
                    ReturnURL.Text = AppLogic.AppConfig("SiteDisclaimerAgreedPage");
                    if (ReturnURL.Text.Length == 0)
                    {
                        if (CommonLogic.QueryStringBool("checkout"))
                        {
                            ReturnURL.Text = "shoppingcart.aspx?checkout=true";
                        }
                        else
                        {
                            ReturnURL.Text = "default.aspx";
                        }
                    }
                }
                // if disclaimer was already accepted, just send them on their way:
                if (CommonLogic.CookieCanBeDangerousContent("SiteDisclaimerAccepted", true).Length != 0)
                {
                    Response.Redirect(ReturnURL.Text);
                }
            }
        }
        public void OnActionExecuting(ActionExecutingContext filterContext)
        {
            // Set the referrer cookie if:
            //	- A referrer value is present
            //	- There is no referrer cookie already set
            //	- The referrer is not coming from internal web site

            var referrer = CommonLogic.PageReferrer();

            if (string.IsNullOrEmpty(referrer))
            {
                return;
            }

            var referrerCookieValue = CommonLogic.CookieCanBeDangerousContent(Customer.ro_ReferrerCookieName, true);

            if (!string.IsNullOrEmpty(referrerCookieValue))
            {
                return;
            }

            var liveServerUrl     = AppLogic.LiveServer();
            var referrerIsIgnored = new[]
            {
                "localhost",
                "192.168.",
                "10.",
                liveServerUrl,
            }
            .Where(s => referrer.IndexOf(s, StringComparison.OrdinalIgnoreCase) != -1)
            .Any();

            if (referrerIsIgnored)
            {
                return;
            }

            AppLogic.SetCookie(Customer.ro_ReferrerCookieName, referrer, TimeSpan.FromDays(365));
        }
Example #8
0
        public ActionResult Detail(string name, bool?disableTemplate = null)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new HttpException(404, null);
            }

            var topic = LoadTopic(name);

            if (topic == null)
            {
                throw new HttpException(404, null);
            }

            if (topic.RequiresDisclaimer && string.IsNullOrEmpty(CommonLogic.CookieCanBeDangerousContent("SiteDisclaimerAccepted", true)))
            {
                return(RedirectToAction(ActionNames.Index, ControllerNames.SiteDisclaimer, new { returnUrl = Url.BuildTopicLink(name) }));
            }

            var customer        = HttpContext.GetCustomer();
            var enteredPassword = customer.ThisCustomerSession.Session(string.Format("Topic{0}", name));

            if (!string.IsNullOrEmpty(topic.Password) &&
                (string.IsNullOrEmpty(enteredPassword) ||
                 Security.UnmungeString(enteredPassword) != topic.Password))
            {
                return(View(ViewNames.Password, new TopicPasswordViewModel {
                    Name = name
                }));
            }

            var viewName = (disableTemplate ?? false)
                                ? "DetailNoTemplate"
                                : "Detail";

            return(View(viewName, BuildViewModel(topic)));
        }
Example #9
0
        protected override void OnPreInit(EventArgs e)
        {
            if (HttpContext.Current != null)
            {
                //Have to call GetPropertyValue once before you actually need it to initialize the PropertyValues collection
                HttpContext.Current.Profile.GetPropertyValue("SkinID").ToString();

                #region SkinID
                //If it's mobile, bypass all the rest
                if (!AppLogic.IsAdminSite && MobileHelper.isMobile())
                {
                    MobileHelper.SetCustomerToMobileSkinId(ThisCustomer);
                    SkinID = ThisCustomer.SkinID;
                }
                else
                {
                    //SkinId querystring overrides everything but mobile
                    if (CommonLogic.QueryStringUSInt("skinid") > 0)
                    {
                        SkinID = CommonLogic.QueryStringUSInt("skinid");

                        //Customer has a querystring so save this to the profile.
                        if (HttpContext.Current.Profile != null)
                        {
                            HttpContext.Current.Profile.SetPropertyValue("SkinID", this.SkinID.ToString());
                        }
                    }
                    //Check to see if we are previewing the skin
                    else if (CommonLogic.QueryStringUSInt("previewskinid") > 0)
                    {
                        SkinID = CommonLogic.QueryStringUSInt("previewskinid");

                        //Customer has a preview querystring so save this to the profile.
                        if (HttpContext.Current.Profile != null)
                        {
                            HttpContext.Current.Profile.SetPropertyValue("PreviewSkinID", this.SkinID.ToString());
                        }
                    }
                    //Use the preview profile value if we have one
                    else if (HttpContext.Current.Profile != null &&
                             HttpContext.Current.Profile.PropertyValues["PreviewSkinID"] != null &&
                             CommonLogic.IsInteger(HttpContext.Current.Profile.GetPropertyValue("PreviewSkinID").ToString()))
                    {
                        int skinFromProfile = int.Parse(HttpContext.Current.Profile.GetPropertyValue("PreviewSkinID").ToString());
                        if (skinFromProfile > 0)
                        {
                            SkinID = skinFromProfile;
                        }
                    }
                    //Pull the skinid from the current profile
                    else if (HttpContext.Current.Profile != null && CommonLogic.IsInteger(HttpContext.Current.Profile.GetPropertyValue("SkinID").ToString()))
                    {
                        int skinFromProfile = int.Parse(HttpContext.Current.Profile.GetPropertyValue("SkinID").ToString());
                        if (skinFromProfile > 0)
                        {
                            SkinID = skinFromProfile;
                        }
                    }
                }

                //Now save the skinID to the customer record.  This is not used OOB.
                if (ThisCustomer.SkinID != this.SkinID)
                {
                    ThisCustomer.SkinID = this.SkinID;
                    ThisCustomer.UpdateCustomer(new SqlParameter[] { new SqlParameter("SkinID", this.SkinID) });
                }
                #endregion

                if (CommonLogic.QueryStringUSInt("affiliateid") > 0)
                {
                    HttpContext.Current.Profile.SetPropertyValue("AffiliateID", CommonLogic.QueryStringUSInt("affiliateid").ToString());
                }

                if (HttpContext.Current.Request.UrlReferrer != null && HttpContext.Current.Request.UrlReferrer.Authority != HttpContext.Current.Request.Url.Authority)
                {
                    HttpContext.Current.Profile.SetPropertyValue("Referrer", HttpContext.Current.Request.UrlReferrer.ToString());
                }

                // don't fire disclaimer logic on admin pages
                if (!AppLogic.IsAdminSite && CommonLogic.QueryStringCanBeDangerousContent("ReturnURL").IndexOf(AppLogic.AppConfig("AdminDir")) == -1 && (AppLogic.AppConfigBool("SiteDisclaimerRequired") && CommonLogic.CookieCanBeDangerousContent("SiteDisclaimerAccepted", true).Length == 0))
                {
                    String ThisPageURL = CommonLogic.GetThisPageName(true) + "?" + CommonLogic.ServerVariables("QUERY_STRING");
                    Response.Redirect("disclaimer.aspx?returnURL=" + Server.UrlEncode(ThisPageURL));
                }

                #region Impersonation
                bool IGDQueryClear = false;
                m_IGD = CommonLogic.QueryStringCanBeDangerousContent("IGD").Trim();
                if (m_IGD.Length == 0 && CommonLogic.ServerVariables("QUERY_STRING").IndexOf("IGD=") != -1)
                {
                    m_IGD         = String.Empty; // there was IGD={blank} in the query string, so forcefully clear IGD!
                    IGDQueryClear = true;
                }
                bool IsStartOfImpersonation = m_IGD.Length != 0; // the url invocation starts the impersonation only!

                if (!IGDQueryClear && m_IGD.Length == 0)
                {
                    if (ThisCustomer.IsAdminUser)
                    {
                        // pull out the impersonation IGD from the customer session, if any
                        m_IGD = ThisCustomer.ThisCustomerSession["IGD"];
                    }
                }

                if (IGDQueryClear)
                {
                    // forcefully clear any IGD for this customer, just to be safe!
                    ThisCustomer.ThisCustomerSession["IGD"] = "";
                    ThisCustomer.ThisCustomerSession["IGD_EDITINGORDER"] = "";
                }

                Customer PhoneCustomer = null;
                if (m_IGD.Length != 0)
                {
                    if (ThisCustomer.IsAdminUser)
                    {
                        try
                        {
                            Guid IGD = new Guid(m_IGD);
                            PhoneCustomer = new Customer(IGD);
                            PhoneCustomer.IsImpersonated = true;
                        }
                        catch
                        {
                            ThisCustomer.ThisCustomerSession["IGD"] = "";
                            ThisCustomer.ThisCustomerSession["IGD_EDITINGORDER"] = "";
                            m_IGD = string.Empty;
                        }
                    }
                    if (PhoneCustomer != null && PhoneCustomer.HasCustomerRecord)
                    {
                        int ImpersonationTimeoutInMinutes = AppLogic.AppConfigUSInt("ImpersonationTimeoutInMinutes");
                        if (ImpersonationTimeoutInMinutes == 0)
                        {
                            ImpersonationTimeoutInMinutes = 20;
                        }
                        if (PhoneCustomer.ThisCustomerSession.LastActivity >= DateTime.Now.AddMinutes(-ImpersonationTimeoutInMinutes))
                        {
                            ThisCustomer.ThisCustomerSession["IGD"] = IGD;
                            m_AdminCustomer = ThisCustomer;  // save the owning admin user doing the impersonation here
                            ThisCustomer    = PhoneCustomer; // build the impersonation customer the phone order customer
                            bool IsAdmin = CommonLogic.ApplicationBool("IsAdminSite");

                            if (!HttpContext.Current.Items.Contains("IsBeingImpersonated"))
                            {
                                HttpContext.Current.Items.Add("IsBeingImpersonated", "true");
                            }
                        }
                        else
                        {
                            if (HttpContext.Current.Items.Contains("IsBeingImpersonated"))
                            {
                                HttpContext.Current.Items["IsBeingImpersonated"] = "false";
                            }
                            ThisCustomer.ThisCustomerSession["IGD"] = "";
                            ThisCustomer.ThisCustomerSession["IGD_EDITINGORDER"] = "";
                            m_IGD = string.Empty;
                            //Response.Redirect("t-phoneordertimeout.aspx");
                            Response.Redirect(SE.MakeDriverLink("phoneordertimeout"));
                        }
                    }
                }
                #endregion

                Thread.CurrentThread.CurrentCulture   = CultureInfo.CreateSpecificCulture(Localization.GetDefaultLocale());
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(ThisCustomer.LocaleSetting);

                m_TemplateName = GetTemplateName();

                if (!AppLogic.IsAdminSite)
                {
                    ThisCustomer = MobileRedirectController.SkinBaseHook(SkinID, ThisCustomer);
                    if (SkinID == Vortx.Data.Config.MobilePlatform.SkinId && MobileHelper.isMobile())
                    {
                        m_TemplateName = "template.master";
                    }
                }

                //needs to come after the mobile check
                m_Parser = new Parser(m_EntityHelpers, SkinID, ThisCustomer);

                String SkinDirectory = String.Empty;
                String PageTheme     = String.Empty;

                SkinDirectory = "Skin_" + this.SkinID.ToString();
                PageTheme     = "Skin_" + this.SkinID.ToString();

                if (!m_TemplateName.EndsWith(".master", StringComparison.OrdinalIgnoreCase))
                {
                    m_TemplateName = m_TemplateName + ".master";
                }

                this.MasterPageFile = "~/App_Templates/" + SkinDirectory + "/" + m_TemplateName;
                this.Theme          = PageTheme;

                if (!CommonLogic.FileExists(this.MasterPageFile))
                {
                    this.SkinID = AppLogic.DefaultSkinID();

                    m_TemplateName = "template.master";
                    SkinDirectory  = "Skin_" + this.SkinID.ToString();
                    PageTheme      = "Skin_" + this.SkinID.ToString();

                    this.MasterPageFile = "~/App_Templates/" + SkinDirectory + "/" + m_TemplateName;
                    this.Theme          = PageTheme;
                }
            }

            base.OnPreInit(e);
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (AppLogic.AppConfigBool("GoNonSecureAgain"))
            {
                SkinBase.GoNonSecureAgain();
            }

            _itemCounter   = "ProductID".ToQueryString().TryParseIntUsLocalization().Value;
            CategoryID     = "CategoryID".ToQueryString();
            DepartmentID   = "DepartmentID".ToQueryString();
            ManufacturerID = "ManufacturerID".ToQueryString();

            _itemCode = AppLogic.GetItemCodeByCounter(_itemCounter);

            var eCommerceProductInfoView = AppLogic.GetProductInfoViewForShowProduct(DB.SQuote(_itemCode),
                                                                                     DB.SQuote(ThisCustomer.LocaleSetting),
                                                                                     DB.SQuote(InterpriseHelper.ConfigInstance.UserCode),
                                                                                     DB.SQuote(InterpriseHelper.ConfigInstance.WebSiteCode),
                                                                                     DB.SQuote(Localization.DateTimeStringForDB(DateTime.Now)),
                                                                                     DB.SQuote(ThisCustomer.ProductFilterID),
                                                                                     DB.SQuote(ThisCustomer.ContactCode));

            int sessionLifetime = AppLogic.AppConfigUSInt("ViewedProductsSessionLifetime");

            if (sessionLifetime == null)
            {
                sessionLifetime = 60;
            }

            if (ThisCustomer.ContactCode == "")
            {
                RequireCustomerRecord();
            }

            //DateTime expirationdatetime = DateTime.Now.AddMinutes(-sessionLifetime);
            //string updatevieweditems =
            //        string.Format("exec UpdateEcommerceViewedItems @ExpirationDate = {0}, @WebSiteCode = {1}, @ContactCode = {2}, @ItemCode = {3}, @CurrentDate = {4}, @SessionID = {5}",
            //        DB.SQuote(Localization.DateTimeStringForDB(expirationdatetime)),
            //        DB.SQuote(InterpriseHelper.ConfigInstance.WebSiteCode),
            //        DB.SQuote(ThisCustomer.ContactCode),
            //        DB.SQuote(_itemCode),
            //        DB.SQuote(Localization.DateTimeStringForDB(DateTime.Now)),
            //        ThisCustomer.CurrentSessionID);
            //DB.ExecuteSQL(updatevieweditems);

            string itemDescription = string.Empty;

            if (eCommerceProductInfoView == null)
            {
                Response.Redirect(SE.MakeDriverLink("ProductNotFound"));
            }

            if (eCommerceProductInfoView.CheckOutOption)
            {
                Response.Redirect(SE.MakeDriverLink("ProductNotFound"));
            }

            if (eCommerceProductInfoView.IsCBN == false && AppLogic.IsCBNMode())
            {
                Response.Redirect(SE.MakeDriverLink("MobileProductNotFound"));
            }

            string SENameINURL  = "SEName".ToQueryStringDecode();
            string ActualSEName = eCommerceProductInfoView.ItemDescription.ToMungeName().ToUrlEncode().ToSubString(90);

            if (string.IsNullOrEmpty(ActualSEName))
            {
                ActualSEName = eCommerceProductInfoView.ItemName.ToMungeName().ToUrlEncode().ToSubString(90);
            }

            if (ActualSEName != SENameINURL)
            {
                string NewURL    = AppLogic.GetStoreHTTPLocation(false) + SE.MakeProductLink(_itemCounter.ToString(), ActualSEName);
                string QStr      = "?";
                var    keyvalues = Request.QueryString
                                   .ToPairs()
                                   .Where(q => q.Key == "productid" && q.Key == "sename")
                                   .Select(q => string.Join("=", new[] { q.Key, q.Value + "&" }))
                                   .ToArray();
                QStr += string.Join("", keyvalues);
                if (QStr.Length > 1)
                {
                    NewURL += QStr;
                }

                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }

            m_XmlPackage = eCommerceProductInfoView.MobileXmlPackage.ToLowerInvariant();

            IsAKit   = eCommerceProductInfoView.IsAKit.TryParseBool();
            IsMatrix = eCommerceProductInfoView.IsMatrix.TryParseBool();

            if (m_XmlPackage.Length == 0)
            {
                if (IsAKit)
                {
                    m_XmlPackage = AppLogic.MobileDefaultProductKitXmlPackage; // provide a default
                }
                else if (IsMatrix)
                {
                    m_XmlPackage = AppLogic.MobileDefaultProductMatrixXmlPackage; // provide a default
                }
                else
                {
                    m_XmlPackage = AppLogic.MobileDefaultProductXmlPackage; // provide a default
                }
            }

            RequiresReg = eCommerceProductInfoView.RequiresRegistration;
            ProductName = XmlCommon.GetLocaleEntry(eCommerceProductInfoView.ItemDescription, ThisCustomer.LocaleSetting, true);

            CategoryHelper     = AppLogic.LookupHelper(base.EntityHelpers, DomainConstants.LOOKUP_HELPER_CATEGORIES);
            SectionHelper      = AppLogic.LookupHelper(base.EntityHelpers, DomainConstants.LOOKUP_HELPER_DEPARTMENT);
            ManufacturerHelper = AppLogic.LookupHelper(base.EntityHelpers, DomainConstants.LOOKUP_HELPER_MANUFACTURERS);

            itemDescription = eCommerceProductInfoView.ItemDescription;
            if (string.IsNullOrEmpty(itemDescription))
            {
                itemDescription = ProductName;
            }

            string seITitleTemp = XmlCommon.GetLocaleEntry(eCommerceProductInfoView.SETitle, ThisCustomer.LocaleSetting, true);

            SETitle = string.IsNullOrEmpty(seITitleTemp) ? (AppLogic.AppConfig("StoreName") + " - " + itemDescription).ToHtmlEncode() : seITitleTemp;

            string seDescription = XmlCommon.GetLocaleEntry(eCommerceProductInfoView.SEDescription, ThisCustomer.LocaleSetting, true);

            SEDescription = string.IsNullOrEmpty(seDescription) ? ProductName.ToHtmlEncode() : seDescription;

            string seKeywords = XmlCommon.GetLocaleEntry(eCommerceProductInfoView.SEKeywords, ThisCustomer.LocaleSetting, true);

            SEKeywords = string.IsNullOrEmpty(seKeywords) ? ProductName.ToHtmlEncode() : seKeywords;

            SENoScript = XmlCommon.GetLocaleEntry(eCommerceProductInfoView.SENoScript, ThisCustomer.LocaleSetting, true);

            CategoryName = (CategoryHelper.GetEntityField(CategoryID, "Description", ThisCustomer.LocaleSetting) != String.Empty) ?
                           CategoryHelper.GetEntityField(CategoryID, "Description", ThisCustomer.LocaleSetting) :
                           CategoryHelper.GetEntityName(CategoryID, ThisCustomer.LocaleSetting);

            SectionName = (SectionHelper.GetEntityField(DepartmentID, "Description", ThisCustomer.LocaleSetting) != String.Empty) ?
                          SectionHelper.GetEntityField(DepartmentID, "Description", ThisCustomer.LocaleSetting) :
                          SectionHelper.GetEntityName(DepartmentID, ThisCustomer.LocaleSetting);

            ManufacturerName = (ManufacturerHelper.GetEntityField(ManufacturerID, "Description", ThisCustomer.LocaleSetting) != String.Empty) ?
                               ManufacturerHelper.GetEntityField(ManufacturerID, "Description", ThisCustomer.LocaleSetting) :
                               ManufacturerHelper.GetEntityName(ManufacturerID, ThisCustomer.LocaleSetting);

            if (ManufacturerID.Length != 0)
            {
                CookieTool.Add("LastViewedEntityName", "Manufacturer", new TimeSpan(1, 0, 0, 0, 0));
                CookieTool.Add("LastViewedEntityInstanceID", ManufacturerID.ToString(), new TimeSpan(1, 0, 0, 0, 0));
                CookieTool.Add("LastViewedEntityInstanceName", ManufacturerName, new TimeSpan(1, 0, 0, 0, 0));
                String NewURL = AppLogic.GetStoreHTTPLocation(false) + SE.MakeProductLink(_itemCounter.ToString(), _itemCode);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }
            else if (CategoryID.Length != 0)
            {
                CookieTool.Add("LastViewedEntityName", "Category", new TimeSpan(1, 0, 0, 0, 0));
                CookieTool.Add("LastViewedEntityInstanceID", CategoryID.ToString(), new TimeSpan(1, 0, 0, 0, 0));
                CookieTool.Add("LastViewedEntityInstanceName", CategoryName, new TimeSpan(1, 0, 0, 0, 0));
                string NewURL = AppLogic.GetStoreHTTPLocation(false) + SE.MakeProductLink(_itemCounter.ToString(), _itemCode);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }
            else if (DepartmentID.Length != 0)
            {
                var cookierExpires = new TimeSpan(1, 0, 0, 0, 0);
                CookieTool.Add("LastViewedEntityName", "Department", cookierExpires);
                CookieTool.Add("LastViewedEntityInstanceID", DepartmentID.ToString(), cookierExpires);
                CookieTool.Add("LastViewedEntityInstanceName", SectionName, cookierExpires);

                String NewURL = AppLogic.GetStoreHTTPLocation(false) + SE.MakeProductLink(_itemCounter.ToString(), _itemCode);
                HttpContext.Current.Response.Write("<html><head><title>Object Moved</title></head><body><b>Object moved to <a href=\"" + NewURL + "\">HERE</a></b></body></html>");
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", NewURL);
                HttpContext.Current.Response.End();
            }

            SourceEntity = CommonLogic.CookieCanBeDangerousContent("LastViewedEntityName", true);
            string SourceEntityInstanceName = CommonLogic.CookieCanBeDangerousContent("LastViewedEntityInstanceName", true);

            SourceEntityID = CommonLogic.CookieCanBeDangerousContent("LastViewedEntityInstanceID", true);

            // validate that source entity id is actually valid for this product:
            if (SourceEntityID.Length != 0)
            {
                var alE = AppLogic.GetProductEntityList(_itemCode, SourceEntity);
                if (alE.Any(i => i == SourceEntityID.TryParseIntUsLocalization()))
                {
                    SourceEntityID = string.Empty;
                }
            }

            if (SourceEntityID.Length != 0)
            {
                PickupBreadCrumb(ref SourceEntity, ref SourceEntityInstanceName, ref SourceEntityID, false);
            }
            else
            {
                PickupBreadCrumb(ref SourceEntity, ref SourceEntityInstanceName, ref SourceEntityID, true);
            }

            AppLogic.LogEvent(ThisCustomer.CustomerCode, 10, _itemCounter.ToString());
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            productID = CommonLogic.QueryStringUSInt("productId");
            ItemCode  = InterpriseHelper.GetInventoryItemCode(productID);
            EntityHelper CategoryHelper     = AppLogic.LookupHelper(base.EntityHelpers, "Category");
            EntityHelper SectionHelper      = AppLogic.LookupHelper(base.EntityHelpers, "Department");
            EntityHelper ManufacturerHelper = AppLogic.LookupHelper(base.EntityHelpers, "Manufacturer");

            CategoryID     = CommonLogic.QueryStringCanBeDangerousContent("CategoryID");
            DepartmentID   = CommonLogic.QueryStringCanBeDangerousContent("DepartmentID");
            ManufacturerID = CommonLogic.QueryStringCanBeDangerousContent("ManufacturerID");

            String SourceEntity   = "Category";
            String SourceEntityID = String.Empty;

            if (AppLogic.AppConfigBool("GoNonSecureAgain"))
            {
                SkinBase.GoNonSecureAgain();
            }
            // DOS attack prevention:
            if (AppLogic.OnLiveServer() && (Request.UrlReferrer == null || Request.UrlReferrer.Authority != Request.Url.Authority))
            {
                Response.Redirect(SE.MakeDriverLink("EmailError"));
            }
            if (ItemCode == String.Empty)
            {
                Response.Redirect("default.aspx");
            }
            if (AppLogic.ProductHasBeenDeleted(productID))
            {
                Response.Redirect(SE.MakeDriverLink("ProductNotFound"));
            }


            using (SqlConnection con = DB.NewSqlConnection())
            {
                con.Open();
                using (IDataReader rs = DB.GetRSFormat(con, "SELECT * FROM EcommerceViewProduct with (NOLOCK) " +
                                                       " WHERE Counter=" + productID +
                                                       " AND ShortString=" + DB.SQuote(ThisCustomer.LocaleSetting) +
                                                       " AND WebSiteCode=" + DB.SQuote(InterpriseHelper.ConfigInstance.WebSiteCode)))
                {
                    if (!rs.Read())
                    {
                        Response.Redirect("default.aspx");
                    }

                    SEName = SE.MungeName(DB.RSField(rs, "SEName"));
                    if (DB.RSField(rs, "ItemDescription").ToString() != String.Empty)
                    {
                        ProductName = DB.RSField(rs, "ItemDescription");
                    }
                    else
                    {
                        ProductName = DB.RSField(rs, "ItemName");
                    }

                    RequiresReg        = DB.RSFieldBool(rs, "RequiresRegistration");
                    ProductDescription = DB.RSField(rs, "ItemDescription");
                    if (AppLogic.ReplaceImageURLFromAssetMgr)
                    {
                        ProductDescription = ProductDescription.Replace("../images", "images");
                    }
                    String FileDescription = new ProductDescriptionFile(ItemCode, ThisCustomer.LocaleSetting, SkinID).Contents;
                    if (FileDescription.Length != 0)
                    {
                        ProductDescription += "<div align=\"left\">" + FileDescription + "</div>";
                    }
                }
            }

            if (Convert.ToInt32(CategoryID) == 0)
            {
                // no category passed in, pick first one that this product is mapped to:
                String tmpS = CategoryHelper.GetObjectEntities(ItemCode, false);
                if (tmpS.Length != 0)
                {
                    String[] catIDs = tmpS.Split(',');
                    CategoryID = Convert.ToString(Localization.ParseUSInt(catIDs[0]));
                }
            }

            string CategoryName     = CommonLogic.IIF(CategoryHelper.GetEntityField(CategoryID, "Description", ThisCustomer.LocaleSetting) != String.Empty, CategoryHelper.GetEntityField(CategoryID, "Description", ThisCustomer.LocaleSetting), CategoryHelper.GetEntityName(CategoryID, ThisCustomer.LocaleSetting));
            string SectionName      = CommonLogic.IIF(SectionHelper.GetEntityField(DepartmentID, "Description", ThisCustomer.LocaleSetting) != String.Empty, SectionHelper.GetEntityField(DepartmentID, "Description", ThisCustomer.LocaleSetting), SectionHelper.GetEntityName(DepartmentID, ThisCustomer.LocaleSetting));
            string ManufacturerName = CommonLogic.IIF(ManufacturerHelper.GetEntityField(ManufacturerID, "Description", ThisCustomer.LocaleSetting) != String.Empty, ManufacturerHelper.GetEntityField(ManufacturerID, "Description", ThisCustomer.LocaleSetting), ManufacturerHelper.GetEntityName(ManufacturerID, ThisCustomer.LocaleSetting));

            SourceEntity = CommonLogic.CookieCanBeDangerousContent("LastViewedEntityName", true);
            String SourceEntityInstanceName = CommonLogic.CookieCanBeDangerousContent("LastViewedEntityInstanceName", true);

            SourceEntityID = CommonLogic.CookieCanBeDangerousContent("LastViewedEntityInstanceID", true);

            // validate that source entity id is actually valid for this product:
            if (SourceEntityID.Length != 0)
            {
                ArrayList alE = EntityHelper.GetProductEntityList(ItemCode, SourceEntity);
                if (alE.IndexOf(Localization.ParseNativeInt(SourceEntityID)) == -1)
                {
                    SourceEntityID = String.Empty;
                }
            }

            if (SourceEntityID.Length != 0)
            {
                PickupBreadCrumb(ref SourceEntity, ref SourceEntityInstanceName, ref SourceEntityID, false);
            }
            else
            {
                PickupBreadCrumb(ref SourceEntity, ref SourceEntityInstanceName, ref SourceEntityID, true);
            }

            SectionTitle += "<span class=\"SectionTitleText\">";
            SectionTitle += ProductName;
            SectionTitle += "</span>";

            reqToAddress.ErrorMessage     = AppLogic.GetString("emailproduct.aspx.13", SkinID, ThisCustomer.LocaleSetting, true);
            regexToAddress.ErrorMessage   = AppLogic.GetString("emailproduct.aspx.14", SkinID, ThisCustomer.LocaleSetting, true);
            reqFromAddress.ErrorMessage   = AppLogic.GetString("emailproduct.aspx.16", SkinID, ThisCustomer.LocaleSetting, true);
            regexFromAddress.ErrorMessage = AppLogic.GetString("emailproduct.aspx.17", SkinID, ThisCustomer.LocaleSetting, true);

            if (!this.IsPostBack)
            {
                InitializePageContent();
            }
        }
Example #12
0
        protected override void OnPreInit(EventArgs e)
        {
            if (HttpContext.Current != null)
            {
                m_ThisCustomer = ((InterpriseSuiteEcommercePrincipal)Context.User).ThisCustomer;

                if (AppLogic.AppConfigBool("GoogleCheckout.ShowOnCartPage"))
                {
                    string s = CachingFactory.ApplicationCachingEngineInstance.GetItem <string>(DomainConstants.GCCallbackLoadCheck);
                    if (s != null)
                    {
                        string notused = CommonLogic.AspHTTP(AppLogic.GetStoreHTTPLocation(false) + "gccallback.aspx?loadcheck=1", 10);
                        CachingFactory.ApplicationCachingEngineInstance.AddItem(DomainConstants.GCCallbackLoadCheck, "true", 5);
                    }
                }

                if (!CurrentContext.IsInAdminRoot() &&
                    (AppLogic.AppConfigBool("SiteDisclaimerRequired") &&
                     CommonLogic.CookieCanBeDangerousContent("SiteDisclaimerAccepted", true).IsNullOrEmptyTrimmed()))
                {
                    string ThisPageURL = CommonLogic.GetThisPageName(true) + "?" + CommonLogic.ServerVariables("QUERY_STRING");
                    Response.Redirect("disclaimer.aspx?returnURL=" + Server.UrlEncode(ThisPageURL));
                }

                Thread.CurrentThread.CurrentCulture   = CultureInfo.CreateSpecificCulture(ThisCustomer.LocaleSetting);
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(ThisCustomer.LocaleSetting);
                LoadSkinTemplate();
                m_Parser = new Parser(m_EntityHelpers, m_SkinID, m_ThisCustomer);
                m_Parser.RenderHeader += this.OnRenderHeader;

                if (this.HasControls())
                {
                    foreach (Control c in this.Controls)
                    {
                        FindLocaleStrings(c);
                    }

                    Control ctl;
                    int     i         = 1;
                    int     limitLoop = 1000;
                    if (m_Template != null && m_Template.Content != null)
                    {
                        while (this.Controls.Count > 0 && i <= limitLoop)
                        {
                            bool FilterItOut = false;
                            ctl = this.Controls[0];
                            LiteralControl l = ctl as LiteralControl;
                            if (l != null)
                            {
                                string txtVal = l.Text;
                                if (txtVal.IndexOf("<html", StringComparison.InvariantCultureIgnoreCase) != -1 ||
                                    txtVal.IndexOf("</html", StringComparison.InvariantCultureIgnoreCase) != -1)
                                {
                                    FilterItOut = true; // remove outer html/body crap, as we're going to be moving the page controls INSIDE The skin
                                }
                            }
                            if (!FilterItOut)
                            {
                                // reparent the page control to be moved inside the skin template user control
                                m_Template.Content.Controls.Add(ctl);
                            }
                            else
                            {
                                this.Controls.RemoveAt(0);
                            }
                            i++;
                        }
                    }

                    // clear the controls (they were now all moved inside the template user control:
                    this.Controls.Clear();
                    // set the template user control to be owned by this page:
                    this.Controls.Add(m_Template);

                    //register the ScriptManager before loading controls or the ComponentArt menu won't work with AJAX pages
                    CheckIfRequireScriptManager();

                    // Now move the template child controls up to the page level so the ViewState will load
                    while (m_Template.Controls.Count > 0)
                    {
                        this.Controls.Add(m_Template.Controls[0]);
                    }
                }

                if (AppLogic.IsCBNMode() && m_ThisCustomer != null)
                {
                    var cart = new ShoppingCart(m_ThisCustomer.SkinID, m_ThisCustomer, CartTypeEnum.ShoppingCart, string.Empty, false);
                    if (!cart.IsEmpty())
                    {
                        //empty shopping cart
                        cart.ClearContents();
                    }
                }

                string bingAdsTrackingScript = AppLogic.GetBingAdsTrackingScript();

                if (!bingAdsTrackingScript.IsNullOrEmptyTrimmed())
                {
                    ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), DB.GetNewGUID(), bingAdsTrackingScript, false);
                }
            }

            base.OnPreInit(e);
        }
Example #13
0
        private SkinBase m_SkinBase = null; // if not null, this control will set the page metatags to the results from the Topic, IF those Topic results are not "empty strings"

        protected void Page_Load(object sender, EventArgs e)
        {
            m_DesignMode = (HttpContext.Current == null);
            if (m_DesignMode)
            {
                if (TopicName.Length != 0)
                {
                    Contents.Text = "Topic: " + TopicName;
                }
                else
                {
                    Contents.Text = "Topic";
                }
            }
            else
            {
                m_SkinBase = (SkinBase)this.Page;
                try
                {
                    if (m_SkinBase != null)
                    {
                        if (TopicID != 0)
                        {
                            m_T = new Topic(TopicID, m_SkinBase.ThisCustomer.LocaleSetting, m_SkinBase.ThisCustomer.SkinID, m_SkinBase.GetParser);
                        }
                        else
                        {
                            m_T = new Topic(TopicName, m_SkinBase.ThisCustomer.LocaleSetting, m_SkinBase.ThisCustomer.SkinID, m_SkinBase.GetParser);
                        }
                        m_SkinID        = m_SkinBase.ThisCustomer.SkinID;
                        m_LocaleSetting = m_SkinBase.ThisCustomer.LocaleSetting;
                    }
                    else
                    {
                        m_LocaleSetting = Localization.GetDefaultLocale();
                        if (TopicID != 0)
                        {
                            m_T = new Topic(TopicID, m_LocaleSetting, m_SkinID, null);
                        }
                        else
                        {
                            m_T = new Topic(TopicName, m_LocaleSetting, m_SkinID, null);
                        }
                    }
                    StringBuilder tmpS = new StringBuilder(4096);

                    String xpdd = m_SkinBase.ThisCustomer.ThisCustomerSession["Topic" + XmlCommon.GetLocaleEntry(m_T.TopicName, m_SkinBase.ThisCustomer.LocaleSetting, true)];
                    if (xpdd.Length != 0)
                    {
                        // don't let decrypt failure crash, just set xpdd to string.empty so it fails.
                        try
                        {
                            xpdd = Security.UnmungeString(xpdd);
                        }
                        catch
                        {
                            xpdd = String.Empty; // some kind of decrypt failure, deny access, not sure what else to do here.
                        }
                    }
                    if (EnforcePassword && m_T.Password.Length != 0 && xpdd != m_T.Password)
                    {
                        String Url = String.Empty;
                        if (CommonLogic.GetThisPageName(false).Equals("driver.aspx", StringComparison.InvariantCultureIgnoreCase))
                        {
                            Url = SE.MakeDriverLink(XmlCommon.GetLocaleEntry(m_T.TopicName, m_SkinBase.ThisCustomer.LocaleSetting, true));
                        }
                        else
                        {
                            Url = SE.MakeDriver2Link(XmlCommon.GetLocaleEntry(m_T.TopicName, m_SkinBase.ThisCustomer.LocaleSetting, true));
                        }
                        tmpS.Append("<form method=\"POST\" action=\"" + Url + "\">\n");
                        tmpS.Append("<p><b>");
                        tmpS.Append(AppLogic.GetString("driver.aspx.1", m_SkinID, m_LocaleSetting));
                        tmpS.Append("</b></p>\n");
                        tmpS.Append("<p>");
                        tmpS.Append(AppLogic.GetString("driver.aspx.2", m_SkinID, m_LocaleSetting));
                        tmpS.Append(" <input type=\"text\" name=\"Password\" size=\"20\" maxlength=\"100\"><input type=\"submit\" value=\"");
                        tmpS.Append(AppLogic.GetString("driver.aspx.5", m_SkinID, m_LocaleSetting));
                        tmpS.Append("\" name=\"B1\"></p>\n");
                        tmpS.Append("</form>\n");
                        m_SkinBase.ThisCustomer.RequireCustomerRecord();
                    }
                    else
                    {
                        if (EnforceDisclaimer && m_T.RequiresDisclaimer && CommonLogic.CookieCanBeDangerousContent("SiteDisclaimerAccepted", true).Length == 0)
                        {
                            String ThisPageURL = CommonLogic.GetThisPageName(true) + "?" + CommonLogic.ServerVariables("QUERY_STRING");
                            Response.Redirect("disclaimer.aspx?returnURL=" + HttpContext.Current.Server.UrlEncode(ThisPageURL));
                        }

                        if (EnforceSubscription && m_T.RequiresSubscription && m_SkinBase.ThisCustomer.SubscriptionExpiresOn.AddDays((double)AppLogic.AppConfigNativeInt("SubscriptionExpiredGracePeriod")) < System.DateTime.Now)
                        {
                            String Msg = AppLogic.AppConfig("Suscription.ExpiredMessageWhenViewingTopic");
                            if (Msg.Length == 0)
                            {
                                Msg = "<p><b>" + AppLogic.GetString("driver.aspx.3", m_SkinID, m_LocaleSetting) + "</b></p>";
                            }
                            tmpS.Append(Msg);
                        }
                        else
                        {
                            tmpS.Append("<!-- READ FROM ");
                            tmpS.Append(CommonLogic.IIF(m_T.FromDB, "DB", "FILE"));
                            tmpS.Append(" -->");
                            tmpS.Append(m_T.Contents);
                            tmpS.Append("<!-- END OF ");
                            tmpS.Append(CommonLogic.IIF(m_T.FromDB, "DB", "FILE"));
                            tmpS.Append(" -->");
                        }
                    }
                    Contents.Text = tmpS.ToString();
                }
                catch (Exception ex)
                {
                    Contents.Text = CommonLogic.GetExceptionDetail(ex, "<br/>");
                }
                if (m_SkinBase != null && m_AllowSEPropogation && m_T != null)
                {
                    if (m_T.SectionTitle.Length != 0)
                    {
                        m_SkinBase.SectionTitle = m_T.SectionTitle;
                    }
                    if (m_T.SETitle.Length != 0)
                    {
                        m_SkinBase.SETitle = m_T.SETitle;
                    }
                    if (m_T.SEKeywords.Length != 0)
                    {
                        m_SkinBase.SEKeywords = m_T.SEKeywords;
                    }
                    if (m_T.SEDescription.Length != 0)
                    {
                        m_SkinBase.SEDescription = m_T.SEDescription;
                    }
                    if (m_T.SENoScript.Length != 0)
                    {
                        m_SkinBase.SENoScript = m_T.SENoScript;
                    }
                }
            }
        }
        public void Page_Load(object sender, System.EventArgs e)
        {
            if (AppLogic.AppConfigBool("GoNonSecureAgain"))
            {
                SkinBase.GoNonSecureAgain();
            }
            n = m_EntityHelper.m_TblMgr.SetContext(m_EntityInstanceID);

            if (n == null)
            {
                HttpContext.Current.Response.Redirect("t-error404.aspx");
            }

            m_CategoryFilterID     = CommonLogic.QueryStringCanBeDangerousContent("CategoryFilterID");
            m_SectionFilterID      = CommonLogic.QueryStringCanBeDangerousContent("SectionFilterID");
            m_ProductTypeFilterID  = CommonLogic.QueryStringCanBeDangerousContent("ProductTypeFilterID");
            m_ManufacturerFilterID = CommonLogic.QueryStringCanBeDangerousContent("ManufacturerFilterID");
            m_AttributeFilterID    = CommonLogic.QueryStringCanBeDangerousContent("AttributeFilterID");
            m_AttributeFilter      = CommonLogic.GetAttributeFilter();

            if (CommonLogic.QueryStringCanBeDangerousContent("CategoryFilterID").Length == 0)
            {
                if (CommonLogic.QueryStringCanBeDangerousContent("ResetFilters").Length == 0 && CommonLogic.CookieUSInt("CategoryFilterID") != 0)
                {
                    m_CategoryFilterID = CommonLogic.CookieCanBeDangerousContent("CategoryFilterID", false);
                }
            }

            if (CommonLogic.QueryStringCanBeDangerousContent("SectionFilterID").Length == 0)
            {
                if (CommonLogic.QueryStringCanBeDangerousContent("ResetFilters").Length == 0 && CommonLogic.CookieUSInt("SectionFilterID") != 0)
                {
                    m_SectionFilterID = CommonLogic.CookieCanBeDangerousContent("SectionFilterID", false);
                }
            }

            if (CommonLogic.QueryStringCanBeDangerousContent("ProductTypeFilterID").Length == 0)
            {
                if (CommonLogic.QueryStringCanBeDangerousContent("ResetFilters").Length == 0 && CommonLogic.CookieUSInt("ProductTypeFilterID") != 0)
                {
                    m_ProductTypeFilterID = CommonLogic.CookieCanBeDangerousContent("ProductTypeFilterID", false);
                }
                if (m_ProductTypeFilterID != String.Empty && !AppLogic.ProductTypeHasVisibleProducts(m_ProductTypeFilterID))
                {
                    m_ProductTypeFilterID = String.Empty;
                }
            }

            if (CommonLogic.QueryStringCanBeDangerousContent("ManufacturerFilterID").Length == 0)
            {
                if (CommonLogic.QueryStringCanBeDangerousContent("ResetFilters").Length == 0 && CommonLogic.CookieUSInt("ManufacturerFilterID") != 0)
                {
                    m_ManufacturerFilterID = CommonLogic.CookieCanBeDangerousContent("ManufacturerFilterID", false);
                }
            }

            if (CommonLogic.QueryStringCanBeDangerousContent("AttributeFilterID").Length == 0)
            {
                if (CommonLogic.QueryStringCanBeDangerousContent("ResetFilters").Length == 0 && CommonLogic.CookieUSInt("AttributeFilterID") != 0)
                {
                    m_AttributeFilterID = CommonLogic.CookieCanBeDangerousContent("AttributeFilterID", false);
                }
            }

            if (CommonLogic.QueryStringCanBeDangerousContent("ResetFilters").Length != 0)
            {
                m_CategoryFilterID     = String.Empty;
                m_SectionFilterID      = String.Empty;
                m_ManufacturerFilterID = String.Empty;
                m_ProductTypeFilterID  = String.Empty;
                m_AttributeFilterID    = String.Empty;
                m_AttributeFilter      = String.Empty;
            }

            m_EntityInstanceName           = m_EntityHelper.m_TblMgr.CurrentName(n, m_SkinBase.ThisCustomer.LocaleSetting);
            m_EntityInstanceNameForDisplay = CommonLogic.IIF(m_EntityHelper.m_TblMgr.CurrentFieldByLocale(n, "Description", m_SkinBase.ThisCustomer.LocaleSetting) != String.Empty, m_EntityHelper.m_TblMgr.CurrentFieldByLocale(n, "Description", m_SkinBase.ThisCustomer.LocaleSetting), m_EntityHelper.m_TblMgr.CurrentName(n, m_SkinBase.ThisCustomer.LocaleSetting));

            AppLogic.SetCookie("LastViewedEntityName", m_EntitySpecs.m_EntityName, new TimeSpan(1, 0, 0, 0, 0));
            AppLogic.SetCookie("LastViewedEntityInstanceID", m_EntityInstanceID.ToString(), new TimeSpan(1, 0, 0, 0, 0));
            AppLogic.SetCookie("LastViewedEntityInstanceName", m_EntityInstanceNameForDisplay, new TimeSpan(1, 0, 0, 0, 0));

            m_SkinBase.SETitle = m_EntityHelper.m_TblMgr.CurrentFieldByLocale(n, "SETitle", m_SkinBase.ThisCustomer.LocaleSetting);
            if (m_SkinBase.SETitle.Length == 0)
            {
                m_SkinBase.SETitle = HttpContext.Current.Server.HtmlEncode(AppLogic.AppConfig("StoreName") + " - " + m_EntityInstanceName);
            }
            m_SkinBase.SEDescription = m_EntityHelper.m_TblMgr.CurrentFieldByLocale(n, "SEDescription", m_SkinBase.ThisCustomer.LocaleSetting);
            if (m_SkinBase.SEDescription.Length == 0)
            {
                m_SkinBase.SEDescription = HttpContext.Current.Server.HtmlEncode(m_EntityInstanceName);
            }
            m_SkinBase.SEKeywords = m_EntityHelper.m_TblMgr.CurrentFieldByLocale(n, "SEKeywords", m_SkinBase.ThisCustomer.LocaleSetting);
            if (m_SkinBase.SEKeywords.Length == 0)
            {
                m_SkinBase.SEKeywords = HttpContext.Current.Server.HtmlEncode(m_EntityInstanceName);
            }
            m_SkinBase.SENoScript = m_EntityHelper.m_TblMgr.CurrentFieldByLocale(n, "SENoScript", m_SkinBase.ThisCustomer.LocaleSetting);

            m_SkinBase.SectionTitle = "<span class=\"SectionTitleText\">";
            String ParentName = String.Empty;
            String ParentID   = m_EntityHelper.GetParentEntity(m_EntityInstanceID);

            while (ParentID != String.Empty)
            {
                ParentName = CommonLogic.IIF(m_EntityHelper.GetEntityField(ParentID, "Description", m_SkinBase.ThisCustomer.LocaleSetting) != String.Empty,
                                             m_EntityHelper.GetEntityField(ParentID, "Description", m_SkinBase.ThisCustomer.LocaleSetting),
                                             m_EntityHelper.GetEntityName(ParentID, m_SkinBase.ThisCustomer.LocaleSetting));

                m_SkinBase.SectionTitle = "<a class=\"SectionTitleText\" href=\"" + SE.MakeEntityLink(m_EntitySpecs.m_EntityName, ParentID, ParentName) + "\">" + ParentName +
                                          "</a> &rarr; " + m_SkinBase.SectionTitle;
                ParentID = m_EntityHelper.GetParentEntity(ParentID);
            }
            m_SkinBase.SectionTitle += m_EntityInstanceNameForDisplay;
            m_SkinBase.SectionTitle += "</span>";
            AppLogic.LogEvent(m_SkinBase.ThisCustomer.CustomerCode, 9, m_EntityInstanceID.ToString());

            //Include for mobile manufacturer
            if (CurrentContext.IsRequestingFromMobileMode(m_SkinBase.ThisCustomer))
            {
                m_XmlPackage = m_EntityHelper.m_TblMgr.CurrentField(n, "MobileXmlPackage").ToLowerInvariant();
                if (m_XmlPackage.IsNullOrEmptyTrimmed())
                {
                    m_XmlPackage = m_EntityHelper.m_TblMgr.CurrentField(n, "XmlPackage").ToLowerInvariant();
                }
            }
            else
            {
                m_XmlPackage = m_EntityHelper.m_TblMgr.CurrentField(n, "XmlPackage").ToLowerInvariant();
            }

            if (m_XmlPackage.Length == 0)
            {
                m_XmlPackage = AppLogic.ro_DefaultEntityXmlPackage; // provide a default for backwards compatibility
            }

            GeneratePageOutput();
        }
Example #15
0
        protected override void OnPreInit(EventArgs e)
        {
            if (HttpContext.Current != null)
            {
                m_ThisCustomer = ((AspDotNetStorefrontPrincipal)Context.User).ThisCustomer;


                int StoreID = AppLogic.StoreID();
                m_SkinID = AppLogic.GetStoreSkinID(StoreID);

                //TODO: review this
                if (CommonLogic.IsInteger(HttpContext.Current.Profile.GetPropertyValue("SkinID").ToString()))
                {
                    int skinFromProfile = int.Parse(HttpContext.Current.Profile.GetPropertyValue("SkinID").ToString());
                    if (skinFromProfile > 0)
                    {
                        m_SkinID = skinFromProfile;
                    }
                }
                else if (AppLogic.AppConfig("Signin.SkinMaster").EqualsIgnoreCase("session"))
                {
                    m_SkinID = m_ThisCustomer.DBSkinID;
                }

                if (CommonLogic.QueryStringUSInt("skinid") > 0)
                {
                    m_SkinID = CommonLogic.QueryStringUSInt("skinid");
                }

                if (CommonLogic.QueryStringUSInt("affiliateid") > 0)
                {
                    HttpContext.Current.Profile.SetPropertyValue("AffiliateID", CommonLogic.QueryStringUSInt("affiliateid").ToString());
                }

                if (HttpContext.Current.Request.UrlReferrer != null && HttpContext.Current.Request.UrlReferrer.Authority != HttpContext.Current.Request.Url.Authority)
                {
                    HttpContext.Current.Profile.SetPropertyValue("Referrer", HttpContext.Current.Request.UrlReferrer.ToString());
                }


                if (AppLogic.ProductIsMLExpress() == false && AppLogic.AppConfigBool("GoogleCheckout.ShowOnCartPage"))
                {
                    String s = (String)HttpContext.Current.Cache.Get("GCCallbackLoadCheck");
                    if (s == null)
                    {
                        String notused = CommonLogic.AspHTTP(AppLogic.GetStoreHTTPLocation(false) + "gccallback.aspx?loadcheck=1", 10);
                        HttpContext.Current.Cache.Insert("GCCallbackLoadCheck", "true", null, System.DateTime.Now.AddMinutes(5), TimeSpan.Zero);
                    }
                }

                // don't fire disclaimer logic on admin pages
                if (!AppLogic.IsAdminSite && CommonLogic.QueryStringCanBeDangerousContent("ReturnURL").IndexOf(AppLogic.AppConfig("AdminDir")) == -1 && (AppLogic.AppConfigBool("SiteDisclaimerRequired") && CommonLogic.CookieCanBeDangerousContent("SiteDisclaimerAccepted", true).Length == 0))
                {
                    String ThisPageURL = CommonLogic.GetThisPageName(true) + "?" + CommonLogic.ServerVariables("QUERY_STRING");
                    Response.Redirect("disclaimer.aspx?returnURL=" + Server.UrlEncode(ThisPageURL));
                }

                bool IGDQueryClear = false;
                m_IGD = CommonLogic.QueryStringCanBeDangerousContent("IGD").Trim();
                if (m_IGD.Length == 0 && CommonLogic.ServerVariables("QUERY_STRING").IndexOf("IGD=") != -1)
                {
                    m_IGD         = String.Empty; // there was IGD={blank} in the query string, so forcefully clear IGD!
                    IGDQueryClear = true;
                }
                bool IsStartOfImpersonation = m_IGD.Length != 0; // the url invocation starts the impersonation only!

                if (!IGDQueryClear && m_IGD.Length == 0)
                {
                    if (m_ThisCustomer.IsAdminUser)
                    {
                        // pull out the impersonation IGD from the customer session, if any
                        m_IGD = m_ThisCustomer.ThisCustomerSession["IGD"];
                    }
                }

                if (IGDQueryClear)
                {
                    // forcefully clear any IGD for this customer, just to be safe!
                    m_ThisCustomer.ThisCustomerSession["IGD"] = "";
                    m_ThisCustomer.ThisCustomerSession["IGD_EDITINGORDER"] = "";
                }

                Customer PhoneCustomer = null;
                if (m_IGD.Length != 0)
                {
                    if (m_ThisCustomer.IsAdminUser)
                    {
                        try
                        {
                            Guid IGD = new Guid(m_IGD);
                            PhoneCustomer = new Customer(IGD);
                            PhoneCustomer.IsImpersonated = true;
                        }
                        catch
                        {
                            m_ThisCustomer.ThisCustomerSession["IGD"] = "";
                            m_ThisCustomer.ThisCustomerSession["IGD_EDITINGORDER"] = "";
                            m_IGD = string.Empty;
                        }
                    }
                    if (PhoneCustomer != null && PhoneCustomer.HasCustomerRecord)
                    {
                        int ImpersonationTimeoutInMinutes = AppLogic.AppConfigUSInt("ImpersonationTimeoutInMinutes");
                        if (ImpersonationTimeoutInMinutes == 0)
                        {
                            ImpersonationTimeoutInMinutes = 20;
                        }
                        if (PhoneCustomer.ThisCustomerSession.LastActivity >= DateTime.Now.AddMinutes(-ImpersonationTimeoutInMinutes))
                        {
                            m_ThisCustomer.ThisCustomerSession["IGD"] = IGD;
                            m_AdminCustomer = m_ThisCustomer; // save the owning admin user doing the impersonation here
                            m_ThisCustomer  = PhoneCustomer;  // build the impersonation customer the phone order customer
                            bool IsAdmin = CommonLogic.ApplicationBool("IsAdminSite");

                            if (!HttpContext.Current.Items.Contains("IsBeingImpersonated"))
                            {
                                HttpContext.Current.Items.Add("IsBeingImpersonated", "true");
                            }
                        }
                        else
                        {
                            if (HttpContext.Current.Items.Contains("IsBeingImpersonated"))
                            {
                                HttpContext.Current.Items["IsBeingImpersonated"] = "false";
                            }
                            m_ThisCustomer.ThisCustomerSession["IGD"] = "";
                            m_ThisCustomer.ThisCustomerSession["IGD_EDITINGORDER"] = "";
                            m_IGD = string.Empty;
                            //Response.Redirect("t-phoneordertimeout.aspx");
                            Response.Redirect(SE.MakeDriverLink("phoneordertimeout"));
                        }
                    }
                }

                Thread.CurrentThread.CurrentCulture   = CultureInfo.CreateSpecificCulture(Localization.GetDefaultLocale());
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(ThisCustomer.LocaleSetting);

                m_Parser = new Parser(m_EntityHelpers, m_SkinID, m_ThisCustomer);

                m_TemplateName = GetTemplateName();

                #region Vortx Mobile Modification
                if (!AppLogic.IsAdminSite)
                {
                    m_ThisCustomer = MobileRedirectController.SkinBaseHook(SkinID, ThisCustomer);
                    SkinID         = ThisCustomer.SkinID;
                    if (SkinID == Vortx.Data.Config.MobilePlatform.SkinId && MobileHelper.isMobile())
                    {
                        m_TemplateName = "template.master";
                    }
                }
                #endregion

                String SkinDirectory = String.Empty;
                String PageTheme     = String.Empty;

                SkinDirectory = "Skin_" + this.SkinID.ToString();
                PageTheme     = "Skin_" + this.SkinID.ToString();

                if (!m_TemplateName.EndsWith(".master", StringComparison.OrdinalIgnoreCase))
                {
                    m_TemplateName = m_TemplateName + ".master";
                }

                this.MasterPageFile = "~/App_Templates/" + SkinDirectory + "/" + m_TemplateName;
                this.Theme          = PageTheme;

                if (!CommonLogic.FileExists(this.MasterPageFile))
                {
                    this.SkinID = AppLogic.DefaultSkinID();

                    m_TemplateName = "template.master";
                    SkinDirectory  = "Skin_" + this.SkinID.ToString();
                    PageTheme      = "Skin_" + this.SkinID.ToString();

                    this.MasterPageFile = "~/App_Templates/" + SkinDirectory + "/" + m_TemplateName;
                    this.Theme          = PageTheme;
                }

                HttpContext.Current.Profile.SetPropertyValue("SkinID", this.SkinID.ToString());

                if (ThisCustomer.SkinID != this.SkinID)
                {
                    ThisCustomer.SkinID = this.SkinID;
                    ThisCustomer.UpdateCustomer(new SqlParameter[] { new SqlParameter("SkinID", this.SkinID) });
                }
            }

            base.OnPreInit(e);
        }
Example #16
0
        private SkinBase m_SkinBase = null; // if not null, this control will set the page metatags to the results from the Topic, IF those Topic results are not "empty strings"

        protected void Page_Load(object sender, EventArgs e)
        {
            m_DesignMode = (HttpContext.Current == null);

            if (m_DesignMode)
            {
                if (TopicName.Length != 0)
                {
                    Contents.Text = "Topic: " + TopicName;
                }
                else
                {
                    Contents.Text = "Topic";
                }
            }
            else
            {
                try
                {
                    if (Page != null)
                    {
                        m_T             = new Topic(TopicName.Replace("-", " "), ThisCustomer.LocaleSetting, ThisCustomer.SkinID, Page.GetParser);
                        m_SkinID        = ThisCustomer.SkinID;
                        m_LocaleSetting = ThisCustomer.LocaleSetting;
                    }
                    else
                    {
                        m_LocaleSetting = Localization.WebConfigLocale;
                        m_T             = new Topic(TopicName.Replace("-", " "), m_LocaleSetting, m_SkinID, null);
                    }

                    if (m_T.ShowOnWeb == false && (Request.Url.LocalPath.Contains("driver.aspx") || Request.Url.LocalPath.Contains("driver2.aspx")))
                    {
                        //If topic does not exists redirect to 404 error page.
                        HttpContext.Current.Response.Redirect("~/t-error404.aspx");
                    }

                    StringBuilder tmpS     = new StringBuilder(4096);
                    string        password = string.Empty;
                    if (m_T.Password.Length != 0)
                    {
                        password = InterpriseHelper.TopicPassword(m_T.TopicID, m_LocaleSetting);
                    }

                    string xpdd = m_SkinBase.ThisCustomer.ThisCustomerSession["Topic" + XmlCommon.GetLocaleEntry(m_T.TopicName, m_SkinBase.ThisCustomer.LocaleSetting, true)];
                    if (EnforcePassword && m_T.Password.Length != 0 && xpdd != password)
                    {
                        string Url = string.Empty;

                        bool isDriverEquals = "driver.aspx".Equals(CommonLogic.GetThisPageName(false), StringComparison.InvariantCultureIgnoreCase);
                        Url = CommonLogic.IIF(isDriverEquals, SE.MakeDriverLink(m_T.TopicName), SE.MakeDriver2Link(m_T.TopicName));

                        tmpS.Append("<form method=\"POST\" action=\"" + Url + "\">\n");
                        tmpS.Append("<p><b>");
                        tmpS.Append(AppLogic.GetString("driver.aspx.1", m_SkinID, m_LocaleSetting));
                        tmpS.Append("</b></p>\n");
                        tmpS.Append("<p>");
                        tmpS.Append(AppLogic.GetString("driver.aspx.2", m_SkinID, m_LocaleSetting));
                        tmpS.Append(" <input type=\"password\" name=\"Password\" size=\"20\" maxlength=\"100\" TextMode=\"Password\"><input type=\"submit\" value=\"");
                        tmpS.Append(AppLogic.GetString("driver.aspx.4", m_SkinID, m_LocaleSetting));
                        tmpS.Append("\" name=\"B1\"></p>\n");
                        tmpS.Append("</form>\n");
                    }
                    else
                    {
                        if (EnforceDisclaimer && m_T.RequiresDisclaimer && CommonLogic.CookieCanBeDangerousContent("SiteDisclaimerAccepted", true).Length == 0)
                        {
                            string ThisPageURL = CommonLogic.GetThisPageName(true) + "?" + CommonLogic.ServerVariables("QUERY_STRING");
                            Response.Redirect("disclaimer.aspx?returnURL=" + Server.UrlEncode(ThisPageURL));
                        }

                        if (EnforceSubscription && m_T.RequiresSubscription && ThisCustomer.SubscriptionExpiresOn < System.DateTime.Now)
                        {
                            tmpS.Append("<p><b>" + AppLogic.GetString("driver.aspx.3", m_SkinID, m_LocaleSetting) + "</b></p>");
                        }
                        else
                        {
                            tmpS.Append("<!-- READ FROM ");
                            tmpS.Append(CommonLogic.IIF(m_T.FromDB, "DB", "FILE: " + m_T.FN));
                            tmpS.Append(" -->");
                            tmpS.Append(m_T.Contents);
                            tmpS.Append("<!-- END OF ");
                            tmpS.Append(CommonLogic.IIF(m_T.FromDB, "DB", "FILE: " + m_T.FN));
                            tmpS.Append(" -->");
                        }
                    }
                    Contents.Text = tmpS.ToString();
                }
                catch (Exception ex)
                {
                    Contents.Text = CommonLogic.GetExceptionDetail(ex, "<br/>");
                }
                if (Page != null && m_AllowSEPropogation)
                {
                    if (m_T.SectionTitle.Length != 0)
                    {
                        Page.SectionTitle = m_T.SectionTitle;
                    }
                    if (m_T.SETitle.Length != 0)
                    {
                        Page.SETitle = m_T.SETitle;
                    }
                    if (m_T.SEKeywords.Length != 0)
                    {
                        Page.SEKeywords = m_T.SEKeywords;
                    }
                    if (m_T.SEDescription.Length != 0)
                    {
                        Page.SEDescription = m_T.SEDescription;
                    }
                    if (m_T.SENoScript.Length != 0)
                    {
                        Page.SENoScript = m_T.SENoScript;
                    }
                }
            }
        }