<%
' FCKeditor - The text editor for Internet -
' 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")
' /licenses/
'
' - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
' /licenses/
'
' - Mozilla Public License Version 1.1 or later (the "MPL")
' /MPL/MPL-1.
'
' == 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 = ( resourceType )
else
GetResourceTypePath = ( resourceType )
end if
end Function
Function GetResourceTypeDirectory( resourceType, sCommand )
if ( sCommand = "QuickUpload") then
if ( ( resourceType ) <> "" ) then
GetResourceTypeDirectory = ( resourceType )
else
' Map the "UserFiles" path to a local directory.
GetResourceTypeDirectory = ( ( resourceType ) )
end if
else
if ( ( resourceType ) <> "" ) then
GetResourceTypeDirectory = ( resourceType )
else
' Map the "UserFiles" path to a local directory.
GetResourceTypeDirectory = ( ( 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 = ( "" )
Dim sParent
sParent = ( 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 ( sParent ) ) Then CreateServerFolder( sParent )
If ( ( folderPath ) = False ) Then
On Error resume next
( folderPath )
if <>0 then
dim sErrorNumber
Dim iErrNumber, sErrDescription
iErrNumber =
sErrDescription =
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
= True
= True
Dim sAllowed, sDenied
sAllowed = ( resourceType )
sDenied = ( resourceType )
IsAllowedExt = True
If sDenied <> "" Then
= sDenied
IsAllowedExt = Not ( extension )
End If
If IsAllowedExt And sAllowed <> "" Then
= sAllowed
IsAllowedExt = ( extension )
End If
Set oRE = Nothing
End Function
Function IsAllowedType( resourceType )
Dim oRE
Set oRE = New RegExp
= False
= True
= "^(" & ConfigAllowedTypes & ")$"
IsAllowedType = ( resourceType )
Set oRE = Nothing
End Function
Function IsAllowedCommand( sCommand )
Dim oRE
Set oRE = New RegExp
= True
= True
= "^(" & ConfigAllowedCommands & ")$"
IsAllowedCommand = ( sCommand )
Set oRE = Nothing
End Function
function GetCurrentFolder()
dim sCurrentFolder
dim oRegex
sCurrentFolder = ("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
= True
= "(/\.)|(//)|([\\:\*\?\""\<\>\|]|[\u0000-\u001F]|\u007F)"
if ((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
= True
' remove . \ / | : ? * " < > and control characters
= "(\.|\\|\/|\||:|\?|\*|""|\<|\>|[\u0000-\u001F]|\u007F)"
SanitizeFolderName = ( 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
= True
if ( ConfigForceSingleExtension = True ) then
= "\.(?![^.]*$)"
sNewFileName = ( sNewFileName, "_" )
'Get the file extension
sNewFileName = makefilename(now())&"."&GetExtend(sNewFileName)
end if
' remove \ / | : ? * " < > and control characters
= "(\\|\/|\||:|\?|\*|""|\<|\>|[\u0000-\u001F]|\u007F)"
SanitizeFileName = ( 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 'First fname is a variable, and the latter fname is a function parameter reference
fname = replace(fname,"-","")
fname = replace(fname," ","")
fname = replace(fname,":","")
fname = replace(fname,"PM","")
fname = replace(fname,"AM","")
fname = replace(fname,"morning","")
fname = replace(fname,"afternoon","")
makefilename = fname
end function
' This is the function that sends the results of the uploading process.
Sub SendUploadResults( errorNumber, fileUrl, fileName, customMsg )
"<script type=""text/javascript"">"
' Minified version of the automatic fix script (#1919).
' The original script can be found at _dev/domain_fix_template.js
"(function(){var d=;while (true){try{var A=;break;}catch(e) {};d=(/.*?(?:\.|$)/,'');if (==0) break;try{=d;}catch (e){break;}}})();"
"(" & errorNumber & ",""" & Replace( fileUrl, """", "\""" ) & """,""" & Replace( fileName, """", "\""" ) & """,""" & Replace( customMsg , """", "\""" ) & """) ;"
"</script>"
End Sub
%>