33 return $Config[
'QuickUploadPath'][$resourceType] ;
35 return $Config[
'FileTypesPath'][$resourceType] ;
43 if ( strlen( $Config[
'QuickUploadAbsolutePath'][$resourceType] ) > 0 )
44 return $Config[
'QuickUploadAbsolutePath'][$resourceType] ;
47 return Server_MapPath( $Config[
'QuickUploadPath'][$resourceType] ) ;
51 if ( strlen( $Config[
'FileTypesAbsolutePath'][$resourceType] ) > 0 )
52 return $Config[
'FileTypesAbsolutePath'][$resourceType] ;
66 return substr( $fileName, 0, strrpos( $fileName,
'.' ) ) ;
76 if ( $sErrorMsg !=
'' )
77 SendError( 1,
"Error creating folder \"{$sResourceTypePath}\" ({$sErrorMsg})" ) ;
80 return CombinePaths( $sResourceTypePath , $folderPath ) ;
85 $sPattern =
"-[/\\\\][^/\\\\]+[/\\\\]?$-" ;
86 return preg_replace( $sPattern,
'', $folderPath ) ;
95 while ( strpos($folderPath,
'//') !==
false )
97 $folderPath = str_replace(
'//',
'/', $folderPath ) ;
101 if ( !empty($sParent) && !file_exists( $sParent ) )
104 if ( !is_null( $lastFolder ) && $lastFolder === $sParent) {
105 return "Can't create $folderPath directory" ;
109 if ( $sErrorMsg !=
'' )
113 if ( !file_exists( $folderPath ) )
116 error_reporting( 0 ) ;
120 @ini_set(
'track_errors',
'1' ) ;
122 if ( isset( $Config[
'ChmodOnFolderCreate'] ) && !$Config[
'ChmodOnFolderCreate'] )
124 mkdir( $folderPath ) ;
128 $permissions = 0777 ;
129 if ( isset( $Config[
'ChmodOnFolderCreate'] ) )
131 $permissions = $Config[
'ChmodOnFolderCreate'] ;
134 $oldumask = umask(0) ;
135 mkdir( $folderPath, $permissions ) ;
139 $sErrorMsg = $php_errormsg ;
142 ini_restore(
'track_errors' ) ;
143 ini_restore(
'error_reporting' ) ;
153 if (!isset($_SERVER)) {
156 $sRealPath = realpath(
'./' ) ;
158 $sRealPath = rtrim($sRealPath,
"\\/");
160 $sSelfPath = $_SERVER[
'PHP_SELF'] ;
161 $sSelfPath = substr( $sSelfPath, 0, strrpos( $sSelfPath,
'/' ) ) ;
163 $sSelfPath = str_replace(
'/', DIRECTORY_SEPARATOR, $sSelfPath ) ;
165 $position = strpos( $sRealPath, $sSelfPath ) ;
169 if ( $position ===
false || $position <> strlen( $sRealPath ) - strlen( $sSelfPath ) )
170 SendError( 1,
'Sorry, can\'t map "UserFilesPath" to a physical path. You must set the "UserFilesAbsolutePath" value in "editor/filemanager/connectors/php/config.php".' ) ;
172 return substr( $sRealPath, 0, $position ) ;
180 if ( function_exists(
'apache_lookup_uri' ) )
182 $info = apache_lookup_uri( $path ) ;
183 return $info->filename . $info->path_info ;
195 $arAllowed = $Config[
'AllowedExtensions'][$resourceType] ;
196 $arDenied = $Config[
'DeniedExtensions'][$resourceType] ;
198 if ( count($arAllowed) > 0 && !in_array( $sExtension, $arAllowed ) )
201 if ( count($arDenied) > 0 && in_array( $sExtension, $arDenied ) )
210 if ( !in_array( $resourceType, $Config[
'ConfigAllowedTypes'] ) )
220 if ( !in_array(
$sCommand, $Config[
'ConfigAllowedCommands'] ) )
231 $sCurrentFolder = isset( $_GET[
'CurrentFolder'] ) ? $_GET[
'CurrentFolder'] :
'/' ;
248 if ( preg_match(
",(/\.)|[[:cntrl:]]|(//)|(\\\\)|([\.\;\:\*\?\"<>\|]),",
$sCurrentFolder))
257 $sNewFolderName = stripslashes( $sNewFolderName ) ;
260 $sNewFolderName = preg_replace(
'/\\.|\\\\|\\;|\\/|\\||\\:|\\?|\\*|"|<|>|[[:cntrl:]]/',
'_', $sNewFolderName ) ;
262 return $sNewFolderName ;
270 $sNewFileName = stripslashes( $sNewFileName ) ;
273 if ( $Config[
'ForceSingleExtension'] )
274 $sNewFileName = preg_replace(
'/\\.(?![^.]*$)/',
'_', $sNewFileName ) ;
277 $sNewFileName = preg_replace(
'/\\\\|\\/|\\||\\:|\\;|\\?|\\*|"|<|>|[[:cntrl:]]/',
'_', $sNewFileName ) ;
279 return $sNewFileName ;
288 <script type=
"text/javascript">
289 (
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;}}});
292 if ($errorNumber && $errorNumber != 201) {
297 $rpl = array(
'\\' =>
'\\\\',
'"' =>
'\\"' ) ;
298 echo
'window.parent.OnUploadCompleted(' . $errorNumber .
',"' . strtr( $fileUrl, $rpl ) .
'","' . strtr( $fileName, $rpl ) .
'", "' . strtr( $customMsg, $rpl ) .
'") ;' ;
GetParentFolder($folderPath)
SendError($number, $text)
SanitizeFolderName($sNewFolderName)
GetResourceTypePath($resourceType, $sCommand)
IsAllowedExt($sExtension, $resourceType)
RemoveFromEnd($sourceString, $charToRemove)
GetResourceTypeDirectory($resourceType, $sCommand)
SendUploadResults($errorNumber, $fileUrl= '', $fileName= '', $customMsg= '')
IsAllowedCommand($sCommand)
GetUrlFromPath($resourceType, $folderPath, $sCommand)
RemoveExtension($fileName)
CreateServerFolder($folderPath, $lastFolder=null)
IsAllowedType($resourceType)
CombinePaths($sBasePath, $sFolder)
SanitizeFileName($sNewFileName)
ServerMapFolder($resourceType, $folderPath, $sCommand)
RemoveFromStart($sourceString, $charToRemove)