CKEditor3.6.2和CKFinder2.2.1 for ASP.NET部署設定完美解決方案(3)

來源:互聯網
上載者:User

6. 配置CKFinder

修改Admin\ckfinder\config.ascx檔案,內容如下(裡邊有兩處修改,請搜尋“修改”二字):

<%@ Control Language="C#" EnableViewState="false" AutoEventWireup="false" Inherits="CKFinder.Settings.ConfigFile" %><%@ Import Namespace="CKFinder.Settings" %><script runat="server">/** * This function must check the user session to be sure that he/she is * authorized to upload and access files using CKFinder. */public override bool CheckAuthentication(){// WARNING : DO NOT simply return "true". By doing so, you are allowing// "anyone" to upload and list the files in your server. You must implement// some kind of session validation here. Even something very simple as...////return ( Session[ "IsAuthorized" ] != null && (bool)Session[ "IsAuthorized" ] == true );//// ... where Session[ "IsAuthorized" ] is set to "true" as soon as the// user logs on your system.return true; //修改:這裡將false改為了true,即不做認證檢查。如果需要對使用者身份進行認證,請自行實現}/** * All configuration settings must be defined here. */public override void SetConfig(){// Paste your license name and key here. If left blank, CKFinder will// be fully functional, in Demo Mode.LicenseName = "";LicenseKey = "";// The base URL used to reach files in CKFinder through the browser.        BaseUrl = "~/uploader/"; //修改:這裡指定了上傳管理檔案的根目錄,為網站根目錄中的uploader目錄,使用者無需自己建立目錄// The phisical directory in the server where the file will end up. If// blank, CKFinder attempts to resolve BaseUrl.BaseDir = "";// Optional: enable extra plugins (remember to copy .dll files first).Plugins = new string[] {// "CKFinder.Plugins.FileEditor, CKFinder_FileEditor",// "CKFinder.Plugins.ImageResize, CKFinder_ImageResize",// "CKFinder.Plugins.Watermark, CKFinder_Watermark"};// Settings for extra plugins.PluginSettings = new Hashtable();PluginSettings.Add("ImageResize_smallThumb", "90x90" );PluginSettings.Add("ImageResize_mediumThumb", "120x120" );PluginSettings.Add("ImageResize_largeThumb", "180x180" );// Name of the watermark image in plugins/watermark folderPluginSettings.Add("Watermark_source", "logo.gif" );PluginSettings.Add("Watermark_marginRight", "5" );PluginSettings.Add("Watermark_marginBottom", "5" );PluginSettings.Add("Watermark_quality", "90" );PluginSettings.Add("Watermark_transparency", "80" );// Thumbnail settings.// "Url" is used to reach the thumbnails with the browser, while "Dir"// points to the physical location of the thumbnail files in the server.Thumbnails.Url = BaseUrl + "_thumbs/";if ( BaseDir != "" ) {Thumbnails.Dir = BaseDir + "_thumbs/";}Thumbnails.Enabled = true;Thumbnails.DirectAccess = false;Thumbnails.MaxWidth = 100;Thumbnails.MaxHeight = 100;Thumbnails.Quality = 80;// Set the maximum size of uploaded images. If an uploaded image is// larger, it gets scaled down proportionally. Set to 0 to disable this// feature.Images.MaxWidth = 1600;Images.MaxHeight = 1200;Images.Quality = 80;// Indicates that the file size (MaxSize) for images must be checked only// after scaling them. Otherwise, it is checked right after uploading.CheckSizeAfterScaling = true;// Increases the security on an IIS web server.// If enabled, CKFinder will disallow creating folders and uploading files whose names contain characters// that are not safe under an IIS 6.0 web server.DisallowUnsafeCharacters = true;// Due to security issues with Apache modules, it is recommended to leave the// following setting enabled. It can be safely disabled on IIS.ForceSingleExtension = true;// For security, HTML is allowed in the first Kb of data for files having the// following extensions only.HtmlExtensions = new string[] { "html", "htm", "xml", "js" };// Folders to not display in CKFinder, no matter their location. No// paths are accepted, only the folder name.// The * and ? wildcards are accepted.HideFolders = new string[] { ".svn", "CVS" };// Files to not display in CKFinder, no matter their location. No// paths are accepted, only the file name, including extension.// The * and ? wildcards are accepted.HideFiles = new string[] { ".*" };// Perform additional checks for image files.SecureImageUploads = true;// The session variable name that CKFinder must use to retrieve the// "role" of the current user. The "role" is optional and can be used// in the "AccessControl" settings (bellow in this file).RoleSessionVar = "CKFinder_UserRole";// ACL (Access Control) settings. Used to restrict access or features// to specific folders.// Several "AccessControl.Add()" calls can be made, which return a// single ACL setting object to be configured. All properties settings// are optional in that object.// Subfolders inherit their default settings from their parents' definitions.////- The "Role" property accepts the special "*" value, which means//  "everybody".//- The "ResourceType" attribute accepts the special value "*", which//  means "all resource types".AccessControl acl = AccessControl.Add();acl.Role = "*";acl.ResourceType = "*";acl.Folder = "/";acl.FolderView = true;acl.FolderCreate = true;acl.FolderRename = true;acl.FolderDelete = true;acl.FileView = true;acl.FileUpload = true;acl.FileRename = true;acl.FileDelete = true;// Resource Type settings.// A resource type is nothing more than a way to group files under// different paths, each one having different configuration settings.// Each resource type name must be unique.// When loading CKFinder, the "type" querystring parameter can be used// to display a specific type only. If "type" is omitted in the URL,// the "DefaultResourceTypes" settings is used (may contain the// resource type names separated by a comma). If left empty, all types// are loaded.DefaultResourceTypes = "";ResourceType type;type = ResourceType.Add( "Files" );type.Url = BaseUrl + "files/";type.Dir = BaseDir == "" ? "" : BaseDir + "files/";type.MaxSize = 0;type.AllowedExtensions = new string[] { "7z", "aiff", "asf", "avi", "bmp", "csv", "doc", "docx", "fla", "flv", "gif", "gz", "gzip", "jpeg", "jpg", "mid", "mov", "mp3", "mp4", "mpc", "mpeg", "mpg", "ods", "odt", "pdf", "png", "ppt", "pptx", "pxd", "qt", "ram", "rar", "rm", "rmi", "rmvb", "rtf", "sdc", "sitd", "swf", "sxc", "sxw", "tar", "tgz", "tif", "tiff", "txt", "vsd", "wav", "wma", "wmv", "xls", "xlsx", "zip" };type.DeniedExtensions = new string[] { };type = ResourceType.Add( "Images" );type.Url = BaseUrl + "images/";type.Dir = BaseDir == "" ? "" : BaseDir + "images/";type.MaxSize = 0;type.AllowedExtensions = new string[] { "bmp", "gif", "jpeg", "jpg", "png" };type.DeniedExtensions = new string[] { };type = ResourceType.Add( "Flash" );type.Url = BaseUrl + "flash/";type.Dir = BaseDir == "" ? "" : BaseDir + "flash/";type.MaxSize = 0;type.AllowedExtensions = new string[] { "swf", "flv" };type.DeniedExtensions = new string[] { };}</script>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.