温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:多层结构会员管理系统源码
当前文件路径:mvcMemberShip/FCKeditor.Net_2.2/FileWorkerBase.cs

1/* 2
* FCKeditor - The text editor for internet 3
* Copyright (C) 2003-2005 Frederico Caldeira Knabben 4
* 5
* Licensed under the terms of the GNU Lesser General Public License: 6
* http://www.opensource.org/licenses/lgpl-license.php 7
* 8
* For further information visit: 9
* http://www.fckeditor.net/ 10
* 11
* "Support Open Source software. What about a donation today?" 12
* 13
* File Name: FileWorkerBase.cs 14
* Base class used by the FileBrowserConnector and Uploader. 15
* 16
* File Authors: 17
* Frederico Caldeira Knabben (fredck@fckeditor.net) 18
*/ 19
20
using System; 21
22
namespace FredCK.FCKeditorV2 23
{ 24
public abstract class FileWorkerBase : System.Web.UI.Page 25
{ 26
private const string DEFAULT_USER_FILES_PATH = "/UserFiles/"; 27
private const string DEFAULT_UPLOAD_DENIED_EXTENSIONS = ".php|.php3|.php5|.phtml|.asp|.aspx|.ascx|.jsp|.cfm|.cfc|.pl|.bat|.exe|.dll|.reg|.cgi|.cs|.vb|.asa|.cer|c.dx|.ascx|.asax|.ashx|.asmx|.java|.jsl"; 28
29
private string sUserFilesPath; 30
private string sUserFilesDirectory; 31
private string sUploadDeniedExtensions; 32
33
protected string UserFilesPath 34
{ 35
get 36
{ 37
if (sUserFilesPath == null) 38
{ 39
// Try to get from the "Application". 40
sUserFilesPath = (string)Application["FCKeditor:UserFilesPath"]; 41
42
// Try to get from the "Session". 43
if (sUserFilesPath == null || sUserFilesPath.Length == 0) 44
{ 45
sUserFilesPath = (string)Session["FCKeditor:UserFilesPath"]; 46
47
// Try to get from the Web.config file. 48
if (sUserFilesPath == null || sUserFilesPath.Length == 0) 49
{ 50
sUserFilesPath = System.Configuration.ConfigurationSettings.AppSettings["FCKeditor:UserFilesPath"]; 51
52
// Otherwise use the default value. 53
if (sUserFilesPath == null || sUserFilesPath.Length == 0) 54
sUserFilesPath = DEFAULT_USER_FILES_PATH; 55
56
// Try to get from the URL. 57
if (sUserFilesPath == null || sUserFilesPath.Length == 0) 58
{ 59
sUserFilesPath = Request.QueryString["ServerPath"]; 60
} 61
} 62
} 63
64
// Check that the user path ends with slash ("/") 65
if (!sUserFilesPath.EndsWith("/")) 66
sUserFilesPath += "/"; 67
////ResolveUrl add by tupunco 2006-10-9 68
if (sUserFilesPath.StartsWith("~")) 69
sUserFilesPath = this.ResolveUrl(sUserFilesPath); 70
} 71
return sUserFilesPath; 72
} 73
} 74
75
/// <summary> 76
/// The absolution path (server side) of the user files directory. It 77
/// is based on the <see cref="FileWorkerBase.UserFilesPath"/>. 78
/// </summary> 79
protected string UserFilesDirectory 80
{ 81
get 82
{ 83
if (sUserFilesDirectory == null) 84
{ 85
// Get the local (server) directory path translation. 86
sUserFilesDirectory = Server.MapPath(this.UserFilesPath); 87
} 88
return sUserFilesDirectory; 89
} 90
} 91
92
/// <summary> 93
/// Denied File's Extensions 94
/// 不被允许的文件扩展名 95
/// AppSettings["FCKeditor:UploadDeniedExtensions"] 96
/// 适用方法可以参看UserFilesPath属性设置方法 97
/// </summary> 98
public string UploadDeniedExtensions 99
{ 100
get 101
{ 102
if (sUploadDeniedExtensions == null) 103
{ 104
// Try to get from the "Application". 105
sUploadDeniedExtensions = (string)Application["FCKeditor:UploadDeniedExtensions"]; 106
107
// Try to get from the "Session". 108
if (sUploadDeniedExtensions == null || sUploadDeniedExtensions.Length == 0) 109
{ 110
sUploadDeniedExtensions = (string)Session["FCKeditor:UploadDeniedExtensions"]; 111
112
// Try to get from the Web.config file. 113
if (sUploadDeniedExtensions == null || sUploadDeniedExtensions.Length == 0) 114
{ 115
sUploadDeniedExtensions = System.Configuration.ConfigurationSettings.AppSettings["FCKeditor:UploadDeniedExtensions"]; 116
117
// Otherwise use the default value. 118
if (sUploadDeniedExtensions == null || sUploadDeniedExtensions.Length == 0) 119
sUploadDeniedExtensions = DEFAULT_UPLOAD_DENIED_EXTENSIONS; 120
} 121
} 122
} 123
return sUploadDeniedExtensions; 124
} 125
} 126
/// <summary> 127
/// Check Can Upload this file 128
/// 判断文件类型是否可以上传 129
/// </summary> 130
/// <param name="sFileName">will upload file's name将要上传的文件名</param> 131
/// <returns></returns> 132
public bool CheckUploadFileExtension(string sFileName) 133
{ 134
//Denied Extensions Array 135
//不被允许的文件扩展名数组 136
string[] aExtensions = this.UploadDeniedExtensions.Split(new char[] { '|' }); 137
//将要上传的文件扩展名 138
string fileEx = System.IO.Path.GetExtension(sFileName); 139
foreach (string ex in aExtensions) 140
{ 141
if (ex == fileEx) 142
return false; 143
} 144
return true; 145
} 146
} 147
} 148



* FCKeditor - The text editor for internet

}