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;
* @access private
*/
function processUpload() {
- global $wgUser, $wgOut;
+ global $wgOut;
/* Check for PHP error if any, requires php 4.2 or newer */
if( $this->mUploadError == 1/*UPLOAD_ERR_INI_SIZE*/ ) {
}
if( $nt->getArticleID() ) {
- global $wgUser;
- $sk = $wgUser->getSkin();
- $dlink = $sk->makeKnownLinkObj( $nt );
+ $dlink = Linker::makeKnownLinkObj( $nt );
$warning .= '<li>'.wfMsgHtml( 'fileexists', $dlink ).'</li>';
} else {
# If the file existed before and was deleted, warn the user of this
# Don't bother doing so if the image exists now, however
$image = new Image( $nt );
if( $image->wasDeleted() ) {
- $skin = $wgUser->getSkin();
- $ltitle = Title::makeTitle( NS_SPECIAL, 'Log' );
- $llink = $skin->makeKnownLinkObj( $ltitle, wfMsgHtml( 'deletionlog' ), 'type=delete&page=' . $nt->getPrefixedUrl() );
+ $ltitle = SpecialPage::getTitleFor( 'Log' );
+ $llink = Linker::makeKnownLinkObj( $ltitle, wfMsgHtml( 'deletionlog' ), 'type=delete&page=' . $nt->getPrefixedUrl() );
$warning .= wfOpenElement( 'li' ) . wfMsgWikiHtml( 'filewasdeleted', $llink ) . wfCloseElement( 'li' );
}
}
* @access private
*/
function showSuccess() {
- global $wgUser, $wgOut, $wgContLang;
+ global $wgOut, $wgContLang;
- $sk = $wgUser->getSkin();
- $ilink = $sk->makeMediaLink( $this->mUploadSaveName, Image::imageUrl( $this->mUploadSaveName ) );
+ $ilink = Linker::makeMediaLink( $this->mUploadSaveName, Image::imageUrl( $this->mUploadSaveName ) );
$dname = $wgContLang->getNsText( NS_IMAGE ) . ':'.$this->mUploadSaveName;
- $dlink = $sk->makeKnownLink( $dname, $dname );
+ $dlink = Linker::makeKnownLink( $dname, $dname );
$wgOut->addHTML( '<h2>' . wfMsgHtml( 'successfulupload' ) . "</h2>\n" );
$text = wfMsgWikiHtml( 'fileuploaded', $ilink, $dlink );
$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 )
$wgOut->addHTML( '<div id="uploadtext">' );
$wgOut->addWikiText( wfMsg( 'uploadtext' ) );
$wgOut->addHTML( '</div>' );
- $sk = $wgUser->getSkin();
$sourcefilename = wfMsgHtml( 'sourcefilename' );
$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"'
: '';