$wgMaxUploadSize now limits URL upload
authorMagnus Manske <magnusmanske@users.mediawiki.org>
Tue, 22 Aug 2006 10:14:23 +0000 (10:14 +0000)
committerMagnus Manske <magnusmanske@users.mediawiki.org>
Tue, 22 Aug 2006 10:14:23 +0000 (10:14 +0000)
RELEASE-NOTES
includes/DefaultSettings.php
includes/SpecialUpload.php

index 8bb8fd1..df3f729 100644 (file)
@@ -148,6 +148,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * Pass page title as parameters to "linkshere" and "nolinkshere" and update
   default message text
 * Allows to upload from publicy accessible URL. Set $wgAllowCopyUploads = true ; in LocalSettings.php
+  Limited to $wgMaxUploadSize (default:100MB)
 
 == Languages updated ==
 
index e9889fd..9d6a392 100644 (file)
@@ -339,6 +339,8 @@ $wgSharedUploadDBprefix = '';
 $wgCacheSharedUploads = true;
 /** Allow for upload to be copied from an URL. Requires Special:Upload?source=web */
 $wgAllowCopyUploads = false;
+/** Max size for uploads, in bytes */
+$wgMaxUploadSize = 1024*1024*100; # 100MB
 
 /**
  * Point the upload navigation link to an external URL
index f14eecc..7f567f9 100644 (file)
@@ -108,12 +108,12 @@ class UploadForm {
         * @access private
         */
        function initialize_web_file( &$request ) {
-               global $wgTmpDirectory;
+               global $wgTmpDirectory, $wgMaxUploadSize;
                $url = $request->getText( 'wpUploadFile' );
                $local_file = tempnam( $wgTmpDirectory, 'WEBUPLOAD' );
 
-               # Maybe check for filesize($url) first?
-               $error = !@copy( $url, $local_file );
+               if ( $wgMaxUploadSize < @filesize ( $url ) ) $error = true ;
+               else $error = !@copy( $url, $local_file );
                
                $this->mUploadTempName = $local_file;
                $this->mUploadSize     = filesize( $local_file );