$url = trim( $url );
if( stripos($url, 'http://') !== 0 && stripos($url, 'ftp://') !== 0 ) {
# Only HTTP or FTP URLs
- $wgOut->errorPage( 'upload-proto-error', 'upload-proto-error-text' );
+ $wgOut->showErrorPage( 'upload-proto-error', 'upload-proto-error-text' );
return true;
}
$this->mCurlDestHandle = @fopen( $this->mTempPath, "wb" );
if( $this->mCurlDestHandle === false ) {
# Could not open temporary file to write in
- $wgOut->errorPage( 'upload-file-error', 'upload-file-error-text');
+ $wgOut->showErrorPage( 'upload-file-error', 'upload-file-error-text');
return true;
}
if( $error ) {
unlink( $dest );
if( wfEmptyMsg( "upload-curl-error$errornum", wfMsg("upload-curl-error$errornum") ) )
- $wgOut->errorPage( 'upload-misc-error', 'upload-misc-error-text' );
+ $wgOut->showErrorPage( 'upload-misc-error', 'upload-misc-error-text' );
else
- $wgOut->errorPage( "upload-curl-error$errornum", "upload-curl-error$errornum-text" );
+ $wgOut->showErrorPage( "upload-curl-error$errornum", "upload-curl-error$errornum-text" );
}
return $error;
$details = null;
$value = null;
$value = $this->internalProcessUpload( $details );
-
+
switch($value) {
case self::SUCCESS:
$wgOut->redirect( $this->mLocalFile->getTitle()->getFullURL() );
return self::BEFORE_PROCESSING;
}
- /* Check for PHP error if any, requires php 4.2 or newer */
- if( $this->mCurlError == 1/*UPLOAD_ERR_INI_SIZE*/ ) {
- return self::LARGE_FILE_SERVER;
- }
-
/**
* If there was no filename or a zero size given, give up quick.
*/
return self::EMPTY_FILE;
}
+ /* Check for curl error */
+ if( $this->mCurlError ) {
+ return self::BEFORE_PROCESSING;
+ }
+
# Chop off any directories in the given filename
if( $this->mDesiredDestName ) {
$basename = $this->mDesiredDestName;
*/
function uploadError( $error ) {
global $wgOut;
- $wgOut->addHTML( "<h2>" . wfMsgHtml( 'uploadwarning' ) . "</h2>\n" );
- $wgOut->addHTML( "<span class='error'>{$error}</span>\n" );
+ $wgOut->addHTML( Xml::element( 'h2', null, wfMsg( 'uploadwarning' ) . "\n" ) );
+ $wgOut->addHTML( Xml::tags( 'span', array( 'class' => 'error' ), $error ) );
}
/**
* @access private
*/
function uploadWarning( $warning ) {
- global $wgOut, $wgContLang;
+ global $wgOut;
global $wgUseCopyrightUpload;
$this->mSessionKey = $this->stashSession();
return;
}
- $wgOut->addHTML( "<h2>" . wfMsgHtml( 'uploadwarning' ) . "</h2>\n" );
- $wgOut->addHTML( "<ul class='warning'>{$warning}</ul><br />\n" );
+ $wgOut->addHTML( Xml::element( 'h2', null, wfMsg( 'uploadwarning' ) ) . "\n" );
+ $wgOut->addHTML( Xml::tags( 'ul', array( 'class' => 'warning' ), $warning ) . "\n" );
- $save = wfMsgHtml( 'savefile' );
- $reupload = wfMsgHtml( 'reupload' );
- $iw = wfMsgWikiHtml( 'ignorewarning' );
- $reup = wfMsgWikiHtml( 'reuploaddesc' );
$titleObj = SpecialPage::getTitleFor( 'Upload' );
- $action = $titleObj->escapeLocalURL( 'action=submit' );
- $align1 = $wgContLang->isRTL() ? 'left' : 'right';
- $align2 = $wgContLang->isRTL() ? 'right' : 'left';
- if ( $wgUseCopyrightUpload )
- {
- $copyright = "
- <input type='hidden' name='wpUploadCopyStatus' value=\"" . htmlspecialchars( $this->mCopyrightStatus ) . "\" />
- <input type='hidden' name='wpUploadSource' value=\"" . htmlspecialchars( $this->mCopyrightSource ) . "\" />
- ";
+ if ( $wgUseCopyrightUpload ) {
+ $copyright = Xml::hidden( 'wpUploadCopyStatus', $this->mCopyrightStatus ) . "\n" .
+ Xml::hidden( 'wpUploadSource', $this->mCopyrightSource ) . "\n";
} else {
- $copyright = "";
+ $copyright = '';
}
- $wgOut->addHTML( "
- <form id='uploadwarning' method='post' enctype='multipart/form-data' action='$action'>
- <input type='hidden' name='wpIgnoreWarning' value='1' />
- <input type='hidden' name='wpSessionKey' value=\"" . htmlspecialchars( $this->mSessionKey ) . "\" />
- <input type='hidden' name='wpUploadDescription' value=\"" . htmlspecialchars( $this->mComment ) . "\" />
- <input type='hidden' name='wpLicense' value=\"" . htmlspecialchars( $this->mLicense ) . "\" />
- <input type='hidden' name='wpDestFile' value=\"" . htmlspecialchars( $this->mDesiredDestName ) . "\" />
- <input type='hidden' name='wpWatchthis' value=\"" . htmlspecialchars( intval( $this->mWatchthis ) ) . "\" />
- {$copyright}
- <table border='0'>
- <tr>
- <tr>
- <td align='$align1'>
- <input tabindex='2' type='submit' name='wpUpload' value=\"$save\" />
- </td>
- <td align='$align2'>$iw</td>
- </tr>
- <tr>
- <td align='$align1'>
- <input tabindex='2' type='submit' name='wpReUpload' value=\"{$reupload}\" />
- </td>
- <td align='$align2'>$reup</td>
- </tr>
- </tr>
- </table></form>\n" );
+ $wgOut->addHTML(
+ Xml::openElement( 'form', array( 'method' => 'post', 'action' => $titleObj->getLocalURL( 'action=submit' ),
+ 'enctype' => 'multipart/form-data', 'id' => 'uploadwarning' ) ) . "\n" .
+ Xml::hidden( 'wpIgnoreWarning', '1' ) . "\n" .
+ Xml::hidden( 'wpSessionKey', $this->mSessionKey ) . "\n" .
+ Xml::hidden( 'wpUploadDescription', $this->mComment ) . "\n" .
+ Xml::hidden( 'wpLicense', $this->mLicense ) . "\n" .
+ Xml::hidden( 'wpDestFile', $this->mDesiredDestName ) . "\n" .
+ Xml::hidden( 'wpWatchthis', $this->mWatchthis ) . "\n" .
+ "{$copyright}<br />" .
+ Xml::submitButton( wfMsg( 'ignorewarning' ), array ( 'name' => 'wpUpload', 'id' => 'wpUpload', 'checked' => 'checked' ) ) . ' ' .
+ Xml::submitButton( wfMsg( 'reuploaddesc' ), array ( 'name' => 'wpReUpload', 'id' => 'wpReUpload' ) ) .
+ Xml::closeElement( 'form' ) . "\n"
+ );
}
/**
* @access private
*/
function mainUploadForm( $msg='' ) {
- global $wgOut, $wgUser;
+ global $wgOut, $wgUser, $wgLang, $wgMaxUploadSize;
global $wgUseCopyrightUpload, $wgUseAjax, $wgAjaxUploadDestCheck, $wgAjaxLicensePreview;
global $wgRequest, $wgAllowCopyUploads;
global $wgStylePath, $wgStyleVersion;
}
}
+ # Get the maximum file size from php.ini as $wgMaxUploadSize works for uploads from URL via CURL only
+ # See http://www.php.net/manual/en/ini.core.php#ini.upload-max-filesize for possible values of upload_max_filesize
+ $val = trim( ini_get( 'upload_max_filesize' ) );
+ $last = strtoupper( ( substr( $val, -1 ) ) );
+ switch( $last ) {
+ case 'G':
+ $val2 = substr( $val, 0, -1 ) * 1024 * 1024 * 1024;
+ break;
+ case 'M':
+ $val2 = substr( $val, 0, -1 ) * 1024 * 1024;
+ break;
+ case 'K':
+ $val2 = substr( $val, 0, -1 ) * 1024;
+ break;
+ default:
+ $val2 = $val;
+ }
+ $val2 = $wgAllowCopyUploads ? min( $wgMaxUploadSize, $val2 ) : $val2;
+ $maxUploadSize = wfMsgExt( 'upload-maxfilesize', array( 'parseinline', 'escapenoentities' ), $wgLang->formatSize( $val2 ) );
+
$sourcefilename = wfMsgExt( 'sourcefilename', 'escapenoentities' );
$destfilename = wfMsgExt( 'destfilename', 'escapenoentities' );
$summary = wfMsgExt( 'fileuploadsummary', 'parseinline' );
"<input tabindex='1' type='file' name='wpUploadFile' id='wpUploadFile' " .
"onfocus='" .
"toggle_element_activation(\"wpUploadFileURL\",\"wpUploadFile\");" .
- "toggle_element_check(\"wpSourceTypeFile\",\"wpSourceTypeURL\")'" .
+ "toggle_element_check(\"wpSourceTypeFile\",\"wpSourceTypeURL\")' " .
"onchange='fillDestFilename(\"wpUploadFile\")' size='60' />" .
wfMsgHTML( 'upload_source_file' ) . "<br/>" .
"<input type='radio' id='wpSourceTypeURL' name='wpSourceType' value='web' " .
"<input tabindex='1' type='text' name='wpUploadFileURL' id='wpUploadFileURL' " .
"onfocus='" .
"toggle_element_activation(\"wpUploadFile\",\"wpUploadFileURL\");" .
- "toggle_element_check(\"wpSourceTypeURL\",\"wpSourceTypeFile\")'" .
+ "toggle_element_check(\"wpSourceTypeURL\",\"wpSourceTypeFile\")' " .
"onchange='fillDestFilename(\"wpUploadFileURL\")' size='60' disabled='disabled' />" .
wfMsgHtml( 'upload_source_url' ) ;
} else {
<tr>
<td></td>
<td>
+ {$maxUploadSize}
{$extensionsList}
</td>
</tr>
</td>
</tr>" .
Xml::closeElement( 'table' ) .
- Xml::hidden( 'wpDestFileWarningAck', '' ) .
+ Xml::hidden( 'wpDestFileWarningAck', '', array( 'id' => 'wpDestFileWarningAck' ) ) .
Xml::closeElement( 'fieldset' ) .
Xml::closeElement( 'form' )
);