TYPO3 API  SVNRelease
Public Member Functions | Public Attributes
t3lib_basicFileFunctions Class Reference
Inheritance diagram for t3lib_basicFileFunctions:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 init ($mounts, $f_ext)
 getTotalFileInfo ($wholePath)
 is_allowed ($iconkey, $type)
 checkIfFullAccess ($theDest)
 is_webpath ($path)
 checkIfAllowed ($ext, $theDest, $filename= '')
 checkFileNameLen ($fileName)
 is_directory ($theDir)
 isPathValid ($theFile)
 getUniqueName ($theFile, $theDest, $dontCheckForUnique=0)
 checkPathAgainstMounts ($thePath)
 findFirstWebFolder ()
 blindPath ($thePath)
 findTempFolder ()
 cleanDirectoryName ($theDir)
 rmDoubleSlash ($string)
 slashPath ($path)
 cleanFileName ($fileName, $charset= '')

Public Attributes

 $getUniqueNamePrefix = ''
 $maxNumber = 99
 $uniquePrecision = 6
 $maxInputNameLen = 60
 $tempFN = '_temp_'
 $f_ext = Array()
 $mounts = Array()
 $webPath = ''
 $isInit = 0

Detailed Description

Definition at line 79 of file class.t3lib_basicfilefunc.php.


Member Function Documentation

t3lib_basicFileFunctions::blindPath ( thePath)

Removes filemount part of a path, thus blinding the position. Takes a path, $thePath, and removes the part of the path which equals the filemount.

Parameters:
string$thePathis a path which MUST be found within one of the internally set filemounts, $this->mounts
Returns:
string The processed input path

Definition at line 382 of file class.t3lib_basicfilefunc.php.

References checkPathAgainstMounts().

t3lib_basicFileFunctions::checkFileNameLen ( fileName)

Returns true if the input filename string is shorter than $this->maxInputNameLen.

Parameters:
stringFilename, eg "somefile.html"
Returns:
boolean

Definition at line 263 of file class.t3lib_basicfilefunc.php.

Referenced by t3lib_extFileFunctions\func_newfile(), t3lib_extFileFunctions\func_newfolder(), and t3lib_extFileFunctions\func_rename().

t3lib_basicFileFunctions::checkIfAllowed ( ext,
theDest,
filename = '' 
)

If the filename is given, check it against the TYPO3_CONF_VARS[BE][fileDenyPattern] + Checks if the $ext fileextension is allowed in the path $theDest (this is based on whether $theDest is below the $this->webPath)

Parameters:
stringFile extension, eg. "php" or "html"
stringAbsolute path for which to test
stringFilename to check against TYPO3_CONF_VARS[BE][fileDenyPattern]
Returns:
boolean True if extension/filename is allowed

Definition at line 253 of file class.t3lib_basicfilefunc.php.

References is_allowed(), is_webpath(), and t3lib_div\verifyFilenameAgainstDenyPattern().

Referenced by t3lib_extFileFunctions\func_copy(), t3lib_extFileFunctions\func_edit(), t3lib_extFileFunctions\func_move(), t3lib_extFileFunctions\func_newfile(), t3lib_extFileFunctions\func_rename(), and t3lib_extFileFunctions\func_upload().

t3lib_basicFileFunctions::checkIfFullAccess ( theDest)

Returns true if you can operate of ANY file ('*') in the space $theDest is in ('webspace' / 'ftpspace')

Parameters:
stringAbsolute path
Returns:
boolean

Definition at line 217 of file class.t3lib_basicfilefunc.php.

References is_webpath().

Referenced by t3lib_extFileFunctions\func_copy(), t3lib_extFileFunctions\func_move(), and t3lib_extFileFunctions\func_unzip().

t3lib_basicFileFunctions::checkPathAgainstMounts ( thePath)

Checks if $thePath is a path under one of the paths in $this->mounts See comment in the header of this class.

Parameters:
string$thePathMUST HAVE a trailing '/' in order to match correctly with the mounts
Returns:
string The key to the first mount found, otherwise nothing is returned.
See also:
init()

Definition at line 348 of file class.t3lib_basicfilefunc.php.

References t3lib_div\isFirstPartOfStr(), and isPathValid().

Referenced by blindPath(), t3lib_extFileFunctions\findRecycler(), t3lib_extFileFunctions\func_copy(), t3lib_extFileFunctions\func_delete(), t3lib_extFileFunctions\func_edit(), t3lib_extFileFunctions\func_move(), t3lib_extFileFunctions\func_newfile(), t3lib_extFileFunctions\func_newfolder(), t3lib_extFileFunctions\func_rename(), t3lib_extFileFunctions\func_unzip(), and t3lib_extFileFunctions\func_upload().

t3lib_basicFileFunctions::cleanDirectoryName ( theDir)

Removes all dots, slashes and spaces after a path...

Parameters:
stringInput string
Returns:
string Output string

Definition at line 422 of file class.t3lib_basicfilefunc.php.

References rmDoubleSlash().

Referenced by t3lib_extFileFunctions\findRecycler(), and is_directory().

