In Special:RevisionDelete:
[lhc/web/wiklou.git] / includes / specials / SpecialUpload.php
index d8679cd..1e4a81a 100644 (file)
@@ -244,8 +244,11 @@ class UploadForm {
                }
 
                # Check permissions
+               global $wgGroupPermissions;
                if( !$wgUser->isAllowed( 'upload' ) ) {
-                       if( !$wgUser->isLoggedIn() ) {
+                       if( !$wgUser->isLoggedIn() && ( $wgGroupPermissions['user']['upload']
+                               || $wgGroupPermissions['autoconfirmed']['upload'] ) ) {
+                               // Custom message if logged-in users without any special rights can upload
                                $wgOut->showErrorPage( 'uploadnologin', 'uploadnologintext' );
                        } else {
                                $wgOut->permissionRequired( 'upload' );
@@ -288,7 +291,7 @@ class UploadForm {
         * @access private
         */
        function processUpload(){
-               global $wgUser, $wgOut, $wgFileExtensions, $wgLang;
+               global $wgOut, $wgFileExtensions, $wgLang;
                $details = null;
                $value = null;
                $value = $this->internalProcessUpload( $details );
@@ -571,7 +574,9 @@ class UploadForm {
                if( !$this->mForReUpload ) {
                        $pageText = self::getInitialPageText( $this->mComment, $this->mLicense,
                                $this->mCopyrightStatus, $this->mCopyrightSource );
-               }       
+               } else {
+                       $pageText = false;
+               }
 
                $status = $this->mLocalFile->upload( $this->mTempPath, $this->mComment, $pageText,
                        File::DELETE_SOURCE, $this->mFileProps );
@@ -665,7 +670,7 @@ class UploadForm {
                                '</li>' . $dlink2;
 
                } elseif ( ( substr( $partname , 3, 3 ) == 'px-' || substr( $partname , 2, 3 ) == 'px-' )
-                       && ereg( "[0-9]{2}" , substr( $partname , 0, 2) ) )
+                       && preg_match( "/[0-9]{2}/" , substr( $partname , 0, 2 ) ) )
                {
                        # Check for filenames like 50px- or 180px-, these are mostly thumbnails
                        $nt_thb = Title::newFromText( substr( $partname , strpos( $partname , '-' ) +1 ) . '.' . $rawExtension );
@@ -1047,26 +1052,29 @@ wgUploadAutoFill = {$autofill};
                }
 
                # 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;
+               # See http://www.php.net/manual/en/faq.using.php#faq.using.shorthandbytes for possible values of upload_max_filesize and post_max_filesize
+               $max_sizes = array();
+               $max_sizes[] = trim( ini_get( 'upload_max_filesize' ) );
+               $max_sizes[] = trim( ini_get( 'post_max_size' ) );
+               foreach( $max_sizes as &$size) {
+                       $last = strtoupper( substr( $size, -1 ) );
+                       switch( $last ) {
+                               case 'G':
+                                       $size = substr( $size, 0, -1 ) * 1024 * 1024 * 1024;
+                                       break;
+                               case 'M':
+                                       $size = substr( $size, 0, -1 ) * 1024 * 1024;
+                                       break;
+                               case 'K':
+                                       $size = substr( $size, 0, -1 ) * 1024;
+                                       break;
+                       }
                }
-               $val2 = $wgAllowCopyUploads ? min( $wgMaxUploadSize, $val2 ) : $val2;
+               $val = min( $max_sizes[0], $max_sizes[1] );
+               $val = $wgAllowCopyUploads ? min( $wgMaxUploadSize, $val ) : $val;
                $maxUploadSize = '<div id="mw-upload-maxfilesize">' . 
                        wfMsgExt( 'upload-maxfilesize', array( 'parseinline', 'escapenoentities' ), 
-                               $wgLang->formatSize( $val2 ) ) .
+                               $wgLang->formatSize( $val ) ) .
                                "</div>\n";
 
                $sourcefilename = wfMsgExt( 'sourcefilename', array( 'parseinline', 'escapenoentities' ) );
@@ -1498,7 +1506,7 @@ wgUploadAutoFill = {$autofill};
                wfDebug("SpecialUpload::detectScript: checking for embedded scripts and HTML stuff\n");
 
                #check for HTML doctype
-               if (eregi("<!DOCTYPE *X?HTML",$chunk)) return true;
+               if ( preg_match( "/<!DOCTYPE *X?HTML/i", $chunk ) ) return true;
 
                /**
                * Internet Explorer for Windows performs some really stupid file type