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 = strtolower( trim( $url ) );
- if( substr( $url, 0, 7 ) != 'http://' && substr( $url, 0, 6 ) != 'ftp://' ) {
+ $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' );
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;
$image = new Image( $nt );
if( $image->wasDeleted() ) {
$skin = $wgUser->getSkin();
- $ltitle = Title::makeTitle( NS_SPECIAL, 'Log' );
+ $ltitle = SpecialPage::getTitleFor( 'Log' );
$llink = $skin->makeKnownLinkObj( $ltitle, wfMsgHtml( 'deletionlog' ), 'type=delete&page=' . $nt->getPrefixedUrl() );
$warning .= wfOpenElement( 'li' ) . wfMsgWikiHtml( 'filewasdeleted', $llink ) . wfCloseElement( 'li' );
}
$reupload = wfMsgHtml( 'reupload' );
$iw = wfMsgWikiHtml( 'ignorewarning' );
$reup = wfMsgWikiHtml( 'reuploaddesc' );
- $titleObj = Title::makeTitle( NS_SPECIAL, 'Upload' );
+ $titleObj = SpecialPage::getTitleFor( 'Upload' );
$action = $titleObj->escapeLocalURL( 'action=submit' );
if ( $wgUseCopyrightUpload )
$ulb = wfMsgHtml( 'uploadbtn' );
- $titleObj = Title::makeTitle( NS_SPECIAL, 'Upload' );
+ $titleObj = SpecialPage::getTitleFor( 'Upload' );
$action = $titleObj->escapeLocalURL();
$encDestFile = htmlspecialchars( $this->mDestFile );
- $watchChecked = $wgUser->getOption( 'watchdefault' )
+ $watchChecked =
+ ( $wgUser->getOption( 'watchdefault' ) ||
+ ( $wgUser->getOption( 'watchcreations' ) && $this->mDestFile == '' ) )
? 'checked="checked"'
: '';