t3lib_basicFileFunctions::cleanFileName ( fileName,
charset = '' 
)

Returns a string where any character not matching [.a-zA-Z0-9_-] is substituted by '_' Trailing dots are removed

Parameters:
stringInput string, typically the body of a filename
stringCharset of the a filename (defaults to current charset; depending on context)
Returns:
string Output string with any characters not matching [.a-zA-Z0-9_-] is substituted by '_' and trailing dots removed

Definition at line 457 of file class.t3lib_basicfilefunc.php.

References $GLOBALS, and t3lib_div\makeInstance().

Referenced by t3lib_extFileFunctions\func_newfile(), t3lib_extFileFunctions\func_newfolder(), t3lib_extFileFunctions\func_rename(), and t3lib_extFileFunctions\func_upload().

t3lib_basicFileFunctions::findFirstWebFolder ( )

Find first web folder (relative to PATH_site.'fileadmin') in filemounts array

Returns:
string The key to the first mount inside PATH_site."fileadmin" found, otherwise nothing is returned.

Definition at line 363 of file class.t3lib_basicfilefunc.php.

References $TYPO3_CONF_VARS, and t3lib_div\isFirstPartOfStr().

t3lib_basicFileFunctions::findTempFolder ( )

Find temporary folder Finds the first $this->tempFN ('_temp_' usually) -folder in the internal array of filemounts, $this->mounts

Returns:
string Returns the path if found, otherwise nothing if error.

Definition at line 398 of file class.t3lib_basicfilefunc.php.

t3lib_basicFileFunctions::getTotalFileInfo ( wholePath)

Returns an array with a whole lot of fileinformation. Information includes:

  • path : path part of give file
  • file : filename
  • filebody : filename without extension
  • fileext : lowercase extension
  • realFileext : extension
  • tstamp : timestamp of modification
  • size : file size
  • type : file type (block/char/dir/fifo/file/link)
  • owner : user ID of owner of file
  • perms : numerical representation of file permissions
  • writable : is file writeable by web user (FALSE = yes; TRUE = no) *)
  • readable : is file readable by web user (FALSE = yes; TRUE = no) *)

*) logic is reversed because of handling by functions in class.file_list.inc

Parameters:
stringFilepath to existing file. Should probably be absolute. Filefunctions are performed on this value.
Returns:
array Information about the file in the filepath

Definition at line 164 of file class.t3lib_basicfilefunc.php.

References t3lib_div\split_fileref().

t3lib_basicFileFunctions::getUniqueName ( theFile,
theDest,
dontCheckForUnique = 0 
)

