protected void Page_Load(object sender, EventArgs e) { guidImportID = GetGuidParameterFromQuery("importid"); iPageCount = pageHelper.GetSitePageCount(SiteID, ContentPageType.PageType.ContentEntry); litTrust.Visible = false; if (SiteData.CurrentTrustLevel != AspNetHostingPermissionLevel.Unrestricted) { chkFileGrab.Checked = false; chkFileGrab.Enabled = false; litTrust.Visible = true; } litMessage.Text = ""; if (guidImportID != Guid.Empty) { wpSite = ContentImportExportUtils.GetSerializedWPExport(guidImportID); litName.Text = wpSite.SiteTitle; litDescription.Text = wpSite.SiteDescription; litImportSource.Text = wpSite.ImportSource; litWXR.Text = wpSite.wxrVersion; litDate.Text = wpSite.ExtractDate.ToString(); if (!IsPostBack) { BuildFolderList(); BindData(); } } }
protected void btnUpload_Click(object sender, EventArgs e) { string sXML = String.Empty; if (upFile.HasFile) { using (StreamReader sr = new StreamReader(upFile.FileContent)) { sXML = sr.ReadToEnd(); } } string sTest = String.Empty; if (!string.IsNullOrEmpty(sXML) && sXML.Length > 500) { sTest = sXML.Substring(0, 250).ToLower(); try { if (sXML.Contains("<channel>") && sXML.Contains("<rss")) { int iChnl = sXML.IndexOf("<channel>"); sTest = sXML.Substring(0, iChnl).ToLower(); } if (sTest.Contains("<!-- this is a wordpress extended rss file generated by wordpress as an export of your") && sTest.Contains("http://purl.org/rss") && sTest.Contains("http://wordpress.org/export")) { WordPressSite wps = ContentImportExportUtils.DeserializeWPExportAll(sXML); ContentImportExportUtils.AssignWPExportNewIDs(SiteData.CurrentSite, wps); ContentImportExportUtils.SaveSerializedDataExport <WordPressSite>(wps.NewSiteID, wps); Response.Redirect(CreateLink("WPGalleryImport", String.Format("id={0}", wps.NewSiteID))); } lblWarning.Text = "File did not appear to match an expected format."; lblWarning.Attributes["style"] = "color: #990000;"; } catch (Exception ex) { lblWarning.Text = ex.ToString(); lblWarning.Attributes["style"] = "color: #990000;"; } } else { lblWarning.Text = "No file appeared in the upload queue."; lblWarning.Attributes["style"] = "color: #990000;"; } }
protected void Page_Load(object sender, EventArgs e) { pnlReview.Visible = false; pnlUpload.Visible = false; litTrust.Visible = false; if (SiteData.CurrentTrustLevel != AspNetHostingPermissionLevel.Unrestricted) { chkFileGrab.Checked = true; chkFileGrab.Enabled = false; litTrust.Visible = true; } if (!string.IsNullOrEmpty(Request.QueryString["id"])) { gTheID = new Guid(Request.QueryString["id"].ToString()); } else { pnlUpload.Visible = true; } lblWarning.Text = String.Empty; lblWarning.Attributes["style"] = "color: #000000;"; if (gTheID != Guid.Empty) { wpSite = ContentImportExportUtils.GetSerializedWPExport(gTheID); } if (!IsPostBack && gTheID != Guid.Empty) { pnlReview.Visible = true; LoadLists(); } }
protected void btnUpload_Click(object sender, EventArgs e) { string sXML = ""; if (upFile.HasFile) { using (StreamReader sr = new StreamReader(upFile.FileContent)) { sXML = sr.ReadToEnd(); } } string sTest = ""; if (!String.IsNullOrEmpty(sXML) && sXML.Length > 500) { sTest = sXML.Substring(0, 250).ToLower(); try { if (sTest.Contains("<contentpageexport xmlns:xsi=\"http://www.w3.org/2001/xmlschema-instance\" xmlns:xsd=\"http://www.w3.org/2001/xmlschema\">")) { ContentPageExport cph = ContentImportExportUtils.DeserializeContentPageExport(sXML); ContentImportExportUtils.AssignContentPageExportNewIDs(cph); ContentImportExportUtils.SaveSerializedDataExport <ContentPageExport>(cph.NewRootContentID, cph); if (cph.ThePage.ContentType == ContentPageType.PageType.ContentEntry) { Response.Redirect(SiteFilename.PageAddEditURL + "?importid=" + cph.NewRootContentID.ToString()); } else { Response.Redirect(SiteFilename.BlogPostAddEditURL + "?importid=" + cph.NewRootContentID.ToString()); } } if (sTest.Contains("<siteexport xmlns:xsi=\"http://www.w3.org/2001/xmlschema-instance\" xmlns:xsd=\"http://www.w3.org/2001/xmlschema\">")) { SiteExport site = ContentImportExportUtils.DeserializeSiteExport(sXML); ContentImportExportUtils.AssignSiteExportNewIDs(site); ContentImportExportUtils.SaveSerializedDataExport <SiteExport>(site.NewSiteID, site); Response.Redirect(SiteFilename.SiteImportURL + "?importid=" + site.NewSiteID.ToString()); } if (sXML.Contains("<channel>") && sXML.Contains("<rss")) { int iChnl = sXML.IndexOf("<channel>"); sTest = sXML.Substring(0, iChnl).ToLower(); } if (sTest.Contains("<!-- this is a wordpress extended rss file generated by wordpress as an export of your") && sTest.Contains("http://purl.org/rss") && sTest.Contains("http://wordpress.org/export")) { WordPressSite wps = ContentImportExportUtils.DeserializeWPExport(sXML); ContentImportExportUtils.AssignWPExportNewIDs(SiteData.CurrentSite, wps); ContentImportExportUtils.SaveSerializedDataExport <WordPressSite>(wps.NewSiteID, wps); Response.Redirect(SiteFilename.WPSiteImportURL + "?importid=" + wps.NewSiteID.ToString()); } lblWarning.Text = "File did not appear to match an expected format."; lblWarning.Attributes["style"] = "color: #990000;"; } catch (Exception ex) { lblWarning.Text = ex.ToString(); lblWarning.Attributes["style"] = "color: #990000;"; } } else { lblWarning.Text = "No file appeared in the upload queue."; lblWarning.Attributes["style"] = "color: #990000;"; } }