国产激情自拍_国产9色视频_丁香花在线电影小说观看 _久久久久国产精品嫩草影院

首頁 > 編程 > ASP > 正文

網頁編輯器fckeditor asp版本的文件重命名

2024-07-21 02:53:34
字體:
來源:轉載
供稿:網友
最近不得不研究FCKEDITOR,而且是ASP版本。對其文件上傳后的重命名,很郁悶。下面記錄我修改的過程,部分函數來自網絡。
 
定位到:editor/filemanager/connectors/asp/io.asp 
主要是修改:SanitizeFileName這個函數,并添加取得擴展名和文件重命名的方法,詳細代碼如下:
復制代碼代碼如下:

' Do a cleanup of the file name to avoid possible problems 
function SanitizeFileName( sNewFileName ) 
Dim oRegex 
Dim oExt 
Set oRegex = New RegExp 
oRegex.Global = True 

if ( ConfigForceSingleExtension = True ) then 
oRegex.Pattern = "/.(?![^.]*$)" 
sNewFileName = oRegex.Replace( sNewFileName, "_" ) 
'取得文件擴展名 
sNewFileName = makefilename(now())"."&GetExtend(sNewFileName) 
end if 

' remove / / | : ? * " < > and control characters 
oRegex.Pattern = "(//|//|/||:|/?|/*|""|/<|/>|[/u0000-/u001F]|/u007F)" 
SanitizeFileName = oRegex.Replace( sNewFileName, "_" ) 

Set oRegex = Nothing 
end function 

Function GetExtend(filename) 
dim tmp 
if filename<>"" then 
tmp=mid(filename,instrrev(filename,".")+1,len(filename)-instrrev(filename,".")) 
tmp=LCase(tmp) 
if instr(1,tmp,"asp")>0 or instr(1,tmp,"php")>0 or instr(1,tmp,"php3")>0 or instr(1,tmp,"aspx")>0 then 
getextend="txt" 
else 
getextend=tmp 
end if 
else 
getextend="" 
end if 
End Function 

function makefilename(fname) 
fname = fname '前fname為變量,后fname為函數參數引用 
fname = replace(fname,"-","") 
fname = replace(fname," ","") 
fname = replace(fname,":","") 
fname = replace(fname,"PM","") 
fname = replace(fname,"AM","") 
fname = replace(fname,"上午","") 
fname = replace(fname,"下午","") 
makefilename = fname 
end function 

懶得改的話就直接拷貝下面的代碼: 
復制代碼代碼如下:

<% 
' FCKeditor - The text editor for Internet - http://www.fckeditor.net 
' Copyright (C) 2003-2009 Frederico Caldeira Knabben 

' == BEGIN LICENSE == 

' Licensed under the terms of any of the following licenses at your 
' choice: 

' - GNU General Public License Version 2 or later (the "GPL") 
' http://www.gnu.org/licenses/gpl.html 

' - GNU Lesser General Public License Version 2.1 or later (the "LGPL") 
' http://www.gnu.org/licenses/lgpl.html 

' - Mozilla Public License Version 1.1 or later (the "MPL") 
' http://www.mozilla.org/MPL/MPL-1.1.html 

' == END LICENSE == 

' This file include IO specific functions used by the ASP Connector. 
%> 
<% 
function CombinePaths( sBasePath, sFolder) 
sFolder = replace(sFolder, "/", "/") 
CombinePaths = RemoveFromEnd( sBasePath, "/" ) & "/" & RemoveFromStart( sFolder, "/" ) 
end function 

function CombineLocalPaths( sBasePath, sFolder) 
sFolder = replace(sFolder, "/", "/") 
' The RemoveFrom* functions use RegExp, so we must escape the / 
CombineLocalPaths = RemoveFromEnd( sBasePath, "//" ) & "/" & RemoveFromStart( sFolder, "//" ) 
end function 

Function GetResourceTypePath( resourceType, sCommand ) 
if ( sCommand = "QuickUpload") then 
GetResourceTypePath = ConfigQuickUploadPath.Item( resourceType ) 
else 
GetResourceTypePath = ConfigFileTypesPath.Item( resourceType ) 
end if 
end Function 

Function GetResourceTypeDirectory( resourceType, sCommand ) 
if ( sCommand = "QuickUpload") then 

if ( ConfigQuickUploadAbsolutePath.Item( resourceType ) <> "" ) then 
GetResourceTypeDirectory = ConfigQuickUploadAbsolutePath.Item( resourceType ) 
else 
' Map the "UserFiles" path to a local directory. 
GetResourceTypeDirectory = Server.MapPath( ConfigQuickUploadPath.Item( resourceType ) ) 
end if 
else 
if ( ConfigFileTypesAbsolutePath.Item( resourceType ) <> "" ) then 
GetResourceTypeDirectory = ConfigFileTypesAbsolutePath.Item( resourceType ) 
else 
' Map the "UserFiles" path to a local directory. 
GetResourceTypeDirectory = Server.MapPath( ConfigFileTypesPath.Item( resourceType ) ) 
end if 
end if 
end Function 

