Exemplo n.º 1
0
        /// <summary>
        /// Formats and extracts details from an exception for log entry
        /// </summary>
        /// <param name="ex">The exception to format</param>
        /// <returns></returns>
        public static string FormatExceptionForLog(Exception ex)
        {
            try  // Never let logging crash the site!
            {
                StringBuilder details = new StringBuilder();

                try // In case returning the page name fails, still log the rest of the data
                {
                    details.Append("Page URL:" + Security.ScrubCCNumbers(CommonLogic.GetThisPageName(true)) + "\r\n");
                }
                catch { }

                if (ex.InnerException != null)
                {
                    details.Append("Source:" + ex.InnerException.Source + "\r\n");
                    details.Append("Message:" + ex.InnerException.Message + "\r\n");
                    details.Append("Stack Trace: " + "\r\n" + ex.InnerException.StackTrace + "\r\n");
                }
                else
                {
                    details.Append("Source: " + ex.Source + "\r\n");
                    details.Append("Message: " + ex.Message + "\r\n");
                    details.Append("Stack Trace: " + "\r\n" + ex.StackTrace + "\r\n");
                }
                return(details.ToString());
            }
            catch
            {
                return(String.Empty);
            }
        }
Exemplo n.º 2
0
 private static String EnforceBaseURL(String BaseURL)
 {
     if (BaseURL.Length == 0)
     {
         BaseURL = CommonLogic.GetThisPageName(false) + "?" + CommonLogic.ServerVariables("QUERY_STRING");
     }
     return(BaseURL);
 }
