Example #1
0
        private static void PreRequestHandlerExecute(object sender, EventArgs e)
        {
            if (bool.Parse(SettingProvider.GetConfigSettingValue("EnableCompressContent")) == false)
            {
                return;
            }

            var          app      = (HttpApplication)sender;
            HttpRequest  request  = app.Context.Request;
            HttpResponse response = app.Context.Response;

            //if (app.Context.CurrentHandler == null) return;

            //if (!(app.Context.CurrentHandler is Page || app.Context.CurrentHandler.GetType().Name == "SyncSessionlessHandler") || app.Request["http_x_microsoftajax"] != null)
            //{
            //    return;
            //}

            if (request.FilePath == "/" || request.FilePath.Contains(".aspx") || request.FilePath.Contains(".js") || request.FilePath.Contains(".css") || request.FilePath.Contains(".ashx") || request.FilePath.Contains(".tpl"))
            {
                if (request.RawUrl.Contains(".aspx") && request.RawUrl.Contains("TSM_HiddenField"))
                {
                    return;
                }
                if (request.RawUrl.Contains(".js") && request.RawUrl.Contains(".axd"))
                {
                    return;
                }
                if (!(request.Browser.IsBrowser("IE") && request.Browser.MajorVersion <= 6))
                {
                    string acceptEncoding = request.Headers[HttpConstants.HttpAcceptEncoding];
                    if (!string.IsNullOrEmpty(acceptEncoding))
                    {
                        acceptEncoding = acceptEncoding.ToLower(CultureInfo.InvariantCulture);
                        if (acceptEncoding.Contains(HttpConstants.HttpContentEncodingGzip))
                        {
                            response.Filter = new HttpCompressStream(response.Filter, CompressionMode.Compress, HttpCompressStream.CompressionType.GZip);
                            response.AddHeader(HttpConstants.HttpContentEncoding, HttpConstants.HttpContentEncodingGzip);
                        }
                        else if (acceptEncoding.Contains(HttpConstants.HttpContentEncodingDeflate))
                        {
                            response.Filter = new HttpCompressStream(response.Filter, CompressionMode.Compress, HttpCompressStream.CompressionType.Deflate);
                            response.AddHeader(HttpConstants.HttpContentEncoding, HttpConstants.HttpContentEncodingDeflate);
                        }
                    }
                }
                else
                {
                    response.Filter = new HttpCompressStream(response.Filter, CompressionMode.Compress, HttpCompressStream.CompressionType.None);
                }
            }
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CommonHelper.DisableBrowserCache();
            Response.TrySkipIisCustomErrors = true;
            Response.StatusCode             = 500;
            Response.Status = "500 Internal Server Error";

            if (bool.Parse(SettingProvider.GetConfigSettingValue("EnableCompressContent")))
            {
                Response.Filter = new HttpCompressStream(Response.Filter, CompressionMode.Compress,
                                                         HttpCompressStream.CompressionType.GZip);
                Response.AddHeader(HttpConstants.HttpContentEncoding, HttpConstants.HttpContentEncodingGzip);
            }
        }
 protected string GetCssClass()
 {
     if (SettingProvider.GetConfigSettingValue <string>("Version").ToLower().Contains("beta"))
     {
         return("link-feedback-beta");
     }
     if (Demo.IsDemoEnabled)
     {
         return("link-feedback-demo-" + SettingsMain.Language);
     }
     if (TrialService.IsTrialEnabled)
     {
         return("link-feedback-trial-" + SettingsMain.Language);
     }
     return("link-feedback-" + SettingsMain.Language);
 }
Example #4
0
        private static void DeleteFile(PhotoType type, string photoName)
        {
            bool backup = SettingProvider.GetConfigSettingValue <bool>("BackupPhotosBeforeDeleting");

            switch (type)
            {
            case PhotoType.Product:

                if (backup)
                {
                    FileHelpers.BackupFhoto(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.Original, photoName));
                    FileHelpers.BackupFhoto(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.Big, photoName));
                    FileHelpers.BackupFhoto(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.Middle, photoName));
                    FileHelpers.BackupFhoto(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.Small, photoName));
                    FileHelpers.BackupFhoto(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.XSmall, photoName));
                }
                else
                {
                    FileHelpers.DeleteFile(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.Original, photoName));
                    FileHelpers.DeleteFile(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.Big, photoName));
                    FileHelpers.DeleteFile(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.Middle, photoName));
                    FileHelpers.DeleteFile(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.Small, photoName));
                    FileHelpers.DeleteFile(FoldersHelper.GetImageProductPathAbsolut(ProductImageType.XSmall, photoName));
                }
                break;

            case PhotoType.Brand:
                if (backup)
                {
                    FileHelpers.BackupFhoto(FoldersHelper.GetPathAbsolut(FolderType.BrandLogo, photoName));
                }
                else
                {
                    FileHelpers.DeleteFile(FoldersHelper.GetPathAbsolut(FolderType.BrandLogo, photoName));
                }
                break;

            case PhotoType.CategoryBig:
                if (backup)
                {
                    FileHelpers.BackupFhoto(FoldersHelper.GetImageCategoryPathAbsolut(CategoryImageType.Big, photoName));
                }
                else
                {
                    FileHelpers.DeleteFile(FoldersHelper.GetImageCategoryPathAbsolut(CategoryImageType.Big, photoName));
                }
                break;

            case PhotoType.CategorySmall:
                if (backup)
                {
                    FileHelpers.BackupFhoto(FoldersHelper.GetImageCategoryPathAbsolut(CategoryImageType.Small, photoName));
                }
                else
                {
                    FileHelpers.DeleteFile(FoldersHelper.GetImageCategoryPathAbsolut(CategoryImageType.Small, photoName));
                }
                break;

            case PhotoType.CategoryIcon:
                if (backup)
                {
                    FileHelpers.BackupFhoto(FoldersHelper.GetImageCategoryPathAbsolut(CategoryImageType.Icon, photoName));
                }
                else
                {
                    FileHelpers.DeleteFile(FoldersHelper.GetImageCategoryPathAbsolut(CategoryImageType.Icon, photoName));
                }
                break;

            case PhotoType.Carousel:
                if (backup)
                {
                    FileHelpers.BackupFhoto(FoldersHelper.GetPathAbsolut(FolderType.Carousel, photoName));
                }
                else
                {
                    FileHelpers.DeleteFile(FoldersHelper.GetPathAbsolut(FolderType.Carousel, photoName));
                }
                break;

            case PhotoType.News:
                if (backup)
                {
                    FileHelpers.BackupFhoto(FoldersHelper.GetPathAbsolut(FolderType.News, photoName));
                }
                else
                {
                    FileHelpers.DeleteFile(FoldersHelper.GetPathAbsolut(FolderType.News, photoName));
                }
                break;

            case PhotoType.StaticPage:
                if (backup)
                {
                    FileHelpers.BackupFhoto(FoldersHelper.GetPathAbsolut(FolderType.StaticPage, photoName));
                }
                else
                {
                    FileHelpers.DeleteFile(FoldersHelper.GetPathAbsolut(FolderType.StaticPage, photoName));
                }
                break;

            case PhotoType.Shipping:
                if (backup)
                {
                    FileHelpers.BackupFhoto(FoldersHelper.GetPathAbsolut(FolderType.ShippingLogo, photoName));
                }
                else
                {
                    FileHelpers.DeleteFile(FoldersHelper.GetPathAbsolut(FolderType.ShippingLogo, photoName));
                }
                break;

            case PhotoType.Payment:
                if (backup)
                {
                    FileHelpers.BackupFhoto(FoldersHelper.GetPathAbsolut(FolderType.PaymentLogo, photoName));
                }
                else
                {
                    FileHelpers.DeleteFile(FoldersHelper.GetPathAbsolut(FolderType.PaymentLogo, photoName));
                }
                break;

            case PhotoType.MenuIcon:
                if (backup)
                {
                    FileHelpers.BackupFhoto(FoldersHelper.GetPathAbsolut(FolderType.MenuIcons, photoName));
                }
                else
                {
                    FileHelpers.DeleteFile(FoldersHelper.GetPathAbsolut(FolderType.MenuIcons, photoName));
                }
                break;

            case PhotoType.Color:
                if (backup)
                {
                    FileHelpers.BackupFhoto(FoldersHelper.GetImageColorPathAbsolut(ColorImageType.Catalog, photoName));
                    FileHelpers.BackupFhoto(FoldersHelper.GetImageColorPathAbsolut(ColorImageType.Details, photoName));
                }
                else
                {
                    FileHelpers.DeleteFile(FoldersHelper.GetImageColorPathAbsolut(ColorImageType.Catalog, photoName));
                    FileHelpers.DeleteFile(FoldersHelper.GetImageColorPathAbsolut(ColorImageType.Details, photoName));
                }
                break;

            default:
                throw new NotImplementedException();
            }
        }