claroline/claroline/inc/lib/fileUpload.lib.php File Reference
Go to the source code of this file.
Namespaces |
| namespace | CLDOC |
Functions |
| | php2phps ($fileName) |
| | htaccess2txt ($fileName) |
| | get_secure_file_name ($fileName) |
| | enough_size ($fileSize, $dir, $maxDirSpace) |
| | dir_total_space ($dirPath) |
| | add_extension_for_uploaded_file ($uploadedFile) |
| | get_extension_from_file_name ($fileName) |
| | get_extension_from_mime_type ($mimeType) |
| | get_mime_type_from_extension ($extension) |
| | get_mime_type_extension_map () |
| | treat_uploaded_file ($uploadedFile, $baseWorkDir, $uploadPath, $maxFilledSpace, $uncompress= '', $allowPHP=false) |
| | treat_secure_uploaded_file_unzip ($uploadedFile, $uploadPath, $baseWorkDir, $maxFilledSpace, $allowPHP=false) |
| | treat_secure_file_unzip ($fileName, $filePath, $extractPath, $maxFilledSpace, $allowPHP=false) |
| | search_img_from_html ($htmlFile) |
| | create_unexisting_directory ($desiredDirName) |
| | get_unexisting_file_name ($desiredDirName) |
| | move_uploaded_file_collection_into_directory ($uploadedFileCollection, $destPath) |
| | replace_img_path_in_html_file ($originalImgPath, $newImgPath, $htmlFile) |
| | create_link_file ($filePath, $url) |
| | create_file ($filePath, $fileContent) |
| | get_max_upload_size ($maxFilledSpace, $baseWorkDir) |
Function Documentation
| add_extension_for_uploaded_file |
( |
$ |
uploadedFile |
) |
|
Try to add an extension to files witout extension Some applications on Macintosh computers don't add an extension to the files. This subroutine try to fix this on the basis of the MIME type send by the browser.
Note : some browsers don't send the MIME Type (e.g. Netscape 4). We don't have solution for this kind of situation
- Parameters:
-
| array | $uploadedFile It has to be the superglobals $_FILE['myFile'] array |
- Returns:
- string : extension (empty string if the file has already an extension)
Definition at line 174 of file fileUpload.lib.php.
| create_file |
( |
$ |
filePath, |
|
|
$ |
fileContent | |
|
) |
| | |
| create_link_file |
( |
$ |
filePath, |
|
|
$ |
url | |
|
) |
| | |
| create_unexisting_directory |
( |
$ |
desiredDirName |
) |
|
creates a new directory trying to find a directory name that doesn't already exist
- Author:
- Hugues Peeters <hugues.peeters@claroline.net>
- Parameters:
-
| string | $desiredDirName complete path of the desired name |
- Returns:
- string actual directory name if it succeeds, boolean false otherwise
Definition at line 493 of file fileUpload.lib.php.
| dir_total_space |
( |
$ |
dirPath |
) |
|
Compute the size already occupied by a directory and is subdirectories
- Parameters:
-
| string | $dirPath Size of the file in byte |
- Returns:
- integer : the directory size in bytes
Definition at line 117 of file fileUpload.lib.php.
| enough_size |
( |
$ |
fileSize, |
|
|
$ |
dir, |
|
|
$ |
maxDirSpace | |
|
) |
| | |
Check if there is enough place to add a file on a directory on the base of a maximum directory size allowed
- Parameters:
-
| interger | $fileSize Size of the file in byte |
| string | $dir Path of the directory where the file should be added |
| interger | $maxDirSpace Maximum size of the diretory in byte |
- Returns:
- mixed : boolean true if there is enough space false otherwise
- See also:
- - enough_size() uses dir_total_space() function
Definition at line 91 of file fileUpload.lib.php.
| get_extension_from_file_name |
( |
$ |
fileName |
) |
|
Return the extention of a given filename
- Parameters:
-
- Returns:
- mixed : string : extension or false : if no extension is found
Definition at line 204 of file fileUpload.lib.php.
| get_extension_from_mime_type |
( |
$ |
mimeType |
) |
|
return the common extension for a given mimeType
- Parameters:
-
- Returns:
- mixed : string : extension or false : if no extension is found
Definition at line 221 of file fileUpload.lib.php.
| get_max_upload_size |
( |
$ |
maxFilledSpace, |
|
|
$ |
baseWorkDir | |
|
) |
| | |
Determine the maximum size allowed to upload. This size is based on the tool $maxFilledSpace regarding the space already opccupied by previous uploaded files, and the php.ini upload_max_filesize and post_max_size parameters. This value is diplayed on the upload form.
- Parameters:
-
| integer | $maxFilledSpace local max allowed file size e.g. remaining place in an allocated course directory |
- Returns:
- integer : lower value between php.ini values of upload_max_filesize and post_max_size and the claroline value of size left in directory
- See also:
- - get_max_upload_size() uses dir_total_space() function
Definition at line 661 of file fileUpload.lib.php.
| get_mime_type_extension_map |
( |
|
) |
|
Typical use : list(mimeTypeLis, $extensionList) = get_mime_type_extension_map()
- Returns:
- array : nested array containing two other arrays, the firt one with the MIME TYPES, and the second with the corresponding EXTENSIONS. keys of both sub arrays are mapped
Definition at line 259 of file fileUpload.lib.php.
| get_mime_type_from_extension |
( |
$ |
extension |
) |
|
| get_secure_file_name |
( |
$ |
fileName |
) |
|
change the file named .htacess in htacess.txt Useful to secure a site working on Apache.
- Parameters:
-
| - | fileName (string) name of a file |
- Returns:
- - string innocuous filename
- See also:
- - htaccess2txt and php2phps
Definition at line 67 of file fileUpload.lib.php.
| get_unexisting_file_name |
( |
$ |
desiredDirName |
) |
|
creates a guinely file name that doesn't already exist inside a specific path
- Author:
- Hugues Peeters <hugues.peeters@claroline.net>
- Parameters:
-
| string | $desiredDirName complete path of the desired name |
- Returns:
- string actual file name if it succeeds, boolean false otherwise
Definition at line 513 of file fileUpload.lib.php.
| htaccess2txt |
( |
$ |
fileName |
) |
|
change the file named .htacess in htacess.txt Useful to secure a site working on Apache.
- Parameters:
-
| string | $fileName Name of a file |
- Returns:
- string : 'Apache safe' file name
Definition at line 50 of file fileUpload.lib.php.
| move_uploaded_file_collection_into_directory |
( |
$ |
uploadedFileCollection, |
|
|
$ |
destPath | |
|
) |
| | |
Change the file name extension from .php to .phps Useful to secure a site !!
- Parameters:
-
| string | $fileName Name of a file |
- Returns:
- string : the filename phps'ized
Definition at line 34 of file fileUpload.lib.php.
| replace_img_path_in_html_file |
( |
$ |
originalImgPath, |
|
|
$ |
newImgPath, |
|
|
$ |
htmlFile | |
|
) |
| | |
| search_img_from_html |
( |
$ |
htmlFile |
) |
|
| treat_secure_file_unzip |
( |
$ |
fileName, |
|
|
$ |
filePath, |
|
|
$ |
extractPath, |
|
|
$ |
maxFilledSpace, |
|
|
$ |
allowPHP = false | |
|
) |
| | |
unzip safly a zipfile
- Author:
- Hugues Peeters <hugues.peeters@claroline.net>
- Parameters:
-
| string | $fileName file name of zip |
| string | $filePath file path of zip |
| string | $extractPath |
| integer | $maxFilledSpace (byte) count of byte size aivailable |
| boolean | $allowPHP whether True the file can't contain php or phtml files |
- Returns:
- true
- Exceptions:
-
Definition at line 397 of file fileUpload.lib.php.
| treat_secure_uploaded_file_unzip |
( |
$ |
uploadedFile, |
|
|
$ |
uploadPath, |
|
|
$ |
baseWorkDir, |
|
|
$ |
maxFilledSpace, |
|
|
$ |
allowPHP = false | |
|
) |
| | |
Securely manage all the unzipping process of an uploaded document
- Author:
- Christophe Gesché <moosh@claroline.net>
- Parameters:
-
| array | $uploadedFile - follows the $_FILES Structure |
| string | $uploadPath - destination of the upload. This path is to append to $baseWorkDir |
| string | $baseWorkDir - base working directory of the module |
| int | $maxFilledSpace - amount of bytes to not exceed in the base working directory |
| string | $allowPHP - if set to true, then there is no security check for .php files |
- Returns:
- boolean true if it succeeds false otherwise
Definition at line 376 of file fileUpload.lib.php.
| treat_uploaded_file |
( |
$ |
uploadedFile, |
|
|
$ |
baseWorkDir, |
|
|
$ |
uploadPath, |
|
|
$ |
maxFilledSpace, |
|
|
$ |
uncompress = '', |
|
|
$ |
allowPHP = false | |
|
) |
| | |
Executes all the necessary operation to upload the file in the document tool
- Author:
- Hugues Peeters <hugues.peeters@claroline.net>
- Parameters:
-
| array | $uploadedFile - follows the $_FILES Structure |
| string | $baseWorkDir - base working directory of the module |
| string | $uploadPath - destination of the upload. This path is to append to $baseWorkDir |
| int | $maxFilledSpace - amount of bytes to not exceed in the base working directory |
| string | $uncompress - whether 'unzip' and file is a zip; extract the content. |
| string | $allowPHP - if set to true, then there is no security check for .php files |
- Returns:
- boolean : true if it succeds, false otherwise
Definition at line 314 of file fileUpload.lib.php.