var $mUploadSaveName, $mUploadTempName, $mUploadSize, $mUploadOldVersion;
var $mUploadCopyStatus, $mUploadSource, $mReUpload, $mAction, $mUpload;
var $mOname, $mSessionKey, $mStashed, $mDestFile, $mRemoveTempFile, $mSourceType;
+ var $mUploadTempFileSize = 0;
/**#@-*/
/**
* Returns true if there was an error, false otherwise
*/
private function curlCopy( $url, $dest ) {
- global $wgMaxUploadSize, $wgUser;
+ global $wgMaxUploadSize, $wgUser, $wgOut;
if( !$wgUser->isAllowed( 'upload_by_url' ) ) {
$wgOut->permissionRequired( 'upload_by_url' );
# Maybe remove some pasting blanks :-)
$url = trim( $url );
- if( substr( $url, 0, 7 ) != 'http://' && substr( $url, 0, 6 ) != 'ftp://' ) {
+ if( stripos($url, 'http://') !== 0 && stripos($url, 'ftp://') !== 0 ) {
# Only HTTP or FTP URLs
+ $wgOut->errorPage( 'upload-proto-error', 'upload-proto-error-text' );
return true;
}
# Open temporary file
- $this->mUploadTempFileSize = 0;
$this->mUploadTempFile = @fopen( $this->mUploadTempName, "wb" );
if( $this->mUploadTempFile === false ) {
# Could not open temporary file to write in
+ $wgOut->errorPage( 'upload-file-error', 'upload-file-error-text');
return true;
}
curl_setopt( $ch, CURLOPT_WRITEFUNCTION, array( $this, 'uploadCurlCallback' ) );
curl_exec( $ch );
$error = curl_errno( $ch ) ? true : false;
-# if ( $error ) print curl_error ( $ch ) ; # Debugging output
+ $errornum = curl_errno( $ch );
+ // if ( $error ) print curl_error ( $ch ) ; # Debugging output
curl_close( $ch );
fclose( $this->mUploadTempFile );
unset( $this->mUploadTempFile );
if( $error ) {
unlink( $dest );
+ if( wfEmptyMsg( "upload-curl-error$errornum", wfMsg("upload-curl-error$errornum") ) )
+ $wgOut->errorPage( 'upload-misc-error', 'upload-misc-error-text' );
+ else
+ $wgOut->errorPage( "upload-curl-error$errornum", "upload-curl-error$errornum-text" );
}
return $error;