Function GetUrlFromPath( resourceType, folderPath, sCommand ) 
GetUrlFromPath = CombinePaths( GetResourceTypePath( resourceType, sCommand ), folderPath ) 
End Function 

Function RemoveExtension( fileName ) 
RemoveExtension = Left( fileName, InStrRev( fileName, "." ) - 1 ) 
End Function 

Function ServerMapFolder( resourceType, folderPath, sCommand ) 
Dim sResourceTypePath 
' Get the resource type directory. 
sResourceTypePath = GetResourceTypeDirectory( resourceType, sCommand ) 

' Ensure that the directory exists. 
CreateServerFolder sResourceTypePath 

' Return the resource type directory combined with the required path. 
ServerMapFolder = CombineLocalPaths( sResourceTypePath, folderPath ) 
End Function 

Sub CreateServerFolder( folderPath ) 
Dim oFSO 
Set oFSO = Server.CreateObject( "Scripting.FileSystemObject" ) 

Dim sParent 
sParent = oFSO.GetParentFolderName( folderPath ) 

' If folderPath is a network path (//server/folder/) then sParent is an empty string. 
' Get out. 
if (sParent = "") then exit sub 

' Check if the parent exists, or create it. 
If ( NOT oFSO.FolderExists( sParent ) ) Then CreateServerFolder( sParent ) 

If ( oFSO.FolderExists( folderPath ) = False ) Then 
On Error resume next 
oFSO.CreateFolder( folderPath ) 

if err.number<>0 then 
dim sErrorNumber 
Dim iErrNumber, sErrDescription 
iErrNumber = err.number 
sErrDescription = err.Description 

On Error Goto 0 

Select Case iErrNumber 
Case 52 
sErrorNumber = "102" ' Invalid Folder Name. 
Case 70 
sErrorNumber = "103" ' Security Error. 
Case 76 
sErrorNumber = "102" ' Path too long. 
Case Else 
sErrorNumber = "110" 
End Select 

SendError sErrorNumber, "CreateServerFolder(" & folderPath & ") : " & sErrDescription 
end if 

End If 

Set oFSO = Nothing 
End Sub 

Function IsAllowedExt( extension, resourceType ) 
Dim oRE 
Set oRE = New RegExp 
oRE.IgnoreCase = True 
oRE.Global = True 

Dim sAllowed, sDenied 
sAllowed = ConfigAllowedExtensions.Item( resourceType ) 
sDenied = ConfigDeniedExtensions.Item( resourceType ) 

IsAllowedExt = True 

If sDenied <> "" Then 
oRE.Pattern = sDenied 
IsAllowedExt = Not oRE.Test( extension ) 
End If 

If IsAllowedExt And sAllowed <> "" Then 
oRE.Pattern = sAllowed 
IsAllowedExt = oRE.Test( extension ) 
End If 

Set oRE = Nothing 
End Function 

Function IsAllowedType( resourceType ) 
Dim oRE 
Set oRE = New RegExp 
oRE.IgnoreCase = False 
oRE.Global = True 
oRE.Pattern = "^(" & ConfigAllowedTypes & ")$" 

IsAllowedType = oRE.Test( resourceType ) 

Set oRE = Nothing 
End Function 

Function IsAllowedCommand( sCommand ) 
Dim oRE 
Set oRE = New RegExp 
oRE.IgnoreCase = True 
oRE.Global = True 
oRE.Pattern = "^(" & ConfigAllowedCommands & ")$" 

IsAllowedCommand = oRE.Test( sCommand ) 

Set oRE = Nothing 
End Function 

function GetCurrentFolder() 
dim sCurrentFolder 
dim oRegex 

sCurrentFolder = Request.QueryString("CurrentFolder") 
If ( sCurrentFolder = "" ) Then sCurrentFolder = "/" 

' Check the current folder syntax (must begin and start with a slash). 
If ( Right( sCurrentFolder, 1 ) <> "/" ) Then sCurrentFolder = sCurrentFolder & "/" 
If ( Left( sCurrentFolder, 1 ) <> "/" ) Then sCurrentFolder = "/" & sCurrentFolder 

' Check for invalid folder paths (..) 
If ( InStr( 1, sCurrentFolder, ".." ) <> 0 OR InStr( 1, sCurrentFolder, "/" ) <> 0) Then 
SendError 102, "" 
End If 

