/**
* Image authorisation script
*
- * To use this, see http://www.mediawiki.org/wiki/Manual:Image_Authorization
+ * To use this, see https://www.mediawiki.org/wiki/Manual:Image_Authorization
*
* - Set $wgUploadDirectory to a non-public directory (not web accessible)
* - Set $wgUploadPath to point to this file
if ( strpos( $path, $prefix ) === 0 ) {
$be = FileBackendGroup::singleton()->backendFromPath( $storageDir );
$filename = $storageDir . substr( $path, strlen( $prefix ) ); // strip prefix
- // Check basic user authorization
- if ( !RequestContext::getMain()->getUser()->isAllowed( 'read' ) ) {
- wfForbidden( 'img-auth-accessdenied', 'img-auth-noread', $path );
- return;
- }
+ // Check basic user authorization
+ if ( !RequestContext::getMain()->getUser()->isAllowed( 'read' ) ) {
+ wfForbidden( 'img-auth-accessdenied', 'img-auth-noread', $path );
+ return;
+ }
if ( $be->fileExists( array( 'src' => $filename ) ) ) {
wfDebugLog( 'img_auth', "Streaming `" . $filename . "`." );
$be->streamFile( array( 'src' => $filename ),
return;
}
+ if ( $wgRequest->getCheck( 'download' ) ) {
+ header( 'Content-Disposition: attachment' );
+ }
+
// Stream the requested file
wfDebugLog( 'img_auth', "Streaming `" . $filename . "`." );
$repo->streamFile( $filename, array( 'Cache-Control: private', 'Vary: Cookie' ) );