Exemplo n.º 3
0
        private static String EnforceBaseURL(String baseURL)
        {
            if (string.IsNullOrEmpty(baseURL))
            {
                baseURL = CommonLogic.GetThisPageName(false) + "?" + CommonLogic.ServerVariables("QUERY_STRING");
            }

            return(baseURL);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Formats and extracts details from an exception for log entry
        /// </summary>
        /// <param name="ex">The exception to format</param>
        /// <returns></returns>
        public static string FormatExceptionForLog(Exception ex)
        {
            try              // Never let logging crash the site!
            {
                StringBuilder details = new StringBuilder();

                try                 // In case returning the page name fails, still log the rest of the data
                {
                    details.Append(AppLogic.GetString("admin.systemlog.PageURL", AppLogic.GetStoreSkinID(AppLogic.StoreID()), Localization.GetDefaultLocale()) + Security.ScrubCCNumbers(CommonLogic.GetThisPageName(true)) + "\r\n");
                }
                catch { }

                if (ex.InnerException != null)
                {
                    details.Append(AppLogic.GetString("admin.systemlog.Source", AppLogic.GetStoreSkinID(AppLogic.StoreID()), Localization.GetDefaultLocale()) + ex.InnerException.Source + "\r\n");
                    details.Append(AppLogic.GetString("admin.systemlog.Message", AppLogic.GetStoreSkinID(AppLogic.StoreID()), Localization.GetDefaultLocale()) + ex.InnerException.Message + "\r\n");
                    details.Append(AppLogic.GetString("admin.systemlog.StackTrace", AppLogic.GetStoreSkinID(AppLogic.StoreID()), Localization.GetDefaultLocale()) + "\r\n" + ex.InnerException.StackTrace + "\r\n");
                }
                else
                {
                    details.Append(AppLogic.GetString("admin.systemlog.Source", AppLogic.GetStoreSkinID(AppLogic.StoreID()), Localization.GetDefaultLocale()) + ex.Source + "\r\n");
                    details.Append(AppLogic.GetString("admin.systemlog.Message", AppLogic.GetStoreSkinID(AppLogic.StoreID()), Localization.GetDefaultLocale()) + ex.Message + "\r\n");
                    details.Append(AppLogic.GetString("admin.systemlog.StackTrace", AppLogic.GetStoreSkinID(AppLogic.StoreID()), Localization.GetDefaultLocale()) + "\r\n" + ex.StackTrace + "\r\n");
                }
                return(details.ToString());
            }
            catch
            {
                return(String.Empty);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Gets the eval data.
        /// </summary>
        /// <param name="expression">The expression.</param>
        /// <param name="target">The target.</param>
        /// <param name="entry">The entry.</param>
        /// <returns></returns>
        public static object GetEvalData(string expression, Type target, string entry)
        {
            Customer ThisCustomer = AppLogic.GetCurrentCustomer();
            bool     IsRegistered = CommonLogic.IIF(ThisCustomer != null, ThisCustomer.IsRegistered, false);

            string[] values  = expression.Split(',');
            string   command = values[0];

            switch (command.ToLowerInvariant())
            {
            case "cartprompt":
                return(AppLogic.GetString("AppConfig.CartPrompt", ThisCustomer.SkinID, ThisCustomer.LocaleSetting));

            case "currency_locale_robots_tag":
                return(CurrencyLocaleRobotsTag(ThisCustomer));

            case "num_cart_items":
                return(NumCartItemsParser(ThisCustomer));

            case "pageinfo":
                return(PageInfoParser(ThisCustomer));

            case "buysafeseal":
                return(BuySafeSealParser(ThisCustomer));

            case "bongoextend":
                return(BongoExtendParser(ThisCustomer));

            case "username":
                return(UserNameParser(ThisCustomer));

            case "signinout_link":
                return(SignInOutLinkParser(ThisCustomer));

            case "signinout_text":
                return(SignInOutTextParser(ThisCustomer));

            case "skinid":
                return(ThisCustomer.SkinID.ToString());

            case "stringresource":
                return(StringResourceParser(ThisCustomer, values));

            case "stringresourceformat":
                return(StringResourceFormatParser(ThisCustomer, values));

            case "appconfig":
                return(AppConfigParser(values));

            case "appconfigbool":
                return(AppConfigBoolParser(values));

            case "appconfigusint":
                return(AppConfigUSIntParser(values));

            case "topic":
                return(TopicParser(ThisCustomer, values));

            case "topictitle":
                return(Topic.GetTitle(values[1].Trim(), ThisCustomer.LocaleSetting, AppLogic.StoreID()));

            case "topiclink":
                return(SE.MakeDriverLink(values[1].Trim()));

            case "xmlpackage":
                if (values.Length >= 2)
                {
                    string xmlPackageName = values[1];
                    string runtimeParams  = values.Length >= 3 ? values[2] : string.Empty;

                    return(RunXmlPackage(ThisCustomer, xmlPackageName.Trim(), runtimeParams.Trim()));
                }
                else
                {
                    return("Invalid number of parameters");
                }


            case "stringformat":
                return(StringFormat(expression));

            case "user_menu_name":
                return(CommonLogic.IIF(!IsRegistered, "my account", ThisCustomer.FullName()));

            case "customerid":
                return(ThisCustomer.CustomerID.ToString());

            case "skinimagedir":
                return(AppLogic.SkinImageDir());

            case "skinimage":
                if (values.Length < 2)
                {
                    return("{Image File name not specified}");
                }
                string imgFile = values[1];
                return(AppLogic.SkinImage(imgFile.Trim()));

            case "adminlink":
                return(AppLogic.AdminLinkUrl(values[1].Trim()));

            case "google_ecom_tracking_v2":
                if (AppLogic.AppConfigBool("Google.DeprecatedEcomTokens.Enabled"))
                {
                    if (CommonLogic.GetThisPageName(false).ToLowerInvariant().StartsWith("orderconfirmation.aspx"))
                    {
                        return(String.Empty);
                    }
                    else
                    {
                        return(AppLogic.GetGoogleEComTrackingV2(ThisCustomer, false));
                    }
                }
                else
                {
                    return(String.Empty);
                }

            case "google_ecom_tracking_asynch":
                if (AppLogic.AppConfigBool("Google.DeprecatedEcomTokens.Enabled"))
                {
                    if (CommonLogic.GetThisPageName(false).ToLowerInvariant().StartsWith("orderconfirmation.aspx") ||
                        CommonLogic.GetThisPageName(false).ToLowerInvariant().StartsWith("mobileorderconfirmation.aspx"))
                    {
                        return(AppLogic.GetGoogleEComTrackingAsynch(ThisCustomer, true));
                    }
                    else
                    {
                        return(AppLogic.GetGoogleEComTrackingAsynch(ThisCustomer, false));
                    }
                }
                else
                {
                    return(String.Empty);
                }

            case "vbv":
                return(VBVParser(ThisCustomer));

            default:
                return(string.Empty);
            }
        }
Exemplo n.º 6
0
        // these can change on EVERY page request!!
        public void BuildPageDynamicTokens()
        {
            if (m_DynamicTokens == null)
            {
                // page/customer specific items (that may change every page):
                m_DynamicTokens = new Hashtable();

                if (CommonLogic.GetThisPageName(false).ToLowerInvariant().StartsWith("orderconfirmation.aspx"))
                {
                    m_DynamicTokens.Add("(!GOOGLE_ECOM_TRACKING!)", AppLogic.GetGoogleEComTracking(ThisCustomer));
                }
                else
                {
                    m_DynamicTokens.Add("(!GOOGLE_ECOM_TRACKING!)", String.Empty);
                }

                if (CommonLogic.GetThisPageName(false).ToLowerInvariant().StartsWith("orderconfirmation.aspx"))
                {
                    m_DynamicTokens.Add("(!GOOGLE_ECOM_TRACKING_V2!)", String.Empty);
                }
                else
                {
                    m_DynamicTokens.Add("(!GOOGLE_ECOM_TRACKING_V2!)", AppLogic.GetGoogleEComTrackingV2(ThisCustomer, false));
                }

                if (!AppLogic.VATIsEnabled())
                {
                    m_DynamicTokens.Add("(!VATREGISTRATIONID!)", String.Empty);
                }
                else
                {
                    StringBuilder tmpS2 = new StringBuilder(1024);
                    if (ThisCustomer.HasCustomerRecord)
                    {
                        tmpS2.Append("<span class=\"VATRegistrationIDPrompt\">" + AppLogic.GetString("setvatsetting.aspx.8", ThisCustomer.SkinID, ThisCustomer.LocaleSetting) + "</span><input type=\"text\" style=\"VATRegistrationID\" id=\"VATRegistrationID\" value=\"" + ThisCustomer.VATRegistrationID + "\">");
                    }
                    m_DynamicTokens.Add("(!VATREGISTRATIONID!)", tmpS2.ToString());
                }

                if (AppLogic.NumLocaleSettingsInstalled() < 2)
                {
                    m_DynamicTokens.Add("(!COUNTRYDIVVISIBILITY!)", "hidden");
                    m_DynamicTokens.Add("(!COUNTRYDIVDISPLAY!)", "none");
                    m_DynamicTokens.Add("(!COUNTRYSELECTLIST!)", String.Empty);
                }
                else
                {
                    m_DynamicTokens.Add("(!COUNTRYDIVVISIBILITY!)", "visible");
                    m_DynamicTokens.Add("(!COUNTRYDIVDISPLAY!)", "inline");
                    m_DynamicTokens.Add("(!COUNTRYSELECTLIST!)", AppLogic.GetCountrySelectList(ThisCustomer.LocaleSetting));
                }

                if (Currency.NumPublishedCurrencies() < 2)
                {
                    m_DynamicTokens.Add("(!CURRENCYDIVVISIBILITY!)", "hidden");
                    m_DynamicTokens.Add("(!CURRENCYDIVDISPLAY!)", "none");
                    m_DynamicTokens.Add("(!CURRENCYSELECTLIST!)", String.Empty);
                }
                else
                {
                    m_DynamicTokens.Add("(!CURRENCYDIVVISIBILITY!)", "visible");
                    m_DynamicTokens.Add("(!CURRENCYDIVDISPLAY!)", "inline");
                    m_DynamicTokens.Add("(!CURRENCYSELECTLIST!)", AppLogic.GetCurrencySelectList(ThisCustomer));
                }

                if (AppLogic.VATIsEnabled() && AppLogic.AppConfigBool("VAT.AllowCustomerToChooseSetting"))
                {
                    m_DynamicTokens.Add("(!VATDIVVISIBILITY!)", "visible");
                    m_DynamicTokens.Add("(!VATDIVDISPLAY!)", "inline");
                    m_DynamicTokens.Add("(!VATSELECTLIST!)", AppLogic.GetVATSelectList(ThisCustomer));
                }
                else
                {
                    m_DynamicTokens.Add("(!VATDIVVISIBILITY!)", "hidden");
                    m_DynamicTokens.Add("(!VATDIVDISPLAY!)", "none");
                    m_DynamicTokens.Add("(!VATSELECTLIST!)", String.Empty);
                }

                if (!ThisCustomer.IsRegistered)
                {
                    m_DynamicTokens.Add("(!SUBSCRIPTION_EXPIRATION!)", AppLogic.ro_NotApplicable);
                }
                else
                {
                    if (ThisCustomer.SubscriptionExpiresOn.Equals(System.DateTime.MinValue))
                    {
                        m_DynamicTokens.Add("(!SUBSCRIPTION_EXPIRATION!)", "Expired");
                    }
                    else
                    {
                        m_DynamicTokens.Add("(!SUBSCRIPTION_EXPIRATION!)", Localization.ToThreadCultureShortDateString(ThisCustomer.SubscriptionExpiresOn));
                    }
                }

                m_DynamicTokens.Add("(!PAGEURL!)", HttpContext.Current.Server.UrlEncode(CommonLogic.GetThisPageName(false) + "?" + CommonLogic.ServerVariables("QUERY_STRING")));
                m_DynamicTokens.Add("(!RANDOM!)", CommonLogic.GetRandomNumber(1, 7).ToString());
                m_DynamicTokens.Add("(!HDRID!)", CommonLogic.GetRandomNumber(1, 7).ToString());
                m_DynamicTokens.Add("(!INVOCATION!)", HttpContext.Current.Server.HtmlEncode(CommonLogic.PageInvocation()));
                m_DynamicTokens.Add("(!REFERRER!)", HttpContext.Current.Server.HtmlEncode(CommonLogic.PageReferrer()));

                StringBuilder tmp = new StringBuilder(4096);
                tmp.Append("<!--\n");
                tmp.Append("PAGE INVOCATION: " + HttpContext.Current.Server.HtmlEncode(CommonLogic.PageInvocation()) + "\n");
                tmp.Append("PAGE REFERRER: " + HttpContext.Current.Server.HtmlEncode(CommonLogic.PageReferrer()) + "\n");
                tmp.Append("STORE LOCALE: " + Localization.GetDefaultLocale() + "\n");
                tmp.Append("STORE CURRENCY: " + Localization.GetPrimaryCurrency() + "\n");
                tmp.Append("CUSTOMER ID: " + ThisCustomer.CustomerID.ToString() + "\n");
                tmp.Append("AFFILIATE ID: " + ThisCustomer.AffiliateID.ToString() + "\n");
                tmp.Append("CUSTOMER LOCALE: " + ThisCustomer.LocaleSetting + "\n");
                tmp.Append("CURRENCY SETTING: " + ThisCustomer.CurrencySetting + "\n");
                tmp.Append("CACHE MENUS: " + AppLogic.AppConfigBool("CacheMenus").ToString() + "\n");
                tmp.Append("-->\n");
                m_DynamicTokens.Add("(!PAGEINFO!)", tmp.ToString());

                bool IsRegistered = CommonLogic.IIF(ThisCustomer != null, ThisCustomer.IsRegistered, false);

                String tmpS = String.Empty;

                if (IsRegistered)
                {
                    if (!AppLogic.IsAdminSite)
                    {
                        tmpS = AppLogic.GetString("skinbase.cs.1", SkinID, ThisCustomer.LocaleSetting) + " <a class=\"username\" href=\"account.aspx\">" + ThisCustomer.FullName() + "</a>" + CommonLogic.IIF(ThisCustomer.CustomerLevelID != 0, "&nbsp;(" + ThisCustomer.CustomerLevelName + ")", "");
                    }
                    m_DynamicTokens.Add("(!USER_NAME!)", tmpS);
                    m_DynamicTokens.Add("(!USERNAME!)", tmpS);
                }
                else
                {
                    m_DynamicTokens.Add("(!USER_NAME!)", String.Empty);
                    m_DynamicTokens.Add("(!USERNAME!)", String.Empty);
                }

                m_DynamicTokens.Add("(!USER_MENU_NAME!)", CommonLogic.IIF(!IsRegistered, "my account", ThisCustomer.FullName()));
                m_DynamicTokens.Add("(!USER_MENU!)", AppLogic.GetUserMenu(ThisCustomer.IsRegistered, SkinID, ThisCustomer.LocaleSetting));
                if (AppLogic.MicropayIsEnabled())
                {
                    tmpS = "Your " + AppLogic.GetString("account.aspx.11", SkinID, ThisCustomer.LocaleSetting) + " balance is: " + Localization.DecimalStringForDB(ThisCustomer.MicroPayBalance);
                    m_DynamicTokens.Add("(!MICROPAY_BALANCE!)", tmpS);
                    m_DynamicTokens.Add("(!MICROPAY_BALANCE_RAW!)", Localization.DecimalStringForDB(ThisCustomer.MicroPayBalance));
                    m_DynamicTokens.Add("(!MICROPAY_BALANCE_CURRENCY!)", ThisCustomer.CurrencyString(ThisCustomer.MicroPayBalance));
                }
                tmpS = ShoppingCart.NumItems(ThisCustomer.CustomerID, CartTypeEnum.ShoppingCart).ToString();
                m_DynamicTokens.Add("(!NUM_CART_ITEMS!)", tmpS);
                tmpS = AppLogic.GetString("AppConfig.CartPrompt", SkinID, ThisCustomer.LocaleSetting);
                m_DynamicTokens.Add("(!CARTPROMPT!)", tmpS);
                tmpS = ShoppingCart.NumItems(ThisCustomer.CustomerID, CartTypeEnum.WishCart).ToString();
                m_DynamicTokens.Add("(!NUM_WISH_ITEMS!)", tmpS);
                tmpS = ShoppingCart.NumItems(ThisCustomer.CustomerID, CartTypeEnum.GiftRegistryCart).ToString();
                m_DynamicTokens.Add("(!NUM_GIFT_ITEMS!)", tmpS);
                tmpS = CommonLogic.IIF(!IsRegistered, AppLogic.GetString("skinbase.cs.4", SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("skinbase.cs.5", SkinID, ThisCustomer.LocaleSetting));
                m_DynamicTokens.Add("(!SIGNINOUT_TEXT!)", tmpS);
                m_DynamicTokens.Add("(!SIGNINOUT_LINK!)", CommonLogic.IIF(!IsRegistered, "signin.aspx", "signout.aspx"));
                String PN = CommonLogic.GetThisPageName(false);
                if (AppLogic.AppConfigBool("ShowMiniCart"))
                {
                    if (PN.StartsWith("shoppingcart", StringComparison.InvariantCultureIgnoreCase) || PN.StartsWith("checkout", StringComparison.InvariantCultureIgnoreCase) || PN.StartsWith("cardinal", StringComparison.InvariantCultureIgnoreCase) || PN.StartsWith("addtocart") || PN.IndexOf("_process", StringComparison.InvariantCultureIgnoreCase) != -1 || PN.StartsWith("lat_", StringComparison.InvariantCultureIgnoreCase))
                    {
                        m_DynamicTokens.Add("(!MINICART!)", String.Empty); // don't show on these pages
                    }
                    else
                    {
                        m_DynamicTokens.Add("(!MINICART!)", ShoppingCart.DisplayMiniCart(ThisCustomer, SkinID, true));
                    }
                    if (PN.StartsWith("shoppingcart", StringComparison.InvariantCultureIgnoreCase) || PN.StartsWith("checkout", StringComparison.InvariantCultureIgnoreCase) || PN.StartsWith("cardinal", StringComparison.InvariantCultureIgnoreCase) || PN.StartsWith("addtocart", StringComparison.InvariantCultureIgnoreCase) || PN.IndexOf("_process", StringComparison.InvariantCultureIgnoreCase) != -1 || PN.StartsWith("lat_", StringComparison.InvariantCultureIgnoreCase))
                    {
                        m_DynamicTokens.Add("(!MINICART_PLAIN!)", String.Empty); // don't show on these pages
                    }
                    else
                    {
                        m_DynamicTokens.Add("(!MINICART_PLAIN!)", ShoppingCart.DisplayMiniCart(ThisCustomer, SkinID, false));
                    }
                }
                m_DynamicTokens.Add("(!CUSTOMERID!)", ThisCustomer.CustomerID.ToString());
            }
        }