[ Index ] |
PHP Cross Reference of MediaWiki-1.24.0 |
[Source view] [Print] [Project Stats]
Base class for the backend of file upload. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
File Size: | 1983 lines (59 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
getVerificationErrorCode( $error ) X-Ref |
param: int $error return: string |
isEnabled() X-Ref |
Returns true if uploads are enabled. Can be override by subclasses. return: bool |
isAllowed( $user ) X-Ref |
Returns true if the user can use this upload module or else a string identifying the missing permission. Can be overridden by subclasses. param: User $user return: bool|string |
createFromRequest( &$request, $type = null ) X-Ref |
Create a form of UploadBase depending on wpSourceType and initializes it param: WebRequest $request param: string|null $type return: null|UploadBase |
isValidRequest( $request ) X-Ref |
Check whether a request if valid for this handler param: WebRequest $request return: bool |
__construct() X-Ref |
No description |
getSourceType() X-Ref |
Returns the upload type. Should be overridden by child classes return: string |
initializePathInfo( $name, $tempPath, $fileSize, $removeTempFile = false ) X-Ref |
Initialize the path information param: string $name The desired destination name param: string $tempPath The temporary path param: int $fileSize The file size param: bool $removeTempFile (false) remove the temporary file? |
fetchFile() X-Ref |
Fetch the file. Usually a no-op return: Status |
isEmptyFile() X-Ref |
Return true if the file is empty return: bool |
getFileSize() X-Ref |
Return the file size return: int |
getTempFileSha1Base36() X-Ref |
Get the base 36 SHA1 of the file return: string |
getRealPath( $srcPath ) X-Ref |
param: string $srcPath The source path return: string|bool The real path if it was a virtual URL Returns false on failure |
verifyUpload() X-Ref |
Verify whether the upload is sane. return: mixed Const self::OK or else an array with error information |
validateName() X-Ref |
Verify that the name is valid and, if necessary, that we can overwrite return: mixed True if valid, otherwise and array with 'status' |
verifyMimeType( $mime ) X-Ref |
Verify the MIME type. param: string $mime Representing the MIME return: mixed True if the file is verified, an array otherwise |
verifyFile() X-Ref |
Verifies that it's ok to include the uploaded file return: mixed True of the file is verified, array otherwise. |
verifyPartialFile() X-Ref |
A verification routine suitable for partial files Runs the blacklist checks, but not any checks that may assume the entire file is present. return: mixed True for valid or array with error message key. |
zipEntryCallback( $entry ) X-Ref |
Callback for ZipDirectoryReader to detect Java class files. param: array $entry |
verifyPermissions( $user ) X-Ref |
Alias for verifyTitlePermissions. The function was originally 'verifyPermissions', but that suggests it's checking the user, when it's really checking the title + user combination. param: User $user User object to verify the permissions against return: mixed An array as returned by getUserPermissionsErrors or true |
verifyTitlePermissions( $user ) X-Ref |
Check whether the user can edit, upload and create the image. This checks only against the current title; if it returns errors, it may very well be that another title will not give errors. Therefore isAllowed() should be called as well for generic is-user-blocked or can-user-upload checking. param: User $user User object to verify the permissions against return: mixed An array as returned by getUserPermissionsErrors or true |
checkWarnings() X-Ref |
Check for non fatal problems with the file. This should not assume that mTempPath is set. return: array Array of warnings |
performUpload( $comment, $pageText, $watch, $user ) X-Ref |
Really perform the upload. Stores the file in the local repo, watches if necessary and runs the UploadComplete hook. param: string $comment param: string $pageText param: bool $watch param: User $user return: Status Indicating the whether the upload succeeded. |
getTitle() X-Ref |
Returns the title of the file to be uploaded. Sets mTitleError in case the name was illegal. return: Title The title of the file or null in case the name was illegal |
getLocalFile() X-Ref |
Return the local file and initializes if necessary. return: LocalFile|UploadStashFile|null |
stashFile( User $user = null ) X-Ref |
If the user does not supply all necessary information in the first upload form submission (either by accident or by design) then we may want to stash the file temporarily, get more information, and publish the file later. This method will stash a file in a temporary directory for later processing, and save the necessary descriptive info into the database. This method returns the file object, which also has a 'fileKey' property which can be passed through a form or API request to find this stashed file again. param: User $user return: UploadStashFile Stashed file |
stashFileGetKey() X-Ref |
Stash a file in a temporary directory, returning a key which can be used to find the file again. See stashFile(). return: string File key |
stashSession() X-Ref |
alias for stashFileGetKey, for backwards compatibility return: string File key |
cleanupTempFile() X-Ref |
If we've modified the upload file we need to manually remove it on exit to clean up. |
getTempPath() X-Ref |
No description |
splitExtensions( $filename ) X-Ref |
Split a file into a base name and all dot-delimited 'extensions' on the end. Some web server configurations will fall back to earlier pseudo-'extensions' to determine type and execute scripts, so the blacklist needs to check them all. param: string $filename return: array |
checkFileExtension( $ext, $list ) X-Ref |
Perform case-insensitive match against a list of file extensions. Returns true if the extension is in the list. param: string $ext param: array $list return: bool |
checkFileExtensionList( $ext, $list ) X-Ref |
Perform case-insensitive match against a list of file extensions. Returns an array of matching extensions. param: array $ext param: array $list return: bool |
verifyExtension( $mime, $extension ) X-Ref |
Checks if the MIME type of the uploaded file matches the file extension. param: string $mime The MIME type of the uploaded file param: string $extension The filename extension that the file is to be served with return: bool |
detectScript( $file, $mime, $extension ) X-Ref |
Heuristic for detecting files that *could* contain JavaScript instructions or things that may look like HTML to a browser and are thus potentially harmful. The present implementation will produce false positives in some situations. param: string $file Pathname to the temporary upload file param: string $mime The MIME type of the file param: string $extension The extension of the file return: bool True if the file contains something looking like embedded scripts |
checkXMLEncodingMissmatch( $file ) X-Ref |
Check a whitelist of xml encodings that are known not to be interpreted differently by the server's xml parser (expat) and some common browsers. param: string $file Pathname to the temporary upload file return: bool True if the file contains an encoding that could be misinterpreted |
detectScriptInSvg( $filename ) X-Ref |
param: string $filename return: mixed False of the file is verified (does not contain scripts), array otherwise. |
checkSvgPICallback( $target, $data ) X-Ref |
Callback to filter SVG Processing Instructions. param: string $target Processing instruction name param: string $data Processing instruction attribute and value return: bool (true if the filter identified something bad) |
checkSvgScriptCallback( $element, $attribs, $data = null ) X-Ref |
param: string $element param: array $attribs return: bool |
checkCssFragment( $value ) X-Ref |
Check a block of CSS or CSS fragment for anything that looks like it is bringing in remote code. param: string $value a string of CSS param: bool $propOnly only check css properties (start regex with :) return: bool true if the CSS contains an illegal string, false if otherwise |
splitXmlNamespace( $element ) X-Ref |
Divide the element name passed by the xml parser to the callback into URI and prifix. param: string $element return: array Containing the namespace URI and prefix |
stripXmlNamespace( $name ) X-Ref |
param: string $name return: string |
detectVirus( $file ) X-Ref |
Generic wrapper function for a virus scanner program. This relies on the $wgAntivirus and $wgAntivirusSetup variables. $wgAntivirusRequired may be used to deny upload if the scan fails. param: string $file Pathname to the temporary upload file return: mixed False if not virus is found, null if the scan fails or is disabled, |
checkOverwrite( $user ) X-Ref |
Check if there's an overwrite conflict and, if so, if restrictions forbid this user from performing the upload. param: User $user return: mixed True on success, array on failure |
userCanReUpload( User $user, $img ) X-Ref |
Check if a user is the last uploader param: User $user param: string $img Image name return: bool |
getExistsWarning( $file ) X-Ref |
Helper function that does various existence checks for a file. The following checks are performed: - The file exists - Article with the same name as the file exists - File exists with normalized extension - The file looks like a thumbnail and the original exists param: File $file The File object to check return: mixed False if the file does not exists, else an array |
isThumbName( $filename ) X-Ref |
Helper function that checks whether the filename looks like a thumbnail param: string $filename return: bool |
getFilenamePrefixBlacklist() X-Ref |
Get a list of blacklisted filename prefixes from [[MediaWiki:Filename-prefix-blacklist]] return: array List of prefixes |
getImageInfo( $result ) X-Ref |
Gets image info about the file just uploaded. Also has the effect of setting metadata to be an 'indexed tag name' in returned API result if 'metadata' was requested. Oddly, we have to pass the "result" object down just so it can do that with the appropriate format, presumably. param: ApiResult $result return: array Image info |
convertVerifyErrorToStatus( $error ) X-Ref |
param: array $error return: Status |
getMaxUploadSize( $forType = null ) X-Ref |
param: null|string $forType return: int |
getSessionStatus( $statusKey ) X-Ref |
Get the current status of a chunked upload (used for polling). The status will be read from the *current* user session. param: string $statusKey return: Status[]|bool |
setSessionStatus( $statusKey, $value ) X-Ref |
Set the current status of a chunked upload (used for polling). The status will be stored in the *current* user session. param: string $statusKey param: array|bool $value return: void |
Generated: Fri Nov 28 14:03:12 2014 | Cross-referenced by PHPXref 0.7.1 |