Exemplo n.º 1
0
        private void LoadSettings()
        {
            config = new XmlConfiguration(Settings);

            if (WebConfigSettings.XmlUseMediaFolder)
            {
                xmlBasePath = "~/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/media/xml/";
                xslBasePath = "~/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/media/xsl/";
            }
            else
            {
                xmlBasePath = "~/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/xml/";
                xslBasePath = "~/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/xsl/";
            }

            if (config.AllowExternalImages) allowedImageUrlRegexPattern = SecurityHelper.RegexAnyImageUrlPatern;
            UntrustedContent1.TrustedImageUrlPattern = allowedImageUrlRegexPattern;
        }
Exemplo n.º 2
0
        private void LoadSettings()
        {
            if (moduleId > -1)
            {
                Hashtable settings = ModuleSettings.GetModuleSettings(moduleId);
                config = new XmlConfiguration(settings);


                if (WebConfigSettings.XmlUseMediaFolder)
                {
                    xmlBasePath = "~/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/media/xml/";
                    xslBasePath = "~/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/media/xsl/";
                }
                else
                {
                    xmlBasePath = "~/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/xml/";
                    xslBasePath = "~/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/xsl/";
                }
            }

            uploader.AcceptFileTypes      = SecurityHelper.GetRegexValidationForAllowedExtensionsJqueryFileUploader("xml|xsl");
            uploader.UploadButtonClientId = btnUpload.ClientID;
            uploader.ServiceUrl           = SiteRoot + "/XmlXsl/uploader.ashx?pageid=" + pageId.ToInvariantString()
                                            + "&mid=" + moduleId.ToInvariantString();
            uploader.FormFieldClientId = hdnState.ClientID; // not really used but prevents submitting all the form

            string refreshFunction = "function refresh" + moduleId.ToInvariantString()
                                     + " () { window.location.reload(true);  } ";

            uploader.UploadCompleteCallback = "refresh" + moduleId.ToInvariantString();

            ScriptManager.RegisterClientScriptBlock(
                this,
                this.GetType(), "refresh" + moduleId.ToInvariantString(),
                refreshFunction,
                true);

            AddClassToBody("xmledit");
        }
Exemplo n.º 3
0
        private void LoadSettings()
        {
            config = new XmlConfiguration(Settings);

            if (WebConfigSettings.XmlUseMediaFolder)
            {
                xmlBasePath = "~/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/media/xml/";
                xslBasePath = "~/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/media/xsl/";
            }
            else
            {
                xmlBasePath = "~/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/xml/";
                xslBasePath = "~/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/xsl/";
            }


            if (config.AllowExternalImages)
            {
                allowedImageUrlRegexPattern = SecurityHelper.RegexAnyImageUrlPatern;
            }
            UntrustedContent1.TrustedImageUrlPattern = allowedImageUrlRegexPattern;
        }
Exemplo n.º 4
0
        private void LoadSettings()
        {
            if (moduleId > -1)
            {
                Hashtable settings = ModuleSettings.GetModuleSettings(moduleId);
                config = new XmlConfiguration(settings);

                if (WebConfigSettings.XmlUseMediaFolder)
                {
                    xmlBasePath = "~/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/media/xml/";
                    xslBasePath = "~/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/media/xsl/";
                }
                else
                {
                    xmlBasePath = "~/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/xml/";
                    xslBasePath = "~/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/xsl/";
                }

            }

            uploader.AcceptFileTypes = SecurityHelper.GetRegexValidationForAllowedExtensionsJqueryFileUploader("xml|xsl");
            uploader.UploadButtonClientId = btnUpload.ClientID;
            uploader.ServiceUrl = SiteRoot + "/XmlXsl/uploader.ashx?pageid=" + pageId.ToInvariantString()
                + "&mid=" + moduleId.ToInvariantString();
            uploader.FormFieldClientId = hdnState.ClientID; // not really used but prevents submitting all the form

            string refreshFunction = "function refresh" + moduleId.ToInvariantString()
                    + " () { window.location.reload(true);  } ";

            uploader.UploadCompleteCallback = "refresh" + moduleId.ToInvariantString();

            ScriptManager.RegisterClientScriptBlock(
                this,
                this.GetType(), "refresh" + moduleId.ToInvariantString(),
                refreshFunction,
                true);

            AddClassToBody("xmledit");
        }
Exemplo n.º 5
0
        public void ProcessRequest(HttpContext context)
        {
            base.Initialize(context);

            if (!UserCanEditModule(ModuleId, XmlConfiguration.FeatureGuid))
            {
                log.Info("User has no edit permission so returning 404");
                Response.StatusCode = 404;
                return;
            }

            if (CurrentSite == null)
            {
                log.Info("CurrentSite is null so returning 404");
                Response.StatusCode = 404;
                return;
            }

            if (CurrentUser == null)
            {
                log.Info("CurrentUser is null so returning 404");
                Response.StatusCode = 404;
                return;
            }

            // this feature only uses the actual system.io file system
            //if (FileSystem == null)
            //{
            //    log.Info("FileSystem is null so returning 404");
            //    Response.StatusCode = 404;
            //    return;
            //}

            if (Request.Files.Count == 0)
            {
                log.Info("Posted File Count is zero so returning 404");
                Response.StatusCode = 404;
                return;
            }

            module = GetModule(ModuleId, XmlConfiguration.FeatureGuid);

            if (module == null)
            {
                log.Info("Module is null so returning 404");
                Response.StatusCode = 404;
                return;
            }

            Hashtable moduleSettings = ModuleSettings.GetModuleSettings(ModuleId);
            config = new XmlConfiguration(moduleSettings);

            HttpPostedFile file = Request.Files[0]; // only expecting one file per post

            string newFileName = Path.GetFileName(file.FileName).ToCleanFileName(WebConfigSettings.ForceLowerCaseForUploadedFiles);

            string ext = Path.GetExtension(file.FileName).ToLowerInvariant();
            if (!SiteUtils.IsAllowedUploadBrowseFile(ext, ".xml|.xsl"))
            {
                log.Info("file extension was " + ext + " so returning 404");
                Response.StatusCode = 404;

                return;
            }

            context.Response.ContentType = "text/plain";//"application/json";
            var r = new System.Collections.Generic.List<UploadFilesResult>();
            JavaScriptSerializer js = new JavaScriptSerializer();

            string destPath;

            switch (ext)
            {
                case ".xml":
                    string xmlBasePath = "~/Data/Sites/" + CurrentSite.SiteId.ToInvariantString() + "/xml/";
                    destPath = Server.MapPath(xmlBasePath + newFileName);

                    if (File.Exists(destPath))
                        {
                            File.Delete(destPath);
                        }

                    file.SaveAs(destPath);

                    break;

                case ".xsl":
                    string xslBasePath = "~/Data/Sites/" + CurrentSite.SiteId.ToInvariantString() + "/xsl/";
                    destPath = Server.MapPath(xslBasePath + newFileName);

                    if (File.Exists(destPath))
                        {
                            File.Delete(destPath);
                        }

                    file.SaveAs(destPath);

                    break;
            }

            r.Add(new UploadFilesResult()
            {
                //Thumbnail_url =
                Name = newFileName,
                Length = file.ContentLength,
                Type = file.ContentType
            });

            var uploadedFiles = new
            {
                files = r.ToArray()
            };

            var jsonObj = js.Serialize(uploadedFiles);
            context.Response.Write(jsonObj.ToString());
        }