public static XmlReader CreateXmlReader(string xmlsrc, int portalId, bool prohibitDtd) { if (xmlsrc == String.Empty) return null; var filecontroller = new FileController(); var xmlFileInfo = filecontroller.GetFileById(filecontroller.ConvertFilePathToFileId(xmlsrc, portalId), portalId); return XmlReader.Create(FileSystemUtils.GetFileStream(xmlFileInfo), new XmlReaderSettings {ProhibitDtd = prohibitDtd}); }
protected void Page_Load(object sender, System.EventArgs e) { try { string renderUrl = Request.QueryString["rurl"]; if (! (string.IsNullOrEmpty(renderUrl))) { string fileContents = string.Empty; FileController fileCtrl = new FileController(); FileInfo fileInfo = null; int portalID = PortalController.GetCurrentPortalSettings().PortalId; if (renderUrl.ToLower().Contains("linkclick.aspx") && renderUrl.ToLower().Contains("fileticket")) { //File Ticket int fileID = GetFileIDFromURL(renderUrl); if (fileID > -1) { fileInfo = fileCtrl.GetFileById(fileID, portalID); } } else { //File URL string dbPath = (string)(string)FileSystemValidation.ToDBPath(renderUrl); string fileName = System.IO.Path.GetFileName(renderUrl); if (! (string.IsNullOrEmpty(fileName))) { FolderInfo dnnFolder = GetDNNFolder(dbPath); if (dnnFolder != null) { fileInfo = fileCtrl.GetFile(fileName, portalID, dnnFolder.FolderID); } } } if (fileInfo != null) { if (CanViewFile(fileInfo.Folder) && fileInfo.Extension.ToLower() == "htmtemplate") { byte[] fileBytes = FileSystemUtils.GetFileContent(fileInfo); fileContents = System.Text.Encoding.ASCII.GetString(fileBytes); } } if (! (string.IsNullOrEmpty(fileContents))) { Content.Text = Server.HtmlEncode(fileContents); } } } catch (Exception ex) { Services.Exceptions.Exceptions.LogException(ex); Content.Text = string.Empty; } }
/// <summary> /// Streams a file to the output stream if the user has the proper permissions /// </summary> /// <param name="PortalId">The Id of the Portal to which the file belongs</param> /// <param name="FileId">FileId identifying file in database</param> /// <param name="ClientCache">Cache file in client browser - true/false</param> /// <param name="ForceDownload">Force Download File dialog box - true/false</param> public static bool DownloadFile( int PortalId, int FileId, bool ClientCache, bool ForceDownload ) { bool blnDownload = false; // get file FileController objFiles = new FileController(); Services.FileSystem.FileInfo objFile = objFiles.GetFileById( FileId, PortalId ); if( objFile != null ) { // check folder view permissions if( PortalSecurity.IsInRoles( GetRoles( objFile.Folder, PortalId, "READ" ) ) ) { // auto sync bool blnFileExists = true; if( HostSettings.GetHostSetting( "EnableFileAutoSync" ) != "N" ) { string strFile = ""; if( objFile.StorageLocation == (int)FolderController.StorageLocationTypes.InsecureFileSystem ) { strFile = objFile.PhysicalPath; } else if( objFile.StorageLocation == (int)FolderController.StorageLocationTypes.SecureFileSystem ) { strFile = objFile.PhysicalPath + Globals.glbProtectedExtension; } if( strFile != "" ) { // synchronize file FileInfo objFileInfo = new FileInfo( strFile ); if( objFileInfo.Exists ) { if( objFile.Size != objFileInfo.Length ) { objFile.Size = Convert.ToInt32( objFileInfo.Length ); UpdateFileData( FileId, objFile.FolderId, PortalId, objFile.FileName, objFile.Extension, GetContentType( objFile.Extension ), objFileInfo.Length, objFile.Folder ); } } else // file does not exist { RemoveOrphanedFile( objFile, PortalId ); blnFileExists = false; } } } // download file if( blnFileExists ) { // save script timeout int scriptTimeOut = HttpContext.Current.Server.ScriptTimeout; // temporarily set script timeout to large value ( this value is only applicable when application is not running in Debug mode ) HttpContext.Current.Server.ScriptTimeout = int.MaxValue; HttpResponse objResponse = HttpContext.Current.Response; objResponse.ClearContent(); objResponse.ClearHeaders(); // force download dialog if( ForceDownload || objFile.Extension.ToLower().Equals( "pdf" ) ) { objResponse.AppendHeader( "content-disposition", "attachment; filename=" + objFile.FileName ); } else { //use proper file name when browser forces download because of file type (save as name should match file name) objResponse.AppendHeader( "content-disposition", "inline; filename=" + objFile.FileName ); } objResponse.AppendHeader( "Content-Length", objFile.Size.ToString() ); objResponse.ContentType = GetContentType( objFile.Extension.Replace( ".", "" ) ); //Stream the file to the response Stream objStream = GetFileStream( objFile ); try { WriteStream( objResponse, objStream ); } catch( Exception ex ) { // Trap the error, if any. objResponse.Write( "Error : " + ex.Message ); } finally { if( objStream != null ) { // Close the file. objStream.Close(); } } objResponse.Flush(); objResponse.Close(); blnDownload = true; } } } return blnDownload; }
private static string UpdateFileData( int fileID, int folderID, int PortalId, string fileName, string extension, string contentType, long length, string folderName ) { string retvalue = ""; try { FileController objFileController = new FileController(); Image imgImage = null; int imageWidth = 0; int imageHeight = 0; // HACK : VB version of this line used InStr() and converted the outputed // int to a boolean to check if the file extention was an image type, // which does not work in C# hence the line as it is now. if((Globals.glbImageFileTypes.IndexOf(extension.ToLower())+1) > 0) { try { Services.FileSystem.FileInfo objFile = objFileController.GetFileById( fileID, PortalId ); Stream imageStream = GetFileStream( objFile ); imgImage = Image.FromStream( imageStream ); imageHeight = imgImage.Height; imageWidth = imgImage.Width; imgImage.Dispose(); imageStream.Close(); } catch { // error loading image file contentType = "application/octet-stream"; } finally { //Update the File info objFileController.UpdateFile( fileID, fileName, extension, length, imageWidth, imageHeight, contentType, folderName, folderID ); } } } catch( Exception ex ) { retvalue = ex.Message; } return retvalue; }
/// <summary> /// Binds the data. /// </summary> public void BindData() { this.LoadFolders(); this.Files.Items.Clear(); this.Files.DataSource = this.GetFileList(true); this.Files.DataBind(); this.ReloadFiles = false; var _url = Convert.ToString(this.ViewState["Url"]); if (string.IsNullOrEmpty(_url)) { return; } var _urltype = DotNetNuke.Common.Globals.GetURLType(_url).ToString("g").Substring(0, 1); if (_urltype == "F") { var files = new FileController(); if (_url.ToLower().StartsWith("fileid=")) { FileInfo objFile = files.GetFileById(int.Parse(_url.Substring(7)), this.PortalId); if (objFile != null) { _url = objFile.Folder + objFile.FileName; var fileName = _url.Substring(_url.LastIndexOf("/", StringComparison.Ordinal) + 1); var folderPath = _url.Replace(fileName, string.Empty); if (this.Folders.Items.FindByValue(folderPath) != null) { this.Folders.ClearSelection(); this.Folders.Items.FindByValue(folderPath).Selected = true; } else if (this.Folders.Items.Count > 0) { this.Folders.ClearSelection(); this.Folders.Items[0].Selected = true; } if (this.Files.Items.FindByText(fileName) != null) { this.Files.ClearSelection(); this.Files.Items.FindByText(fileName).Selected = true; } } } } this.ViewState["Url"] = _url; }
/// <summary> /// Format the Url from FileID to File Path Url /// </summary> /// <param name="sInputUrl"> /// The s Input Url. /// </param> /// <returns> /// The format url. /// </returns> private string FormatUrl(string sInputUrl) { string sImageUrl = string.Empty; if (sInputUrl.Equals(string.Empty)) { return sImageUrl; } if (sInputUrl.StartsWith("http://")) { sImageUrl = sInputUrl; } else if (sInputUrl.StartsWith("FileID=")) { int iFileId = int.Parse(sInputUrl.Substring(7)); FileController objFileController = new FileController(); FileInfo objFileInfo = objFileController.GetFileById(iFileId, this._portalSettings.PortalId); sImageUrl = this._portalSettings.HomeDirectory + objFileInfo.Folder + objFileInfo.FileName; } return sImageUrl; }
private void Page_Load(object sender, EventArgs e) { //PortalSettings ps = (PortalSettings)HttpContext.Current.Items["PortalSettings"]; PortalSettings ps = Utility.GetPortalSettings(PortalId); Response.ContentType = "text/xml"; Response.ContentEncoding = Encoding.UTF8; var sw = new StringWriter(CultureInfo.InvariantCulture); var wr = new XmlTextWriter(sw); wr.WriteStartElement("rss"); wr.WriteAttributeString("version", "2.0"); wr.WriteAttributeString("xmlns:wfw", "http://wellformedweb.org/CommentAPI/"); wr.WriteAttributeString("xmlns:slash", "http://purl.org/rss/1.0/modules/slash/"); wr.WriteAttributeString("xmlns:dc", "http://purl.org/dc/elements/1.1/"); wr.WriteAttributeString("xmlns:trackback", "http://madskills.com/public/xml/rss/module/trackback/"); wr.WriteStartElement("channel"); wr.WriteElementString("title", ps.PortalName); if (ps.PortalAlias.HTTPAlias.IndexOf("http://", StringComparison.OrdinalIgnoreCase) == -1) { wr.WriteElementString("link", "http://" + ps.PortalAlias.HTTPAlias); } else { wr.WriteElementString("link", ps.PortalAlias.HTTPAlias); } wr.WriteElementString("description", "RSS Feed for " + ps.PortalName); wr.WriteElementString("ttl", "120"); //TODO: look into options for how to display the "Title" of the RSS feed var dt = new DataTable {Locale = CultureInfo.InvariantCulture}; if (DisplayType == "ItemListing" || DisplayType == null) { dt = ItemId == -1 ? DataProvider.Instance().GetMostRecent(ItemTypeId, NumberOfItems, PortalId) : DataProvider.Instance().GetMostRecentByCategoryId(ItemId, ItemTypeId, NumberOfItems, PortalId); } else if (DisplayType == "CategoryFeature") { DataSet ds = DataProvider.Instance().GetParentItems(ItemId, PortalId, RelationshipTypeId); dt = ds.Tables[0]; } else if (DisplayType == "TagFeed") { if (AllowTags && _tagQuery != null && _tagQuery.Count > 0) { string tagCacheKey = Utility.CacheKeyPublishTag + PortalId + ItemTypeId.ToString(CultureInfo.InvariantCulture) + _qsTags; // +"PageId"; dt = DataCache.GetCache(tagCacheKey) as DataTable; if (dt == null) { //ToDo: we need to make getitemsfromtags use the numberofitems value dt = Tag.GetItemsFromTags(PortalId, _tagQuery); //TODO: we should sort the tags //TODO: should we set a 5 minute cache on RSS? DataCache.SetCache(tagCacheKey, dt, DateTime.Now.AddMinutes(5)); Utility.AddCacheKey(tagCacheKey, PortalId); } } } if (dt != null) { DataView dv = dt.DefaultView; if (dv.Table.Columns.IndexOf("dateColumn") > 0) { dv.Table.Columns.Add("dateColumn", typeof(DateTime)); foreach (DataRowView dr in dv) { dr["dateColumn"] = Convert.ToDateTime(dr["startdate"]); } dv.Sort = " dateColumn desc "; } for (int i = 0; i < dv.Count; i++) { //DataRow r = dt.Rows[i]; DataRow r = dv[i].Row; wr.WriteStartElement("item"); // wr.WriteElementString("slash:comments", objArticle.CommentCount.ToString()); // wr.WriteElementString("wfw:commentRss", "http://" & Request.Url.Host & Me.ResolveUrl("RssComments.aspx?TabID=" & m_tabID & "&ModuleID=" & m_moduleID & "&ArticleID=" & objArticle.ArticleID.ToString()).Replace(" ", "%20")); // wr.WriteElementString("trackback:ping", "http://" & Request.Url.Host & Me.ResolveUrl("Tracking/Trackback.aspx?ArticleID=" & objArticle.ArticleID.ToString() & "&PortalID=" & _portalSettings.PortalId.ToString() & "&TabID=" & _portalSettings.ActiveTab.TabID.ToString()).Replace(" ", "%20")); string title = String.Empty, description = String.Empty, childItemId = String.Empty, thumbnail = String.Empty, guid = String.Empty, author = string.Empty; DateTime startDate = DateTime.MinValue; if (DisplayType == null || string.Equals(DisplayType, "ItemListing", StringComparison.OrdinalIgnoreCase) || string.Equals(DisplayType, "TagFeed", StringComparison.OrdinalIgnoreCase)) { title = r["ChildName"].ToString(); description = r["ChildDescription"].ToString(); childItemId = r["ChilditemId"].ToString(); guid = r["itemVersionIdentifier"].ToString(); startDate = (DateTime)r["StartDate"]; thumbnail = r["Thumbnail"].ToString(); author = r["Author"].ToString(); //UserController uc = new UserController(); //UserInfo ui = uc.GetUser(PortalId, Convert.ToInt32(r["AuthorUserId"].ToString())); //if(ui!=null) //author = ui.DisplayName; } else if (string.Equals(DisplayType, "CategoryFeature", StringComparison.OrdinalIgnoreCase)) { title = r["Name"].ToString(); description = r["Description"].ToString(); childItemId = r["itemId"].ToString(); guid = r["itemVersionIdentifier"].ToString(); startDate = (DateTime)r["StartDate"]; thumbnail = r["Thumbnail"].ToString(); author = r["Author"].ToString(); //UserController uc = new UserController(); //UserInfo ui = uc.GetUser(PortalId, Convert.ToInt32(r["AuthorUserId"].ToString())); //if (ui != null) //author = ui.DisplayName; } if (!Uri.IsWellFormedUriString(thumbnail, UriKind.Absolute) && thumbnail!=string.Empty) { var thumnailLink = new Uri(Request.Url, ps.HomeDirectory + thumbnail); thumbnail = thumnailLink.ToString(); } wr.WriteElementString("title", title); //if the item isn't disabled add the link if (!Utility.IsDisabled(Convert.ToInt32(childItemId, CultureInfo.InvariantCulture), PortalId)) { wr.WriteElementString("link", Utility.GetItemLinkUrl(childItemId, PortalId)); } //wr.WriteElementString("description", Utility.StripTags(this.Server.HtmlDecode(description))); description = Utility.ReplaceTokens(description); wr.WriteElementString("description", Server.HtmlDecode(description)); //wr.WriteElementString("author", Utility.StripTags(this.Server.HtmlDecode(author))); wr.WriteElementString("thumbnail", thumbnail); wr.WriteElementString("dc:creator", author); wr.WriteElementString("pubDate", startDate.ToUniversalTime().ToString("r", CultureInfo.InvariantCulture)); //file attachment enclosure ItemVersionSetting attachmentSetting = ItemVersionSetting.GetItemVersionSetting(Convert.ToInt32(r["ItemVersionId"].ToString()), "ArticleSettings", "ArticleAttachment", PortalId); if (attachmentSetting != null) { if (attachmentSetting.PropertyValue.Length > 7) { var fileController = new FileController(); int fileId = Convert.ToInt32(attachmentSetting.PropertyValue.Substring(7)); DotNetNuke.Services.FileSystem.FileInfo fi = fileController.GetFileById(fileId, PortalId); string fileurl = "http://" + PortalSettings.PortalAlias.HTTPAlias + PortalSettings.HomeDirectory + fi.Folder + fi.FileName; wr.WriteStartElement("enclosure"); wr.WriteAttributeString("url", fileurl); wr.WriteAttributeString("length",fi.Size.ToString()); wr.WriteAttributeString("type", fi.ContentType); wr.WriteEndElement(); } } wr.WriteStartElement("guid"); wr.WriteAttributeString("isPermaLink", "false"); wr.WriteString(guid); //wr.WriteString(itemVersionId); wr.WriteEndElement(); wr.WriteEndElement(); } } wr.WriteEndElement(); wr.WriteEndElement(); Response.Write(sw.ToString()); }
public string GetProperty(string strPropertyName, string strFormat, CultureInfo formatProvider, UserInfo AccessingUser, Scope AccessLevel, ref bool PropertyNotFound) { PortalSettings portalSettings = PortalController.GetCurrentPortalSettings(); string outputFormat = strFormat == string.Empty ? "D" : strFormat; switch (strPropertyName.ToLowerInvariant()) { case "edit": if (IsEditable) { string editUrl = Globals.NavigateURL(portalSettings.ActiveTab.TabID, false, portalSettings, "Edit", CultureInfo.CurrentCulture.Name, "mid=" + ModuleID.ToString(CultureInfo.InvariantCulture), "itemid=" + ItemID.ToString(CultureInfo.InvariantCulture)); if (portalSettings.EnablePopUps) { editUrl = UrlUtils.PopUpUrl(editUrl, null, portalSettings, false, false); } return "<a href=\"" + editUrl + "\"><img border=\"0\" src=\"" + Globals.ApplicationPath + "/icons/sigma/Edit_16X16_Standard_2.png\" alt=\"" + Localization.GetString("EditAnnouncement.Text", _localResourceFile) + "\" /></a>"; } return string.Empty; case "itemid": return (ItemID.ToString(outputFormat, formatProvider)); case "moduleid": return (ModuleID.ToString(outputFormat, formatProvider)); case "title": return PropertyAccess.FormatString(Title, strFormat); case "url": return PropertyAccess.FormatString(string.IsNullOrEmpty(URL) ? URL : Utilities.FormatUrl(URL, portalSettings.ActiveTab.TabID, ModuleID, TrackClicks), strFormat); case "description": return HttpUtility.HtmlDecode(Description); case "imagesource": case "rawimage": string strValue = ImageSource; if (strPropertyName.ToLowerInvariant() == "imagesource" && string.IsNullOrEmpty(strFormat)) { strFormat = "<img src=\"{0}\" alt=\"" + Title + "\" />"; } //Retrieve the path to the imagefile if (strValue != "") { //Get path from filesystem only when the image comes from within DNN. // this is now legacy, from version 7.0.0, a real filename is saved in the DB if (ImageSource.StartsWith("FileID=")) { var fileCnt = new FileController(); FileInfo objFile = fileCnt.GetFileById(Convert.ToInt32(strValue.Substring(7)), portalSettings.PortalId); if (objFile != null) { strValue = portalSettings.HomeDirectory + objFile.Folder + objFile.FileName; } else { strValue = ""; } } else { if (!ImageSource.ToLowerInvariant().StartsWith("http")) { strValue = portalSettings.HomeDirectory + ImageSource; } } strValue = PropertyAccess.FormatString(strValue, strFormat); } return strValue; case "vieworder": return (ViewOrder.ToString(outputFormat, formatProvider)); case "createdbyuserid": return (CreatedByUserID.ToString(outputFormat, formatProvider)); case "createdbyuser": UserInfo tmpUser = CreatedByUser(portalSettings.PortalId); return tmpUser != null ? tmpUser.DisplayName : Localization.GetString("userUnknown.Text", _localResourceFile); case "lastmodifiedbyuserid": return (LastModifiedByUserID.ToString(outputFormat, formatProvider)); case "lastmodifiedbyuser": UserInfo tmpUser2 = LastModifiedByUser(portalSettings.PortalId); return tmpUser2 != null ? tmpUser2.DisplayName : Localization.GetString("userUnknown.Text", _localResourceFile); case "trackclicks": return (PropertyAccess.Boolean2LocalizedYesNo(TrackClicks, formatProvider)); case "newwindow": return NewWindow ? "_blank" : "_self"; case "createddate": case "createdondate": return (CreatedOnDate.ToString(outputFormat, formatProvider)); case "lastmodifiedondate": return (LastModifiedOnDate.ToString(outputFormat, formatProvider)); case "publishdate": return PublishDate.HasValue ? (PublishDate.Value.ToString(outputFormat, formatProvider)) : ""; case "expiredate": return ExpireDate.HasValue ? (ExpireDate.Value.ToString(outputFormat, formatProvider)) : ""; case "more": return Localization.GetString("More.Text", _localResourceFile); case "readmore": string strTarget = NewWindow ? "_new" : "_self"; return !(string.IsNullOrEmpty(URL)) ? "<a href=\"" + Utilities.FormatUrl(URL, portalSettings.ActiveTab.TabID, ModuleID, TrackClicks) + "\" target=\"" + strTarget + "\">" + Localization.GetString("More.Text", _localResourceFile) + "</a>" : ""; case "permalink": return Permalink(); case "subscribe": default: PropertyNotFound = true; break; } return Null.NullString; }
/// <summary> /// Import Current Settings /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Import_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.ImportFile.Url)) { return; } string sXmlImport = this.ImportFile.Url; this.upOptions.Update(); // RESET Dialog this.ImportFile.Url = null; int imageFileId = int.Parse(sXmlImport.Substring(7)); FileController objFileController = new FileController(); FileInfo objFileInfo = objFileController.GetFileById(imageFileId, this._portalSettings.PortalId); sXmlImport = this._portalSettings.HomeDirectoryMapPath + objFileInfo.Folder + objFileInfo.FileName; try { this.ImportXmlFile(sXmlImport); this.ShowNotification(Localization.GetString("Imported.Text", this.ResXFile, this.LangCode), "success"); } catch (Exception) { this.ShowNotification( Localization.GetString("BadImportXml.Text", this.ResXFile, this.LangCode), "error"); } }
private string GetImageThumbnail(int fileId) { string thumbnail = ""; if (Settings_Portal.General.FileStorage == LocalUtils.FileStorage_Local) { FileController ctlFile = new FileController(); DotNetNuke.Services.FileSystem.FileInfo objFile = new DotNetNuke.Services.FileSystem.FileInfo(); DotNetNuke.Entities.Portals.PortalController ctlPortal = new DotNetNuke.Entities.Portals.PortalController(); DotNetNuke.Entities.Portals.PortalInfo pi = ctlPortal.GetPortal(PortalId); objFile = ctlFile.GetFileById(fileId, PortalId); if (objFile != null && File.Exists(objFile.PhysicalPath)) { System.IO.FileInfo objPhysical = new System.IO.FileInfo(objFile.PhysicalPath); if (File.Exists(objPhysical.DirectoryName + "\\" + "thumb_" + objPhysical.Name))//Find if exist thumbnail image { thumbnail = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + objFile.Folder + "thumb_" + objFile.FileName; } } } if (Settings_Portal.General.FileStorage == LocalUtils.FileStorage_A3) { A3FileInfo objA3File = A3FileController.Get(fileId); if (objA3File != null) { if (A3FileController.GetByA3Key(GetA3FilePrefix(objA3File.FolderId) + "thumb_" + objA3File.FileName) != null) { thumbnail = A3FileController.GetByA3Key(GetA3FilePrefix(objA3File.FolderId) + "thumb_" + objA3File.FileName).A3Url; } } } return thumbnail; }
private string GetVideoThumbnail(int fileId) { string thumbnail = ""; if (Settings_Portal.General.FileStorage == LocalUtils.FileStorage_Local) { FileController ctlFile = new FileController(); DotNetNuke.Services.FileSystem.FileInfo objFile = new DotNetNuke.Services.FileSystem.FileInfo(); DotNetNuke.Entities.Portals.PortalController ctlPortal = new DotNetNuke.Entities.Portals.PortalController(); DotNetNuke.Entities.Portals.PortalInfo pi = ctlPortal.GetPortal(PortalId); objFile = ctlFile.GetFileById(fileId, PortalId); if (objFile != null && File.Exists(objFile.PhysicalPath)) { System.IO.FileInfo objPhysical = new System.IO.FileInfo(objFile.PhysicalPath); if (File.Exists(objPhysical.DirectoryName + "\\" + "thumb_" + objPhysical.Name.Replace(objPhysical.Extension, ".jpg")))//Find if exist thumbnail image { thumbnail = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + objFile.Folder + "thumb_" + objFile.FileName.Replace(objPhysical.Extension, ".jpg"); return thumbnail; } if (File.Exists(objPhysical.DirectoryName + "\\" + objPhysical.Name.Replace(objPhysical.Extension, ".jpg")))//Find if exist same name image { thumbnail = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + objFile.Folder + objFile.FileName.Replace(objPhysical.Extension, ".jpg"); return thumbnail; } if (Settings_Portal.Video.VideoConvert && Settings_Portal.Video.PassPermissionCheck)// 如果同名的jpg文件不存在,则试图生成一个 { Cross.DNN.Common.VideoManage.VideoManageOption option = new Cross.DNN.Common.VideoManage.VideoManageOption(); option.General.FFMPEGPath = VideoConvert_ExecuteFolder + "\\ffmpeg\\ffmpeg.exe"; option.General.FLVToolPath = VideoConvert_ExecuteFolder + "\\ffmpeg\\flvtool2.exe"; option.General.MencoderPath = VideoConvert_ExecuteFolder + "\\mencoder\\mencoder.exe"; option.General.MencoderDirectory = VideoConvert_ExecuteFolder + "\\mencoder"; option.General.InputPath = objPhysical.Directory.FullName; option.General.OutputPath = objPhysical.Directory.FullName; option.Video.ExitProcess = Settings_Portal.Video.ProcessExitTime; option.General.FileName = objPhysical.Name; Cross.DNN.Common.VideoManage.VideoController ctlVideo = new Cross.DNN.Common.VideoManage.VideoController(option); if (File.Exists(option.General.FFMPEGPath))//First we need check if execute package available { ctlVideo.CaptureSingleImage(); thumbnail = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + objFile.Folder + objFile.FileName.Replace(objPhysical.Extension, ".jpg"); return thumbnail; } } } } if (Settings_Portal.General.FileStorage == LocalUtils.FileStorage_A3) { A3FileInfo objA3File = A3FileController.Get(fileId); if (objA3File != null) { if (A3FileController.GetByA3Key(GetA3FilePrefix(objA3File.FolderId) + "thumb_" + objA3File.FileName.Replace(objA3File.Extension, ".jpg")) != null) { thumbnail = A3FileController.GetByA3Key(GetA3FilePrefix(objA3File.FolderId) + "thumb_" + objA3File.FileName.Replace(objA3File.Extension, ".jpg")).A3Url; } else { if (A3FileController.GetByA3Key(GetA3FilePrefix(objA3File.FolderId) + objA3File.FileName.Replace(objA3File.Extension, ".jpg")) != null) { thumbnail = A3FileController.GetByA3Key(GetA3FilePrefix(objA3File.FolderId) + objA3File.FileName.Replace(objA3File.Extension, ".jpg")).A3Url; } } } } return thumbnail; }
private string GetVideoDuration(int fileId) { string duration = ""; if (Settings_Portal.General.FileStorage == LocalUtils.FileStorage_Local) { FileController ctlFile = new FileController(); DotNetNuke.Services.FileSystem.FileInfo objFile = new DotNetNuke.Services.FileSystem.FileInfo(); DotNetNuke.Entities.Portals.PortalController ctlPortal = new DotNetNuke.Entities.Portals.PortalController(); DotNetNuke.Entities.Portals.PortalInfo pi = ctlPortal.GetPortal(PortalId); objFile = ctlFile.GetFileById(fileId, PortalId); if (objFile != null && System.IO.File.Exists(objFile.PhysicalPath)) { System.IO.FileInfo objPhysical = new System.IO.FileInfo(objFile.PhysicalPath); if (Settings_Portal.Video.VideoConvert && Settings_Portal.Video.PassPermissionCheck) { Cross.DNN.Common.VideoManage.VideoManageOption option = new Cross.DNN.Common.VideoManage.VideoManageOption(); option.General.FFMPEGPath = VideoConvert_ExecuteFolder + "\\ffmpeg\\ffmpeg.exe"; option.General.FLVToolPath = VideoConvert_ExecuteFolder + "\\ffmpeg\\flvtool2.exe"; option.General.MencoderPath = VideoConvert_ExecuteFolder + "\\mencoder\\mencoder.exe"; option.General.MencoderDirectory = VideoConvert_ExecuteFolder + "\\mencoder"; option.General.InputPath = objPhysical.Directory.FullName; option.General.OutputPath = objPhysical.Directory.FullName; option.Video.ExitProcess = Settings_Portal.Video.ProcessExitTime; option.General.FileName = objPhysical.Name; Cross.DNN.Common.VideoManage.VideoController ctlVideo = new Cross.DNN.Common.VideoManage.VideoController(option); duration = ctlVideo.Get_Info().Duration; } } } if (Settings_Portal.General.FileStorage == LocalUtils.FileStorage_A3) { A3FileInfo objA3File = A3FileController.Get(fileId); if (objA3File != null) { duration = objA3File.Duration; } } return duration.Trim(); }
private string GetFileFullUrl(int fileId) { string url = ""; if (Settings_Portal.General.FileStorage.ToLower() == "local") { FileController ctlFile = new FileController(); DotNetNuke.Services.FileSystem.FileInfo objFile = new DotNetNuke.Services.FileSystem.FileInfo(); DotNetNuke.Entities.Portals.PortalController ctlPortal = new DotNetNuke.Entities.Portals.PortalController(); DotNetNuke.Entities.Portals.PortalInfo pi = ctlPortal.GetPortal(PortalSettings.PortalId); objFile = ctlFile.GetFileById(fileId, PortalSettings.PortalId); if (objFile != null) { url = DotNetNuke.Common.Globals.ApplicationPath + "/" + pi.HomeDirectory + "/" + objFile.Folder + objFile.FileName; } } if (Settings_Portal.General.FileStorage.ToLower() == "a3") { if (A3FileController.Get(fileId) != null) { url = A3FileController.Get(fileId).A3Url; } } return url; }
private void ShowControls() { UrlController objUrls = new UrlController(); // set url type if (optType.SelectedItem == null) { if (!String.IsNullOrEmpty(_Url)) { string TrackingUrl = _Url; _UrlType = Globals.GetURLType(_Url).ToString("g").Substring(0, 1); if (_UrlType == "F") { FileController objFiles = new FileController(); if (_Url.ToLower().StartsWith("fileid=")) { TrackingUrl = _Url; FileInfo objFile = objFiles.GetFileById(int.Parse(_Url.Substring(7)), _objPortal.PortalID); if (objFile != null) { _Url = objFile.Folder + objFile.FileName; } } else { // to handle legacy scenarios before the introduction of the FileServerHandler TrackingUrl = "FileID=" + objFiles.ConvertFilePathToFileId(_Url, _objPortal.PortalID); } } if (_UrlType == "M") { if (_Url.ToLower().StartsWith("userid=")) { UserInfo objUser = UserController.GetUser(_objPortal.PortalID, int.Parse(_Url.Substring(7)), false); if (objUser != null) { _Url = objUser.Username; } } } UrlTrackingInfo objUrlTracking = objUrls.GetUrlTracking(_objPortal.PortalID, TrackingUrl, ModuleID); if (objUrlTracking != null) { optType.Items.FindByValue(objUrlTracking.UrlType).Selected = true; chkNewWindow.Checked = objUrlTracking.NewWindow; chkTrack.Checked = objUrlTracking.TrackClicks; chkLog.Checked = objUrlTracking.LogActivity; } else // the url does not exist in the tracking table { optType.Items.FindByValue(_UrlType).Selected = true; chkNewWindow.Checked = false; chkTrack.Checked = true; chkLog.Checked = false; } } else { if (!String.IsNullOrEmpty(_UrlType)) { if (optType.Items.FindByValue(_UrlType) != null) { optType.Items.FindByValue(_UrlType).Selected = true; } else { optType.Items[0].Selected = true; } } else { optType.Items[0].Selected = true; } chkNewWindow.Checked = false; chkTrack.Checked = true; chkLog.Checked = false; } } // load listitems switch (optType.SelectedItem.Value) { case "N": // None URLRow.Visible = false; TabRow.Visible = false; FileRow.Visible = false; UserRow.Visible = false; break; case "U": // Url URLRow.Visible = true; TabRow.Visible = false; FileRow.Visible = false; UserRow.Visible = false; if (txtUrl.Text == "") { txtUrl.Text = _Url; } if (txtUrl.Text == "") { txtUrl.Text = "http://"; } txtUrl.Visible = true; cmdSelect.Visible = true; cboUrls.Items.Clear(); cboUrls.DataSource = objUrls.GetUrls(_objPortal.PortalID); cboUrls.DataBind(); if (cboUrls.Items.FindByValue(_Url) != null) { cboUrls.Items.FindByValue(_Url).Selected = true; } cboUrls.Visible = false; cmdAdd.Visible = false; cmdDelete.Visible = false; break; case "T": // tab URLRow.Visible = false; TabRow.Visible = true; FileRow.Visible = false; UserRow.Visible = false; cboTabs.Items.Clear(); cboTabs.DataSource = Globals.GetPortalTabs(_objPortal.PortalID, !_Required, true, false, false, false); cboTabs.DataBind(); if (cboTabs.Items.FindByValue(_Url) != null) { cboTabs.Items.FindByValue(_Url).Selected = true; } break; case "F": // file URLRow.Visible = false; TabRow.Visible = false; FileRow.Visible = true; UserRow.Visible = false; LoadFolders(); if (cboFolders.Items.Count == 0) { lblMessage.Text = Localization.GetString("NoPermission", this.LocalResourceFile); FileRow.Visible = false; return; } // select folder string FileName; string FolderPath; if (_Url != string.Empty) { FileName = _Url.Substring(_Url.LastIndexOf("/") + 1); FolderPath = _Url.Replace(FileName, ""); } else { FileName = _Url; FolderPath = string.Empty; } if (cboFolders.Items.FindByValue(FolderPath) != null) { cboFolders.Items.FindByValue(FolderPath).Selected = true; } else { cboFolders.Items[0].Selected = true; FolderPath = cboFolders.SelectedValue; } //cboFiles.DataSource = GetFileList(FileFilter, !_Required, cboFolders.SelectedItem.Value); cboFiles.DataSource = GetFileList(!_Required); cboFiles.DataBind(); if (cboFiles.Items.FindByText(FileName) != null) { cboFiles.Items.FindByText(FileName).Selected = true; } cboFiles.Visible = true; txtFile.Visible = false; string strWriteRoles = GetWriteRoles(FolderPath); cmdUpload.Visible = PortalSecurity.IsInRoles(strWriteRoles) && _ShowUpLoad; SetStorageLocationType(); txtUrl.Visible = false; cmdSave.Visible = false; cmdCancel.Visible = false; break; case "M": // membership users URLRow.Visible = false; TabRow.Visible = false; FileRow.Visible = false; UserRow.Visible = true; if (txtUser.Text == "") { txtUser.Text = _Url; } break; } }
private bool CheckFileOrTab(string link, string contentType) { int intId; PortalSettings portal = Globals.GetPortalSettings(); if (link.StartsWith("FileID=", StringComparison.OrdinalIgnoreCase)) { // the link is a file. Check wether it exists in the portal if (Int32.TryParse(link.Replace("FileID=", ""), out intId)) { var objFileController = new FileController(); FileInfo objFile = objFileController.GetFileById(intId, portal.PortalId); if (objFile != null) { if ((!(string.IsNullOrEmpty(contentType))) && (!(objFile.ContentType.StartsWith(contentType, StringComparison.OrdinalIgnoreCase)))) { // the file exists but is of the wrong type return false; } } else { // the file does not exist for this portal return false; } } } else if (Int32.TryParse(link, out intId)) { // the link is a tab var objTabController = new Entities.Tabs.TabController(); if (objTabController.GetTab(intId, portal.PortalId, false) == null) { // the tab does not exist return false; } } // no reasons where found to reject the file return true; }
/// <summary> /// cmdSend_Click runs when the cmdSend Button is clicked /// </summary> /// <remarks> /// </remarks> /// <history> /// [cnurse] 9/10/2004 Updated to reflect design changes for Help, 508 support /// and localisation /// </history> protected void cmdSend_Click( Object sender, EventArgs e ) { try { ArrayList objRecipients = new ArrayList(); RoleController objRoles = new RoleController(); ListItem objListItem; // load all user emails based on roles selected foreach( ListItem objRole in chkRoles.Items ) { if( objRole.Selected ) { foreach( UserInfo objUser in objRoles.GetUsersByRoleName( PortalId, objRole.Value ) ) { if( objUser.Membership.Approved ) { objListItem = new ListItem( objUser.Email, objUser.DisplayName ); if( ! objRecipients.Contains( objListItem ) ) { objRecipients.Add( objListItem ); } } } } } // load emails specified in email distribution list if( !String.IsNullOrEmpty(txtEmail.Text) ) { string[] splitter = {";"}; Array arrEmail = txtEmail.Text.Split(splitter, StringSplitOptions.None); foreach( string strEmail in arrEmail ) { objListItem = new ListItem( strEmail, strEmail ); if( ! objRecipients.Contains( objListItem ) ) { objRecipients.Add( objListItem ); } } } // create object SendBulkEmail objSendBulkEMail = new SendBulkEmail( objRecipients, cboPriority.SelectedItem.Value, teMessage.Mode, PortalSettings.PortalAlias.HTTPAlias ); objSendBulkEMail.Subject = txtSubject.Text; objSendBulkEMail.Body += teMessage.Text; if( ctlAttachment.Url.StartsWith( "FileID=" ) ) { int fileId = int.Parse( ctlAttachment.Url.Substring( 7 ) ); FileController objFileController = new FileController(); FileInfo objFileInfo = objFileController.GetFileById( fileId, PortalId ); objSendBulkEMail.Attachment = PortalSettings.HomeDirectoryMapPath + objFileInfo.Folder + objFileInfo.FileName; } objSendBulkEMail.SendMethod = cboSendMethod.SelectedItem.Value; objSendBulkEMail.SMTPServer = Convert.ToString( PortalSettings.HostSettings["SMTPServer"] ); objSendBulkEMail.SMTPAuthentication = Convert.ToString( PortalSettings.HostSettings["SMTPAuthentication"] ); objSendBulkEMail.SMTPUsername = Convert.ToString( PortalSettings.HostSettings["SMTPUsername"] ); objSendBulkEMail.SMTPPassword = Convert.ToString( PortalSettings.HostSettings["SMTPPassword"] ); objSendBulkEMail.Administrator = txtFrom.Text; objSendBulkEMail.Heading = Localization.GetString( "Heading", this.LocalResourceFile ); // send mail if( optSendAction.SelectedItem.Value == "S" ) { objSendBulkEMail.Send(); } else // ansynchronous uses threading { Thread objThread = new Thread( new ThreadStart( objSendBulkEMail.Send ) ); objThread.Start(); } // completed UI.Skins.Skin.AddModuleMessage( this, Localization.GetString( "MessageSent", this.LocalResourceFile ), ModuleMessageType.GreenSuccess ); } catch( Exception exc ) //Module failed to load { Exceptions.ProcessModuleLoadException( this, exc ); } }
/// <summary>process export for multi-instance portability, rewrite images into base64 and tab id's into paths</summary> /// <param name="slideUrl">The slide url.</param> /// <param name="outputPrefix">The output prefix. (image, or link)</param> /// <param name="output">The output.</param> private static void ProcessExport(string slideUrl, string outputPrefix, StringBuilder output) { var ps = DotNetNuke.Entities.Portals.PortalController.GetCurrentPortalSettings(); // var linkType = DotNetNuke.Common.Globals.GetURLType(slide.LinkUrl); if (slideUrl.StartsWith("FileID=", StringComparison.OrdinalIgnoreCase)) { var fileId = int.Parse(UrlUtils.GetParameterValue(slideUrl), CultureInfo.InvariantCulture); var fileController = new FileController(); var file = fileController.GetFileById(fileId, ps.PortalId); if (file != null) { // todo should we check content type before converting to an image? var buffer = File.ReadAllBytes(file.PhysicalPath); var base64 = Convert.ToBase64String(buffer); output.AppendFormat(CultureInfo.InvariantCulture, "<{1}fileextension>{0}</{1}fileextension>", file.Extension, outputPrefix); output.AppendFormat(CultureInfo.InvariantCulture, "<{1}filename>{0}</{1}filename>", file.FileName, outputPrefix); output.AppendFormat(CultureInfo.InvariantCulture, "<{1}contenttype>{0}</{1}contenttype>", file.ContentType, outputPrefix); output.AppendFormat(CultureInfo.InvariantCulture, "<{1}folderpath>{0}</{1}folderpath>", file.Folder, outputPrefix); output.AppendFormat(CultureInfo.InvariantCulture, "<{1}filedata>{0}</{1}filedata>", base64, outputPrefix); } } else if (slideUrl.StartsWith("TabID=", StringComparison.OrdinalIgnoreCase)) { var tabId = int.Parse(UrlUtils.GetParameterValue(slideUrl), CultureInfo.InvariantCulture); var tabController = new TabController(); var tab = tabController.GetTab(tabId, ps.PortalId, true); if (tab != null) { output.AppendFormat(CultureInfo.InvariantCulture, "<{1}tabpath>{0}</{1}tabpath>", tab.TabPath, outputPrefix); } } }