Set oRegex = New RegExp 
oRegex.Global = True 
oRegex.Pattern = "(//.)|(//)|([//:/*/?/""/</>/|]|[/u0000-/u001F]|/u007F)" 

if (oRegex.Test(sCurrentFolder)) Then 
SendError 102, "" 
End If 

GetCurrentFolder = sCurrentFolder 
end function 

' Do a cleanup of the folder name to avoid possible problems 
function SanitizeFolderName( sNewFolderName ) 
Dim oRegex 
Set oRegex = New RegExp 
oRegex.Global = True 

' remove . / / | : ? * " < > and control characters 
oRegex.Pattern = "(/.|//|//|/||:|/?|/*|""|/<|/>|[/u0000-/u001F]|/u007F)" 
SanitizeFolderName = oRegex.Replace( sNewFolderName, "_" ) 

Set oRegex = Nothing 
end function 

' Do a cleanup of the file name to avoid possible problems 
function SanitizeFileName( sNewFileName ) 
Dim oRegex 
Dim oExt 
Set oRegex = New RegExp 
oRegex.Global = True 

if ( ConfigForceSingleExtension = True ) then 
oRegex.Pattern = "/.(?![^.]*$)" 
sNewFileName = oRegex.Replace( sNewFileName, "_" ) 
'取得文件擴展名 
sNewFileName = makefilename(now())&"."&GetExtend(sNewFileName) 
end if 

' remove / / | : ? * " < > and control characters 
oRegex.Pattern = "(//|//|/||:|/?|/*|""|/<|/>|[/u0000-/u001F]|/u007F)" 
SanitizeFileName = oRegex.Replace( sNewFileName, "_" ) 

Set oRegex = Nothing 
end function 

Function GetExtend(filename) 
dim tmp 
if filename<>"" then 
tmp=mid(filename,instrrev(filename,".")+1,len(filename)-instrrev(filename,".")) 
tmp=LCase(tmp) 
if instr(1,tmp,"asp")>0 or instr(1,tmp,"php")>0 or instr(1,tmp,"php3")>0 or instr(1,tmp,"aspx")>0 then 
getextend="txt" 
else 
getextend=tmp 
end if 
else 
getextend="" 
end if 
End Function 

function makefilename(fname) 
fname = fname '前fname為變量,后fname為函數參數引用 
fname = replace(fname,"-","") 
fname = replace(fname," ","") 
fname = replace(fname,":","") 
fname = replace(fname,"PM","") 
fname = replace(fname,"AM","") 
fname = replace(fname,"上午","") 
fname = replace(fname,"下午","") 
makefilename = fname 
end function 


' This is the function that sends the results of the uploading process. 
Sub SendUploadResults( errorNumber, fileUrl, fileName, customMsg ) 
Response.Clear 
Response.Write "<script type=""text/javascript"">" 
' Minified version of the document.domain automatic fix script (#1919). 
' The original script can be found at _dev/domain_fix_template.js 
Response.Write "(function(){var d=document.domain;while (true){try{var A=window.parent.document.domain;break;}catch(e) {};d=d.replace(/.*?(?:/.|$)/,'');if (d.length==0) break;try{document.domain=d;}catch (e){break;}}})();" 

