Inherited by UploadFormMogile.
Public Member Functions | |
UploadForm (&$request) | |
#@- | |
initializeFromUpload ($request) | |
Initialize the uploaded file from PHP data. | |
initializeFromUrl ($request) | |
Copy a web file to a temporary file. | |
uploadCurlCallback ($ch, $data) | |
Callback function for CURL-based web transfer Write data to file unless we've passed the length limit; if so, abort immediately. | |
execute () | |
Start doing stuff. | |
processUpload () | |
Do the upload Checks are made in SpecialUpload::execute(). | |
internalProcessUpload (&$resultDetails) | |
Really do the upload Checks are made in SpecialUpload::execute(). | |
getDupeWarning ($tempfile, $extension, $destinationTitle) | |
Check for duplicate files and throw up a warning before the upload completes. | |
saveTempUploadedFile ($saveName, $tempName) | |
Stash a file in a temporary directory for later processing after the user has confirmed it. | |
stashSession () | |
Stash a file in a temporary directory for later processing, and save the necessary descriptive info into the session. | |
unsaveUploadedFile () | |
Remove a temporarily kept file stashed by saveTempUploadedFile(). | |
uploadError ($error) | |
uploadWarning ($warning) | |
There's something wrong with this file, not enough to reject it totally but we require manual intervention to save it for real. | |
mainUploadForm ($msg='') | |
Displays the main upload form, optionally with a highlighted error message up at the top. | |
watchCheck () | |
See if we should check the 'watch this page' checkbox on the form based on the user's preferences and whether we're being asked to create a new file or update an existing one. | |
splitExtensions ($filename) | |
Split a file into a base name and all dot-delimited 'extensions' on the end. | |
checkFileExtension ($ext, $list) | |
Perform case-insensitive match against a list of file extensions. | |
checkFileExtensionList ($ext, $list) | |
Perform case-insensitive match against a list of file extensions. | |
verify ($tmpfile, $extension) | |
Verifies that it's ok to include the uploaded file. | |
detectScript ($file, $mime, $extension) | |
Heuristic for detecting files that *could* contain JavaScript instructions or things that may look like HTML to a browser and are thus potentially harmful. | |
detectScriptInSvg ($filename) | |
checkSvgScriptCallback ($element, $attribs) | |
detectVirus ($file) | |
Generic wrapper function for a virus scanner program. | |
checkMacBinary () | |
Check if the temporary file is MacBinary-encoded, as some uploads from Internet Explorer on Mac OS Classic and Mac OS X will be. | |
cleanupTempFile () | |
If we've modified the upload file we need to manually remove it on exit to clean up. | |
checkOverwrite ($name) | |
Check if there's an overwrite conflict and, if so, if restrictions forbid this user from performing the upload. | |
showError ($description) | |
Display an error with a wikitext description. | |
Static Public Member Functions | |
static | getExistsWarning ($file) |
Do existence checks on a file and produce a warning This check is static and can be done pre-upload via AJAX Returns an HTML fragment consisting of one or more LI elements if there is a warning Returns an empty string if there is no warning. | |
static | ajaxGetExistsWarning ($filename) |
Get a list of warnings. | |
static | ajaxGetLicensePreview ($license) |
Render a preview of a given license for the AJAX preview on upload. | |
static | getFilenamePrefixBlacklist () |
Get a list of blacklisted filename prefixes from [[MediaWiki:filename-prefix-blacklist]]. | |
static | verifyExtension ($mime, $extension) |
Checks if the mime type of the uploaded file matches the file extension. | |
static | userCanReUpload (User $user, $img) |
Check if a user is the last uploader. | |
static | getInitialPageText ($comment, $license, $copyStatus, $source) |
Get the initial image page text based on a comment and optional file status information. | |
Public Attributes | |
const | SUCCESS = 0 |
const | BEFORE_PROCESSING = 1 |
const | LARGE_FILE_SERVER = 2 |
const | EMPTY_FILE = 3 |
const | MIN_LENGTH_PARTNAME = 4 |
const | ILLEGAL_FILENAME = 5 |
const | PROTECTED_PAGE = 6 |
const | OVERWRITE_EXISTING_FILE = 7 |
const | FILETYPE_MISSING = 8 |
const | FILETYPE_BADTYPE = 9 |
const | VERIFICATION_ERROR = 10 |
const | UPLOAD_VERIFICATION_ERROR = 11 |
const | UPLOAD_WARNING = 12 |
const | INTERNAL_ERROR = 13 |
$mComment | |
#@+ | |
$mLicense | |
$mIgnoreWarning | |
$mCurlError | |
$mDestName | |
$mTempPath | |
$mFileSize | |
$mFileProps | |
$mCopyrightStatus | |
$mCopyrightSource | |
$mReUpload | |
$mAction | |
$mUploadClicked | |
$mSrcName | |
$mSessionKey | |
$mStashed | |
$mDesiredDestName | |
$mRemoveTempFile | |
$mSourceType | |
$mDestWarningAck | |
$mCurlDestHandle | |
$mLocalFile | |
$uploadFormTextTop | |
$uploadFormTextAfterSummary | |
const | SESSION_VERSION = 1 |
Private Member Functions | |
curlCopy ($url, $dest) | |
Safe copy from URL Returns true if there was an error, false otherwise. | |
stripXmlNamespace ($name) | |
showDeletionLog ($out, $filename) | |
If there are rows in the deletion log for this file, show them, along with a nice little note for the user. |
Definition at line 21 of file SpecialUpload.php.
static UploadForm::ajaxGetExistsWarning | ( | $ | filename | ) | [static] |
Get a list of warnings.
string | local filename, e.g. 'file exists', 'non-descriptive filename' |
Definition at line 724 of file SpecialUpload.php.
References $file, $filename, $s, getExistsWarning(), wfFindFile(), and wfLocalFile().
static UploadForm::ajaxGetLicensePreview | ( | $ | license | ) | [static] |
Render a preview of a given license for the AJAX preview on upload.
string | $license |
Definition at line 747 of file SpecialUpload.php.
References $options, $output, $text, $title, $wgParser, $wgUser, Title::makeTitle(), and ParserOptions::newFromUser().
UploadForm::checkFileExtension | ( | $ | ext, | |
$ | list | |||
) |
Perform case-insensitive match against a list of file extensions.
Returns true if the extension is in the list.
string | $ext | |
array | $list |
Definition at line 1335 of file SpecialUpload.php.
References $ext.
Referenced by internalProcessUpload(), and verify().
UploadForm::checkFileExtensionList | ( | $ | ext, | |
$ | list | |||
) |
Perform case-insensitive match against a list of file extensions.
Returns true if any of the extensions are in the list.
array | $ext | |
array | $list |
Definition at line 1347 of file SpecialUpload.php.
References $ext.
Referenced by internalProcessUpload().
UploadForm::checkMacBinary | ( | ) |
Check if the temporary file is MacBinary-encoded, as some uploads from Internet Explorer on Mac OS Classic and Mac OS X will be.
If so, the data fork will be extracted to a second temporary file, which will then be checked for validity and either kept or discarded.
private
Definition at line 1702 of file SpecialUpload.php.
Referenced by internalProcessUpload().
UploadForm::checkOverwrite | ( | $ | name | ) |
Check if there's an overwrite conflict and, if so, if restrictions forbid this user from performing the upload.
Definition at line 1739 of file SpecialUpload.php.
Referenced by internalProcessUpload().
UploadForm::checkSvgScriptCallback | ( | $ | element, | |
$ | attribs | |||
) |
Definition at line 1567 of file SpecialUpload.php.
References $attrib, stripXmlNamespace(), and wfDebug().
UploadForm::cleanupTempFile | ( | ) |
If we've modified the upload file we need to manually remove it on exit to clean up.
private
Definition at line 1725 of file SpecialUpload.php.
Referenced by execute().
UploadForm::curlCopy | ( | $ | url, | |
$ | dest | |||
) | [private] |
Safe copy from URL Returns true if there was an error, false otherwise.
Definition at line 157 of file SpecialUpload.php.
References $dest, $error, $url, $wgHTTPProxy, $wgOut, $wgUser, wfEmptyMsg(), and wfMsg().
Referenced by initializeFromUrl().
UploadForm::detectScript | ( | $ | file, | |
$ | mime, | |||
$ | extension | |||
) |
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.
string | $file Pathname to the temporary upload file | |
string | $mime The mime type of the file | |
string | $extension The extension of the file |
Definition at line 1470 of file SpecialUpload.php.
References $file, $wgAllowTitlesInSVG, Sanitizer::decodeCharReferences(), and wfDebug().
Referenced by verify().
UploadForm::detectScriptInSvg | ( | $ | filename | ) |
UploadForm::detectVirus | ( | $ | file | ) |
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.
string | $file Pathname to the temporary upload file |
Definition at line 1604 of file SpecialUpload.php.
References $command, $file, $output, $wgAntivirus, $wgAntivirusRequired, $wgAntivirusSetup, $wgOut, wfDebug(), wfEscapeShellArg(), wfIsWindows(), and wfMsg().
Referenced by verify().
UploadForm::execute | ( | ) |
Start doing stuff.
Definition at line 230 of file SpecialUpload.php.
References $wgEnableUploads, $wgOut, $wgUser, cleanupTempFile(), mainUploadForm(), processUpload(), unsaveUploadedFile(), wfIniGetBool(), and wfReadOnly().
UploadForm::getDupeWarning | ( | $ | tempfile, | |
$ | extension, | |||
$ | destinationTitle | |||
) |
Check for duplicate files and throw up a warning before the upload completes.
Definition at line 764 of file SpecialUpload.php.
References $file, $msg, $name, $title, $wgOut, Title::makeTitle(), File::sha1Base36(), RepoGroup::singleton(), Xml::tags(), and wfMsgExt().
Referenced by internalProcessUpload().
static UploadForm::getExistsWarning | ( | $ | file | ) | [static] |
Do existence checks on a file and produce a warning This check is static and can be done pre-upload via AJAX Returns an HTML fragment consisting of one or more LI elements if there is a warning Returns an empty string if there is no warning.
Definition at line 599 of file SpecialUpload.php.
References $file, $n, $prefix, $wgContLang, $wgUser, getFilenamePrefixBlacklist(), SpecialPage::getTitleFor(), Title::makeTitle(), Title::newFromText(), wfLocalFile(), wfMsgExt(), wfMsgHtml(), and wfMsgWikiHtml().
Referenced by ajaxGetExistsWarning(), and internalProcessUpload().
static UploadForm::getFilenamePrefixBlacklist | ( | ) | [static] |
Get a list of blacklisted filename prefixes from [[MediaWiki:filename-prefix-blacklist]].
Definition at line 799 of file SpecialUpload.php.
References wfEmptyMsg(), and wfMsgForContent().
Referenced by getExistsWarning().
static UploadForm::getInitialPageText | ( | $ | comment, | |
$ | license, | |||
$ | copyStatus, | |||
$ | source | |||
) | [static] |
Get the initial image page text based on a comment and optional file status information.
Definition at line 1805 of file SpecialUpload.php.
References $source, $wgUseCopyrightUpload, wfMsg(), and wfMsgForContent().
Referenced by internalProcessUpload(), and LocalFile::recordUpload().
UploadForm::initializeFromUpload | ( | $ | request | ) |
Initialize the uploaded file from PHP data.
Definition at line 122 of file SpecialUpload.php.
Referenced by UploadForm().
UploadForm::initializeFromUrl | ( | $ | request | ) |
Copy a web file to a temporary file.
Definition at line 136 of file SpecialUpload.php.
References $url, $wgTmpDirectory, and curlCopy().
Referenced by UploadForm().
UploadForm::internalProcessUpload | ( | &$ | resultDetails | ) |
Really do the upload Checks are made in SpecialUpload::execute().
array | $resultDetails contains result-specific dict of additional values |
Definition at line 379 of file SpecialUpload.php.
References $error, $ext, $i, $overwrite, $status, $wgCapitalLinks, $wgCheckFileExtensions, $wgContLang, $wgFileBlacklist, $wgFileExtensions, $wgLang, $wgStrictFileExtensions, $wgUploadSizeWarning, $wgUser, checkFileExtension(), checkFileExtensionList(), checkMacBinary(), checkOverwrite(), File::DELETE_SOURCE, getDupeWarning(), getExistsWarning(), getInitialPageText(), File::getPropsFromPath(), Title::makeTitleSafe(), splitExtensions(), verify(), wfArrayDiff2(), wfDebug(), wfLocalFile(), wfMsgExt(), wfMsgHtml(), wfRunHooks(), and wfStripIllegalFilenameChars().
Referenced by processUpload().
UploadForm::mainUploadForm | ( | $ | msg = '' |
) |
Displays the main upload form, optionally with a highlighted error message up at the top.
string | $msg as HTML |
Definition at line 956 of file SpecialUpload.php.
References $count, $msg, $summary, $title, $wgAjaxLicensePreview, $wgAjaxUploadDestCheck, $wgAllowCopyUploads, $wgCheckFileExtensions, $wgFileBlacklist, $wgFileExtensions, $wgLang, $wgMaxUploadSize, $wgOut, $wgRequest, $wgStrictFileExtensions, $wgStylePath, $wgStyleVersion, $wgUseAjax, $wgUseCopyrightUpload, $wgUser, Xml::closeElement(), Xml::element(), SpecialPage::getTitleFor(), Xml::hidden(), Title::makeTitleSafe(), Xml::openElement(), showDeletionLog(), watchCheck(), wfBoolToStr(), wfDebug(), wfEmptyMsg(), wfMsg(), wfMsgExt(), wfMsgHtml(), wfMsgNoTrans(), wfMsgWikiHtml(), and wfRunHooks().
Referenced by execute(), and processUpload().
UploadForm::processUpload | ( | ) |
Do the upload Checks are made in SpecialUpload::execute().
Definition at line 290 of file SpecialUpload.php.
References $error, $wgFileExtensions, $wgLang, $wgOut, $wgUser, internalProcessUpload(), mainUploadForm(), showError(), uploadError(), uploadWarning(), wfMsgExt(), wfMsgHtml(), and wfMsgWikiHtml().
Referenced by execute().
UploadForm::saveTempUploadedFile | ( | $ | saveName, | |
$ | tempName | |||
) |
Stash a file in a temporary directory for later processing after the user has confirmed it.
If the user doesn't explicitly cancel or accept, these files can accumulate in the temp directory.
string | $saveName - the destination filename | |
string | $tempName - the source temporary file to save |
Reimplemented in UploadFormMogile.
Definition at line 833 of file SpecialUpload.php.
References $status, $wgOut, showError(), and RepoGroup::singleton().
Referenced by stashSession().
UploadForm::showDeletionLog | ( | $ | out, | |
$ | filename | |||
) | [private] |
If there are rows in the deletion log for this file, show them, along with a nice little note for the user.
OutputPage | $out | |
string | filename |
Definition at line 1834 of file SpecialUpload.php.
References $filename, $out, $wgUser, and LogEventsList::endLogEventsList().
Referenced by mainUploadForm().
UploadForm::showError | ( | $ | description | ) |
Display an error with a wikitext description.
Definition at line 1793 of file SpecialUpload.php.
References wfMsg().
Referenced by processUpload(), and saveTempUploadedFile().
UploadForm::splitExtensions | ( | $ | filename | ) |
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.
Definition at line 1321 of file SpecialUpload.php.
References $filename.
Referenced by internalProcessUpload().
UploadForm::stashSession | ( | ) |
Stash a file in a temporary directory for later processing, and save the necessary descriptive info into the session.
Returns a key value which will be passed through a form to pick up the path info on a later invocation.
Reimplemented in UploadFormMogile.
Definition at line 854 of file SpecialUpload.php.
References $key, and saveTempUploadedFile().
Referenced by uploadWarning().
UploadForm::stripXmlNamespace | ( | $ | name | ) | [private] |
Definition at line 1588 of file SpecialUpload.php.
References $name.
Referenced by checkSvgScriptCallback().
UploadForm::unsaveUploadedFile | ( | ) |
Remove a temporarily kept file stashed by saveTempUploadedFile().
private
Reimplemented in UploadFormMogile.
Definition at line 878 of file SpecialUpload.php.
References $success, $wgOut, and RepoGroup::singleton().
Referenced by execute().
UploadForm::uploadCurlCallback | ( | $ | ch, | |
$ | data | |||
) |
Callback function for CURL-based web transfer Write data to file unless we've passed the length limit; if so, abort immediately.
Definition at line 215 of file SpecialUpload.php.
References $wgMaxUploadSize.
UploadForm::uploadError | ( | $ | error | ) |
string | $error as HTML private |
Definition at line 897 of file SpecialUpload.php.
References $error, $wgOut, and wfMsgHtml().
Referenced by processUpload().
UploadForm::UploadForm | ( | &$ | request | ) |
#@-
Constructor : initialise object Get data POSTed through the form and assign them to the object
$request | Data posted. |
Definition at line 60 of file SpecialUpload.php.
References $wgAllowCopyUploads, initializeFromUpload(), and initializeFromUrl().
UploadForm::uploadWarning | ( | $ | warning | ) |
There's something wrong with this file, not enough to reject it totally but we require manual intervention to save it for real.
Stash it away, then present a form asking to confirm or cancel.
string | $warning as HTML private |
Definition at line 911 of file SpecialUpload.php.
References $wgOut, $wgUseCopyrightUpload, Xml::closeElement(), SpecialPage::getTitleFor(), Xml::hidden(), Xml::openElement(), stashSession(), Xml::submitButton(), wfMsg(), and wfMsgHtml().
Referenced by processUpload().
static UploadForm::userCanReUpload | ( | User $ | user, | |
$ | img | |||
) | [static] |
Check if a user is the last uploader.
User | $user | |
string | $img, image name |
Definition at line 1773 of file SpecialUpload.php.
References $dbr, $row, User::getId(), User::isAllowed(), and wfGetDB().
Referenced by ImagePage::uploadLinksBox().
UploadForm::verify | ( | $ | tmpfile, | |
$ | extension | |||
) |
Verifies that it's ok to include the uploaded file.
string | $tmpfile the full path of the temporary file to verify | |
string | $extension The filename extension that the file is to be served with |
Definition at line 1363 of file SpecialUpload.php.
References $wgMimeTypeBlacklist, $wgVerifyMimeType, checkFileExtension(), detectScript(), detectScriptInSvg(), detectVirus(), MimeMagic::singleton(), and wfDebug().
Referenced by internalProcessUpload().
static UploadForm::verifyExtension | ( | $ | mime, | |
$ | extension | |||
) | [static] |
Checks if the mime type of the uploaded file matches the file extension.
string | $mime the mime type of the uploaded file | |
string | $extension The filename extension that the file is to be served with |
Definition at line 1428 of file SpecialUpload.php.
References MimeMagic::singleton(), and wfDebug().
UploadForm::watchCheck | ( | ) |
See if we should check the 'watch this page' checkbox on the form based on the user's preferences and whether we're being asked to create a new file or update an existing one.
In the case where 'watch edits' is off but 'watch creations' is on, we'll leave the box unchecked.
Note that the page target can be changed *on the form*, so our check state can get out of sync.
Definition at line 1295 of file SpecialUpload.php.
References $wgUser, and wfLocalFile().
Referenced by mainUploadForm().
UploadForm::$mAction |
Definition at line 42 of file SpecialUpload.php.
UploadForm::$mComment |
UploadForm::$mCopyrightSource |
Definition at line 42 of file SpecialUpload.php.
UploadForm::$mCopyrightStatus |
Definition at line 42 of file SpecialUpload.php.
UploadForm::$mCurlDestHandle |
Definition at line 44 of file SpecialUpload.php.
UploadForm::$mCurlError |
Definition at line 40 of file SpecialUpload.php.
UploadForm::$mDesiredDestName |
Definition at line 43 of file SpecialUpload.php.
UploadForm::$mDestName |
Definition at line 41 of file SpecialUpload.php.
UploadForm::$mDestWarningAck |
Definition at line 44 of file SpecialUpload.php.
UploadForm::$mFileProps |
Definition at line 41 of file SpecialUpload.php.
UploadForm::$mFileSize |
Definition at line 41 of file SpecialUpload.php.
UploadForm::$mIgnoreWarning |
Definition at line 40 of file SpecialUpload.php.
UploadForm::$mLicense |
Definition at line 40 of file SpecialUpload.php.
UploadForm::$mLocalFile |
Definition at line 45 of file SpecialUpload.php.
UploadForm::$mRemoveTempFile |
Definition at line 43 of file SpecialUpload.php.
UploadForm::$mReUpload |
Definition at line 42 of file SpecialUpload.php.
UploadForm::$mSessionKey |
Definition at line 43 of file SpecialUpload.php.
UploadForm::$mSourceType |
Definition at line 43 of file SpecialUpload.php.
UploadForm::$mSrcName |
Definition at line 43 of file SpecialUpload.php.
UploadForm::$mStashed |
Definition at line 43 of file SpecialUpload.php.
UploadForm::$mTempPath |
Definition at line 41 of file SpecialUpload.php.
UploadForm::$mUploadClicked |
Definition at line 42 of file SpecialUpload.php.
UploadForm::$uploadFormTextAfterSummary |
Definition at line 50 of file SpecialUpload.php.
UploadForm::$uploadFormTextTop |
Definition at line 49 of file SpecialUpload.php.
const UploadForm::BEFORE_PROCESSING = 1 |
Definition at line 23 of file SpecialUpload.php.
const UploadForm::EMPTY_FILE = 3 |
Definition at line 25 of file SpecialUpload.php.
const UploadForm::FILETYPE_BADTYPE = 9 |
Definition at line 31 of file SpecialUpload.php.
const UploadForm::FILETYPE_MISSING = 8 |
Definition at line 30 of file SpecialUpload.php.
const UploadForm::ILLEGAL_FILENAME = 5 |
Definition at line 27 of file SpecialUpload.php.
const UploadForm::INTERNAL_ERROR = 13 |
Definition at line 35 of file SpecialUpload.php.
const UploadForm::LARGE_FILE_SERVER = 2 |
Definition at line 24 of file SpecialUpload.php.
const UploadForm::MIN_LENGTH_PARTNAME = 4 |
Definition at line 26 of file SpecialUpload.php.
const UploadForm::OVERWRITE_EXISTING_FILE = 7 |
Definition at line 29 of file SpecialUpload.php.
const UploadForm::PROTECTED_PAGE = 6 |
Definition at line 28 of file SpecialUpload.php.
const UploadForm::SESSION_VERSION = 1 |
Definition at line 52 of file SpecialUpload.php.
const UploadForm::SUCCESS = 0 |
Definition at line 22 of file SpecialUpload.php.
const UploadForm::UPLOAD_VERIFICATION_ERROR = 11 |
Definition at line 33 of file SpecialUpload.php.
const UploadForm::UPLOAD_WARNING = 12 |
Definition at line 34 of file SpecialUpload.php.
const UploadForm::VERIFICATION_ERROR = 10 |
Definition at line 32 of file SpecialUpload.php.