Returns the destination path/filename of a unique filename/foldername in that path. If $theFile exists in $theDest (directory) the file have numbers appended up to $this->maxNumber. Hereafter a unique string will be appended. This function is used by fx. TCEmain when files are attached to records and needs to be uniquely named in the uploads/* folders

Parameters:
stringThe input filename to check
stringThe directory for which to return a unique filename for $theFile. $theDest MUST be a valid directory. Should be absolute.
booleanIf set the filename is returned with the path prepended without checking whether it already existed!
Returns:
string The destination absolute filepath (not just the name!) of a unique filename/foldername in that path.
See also:
t3lib_TCEmain::checkValue()

Definition at line 305 of file class.t3lib_basicfilefunc.php.

References is_directory(), and t3lib_div\split_fileref().

Referenced by t3lib_extFileFunctions\func_copy(), t3lib_extFileFunctions\func_move(), and t3lib_extFileFunctions\func_upload().

t3lib_basicFileFunctions::init ( mounts,
f_ext 
)

Constructor This function should be called to initialise the internal arrays $this->mounts and $this->f_ext

A typical example of the array $mounts is this: $mounts[xx][path] = (..a mounted path..) the 'xx'-keys is just numerical from zero. There are also a [name] and [type] value that just denotes the mountname and type. Not used for athentication here. $this->mounts is traversed in the function checkPathAgainstMounts($thePath), and it is checked that $thePath is actually below one of the mount-paths The mountpaths are with a trailing '/'. $thePath must be with a trailing '/' also! As you can see, $this->mounts is very critical! This is the array that decides where the user will be allowed to copy files!! Typically the global var $WEBMOUNTS would be passed along as $mounts

A typical example of the array $f_ext is this: $f_ext['webspace']['allow']=''; $f_ext['webspace']['deny']= PHP_EXTENSIONS_DEFAULT; $f_ext['ftpspace']['allow']='*'; $f_ext['ftpspace']['deny']=''; The control of fileextensions goes in two catagories. Webspace and Ftpspace. Webspace is folders accessible from a webbrowser (below TYPO3_DOCUMENT_ROOT) and ftpspace is everything else. The control is done like this: If an extension matches 'allow' then the check returns true. If not and an extension matches 'deny' then the check return false. If no match at all, returns true. You list extensions comma-separated. If the value is a '*' every extension is allowed The list is case-insensitive when used in this class (see init()) Typically TYPO3_CONF_VARS['BE']['fileExtensions'] would be passed along as $f_ext.

Example: $basicff->init($GLOBALS['FILEMOUNTS'],$TYPO3_CONF_VARS['BE']['fileExtensions']);

Parameters:
arrayContains the paths of the file mounts for the current BE user. Normally $GLOBALS['FILEMOUNTS'] is passed. This variable is set during backend user initialization; $FILEMOUNTS = $BE_USER->returnFilemounts(); (see typo3/init.php)
arrayArray with information about allowed and denied file extensions. Typically passed: $TYPO3_CONF_VARS['BE']['fileExtensions']
Returns:
void
See also:
typo3/init.php, t3lib_userAuthGroup::returnFilemounts()

Definition at line 130 of file class.t3lib_basicfilefunc.php.

References $f_ext, $GLOBALS, $mounts, t3lib_div\getIndpEnv(), and t3lib_div\uniqueList().

t3lib_basicFileFunctions::is_allowed ( iconkey,
type 
)

Checks if a $iconkey (fileextension) is allowed according to $this->f_ext.

Parameters:
stringThe extension to check, eg. "php" or "html" etc.
stringEither "webspage" or "ftpspace" - points to a key in $this->f_ext
Returns:
boolean True if file extension is allowed.

Definition at line 184 of file class.t3lib_basicfilefunc.php.

References t3lib_div\inList().

Referenced by checkIfAllowed().

t3lib_basicFileFunctions::is_directory ( theDir)

Cleans $theDir for slashes in the end of the string and returns the new path, if it exists on the server.

Parameters:
stringDirectory path to check
Returns:
string Returns the cleaned up directory name if OK, otherwise false.

Definition at line 273 of file class.t3lib_basicfilefunc.php.

References cleanDirectoryName(), and isPathValid().

Referenced by t3lib_extFileFunctions\func_copy(), t3lib_extFileFunctions\func_delete(), t3lib_extFileFunctions\func_move(), t3lib_extFileFunctions\func_newfile(), t3lib_extFileFunctions\func_newfolder(), t3lib_extFileFunctions\func_unzip(), t3lib_extFileFunctions\func_upload(), and getUniqueName().

t3lib_basicFileFunctions::is_webpath ( path)

Checks if $this->webPath (should be TYPO3_DOCUMENT_ROOT) is in the first part of $path Returns true also if $this->init is not set or if $path is empty...

Parameters:
stringAbsolute path to check
Returns:
boolean

Definition at line 233 of file class.t3lib_basicfilefunc.php.

References t3lib_div\isFirstPartOfStr(), and slashPath().

Referenced by checkIfAllowed(), and checkIfFullAccess().

t3lib_basicFileFunctions::isPathValid ( theFile)

Wrapper for t3lib_div::validPathStr()

Parameters:
stringFilepath to evaluate
Returns:
boolean True, if no '//', '..' or '\' is in the $theFile
See also:
t3lib_div::validPathStr()

Definition at line 290 of file class.t3lib_basicfilefunc.php.

References t3lib_div\validPathStr().

Referenced by checkPathAgainstMounts(), t3lib_extFileFunctions\findRecycler(), t3lib_extFileFunctions\func_copy(), t3lib_extFileFunctions\func_delete(), t3lib_extFileFunctions\func_move(), and is_directory().

t3lib_basicFileFunctions::rmDoubleSlash ( string)

Converts any double slashes (//) to a single slash (/)

Parameters:
stringInput value
Returns:
string Returns the converted string

Definition at line 432 of file class.t3lib_basicfilefunc.php.

Referenced by cleanDirectoryName().

t3lib_basicFileFunctions::slashPath ( path)

Returns a string which has a slash '/' appended if it doesn't already have that slash

Parameters:
stringInput string
Returns:
string Output string with a slash in the end (if not already there)

Definition at line 442 of file class.t3lib_basicfilefunc.php.

Referenced by is_webpath().


Member Data Documentation

t3lib_basicFileFunctions::$f_ext = Array()

Definition at line 87 of file class.t3lib_basicfilefunc.php.

Referenced by init().

t3lib_basicFileFunctions::$getUniqueNamePrefix = ''

Definition at line 80 of file class.t3lib_basicfilefunc.php.

t3lib_basicFileFunctions::$isInit = 0

Definition at line 90 of file class.t3lib_basicfilefunc.php.

t3lib_basicFileFunctions::$maxInputNameLen = 60

Definition at line 83 of file class.t3lib_basicfilefunc.php.

t3lib_basicFileFunctions::$maxNumber = 99

Definition at line 81 of file class.t3lib_basicfilefunc.php.

t3lib_basicFileFunctions::$mounts = Array()

Definition at line 88 of file class.t3lib_basicfilefunc.php.

Referenced by init().

t3lib_basicFileFunctions::$tempFN = '_temp_'

Definition at line 84 of file class.t3lib_basicfilefunc.php.

t3lib_basicFileFunctions::$uniquePrecision = 6

Definition at line 82 of file class.t3lib_basicfilefunc.php.

t3lib_basicFileFunctions::$webPath = ''

Definition at line 89 of file class.t3lib_basicfilefunc.php.


The documentation for this class was generated from the following file: