var $mUploadCopyStatus, $mUploadSource, $mReUpload, $mAction, $mUpload;
var $mOname, $mSessionKey, $mStashed, $mDestFile, $mRemoveTempFile, $mSourceType;
var $mUploadTempFileSize = 0;
+
+ # Placeholders for text injection by hooks (must be HTML)
+ # extensions should take care to _append_ to the present value
+ var $uploadFormTextTop;
+ var $uploadFormTextAfterSummary;
+
/**#@-*/
/**
return;
}
+ # Placeholders for text injection by hooks (empty per default)
+ $this->uploadFormTextTop = "";
+ $this->uploadFormTextAfterSummary = "";
+
$this->mIgnoreWarning = $request->getCheck( 'wpIgnoreWarning' );
$this->mReUpload = $request->getCheck( 'wpReUpload' );
$this->mUpload = $request->getCheck( 'wpUpload' );
* @access private
*/
function initializeFromUrl( $request ) {
- global $wgTmpDirectory, $wgMaxUploadSize;
+ global $wgTmpDirectory;
$url = $request->getText( 'wpUploadFileURL' );
$local_file = tempnam( $wgTmpDirectory, 'WEBUPLOAD' );
* Returns true if there was an error, false otherwise
*/
private function curlCopy( $url, $dest ) {
- global $wgMaxUploadSize, $wgUser, $wgOut;
+ global $wgUser, $wgOut;
if( !$wgUser->isAllowed( 'upload_by_url' ) ) {
$wgOut->permissionRequired( 'upload_by_url' );
function processUpload() {
global $wgUser, $wgOut;
+ if( !wfRunHooks( 'UploadForm:BeforeProcessing', array( &$this ) ) )
+ {
+ wfDebug( "Hook 'UploadForm:BeforeProcessing' broke processing the file." );
+ return false;
+ }
+
/* Check for PHP error if any, requires php 4.2 or newer */
if( $this->mUploadError == 1/*UPLOAD_ERR_INI_SIZE*/ ) {
$this->mainUploadForm( wfMsgHtml( 'largefileserver' ) );
if( $this->checkFileExtensionList( $ext, $wgFileBlacklist ) ||
($wgStrictFileExtensions &&
!$this->checkFileExtension( $finalExt, $wgFileExtensions ) ) ) {
- return $this->uploadError( wfMsgHtml( 'badfiletype', htmlspecialchars( $fullExt ) ) );
+ return $this->uploadError( wfMsgHtml( 'badfiletype', htmlspecialchars( $finalExt ) ) );
}
/**
global $wgCheckFileExtensions;
if ( $wgCheckFileExtensions ) {
if ( ! $this->checkFileExtension( $finalExt, $wgFileExtensions ) ) {
- $warning .= '<li>'.wfMsgHtml( 'badfiletype', htmlspecialchars( $fullExt ) ).'</li>';
+ $warning .= '<li>'.wfMsgHtml( 'badfiletype', htmlspecialchars( $finalExt ) ).'</li>';
}
}
global $wgUploadSizeWarning;
if ( $wgUploadSizeWarning && ( $this->mUploadSize > $wgUploadSizeWarning ) ) {
- # TODO: Format $wgUploadSizeWarning to something that looks better than the raw byte
- # value, perhaps add GB,MB and KB suffixes?
- $warning .= '<li>'.wfMsgHtml( 'largefile', $wgUploadSizeWarning, $this->mUploadSize ).'</li>';
+ $skin =& $wgUser->getSkin();
+ $wsize = $skin->formatSize( $wgUploadSizeWarning );
+ $asize = $skin->formatSize( $this->mUploadSize );
+ $warning .= '<li>' . wfMsgHtml( 'large-file', $wsize, $asize ) . '</li>';
}
if ( $this->mUploadSize == 0 ) {
$warning .= '<li>'.wfMsgHtml( 'emptyfile' ).'</li>';
global $wgUseCopyrightUpload;
global $wgRequest, $wgAllowCopyUploads;
+ if( !wfRunHooks( 'UploadForm:initial', array( &$this ) ) )
+ {
+ wfDebug( "Hook 'UploadForm:initial' broke output of the upload form" );
+ return false;
+ }
+
$cols = intval($wgUser->getOption( 'cols' ));
$ew = $wgUser->getOption( 'editwidth' );
if ( $ew ) $ew = " style=\"width:100%\"";
$wgOut->addHTML( '<div id="uploadtext">' );
$wgOut->addWikiText( wfMsg( 'uploadtext' ) );
$wgOut->addHTML( '</div>' );
- $sk = $wgUser->getSkin();
-
$sourcefilename = wfMsgHtml( 'sourcefilename' );
$destfilename = wfMsgHtml( 'destfilename' );
// Prepare form for upload or upload/copy
if( $wgAllowCopyUploads && $wgUser->isAllowed( 'upload_by_url' ) ) {
- $source_comment = wfMsgHtml( 'upload_source_url' );
$filename_form =
"<input type='radio' id='wpSourceTypeFile' name='wpSourceType' value='file' onchange='toggle_element_activation(\"wpUploadFileURL\",\"wpUploadFile\")' checked />" .
"<input tabindex='1' type='file' name='wpUploadFile' id='wpUploadFile' onfocus='toggle_element_activation(\"wpUploadFileURL\",\"wpUploadFile\");toggle_element_check(\"wpSourceTypeFile\",\"wpSourceTypeURL\")'" .
<form id='upload' method='post' enctype='multipart/form-data' action=\"$action\">
<table border='0'>
<tr>
+ {$this->uploadFormTextTop}
<td align='right' valign='top'><label for='wpUploadFile'>{$sourcefilename}:</label></td>
<td align='left'>
{$filename_form}
<td align='right'><label for='wpUploadDescription'>{$summary}</label></td>
<td align='left'>
<textarea tabindex='3' name='wpUploadDescription' id='wpUploadDescription' rows='6' cols='{$cols}'{$ew}>" . htmlspecialchars( $this->mUploadDescription ) . "</textarea>
+ {$this->uploadFormTextAfterSummary}
</td>
</tr>
<tr>" );
<input tabindex='8' type='checkbox' name='wpIgnoreWarning' id='wpIgnoreWarning' value='true' />
<label for='wpIgnoreWarning'>" . wfMsgHtml( 'ignorewarnings' ) . "</label>
</td>
- </tr>
- <tr>
-
</tr>
<tr>
<td></td>
$chunk = Sanitizer::decodeCharReferences( $chunk );
#look for script-types
- if (preg_match("!type\s*=\s*['\"]?\s*(\w*/)?(ecma|java)!sim",$chunk)) return true;
+ if (preg_match('!type\s*=\s*[\'"]?\s*(\w*/)?(ecma|java)!sim',$chunk)) return true;
#look for html-style script-urls
- if (preg_match("!(href|src|data)\s*=\s*['\"]?\s*(ecma|java)script:!sim",$chunk)) return true;
+ if (preg_match('!(href|src|data)\s*=\s*[\'"]?\s*(ecma|java)script:!sim',$chunk)) return true;
#look for css-style script-urls
- if (preg_match("!url\s*\(\s*['\"]?\s*(ecma|java)script:!sim",$chunk)) return true;
+ if (preg_match('!url\s*\(\s*[\'"]?\s*(ecma|java)script:!sim',$chunk)) return true;
wfDebug("SpecialUpload::detectScript: no scripts found\n");
return false;
#NOTE: there's a 50 line workaround to make stderr redirection work on windows, too.
# that does not seem to be worth the pain.
# Ask me (Duesentrieb) about it if it's ever needed.
+ $output = array();
if (wfIsWindows()) exec("$scanner",$output,$code);
else exec("$scanner 2>&1",$output,$code);
- $exit_code= $code; #remeber for user feedback
+ $exit_code= $code; #remember for user feedback
if ($virus_scanner_codes) { #map exit code to AV_xxx constants.
- if (isset($virus_scanner_codes[$code])) $code= $virus_scanner_codes[$code]; #explicite mapping
- else if (isset($virus_scanner_codes["*"])) $code= $virus_scanner_codes["*"]; #fallback mapping
+ if (isset($virus_scanner_codes[$code])) {
+ $code= $virus_scanner_codes[$code]; # explicit mapping
+ } else if (isset($virus_scanner_codes["*"])) {
+ $code= $virus_scanner_codes["*"]; # fallback mapping
+ }
}
if ($code===AV_SCAN_FAILED) { #scan failed (code was mapped to false by $virus_scanner_codes)
wfDebug("$fname: failed to scan $file (code $exit_code).\n");
- if ($wgAntivirusRequired) return "scan failed (code $exit_code)";
- else return NULL;
+ if ($wgAntivirusRequired) { return "scan failed (code $exit_code)"; }
+ else { return NULL; }
}
else if ($code===AV_SCAN_ABORTED) { #scan failed because filetype is unknown (probably imune)
wfDebug("$fname: unsupported file type $file (code $exit_code).\n");
$output= join("\n",$output);
$output= trim($output);
- if (!$output) $output= true; #if ther's no output, return true
+ if (!$output) $output= true; #if there's no output, return true
else if ($msg_pattern) {
$groups= array();
if (preg_match($msg_pattern,$output,$groups)) {