Response.Write "window.parent.OnUploadCompleted(" & errorNumber & ",""" & Replace( fileUrl, """", "/""" ) & """,""" & Replace( fileName, """", "/""" ) & """,""" & Replace( customMsg , """", "/""" ) & """) ;" 
Response.Write "</script>" 
Response.End 
End Sub 
%> 


注:相關教程知識閱讀請移步到編輯器頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
国产激情自拍_国产9色视频_丁香花在线电影小说观看 _久久久久国产精品嫩草影院
在线播放www| 国产精品一区二区婷婷| 国产区在线视频| 18加网站在线| 国产精品合集一区二区| 国产网友自拍电影在线| 国产精品黄页网站在线播放免费| 国产成人精品18| 性网站在线播放| 国产成人久久精品77777| 69视频在线观看| 日本片在线看| 国产一区二区三区不卡免费观看 | 国产女人在线观看| 国产在线观看18| 国产精品蜜臀| 日本福利在线| 国产视频二区在线观看| 性欧美精品xxxx| 国产国语**毛片高清视频 | 精品偷拍激情视频在线观看| 伊人福利在线| 国产精品午夜久久久久久| 2018中文字幕在线| 久草.com| 免费网站看黄yyy222| 精品国产免费观看一区| 99热在线观看免费| а√最新版地址在线天堂| 国产福利在线| 国产精品剧情一区二区在线观看| h视频在线网站| 91涩漫在线观看c| 国产污视频在线| 欧美日韩在线视频免费观看| 2021av天天| ·天天天天操| 在线观看国产视频| 在线色视频观看| 精品视频在线一区二区| 国产三级自拍| √天堂中文在线| 国产免费av网站| 国产免费av高清在线| 免费a级人成a大片在线观看| 任你操在线观看| 免费看ww视频网站入口| 欧美黑人乱大交| 久久精品国产麻豆| 国产va在线观看| 国产一区二区三区不卡在线| 国产私人影院| 在线一区观看| а√资源新版在线天堂| 日本不卡视频一区二区| 狠狠操视频网| 91sp网站在线观看入口| 中文字幕在线看精品乱码| 国产精品欧美色图| av免费在线观看网站| 日本亚洲欧美| 国产性网软件大全| av手机免费观看| 黄网址在线播放免费| 久蕉依人在线视频| 国产精品你懂的在线观看| 精品视频vs精品视频| 先锋影音av中文字幕| 午夜在线视频播放| 国产美女免费观看| 国产三级在线观看| eeuss影院在线播放| 国产精品臀控福利在线观看| 91欧美在线视频| 四虎网站在线观看| 国产视频二区在线观看| 亚洲一道本在线| 国产精品186在线观看在线播放| aaa大片在线观看| 轻轻色免费在线视频| 国产高清在线a视频大全| 亚洲欧美日韩综合精品网| 国产美女在线一区二区三区| 日本韩国精品一区二区| 国产福利小视频在线观看| 超碰在线观看免费| 在线a人片免费观看视频| 中文字幕视频在线观看| 九九精品视频在线观看九九| 99久久国产视频| 91亚洲欧美| 国产区视频在线播放| 超碰在线网址| 欧美日韩性视频一区二区三区| 国产视频一二区| 国产青青草在线| 五月天天在线| 国产在线高清理伦片a| 免费在线观看a| 国产在线资源| 国产尤物视频在线| 成年网在线观看免费观看网址| 亚洲国产成人综合| 四虎a级欧美在线观看| 亚洲精品男人| sm国产在线调教视频| 亚洲精品影院在线| 午夜影院免费| 九九视频精品在线| 亚洲欧美日韩成人网| 伊人永久在线| 欧美96在线| 国产精品午夜久久久久久| 中文字幕在线视频不卡| 国产天堂资源| 永久免费网站在线| 免费午夜一级| 国产高清在线看| 色悠久久久久综合网小说| 免费一区二区在线观看| 中文字幕在线视频观看| 国产99在线|亚洲| 日本a级黄色| 国产特黄在线| 在线观看中文字幕一区| 开心快乐六月丁香婷婷| 国产原创精品视频| 91嫩草在线播放| 九九热视频精品在线观看| 午夜av在线免费观看| 国产精品视频h| 四虎在线免费视频| 国产三区四区在线观看| av网址在线播放| 国产精品一区二三区| 在线天堂中文| 午夜av在线免费观看| 亚洲精品aaaa精品| 国产二区三区四区| 四虎一区二区三区| 国产精品第八页| 国产美女在线一区二区三区| 亚洲成av人影片在线观看| 国产激情自拍| 99热在线免费观看| gogogogo高清视频在线| 国产成人综合美国十次| 国产精选一区二区三区不卡催乳| 99精品老司机免费视频| 国产私人尤物无码不卡| 国产美女福利在线观看| eeuss影院在线观看| 在线视频中文字幕久| 国产youjizz在线| 国产一区精品| 最近中文字幕mv2018在线高清| 四虎成人精品在永久在线观看| 2019天天操夜夜操| 精品视频二区三区| 在线一区观看| 亚洲日本伊人| 欧美成人亚洲高清在线观看| av在线天天| 黄网在线免费| 日本中文字幕在线视频| 激情丁香婷婷| 中文字幕视频在线| 最新超碰在线| 最新天堂资源在线资源| 国产免费av网站| 五月伊人六月| 国产精品入口麻豆免费| 国产馆av播放| 四虎影视成人永久免费观看视频| 日本动漫理论片在线观看网站| 青草视频在线播放| 二人午夜免费观看在线视频| 国产蜜臀在线| 国产aa视频| 免费看的毛片| 国产精品入口麻豆完整版| av黄色在线观看| 青青草原国产在线| 中文字幕在线影院| 国产91在线视频蝌蚪| 在线āv视频| 国产免费高清| 在线免费国产视频| 日本成人网址| 国产黄色免费网| 国产在线日本| 伊人222成人综合网| 青青草免费观看免费视频在线| 免费电影网站在线视频观看福利| 免费视频二区| 伊人免费视频| 国产一区二区三区不卡在线| h视频在线网站| 国产高清在线| 免费观看久久久久|