| [ Index ] |
PHP Cross Reference of moodle-2.8 |
[Source view] [Print] [Project Stats]
uploadlib.php - This class handles all aspects of fileuploading
| Copyright: | 1999 onwards Martin Dougiamas {@link http://moodle.com} |
| License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
| File Size: | 725 lines (29 kb) |
| Included or required: | 0 times |
| Referenced: | 0 times |
| Includes or requires: | 0 files |
upload_manager:: (18 methods):
__construct()
preprocess_files()
validate_file()
save_files()
process_file_uploads()
delete_other_files()
handle_filename_collision()
check_before_renaming()
get_file_upload_error()
print_upload_log()
get_new_filename()
get_new_filepath()
get_original_filename()
get_errors()
clam_handle_infected_file()
clam_scan_moodle_file()
clam_message_admins()
get_clam_error_code()
Class: upload_manager - X-Ref
This class handles all aspects of fileuploading| __construct($inputname='', $deleteothers=false, $handlecollisions=false, $course=null, $recoverifmultiple=false, $modbytes=0, $silent=false, $allownull=false, $allownullmultiple=true) X-Ref |
| Constructor, sets up configuration stuff so we know how to act. Note: destination not taken as parameter as some modules want to use the insertid in the path and we need to check the other stuff first. param: string $inputname If this is given the upload manager will only process the file in $_FILES with this name. param: boolean $deleteothers Whether to delete other files in the destination directory (optional, defaults to false) param: boolean $handlecollisions Whether to use {@link handle_filename_collision()} or not. (optional, defaults to false) param: course $course The course the files are being uploaded for (for logging and virus notifications) {@link $COURSE} param: boolean $recoverifmultiple If we come across a virus, or if a file doesn't validate or whatever, do we continue? optional, defaults to true. param: int $modbytes Max bytes for this module - this and $course->maxbytes are used to get the maxbytes from {@link get_max_upload_file_size()}. param: boolean $silent Whether to notify errors or not. param: boolean $allownull Whether we care if there's no file when we've set the input name. param: boolean $allownullmultiple Whether we care if there's no files AT ALL when we've got multiples. This won't complain if we have file 1 and file 3 but not file 2, only for NO FILES AT ALL. |
| preprocess_files() X-Ref |
| Gets all entries out of $_FILES and stores them locally in $files and then checks each one against {@link get_max_upload_file_size()} and calls {@link cleanfilename()} and scans them for viruses etc. return: boolean |
| validate_file(&$file) X-Ref |
| Validates a single file entry from _FILES param: object $file The entry from _FILES to validate return: boolean True if ok. |
| save_files($destination) X-Ref |
| Moves all the files to the destination directory. param: string $destination The destination directory. return: boolean status; |
| process_file_uploads($destination) X-Ref |
| Wrapper function that calls {@link preprocess_files()} and {@link viruscheck_files()} and then {@link save_files()} Modules that require the insert id in the filepath should not use this and call these functions seperately in the required order. return: boolean |
| delete_other_files($destination, $exceptions=null) X-Ref |
| Deletes all the files in a given directory except for the files in $exceptions (full paths) param: string $destination The directory to clean up. param: array $exceptions Full paths of files to KEEP. |
| handle_filename_collision($destination, &$file) X-Ref |
| Handles filename collisions - if the desired filename exists it will rename it according to the pattern in $format param: string $destination Destination directory (to check existing files against) param: object $file Passed in by reference. The current file from $files we're processing. return: void - modifies &$file parameter. |
| check_before_renaming($destination, $nametocheck, $file) X-Ref |
| This function checks a potential filename against what's on the filesystem already and what's been saved already. param: string $destination Destination directory (to check existing files against) param: string $nametocheck The filename to be compared. param: object $file The current file from $files we're processing. |
| get_file_upload_error(&$file) X-Ref |
| ? param: object $file Passed in by reference. The current file from $files we're processing. return: string |
| print_upload_log($return=false,$skipemptyifmultiple=false) X-Ref |
| prints a log of everything that happened (of interest) to each file in _FILES param: $return - optional, defaults to false (log is echoed) |
| get_new_filename() X-Ref |
| If we're only handling one file (if inputname was given in the constructor) this will return the (possibly changed) filename of the file. |
| get_new_filepath() X-Ref |
| If we're only handling one file (if input name was given in the constructor) this will return the full path to the saved file. return: boolean |
| get_original_filename() X-Ref |
| If we're only handling one file (if inputname was given in the constructor) this will return the ORIGINAL filename of the file. return: boolean |
| get_errors() X-Ref |
| This function returns any errors wrapped up in red. return: string |
| clam_handle_infected_file($file, $userid=0, $basiconly=false) X-Ref |
| Deals with an infected file - either moves it to a quarantinedir (specified in CFG->quarantinedir) or deletes it. If moving it fails, it deletes it. param: string $file Full path to the file param: int $userid If not used, defaults to $USER->id (there in case called from cron) param: boolean $basiconly Admin level reporting or user level reporting. return: string Details of what the function did. |
| clam_scan_moodle_file(&$file, $course) X-Ref |
| If $CFG->runclamonupload is set, we scan a given file. (called from {@link preprocess_files()}) param: mixed $file The file to scan from $files. or an absolute path to a file. param: stdClass $course return: int 1 if good, 0 if something goes wrong (opposite from actual error code from clam) |
| clam_message_admins($notice) X-Ref |
| Emails admins about a clam outcome param: string $notice The body of the email to be sent. |
| get_clam_error_code($returncode) X-Ref |
| Returns the string equivalent of a numeric clam error code param: int $returncode The numeric error code in question. return: string The definition of the error code |
| Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |