X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=img_auth.php;h=e139227eba69d8e29d9a373fd067b3e391ef7779;hb=dd877c916a4588dc6a59e4e6b37d5e633b2505ab;hp=2d2db9a5ed1035a448a2161cf07ac7ff112488f4;hpb=c687c4a9ac95e45e786635a7ada0f9f9348c6534;p=lhc%2Fweb%2Fwiklou.git diff --git a/img_auth.php b/img_auth.php index 2d2db9a5ed..e139227eba 100644 --- a/img_auth.php +++ b/img_auth.php @@ -2,7 +2,7 @@ /** * 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 @@ -92,12 +92,17 @@ function wfImageAuthMain() { 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; + } if ( $be->fileExists( array( 'src' => $filename ) ) ) { wfDebugLog( 'img_auth', "Streaming `" . $filename . "`." ); $be->streamFile( array( 'src' => $filename ), array( 'Cache-Control: private', 'Vary: Cookie' ) ); } else { - wfForbidden( 'img-auth-accessdenied', 'img-auth-nofile', $filename ); + wfForbidden( 'img-auth-accessdenied', 'img-auth-nofile', $path ); } return; } @@ -145,6 +150,10 @@ function wfImageAuthMain() { 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' ) ); @@ -154,8 +163,8 @@ function wfImageAuthMain() { * Issue a standard HTTP 403 Forbidden header ($msg1-a message index, not a message) and an * error message ($msg2, also a message index), (both required) then end the script * subsequent arguments to $msg2 will be passed as parameters only for replacing in $msg2 - * @param $msg1 - * @param $msg2 + * @param string $msg1 + * @param string $msg2 */ function wfForbidden( $msg1, $msg2 ) { global $wgImgAuthDetails;